paraslash.git
9 years agobuild: Silence ggo_descriptions_declared command.
Andre Noll [Sun, 4 May 2014 19:28:16 +0000 (21:28 +0200)]
build: Silence ggo_descriptions_declared command.

This command makes the build output a bit noisy.

9 years agobuild: Call AC_CONFIG_HEADERS rather than AM_CONFIG_HEADER.
Andre Noll [Wed, 27 Aug 2014 19:58:31 +0000 (21:58 +0200)]
build: Call AC_CONFIG_HEADERS rather than AM_CONFIG_HEADER.

The AM_CONFIG_HEADER autoconf macro is obsolete.

9 years agobuild: Remove duplicate -Wno-unused-function.
Andre Noll [Thu, 24 Jul 2014 20:05:56 +0000 (22:05 +0200)]
build: Remove duplicate -Wno-unused-function.

We compile the .c files generated by gengetopt with this option to
silence a compiler warning. The option is first added to CPPFLAGS
and then specified again in the rule for the *.cmdline.o target. This
gets rid of the second instance.

9 years agobuild: Honor --with-xxx-headers also for dependencies.
Andre Noll [Thu, 24 Jul 2014 20:47:23 +0000 (22:47 +0200)]
build: Honor --with-xxx-headers also for dependencies.

This is necessary for depend.sh to do the right thing. Without it the
generated dependency files may contain a reference to a system header.

9 years agoMerge branch 't/audiod_exit_cleanup'
Andre Noll [Sun, 26 Oct 2014 12:11:41 +0000 (13:11 +0100)]
Merge branch 't/audiod_exit_cleanup'

Cooked for two months.

* t/audiod_exit_cleanup:
  audiod: Clean up by notifying tasks.

9 years agoMerge branch 'refs/heads/t/server_cmds'
Andre Noll [Thu, 9 Oct 2014 21:37:09 +0000 (21:37 +0000)]
Merge branch 'refs/heads/t/server_cmds'

Was cooking for three weeks.

* Add sender subcommand "status".
* com_si(): Don't print git version string.
* Doxify the sender_subcommand enum.
* Overhaul help texts of server and afs commands.
* com_sender: Replace memcpy by struct copy.

Conflicts:
command.c

9 years agoMerge branch 't/kill_sender_osl_dep'
Andre Noll [Mon, 29 Sep 2014 20:00:01 +0000 (20:00 +0000)]
Merge branch 't/kill_sender_osl_dep'

Was cooking for three weeks.

* t/kill_sender_osl_dep:
  Make senders independent of afs and osl.

9 years agoMerge branch 't/mvblob_improvement'
Andre Noll [Sun, 14 Sep 2014 17:01:47 +0000 (19:01 +0200)]
Merge branch 't/mvblob_improvement'

Cooking for two months.

* t/mvblob_improvement:
  mvblob: Improve error diagnostics.

9 years agoMake senders independent of afs and osl.
Andre Noll [Sat, 26 Jul 2014 11:51:35 +0000 (13:51 +0200)]
Make senders independent of afs and osl.

Although senders don't know anything about the osl databases of
the audio file selector, all senders currently include afs.h and
osl.h. This is because:

* senders are part of para_server, so they include server.h,

* server.h has an audio_file_data structure embedded in struct
misc_meta_data, so struct audio_file_data must be declared
before server.h is included,

* struct audio_file_data is declared in afs.h,

* afs.h makes use of structures defined in <osl.h>.

This patch moves the declaration of struct audio_file_data from afs.h
to afh.h, which is also included by all senders. This allows to remove
the two include directives for afs.h and osl.h from all three senders.

9 years agoFix typo in logfile.m4.
Andre Noll [Wed, 27 Aug 2014 19:44:34 +0000 (21:44 +0200)]
Fix typo in logfile.m4.

Also add a full stop at the end of the sentence.

9 years agoAdd htacess and icons for fancy indexing.
Andre Noll [Tue, 12 Aug 2014 13:01:59 +0000 (15:01 +0200)]
Add htacess and icons for fancy indexing.

The apache server on people.tuebingen.mpg.de has FancyIndexing via
mod_autoindex enabled. Let's use its features to provide a nicer view
of the download directory.

This adds two .png icons for tarballs and signatures, respectively.
These icons are listed in the new .htaccess file to instruct apache
to show the icons next to the download links, along with a file
description.

On the old page files were listed alphabetically. So one had to scroll
to the bottom to get to the newest tarball link. FancyIndexing lets us
specify the sort order and we use this feature to show new files first.

9 years agoUpdate web URLs to tuebingen.mpg.de.
Andre Noll [Sun, 17 Aug 2014 17:20:58 +0000 (19:20 +0200)]
Update web URLs to tuebingen.mpg.de.

systemlinux.org has been down for a while. Meanwhile the paraslash
web pages have been set up at a new location hosted by the MPI campus
of Tübingen.

This commit lists the alternative URLs in README, INSTALL and manual.

9 years agodoc: Change email address to maan@tuebingen.mpg.de
Andre Noll [Sat, 9 Aug 2014 10:49:56 +0000 (12:49 +0200)]
doc: Change email address to maan@tuebingen.mpg.de

The mail server on systemlinux.org was down for more than a week
lately, so let's use an alternative official address.  This commit
changes all maan@systemlinux.org addresses to maan@tuebingen.mpg.de.

Most .c and .h files contain the email address in the copyright header,
so they must all be patched. Three other files contain the address
for a different reason:

* README lists email and git, gitweb and home page URLs
* configure.ac needs it for configure -h
* version.c contains it for the -V option of all commands

9 years agoChange osl links to new location.
Andre Noll [Sat, 9 Aug 2014 10:47:25 +0000 (12:47 +0200)]
Change osl links to new location.

The osl web pages have been moved to people.tuebingen.mpg.de. This
adjusts the three links in the repository accordingly.

9 years agoMove git services to tuebingen.mpg.de.
Andre Noll [Sun, 17 Aug 2014 17:22:01 +0000 (19:22 +0200)]
Move git services to tuebingen.mpg.de.

Both the gitweb and the git daemon service have been relocated to
tuebingen.mpg.de. This commit changes the git-related URLs in the
repository to their counterparts at the new location.

The new location does not have a gitweb page dedicated to paraslash
alone. Instead, the gitweb service is provided by the gitolite
instance at git.tuebingen.mpg.de which hosts also a couple of other
repositories.

The "Changes" link of the the menu of the paraslash web pages points
to the dedicated gitweb page, so this link is removed from the menu.
There is still a gitweb link on the download page and a new one in
the README file.

Without a dedicated gitweb page, parts of the para.css style sheet
are no longer needed. This patch removes these parts, along with
git-logo.png, header and footer, which also have become unused.

9 years agoweb: Fix logo link.
Andre Noll [Tue, 12 Aug 2014 08:52:07 +0000 (10:52 +0200)]
web: Fix logo link.

The correct destination for this link is the current directory,
rather than /. The latter works only by coincidence since
paraslash.systemlinux.org is an apache vhost.

9 years agoMerge branch 't/daemon_cleanups'
Andre Noll [Sun, 17 Aug 2014 11:17:23 +0000 (13:17 +0200)]
Merge branch 't/daemon_cleanups'

Cooking for two months.

* daemon: Rename public functions.
* Simplify set_server_start_time().

Conflicts:
server.c

9 years agoAdd sender subcommand "status".
Andre Noll [Thu, 19 Jun 2014 09:46:31 +0000 (11:46 +0200)]
Add sender subcommand "status".

Currently, the si (server info) command prints information about each
sender, like the number of connected clients and the access control
lists. As this information is related to senders, the sender command
seems to be a better fit.

This commit introduces the new sender subcommand "status" for this
purpose and changes com_si() to not print the sender information any
more, making the output of com_si() bounded.  It also renames the
->info() function of the senders to ->status() to make it clear that
this function is related to the new status subcommand.

The Networking paragraph of the manual is adjusted accordingly and
now contains an example of the status command.

9 years agocom_si(): Don't print git version string.
Andre Noll [Thu, 19 Jun 2014 09:47:16 +0000 (11:47 +0200)]
com_si(): Don't print git version string.

We have com_version() for this.

9 years agoDoxify the sender_subcommand enum.
Andre Noll [Sun, 13 Apr 2014 23:19:26 +0000 (23:19 +0000)]
Doxify the sender_subcommand enum.

This adds comments to all sender commands and switches to a named enum.

9 years agoOverhaul help texts of server and afs commands.
Andre Noll [Sun, 13 Apr 2014 21:44:36 +0000 (21:44 +0000)]
Overhaul help texts of server and afs commands.

Each server command has a brief help text which is printed by
para_client help <command> and is also included in the para_server
manual page. These texts are defined in server.cmd and afs.cmd and
haven't seen much love for a long time. This commit improves most of
them and also fixes some formating issues.

9 years agocom_sender: Replace memcpy by struct copy.
Andre Noll [Sun, 13 Apr 2014 23:02:56 +0000 (23:02 +0000)]
com_sender: Replace memcpy by struct copy.

This is equivalent and a bit easier to read.

9 years agoaudiod: Clean up by notifying tasks.
Andre Noll [Wed, 1 Jan 2014 22:15:02 +0000 (22:15 +0000)]
audiod: Clean up by notifying tasks.

There are two ways to terminate para_audiod in a controlled way:
by executing the "term" command and by sending SIGINT or SIGTERM
to the process. Currently both code paths call clean_exit() from
some ->post_select function, which terminates para_audiod by calling
exit(3). Despite the name, this is "unclean" because tasks are not shut
down properly, so not all memory can be freed by this approach. While
this is not a big problem, it makes it more difficult to debug real
memory leaks.

This patch tries to overcome this problem by using notifications to
shut down the audiod tasks. Two new error codes E_AUDIOD_TERM and
E_AUDIOD_SIGNAL are introduced for the notification values. All tasks
are modified to check for notifications and now return the (negative)
notification value from their ->post_select() method if a notification
was received. Hence schedule() returns to main() and we may clean up
the resources allocated by the scheduler by calling sched_shutdown(),
along with the usual cleanup performed by clean_exit(). The latter
function is renamed to audiod_cleanup(), which is more to the point.

9 years agoweb: Top-align menu items.
Andre Noll [Tue, 12 Aug 2014 06:47:52 +0000 (08:47 +0200)]
web: Top-align menu items.

Without this, elinks shows the menu items centered with respect to the
main web page. As most pages are short, this is not a real problem. But
for the longer NEWS page the menu was shown in the middle of the page,
making it hard to navigate.

9 years agomanual: Add libopus-dev to package list for the impatient.
Andre Noll [Mon, 11 Aug 2014 16:30:41 +0000 (18:30 +0200)]
manual: Add libopus-dev to package list for the impatient.

Although the opus libraries are not included in the two distributions
on which the paraslash code is build and tested regularly (Ubuntu 10.04
and 12.04), it is available on the newer 14.04 (Trusty) version. Most
people probably run 14.04 by now, so let's include it in the manual.

9 years agoreset version to 'git'
Andre Noll [Fri, 1 Aug 2014 12:28:39 +0000 (14:28 +0200)]
reset version to 'git'

9 years agoparaslash 0.5.3 v0.5.3
Andre Noll [Fri, 1 Aug 2014 12:23:58 +0000 (14:23 +0200)]
paraslash 0.5.3

9 years agobuild: Do not hardcode gcc in depend.sh.
Andre Noll [Thu, 24 Jul 2014 20:42:28 +0000 (22:42 +0200)]
build: Do not hardcode gcc in depend.sh.

Although the clang compiler understands the -MM and -MG options,
we currently rely on gcc to generate the dependency files. Of course
this fails on systems where only clang is installed. The right fix
would be to use the make variable $(CC), but let's go for the minimal
fix that replaces gcc by cc in depend.sh for now.

9 years agobuild: Properly unset CPPFLAGS, LDFLAGS, LIBS.
Andre Noll [Sun, 20 Apr 2014 20:50:45 +0000 (20:50 +0000)]
build: Properly unset CPPFLAGS, LDFLAGS, LIBS.

Currently the directories specified via --with-ogg-headers and
--with-ogg-libs are taken into account also for vorbis/speex/opus
detection. This patch makes sure we start with a pristine values
for the three variables.

9 years agobuild: Compilie opus*.c files with ogg_cppflags.
Andre Noll [Thu, 24 Jul 2014 21:01:09 +0000 (23:01 +0200)]
build: Compilie opus*.c files with ogg_cppflags.

These files include ogg/ogg.h, so we must pass $(ogg_cppflags)
to avoid build failure in case ogg headers are installed at a
non-standard location.

9 years agobuild: Fix --with-gcrypt-headers and --with-vorbis-headers.
Andre Noll [Fri, 2 May 2014 20:07:24 +0000 (22:07 +0200)]
build: Fix --with-gcrypt-headers and --with-vorbis-headers.

The configure script sets the autoconf output variable gcrypt_cppflags
according to the configure option --with-gcrypt-headers, but
gcrypt_cppflags is never used for the build.  Hence, if libgcrypt is
installed in a non-standard location, and that location is specified
as the argument to --with-gcrypt-headers, configure detects the gcrypt
header correctly, but the build fails nevertheless.

The same type of bug also exists for the --with-vorbis-headers option.

To fix this omission this patch sets both variables in Makefile.in
and references it in Makefile.real to compile the affected objects
with the correct flags.

9 years agoMerge branch 'refs/heads/t/play_fix'
Andre Noll [Thu, 31 Jul 2014 06:59:47 +0000 (08:59 +0200)]
Merge branch 'refs/heads/t/play_fix'

Cooking since two weeks.

* 9c1aa5 Never start playback at an empty chunk.

Conflicts:
afh_recv.c

9 years agoMerge branch 't/recv_fix'
Andre Noll [Thu, 31 Jul 2014 06:06:21 +0000 (08:06 +0200)]
Merge branch 't/recv_fix'

Cooking for two months.

* t/recv_fix:
  recv: Don't segfault on invalid chunk values.

9 years agoafh_common: Improve documentation of clear_afh().
Andre Noll [Thu, 3 Jul 2014 21:30:58 +0000 (23:30 +0200)]
afh_common: Improve documentation of clear_afh().

The doxygen comment for this public function was rather bad.
This commit changes the comment to clarify that the function does
not free the given afhi structure but only its contents.

9 years agoMerge branch 't/sched_improvements'
Andre Noll [Wed, 23 Jul 2014 15:29:29 +0000 (17:29 +0200)]
Merge branch 't/sched_improvements'

Cooking for two months. This merge required to also patch gui.c due
to semantic conflics against the changes introduced by the gui_sched
branch which was merged to master in commit d15d8509 two weeks ago.
Also a small fix for server.c is needed to squelch a compiler warning
since the global "now" variable has become a const pointer.

* t/sched_improvements: (36 commits)
  audiod: Fix use after free on exit.
  sched: Mark global now pointer as const.
  sched: Directly pass context pointer to pre/post_select().
  sched: kill task->dead.
  sched: Do not shadow task_info in struct task.
  sched: Dont use fixed-size buffer for task names.
  sched: Rename task->error to tast->status.
  sched: Rename task->status to task->name.
  sched: Make struct task private to sched.c.
  sched: Introduce task_status().
  sched: Remove ->owned_by_sched.
  sched: Remove register_task().
  task_register() conversion: grab client task
  task_register() conversion: audiod status task
  task_register() conversion: audiod command task
  task_register() conversion: client task
  task_register() conversion: client supervisor task
  task_register() conversion: client exec task
  task_register() conversion: afs command task
  task_register() conversion: vss task
  ...

9 years agonet.c: Improve documentation of send_cred_buffer() and recv_cred_buffer().
Andre Noll [Mon, 2 Jun 2014 22:01:41 +0000 (00:01 +0200)]
net.c: Improve documentation of send_cred_buffer() and recv_cred_buffer().

Also fix a few whitespace issues while at it.

9 years agoversion.c: Remove bad doxygen \file comment.
Andre Noll [Sat, 12 Jul 2014 12:16:18 +0000 (14:16 +0200)]
version.c: Remove bad doxygen \file comment.

The file is version.h, not version.h.

9 years agoconfigure.ac: Fix list of command line objects for OS X.
Andre Noll [Thu, 10 Jul 2014 19:06:19 +0000 (21:06 +0200)]
configure.ac: Fix list of command line objects for OS X.

The additional .cmdline suffix causes the build to fail.

This bug was introduced 10 months ago in commit 0f4790f2.

9 years agoaudiod: Fix use after free on exit.
Andre Noll [Tue, 15 Jul 2014 05:04:07 +0000 (07:04 +0200)]
audiod: Fix use after free on exit.

client_close() frees the ->ct structure which is used one line later
by task_reap(). valgrind spots this use after free bug and reports

==13497== Invalid read of size 4
==13497==    at 0x8059EA8: task_reap (sched.c:199)
==13497==    by 0x80542FA: close_stat_pipe (audiod.c:1082)
==13497==    by 0x8055632: clean_exit (audiod.c:1159)
==13497==    by 0x80556B6: signal_post_select (audiod.c:1018)
==13497==    by 0x8059E5F: schedule (sched.c:88)
==13497==    by 0x804D41C: main (audiod.c:1437)
==13497==  Address 0x4833c04 is 204 bytes inside a block of size 212 free'd
==13497==    at 0x4028AC0: free (vg_replace_malloc.c:468)
==13497==    by 0x80542E8: close_stat_pipe (audiod.c:1081)
==13497==    by 0x8055632: clean_exit (audiod.c:1159)
==13497==    by 0x80556B6: signal_post_select (audiod.c:1018)
==13497==    by 0x8059E5F: schedule (sched.c:88)
==13497==    by 0x804D41C: main (audiod.c:1437)

The bug was introduced recently in commit 0b43ec5d (task_register()
conversion: client task).

9 years agoMerge branch 't/gui_sched'
Andre Noll [Sun, 13 Jul 2014 14:20:56 +0000 (16:20 +0200)]
Merge branch 't/gui_sched'

Was cooking for two months, since 2014-05-11.

* t/gui_sched: (53 commits)
  gui: Always initialize theme.
  gui: Simplify color handling.
  gui: Dont catch SIGWINCH.
  gui: Call waitpid() from exec and status task.
  Doxify para_gui.
  gui: Speed up window refresh.
  gui: Rename cmd_task to exec_task.
  gui: Move static variables of cmd_post_select() into struct cmd_task.
  gui: Move some variables into struct status_task.
  gui: Switch to the standard paraslash scheduler.
  gui: Use cpp magic to define command handlers.
  gui: Execute stat command in status_post_select().
  gui: Rename COMMAND/EXTERNAL/GETCH mode.
  gui: Get rid of do_select()'s mode parameter and call it only once.
  gui: Reorder functions.
  gui: Move signal handling code out of do_select().
  gui: Move input related code out of do_select().
  gui: Move external command handling out of do_select().
  gui: Introduce status_post_select().
  gui: Improve config reload.
  ...

9 years agomvblob: Improve error diagnostics.
Andre Noll [Sun, 29 Jun 2014 13:49:45 +0000 (15:49 +0200)]
mvblob: Improve error diagnostics.

On errors the mvblob commands (mvmood, mvlyr, mvimg, mvpl) fail
silently. They do write an error message to the server log, but nobody
might notice the error there. This commit changes these commands to
send the message to the client instead.

9 years agoMerge branch 't/cpsi_improvement'
Andre Noll [Thu, 10 Jul 2014 17:53:06 +0000 (19:53 +0200)]
Merge branch 't/cpsi_improvement'

Cooking since 2014-05-03.

* t/cpsi_improvement:
  com_cpsi(): Tell the user if nothing was copied.

9 years agoNever start playback at an empty chunk.
Andre Noll [Sun, 11 May 2014 19:21:15 +0000 (21:21 +0200)]
Never start playback at an empty chunk.

The chunk table of ogg/* audio files often contains "empty" chunks
which correspond to time slices for which the virtual streaming system
does not need to send any data. When playback is started at an empty
chunk, an unnecessary delay results.

To overcome this issue, this commit introduces a new public helper
afh_get_start_chunk() which looks for the first non-empty chunk before
the given chunk number.

The new function is called from afh_recv.c and from vss.c so that
both para_play and para_server now avoid to start streaming at an
empty chunk.

9 years agomanual: Mention that audio format handlers are part
Andre Noll [Fri, 18 Apr 2014 03:20:55 +0000 (03:20 +0000)]
manual: Mention that audio format handlers are part
of para_recv and para_play.

9 years agoerror.h: Remove obsolete RBTREE_ERRORS
Andre Noll [Fri, 18 Apr 2014 01:50:23 +0000 (01:50 +0000)]
error.h: Remove obsolete RBTREE_ERRORS

9 years agoFix two typos in comments of attribute.c.
Andre Noll [Sun, 8 Jun 2014 10:23:52 +0000 (12:23 +0200)]
Fix two typos in comments of attribute.c.

9 years agoMerge branch 't/bitstream_improvements'
Andre Noll [Thu, 26 Jun 2014 16:58:27 +0000 (18:58 +0200)]
Merge branch 't/bitstream_improvements'

Cooking since 2014-04-22.

* t/bitstream_improvements:
  bitstream: Improve documentation.
  wma: Store ASF header info in afhi->techinfo.
  bitstream: Replace check for impossible condition by assertion.
  bitstream: Remove pointless variable "code_prefix2".
  bitstream: Micro-optimization.
  bitstream: Kill pointless variable "symbol".
  bitstream: Trivial coding style fixes.
  bitstream: Trivial spelling fix auxillary -> auxiliary.

9 years agoMerge branch 't/audiod_com_version'
Andre Noll [Thu, 19 Jun 2014 13:39:33 +0000 (15:39 +0200)]
Merge branch 't/audiod_com_version'

Cooking since 2014-04-03.

* t/audiod_com_version:
  audiod: Implement version command.
  audiod: Trival spelling fix for com_tasks().

9 years agodaemon: Rename public functions.
Andre Noll [Thu, 9 Jan 2014 20:55:31 +0000 (20:55 +0000)]
daemon: Rename public functions.

Let's reserve the daemon_ prefix for public functions of daemon.c
to make it clear where these functions are defined.

9 years agoSimplify set_server_start_time().
Andre Noll [Thu, 9 Jan 2014 16:57:58 +0000 (16:57 +0000)]
Simplify set_server_start_time().

This function receives a pointer to a timeval structure which is
supposed to contain the daemon startup time. Passing NULL means to
set the daemon startup time to the current time.

There are only two callers of this function, in audiod.c and in
server.c.  The first one passes NULL, the other one initialises the
timeval structure pointed to by the global now pointer to the current
time, and passes this pointer.

It's easier to let set_server_start_time() always act as if NULL had
been passed.

9 years agocrypt: Simplify base64_decode().
Andre Noll [Mon, 16 Dec 2013 21:58:39 +0000 (22:58 +0100)]
crypt: Simplify base64_decode().

We never call this function with target == NULL.

9 years agosched: Mark global now pointer as const.
Andre Noll [Thu, 9 Jan 2014 17:04:28 +0000 (17:04 +0000)]
sched: Mark global now pointer as const.

The timeval structure pointed to by the public now pointer should not
be modified outside sched.c. Fortunately play.c is the only place
which violates this rule. This patch fixes up play.c and marks the
pointer as const.

9 years agosched: Directly pass context pointer to pre/post_select().
Andre Noll [Thu, 2 Jan 2014 03:24:48 +0000 (03:24 +0000)]
sched: Directly pass context pointer to pre/post_select().

The patch is large, but it's fairly straight forward: Instead of
a task pointer all ->pre_select() and ->post_select() methods now
receive the context pointer that was passed to the scheduler when
the task was registered. This allows to kill the public task_context().

Two pre_select/post_select functions are not directly called by the
scheduler: session_post_select(), generic_recv_pre_select(). These
are changed to receive a proper struct rather than a void pointer.

Note that generic_filter_pre_select() is not changed in this
manner because some filters do not provide a pre_select wrapper but set
task->pre_select to generic_filter_pre_select().

9 years agosched: kill task->dead.
Andre Noll [Thu, 2 Jan 2014 02:07:01 +0000 (02:07 +0000)]
sched: kill task->dead.

The three possible states of a task are determined by the ->status
and ->dead fields of struct task:

status >= 0, !dead: running
status >= 0, dead: dead (about to be removed from the task list)
status < 0: zombie (dead, but not yet reaped, -status is an error code)

This commit encodes the first two states as two non-negative numbers,
so that the three states become

status == TS_RUNNING: running
status == TS_DEAD: dead
status < 0: zombie

This allows to remove ->dead which improves readability somewhat.

9 years agosched: Do not shadow task_info in struct task.
Andre Noll [Thu, 2 Jan 2014 01:43:21 +0000 (01:43 +0000)]
sched: Do not shadow task_info in struct task.

All fields of struct task_info have direct counterparts in struct
task. The fields of struct task are initialized in task_register()
to the corresponding fields of struct task_info. It's easier to
just embed a task_info structure in struct task instead. This also
guarantees that task_register() stays correct in case another field
is added to struct task_info.

9 years agosched: Dont use fixed-size buffer for task names.
Andre Noll [Thu, 2 Jan 2014 01:16:33 +0000 (01:16 +0000)]
sched: Dont use fixed-size buffer for task names.

This is not more complicated than the strncpy(), and it allows for
arbitrary long task names.

9 years agosched: Rename task->error to tast->status.
Andre Noll [Thu, 2 Jan 2014 01:07:11 +0000 (01:07 +0000)]
sched: Rename task->error to tast->status.

We are going to store not only the (negative) error code in this field
of struct task, so status is a better name for it. The conversion is
trivial.

9 years agosched: Rename task->status to task->name.
Andre Noll [Thu, 2 Jan 2014 01:05:54 +0000 (01:05 +0000)]
sched: Rename task->status to task->name.

"status" has always been a misnomer for the user-defined description
of a task. Now that the structure has been made local, only sched.c
needs to be changed.

9 years agosched: Make struct task private to sched.c.
Andre Noll [Wed, 1 Jan 2014 23:36:16 +0000 (23:36 +0000)]
sched: Make struct task private to sched.c.

No direct users of struct sched remain, so we can move the definition
of this structure from sched.h to sched.c.

9 years agosched: Introduce task_status().
Andre Noll [Tue, 31 Dec 2013 17:22:57 +0000 (17:22 +0000)]
sched: Introduce task_status().

Before struct task can be made private to sched.c we must eliminate
code which directly accesses the fields of this structure. The last
offender is ->error: in many places we check this field to detect
whether some task is in an error condition.

This patch provides a public accessor function, task_status(),
for this purpose. All users of ->error are modified to call this
function instead.

9 years agosched: Remove ->owned_by_sched.
Andre Noll [Sat, 1 Mar 2014 11:55:38 +0000 (12:55 +0100)]
sched: Remove ->owned_by_sched.

With register_task() gone, the ->owned_by_sched field of struct sched
is always true (it gets set in task_register()). So we can remove it.

9 years agosched: Remove register_task().
Andre Noll [Thu, 2 Jan 2014 01:01:58 +0000 (01:01 +0000)]
sched: Remove register_task().

Now that all users of this function have been converted to
task_register(), the old function can go away.

9 years agotask_register() conversion: grab client task
Andre Noll [Tue, 31 Dec 2013 00:13:29 +0000 (00:13 +0000)]
task_register() conversion: grab client task

9 years agotask_register() conversion: audiod status task
Andre Noll [Tue, 31 Dec 2013 00:06:28 +0000 (00:06 +0000)]
task_register() conversion: audiod status task

9 years agotask_register() conversion: audiod command task
Andre Noll [Tue, 31 Dec 2013 00:01:12 +0000 (00:01 +0000)]
task_register() conversion: audiod command task

9 years agotask_register() conversion: client task
Andre Noll [Mon, 30 Dec 2013 23:54:26 +0000 (23:54 +0000)]
task_register() conversion: client task

9 years agotask_register() conversion: client supervisor task
Andre Noll [Mon, 30 Dec 2013 23:45:55 +0000 (23:45 +0000)]
task_register() conversion: client supervisor task

9 years agotask_register() conversion: client exec task
Andre Noll [Mon, 30 Dec 2013 23:39:17 +0000 (23:39 +0000)]
task_register() conversion: client exec task

9 years agotask_register() conversion: afs command task
Andre Noll [Mon, 30 Dec 2013 23:34:08 +0000 (23:34 +0000)]
task_register() conversion: afs command task

9 years agotask_register() conversion: vss task
Andre Noll [Mon, 30 Dec 2013 23:30:03 +0000 (23:30 +0000)]
task_register() conversion: vss task

9 years agotask_register() conversion: signal task
Andre Noll [Mon, 30 Dec 2013 23:20:32 +0000 (23:20 +0000)]
task_register() conversion: signal task

9 years agotask_register() conversion: server command task
Andre Noll [Mon, 30 Dec 2013 23:26:00 +0000 (23:26 +0000)]
task_register() conversion: server command task

9 years agotask_register() conversion: play task
Andre Noll [Tue, 15 Apr 2014 13:49:59 +0000 (13:49 +0000)]
task_register() conversion: play task

9 years agotask_register() conversion: writers
Andre Noll [Mon, 30 Dec 2013 22:59:47 +0000 (22:59 +0000)]
task_register() conversion: writers

9 years agotask_register() conversion: write task
Andre Noll [Mon, 30 Dec 2013 22:42:27 +0000 (22:42 +0000)]
task_register() conversion: write task

9 years agotask_register() conversion: i9e task
Andre Noll [Mon, 30 Dec 2013 22:31:08 +0000 (22:31 +0000)]
task_register() conversion: i9e task

9 years agotask_register() conversion: audioc task
Andre Noll [Mon, 30 Dec 2013 22:23:31 +0000 (22:23 +0000)]
task_register() conversion: audioc task

9 years agotask_register() conversion: filter tasks
Andre Noll [Mon, 30 Dec 2013 22:09:38 +0000 (22:09 +0000)]
task_register() conversion: filter tasks

9 years agotask_register() conversion: stdin task
Andre Noll [Wed, 8 Jan 2014 05:16:15 +0000 (05:16 +0000)]
task_register() conversion: stdin task

This renames stdin_set_defaults() to stdin_task_register() and changes
the function to register the stdin task. Before this patch, the task
was registered in the callers.

9 years agotask_register() conversion: receivers
Andre Noll [Sat, 25 Jan 2014 18:41:45 +0000 (19:41 +0100)]
task_register() conversion: receivers

This adds a new public function, task_reap(), to sched.c. It is
called by para_audiod and para_play to free the memory occupied by
the receiver node after EOF. sched_shutdown() can not be used for
this purpose since the scheduler stays active during the life time of
these programs (i.e. schedule() never returns) while receiver nodes
come and go.

The new task_reap() has to face the problem that it is called
from another task's ->post_select() method, so removing the task
being reaped from the scheduler task list is not possible in
task_reap(). Hence this patch adds the new flag "dead" to struct
task. It is initially unset and is turned on in task_reap() to indicate
that (a) the task has exited (i.e. ->post_select() returned negative)
and (b) task_reap() has been called to fetch the exit status. Only
if this flag is set, the scheduler removes the task from the task list.

9 years agosched: Introduce alternative task API.
Andre Noll [Mon, 30 Dec 2013 19:27:04 +0000 (19:27 +0000)]
sched: Introduce alternative task API.

In the current implementation struct task is public so users of this
structure can mess with internal scheduler details as they please. This
has led to many bugs and questionable code in the past. This commit
is the first step to overcome this design mistake. At the end of this
patch series struct task can be made private to sched.c.

This commit introduces the following new public functions:

* task_register,
* task_context,
* sched_shutdown.

It also adds the new public task_info structure which carries the
information passed to the scheduler when a new task is registered. This
structure will stay public while struct task will become private once
all users have been converted.

task_register() is supposed to eventually replace register_task(). The
main difference of the two is that the new function returns a _pointer_
to a task structure which is allocated dynamically. Users are not
supposed to look at the fields of this pointer directly.

task_context() is a temporary helper which can be removed again at the
end of the series. Its sole purpose is to return the context pointer
which was passed at task register time as part of struct task_info.

The final new function, sched_shutdown(), deallocates the task
structures allocated during task_register() to cleanly shut down the
scheduler after all tasks have terminated.

All users need to be converted to the new API. This patch only converts
the stdout task though. The other tasks will be converted in subsequent
patches. The scheduler can tell if a task was registered using the
new API by means of the new ->owned_by_sched bit of struct task.
This boolean variable can also be removed after all tasks have been
converted.

Some users will need to query the exit status of a terminated
task. Hence we keep all tasks on the task list  after ->post_select()
returned negative but call neither ->pre_select() nor ->post_select()
any more for such tasks. This leads to the concept of zombie tasks.

9 years agosched: Mark argument of task_get_notification() as const.
Andre Noll [Tue, 31 Dec 2013 02:15:42 +0000 (02:15 +0000)]
sched: Mark argument of task_get_notification() as const.

We never write to the memory pointed to by the argument.

9 years agoSimplify sched: Use only a single task list.
Andre Noll [Mon, 30 Dec 2013 17:37:41 +0000 (17:37 +0000)]
Simplify sched: Use only a single task list.

Currently the scheduler maintains two linked task lists, the pre_select
and the post_select list. This is completely unnecessary and bloats
the code for no good reason. This patch makes it use a single list
only and updates the documentation accordingly.

9 years agoaudiod: Simplify start_stop_decoders().
Andre Noll [Tue, 31 Dec 2013 12:56:59 +0000 (12:56 +0000)]
audiod: Simplify start_stop_decoders().

open_filters() DTRT if there are no filters configured.
No need to check twice.

9 years agoDon't set t->error in ->pre_select().
Andre Noll [Tue, 31 Dec 2013 17:20:24 +0000 (17:20 +0000)]
Don't set t->error in ->pre_select().

->pre_select() methods should never fail, and tasks should not
set this variable at all. It is ignored anyway when set there.

9 years agoafh_recv: Don't set t->error unnecessarily.
Andre Noll [Tue, 31 Dec 2013 03:22:40 +0000 (03:22 +0000)]
afh_recv: Don't set t->error unnecessarily.

It is always wrong to set t->error directly as this can only confuse
the scheduler.

9 years agoMerge branch 't/ao_fixes'
Andre Noll [Sun, 25 May 2014 13:31:07 +0000 (15:31 +0200)]
Merge branch 't/ao_fixes'

Cooking since 2014-03-22.

* t/ao_fixes:
  ao_write: Call ao_initialize() only once.
  ao_write: Join threads before returning an error from aow_post_select().
  ao_write: Simplify locking.
  Don't unlock and lock the thread mutex unnecessarily.
  ao_write: Check return value of pthread functions.
  ao_write: Avoid segfault on exit.
  ao_write: Avoid pthread_join().
  ao_write: Enforce a 20ms timeout.
  ao_write: Fix spurious segfault.

9 years agogui: Always initialize theme.
Andre Noll [Mon, 12 May 2014 15:51:49 +0000 (17:51 +0200)]
gui: Always initialize theme.

parse_config_file_or_die() contains the following bug: If the
configuration file ~/.paraslash/gui.conf does not exist, the current
code not only skips the gengetopt config file parser (which is correct)
but also omits to call theme_init(), which is incorrect.

The bug was introduced recently in commit 18d37e (Unify config
file parsing). Fix it by moving the call to theme_init() to
the bottom of the function so that it is called if and only if
parse_config_file_or_die() succeeds.

9 years agorecv: Don't segfault on invalid chunk values.
Andre Noll [Sun, 11 May 2014 19:47:03 +0000 (21:47 +0200)]
recv: Don't segfault on invalid chunk values.

If recv->open() fails, para_recv segfaults after

==10129== Conditional jump or move depends on uninitialised value(s)
==10129==    at 0x41BA18A: vfprintf (vfprintf.c:1634)
==10129==    by 0x41BE3D8: buffered_vfprintf (vfprintf.c:2311)
==10129==    by 0x41B975C: vfprintf (vfprintf.c:1289)
==10129==    by 0x804C6AF: stderr_log (in /home/maan/scm/paraslash/para_recv)
==10129==    by 0x804A193: main (recv.c:114)

This happens for example with the afh_receiver if the given start
chunk is bigger than the end chunk, e.g. when para_recv is executed as

./para_recv -r 'afh -b -80 -e -89 -f foo.opus'

The reason for the bug is we zero-out the stdout structure too late.
Fix this by initializing the stdout task structure upfront rather
than using memset().

This bug was introduced a year ago in commit b01605d7 (Avoid unwanted
log messages during startup) which moved down the call to memset().

9 years agoMerge branch 't/test_man'
Andre Noll [Sun, 11 May 2014 10:19:12 +0000 (12:19 +0200)]
Merge branch 't/test_man'

Cooking since 2014-03-16.

* t/test_man:
  test-lib: Make colors work on FreeBSD.
  test suite: Add sanity check for generated man pages.

9 years agogui: Simplify color handling.
Andre Noll [Sat, 8 Mar 2014 20:18:21 +0000 (21:18 +0100)]
gui: Simplify color handling.

Various gui elements of para_gui can be customized through struct
gui_theme. Currently this structure contains two integers for each
each element, one for the foreground and one for the background color
of the element. This is a bit clumsy and repetitive.

This commit cuts down the number of fields of struct gui_theme by
a factor of two by introducing struct gui_color_spec as a pair of
integers.

The patch is quite large but also simple.

9 years agogui: Dont catch SIGWINCH.
Andre Noll [Thu, 13 Feb 2014 18:59:49 +0000 (19:59 +0100)]
gui: Dont catch SIGWINCH.

This is unnecessary since the curses library generates a KEY_RESIZE
event on SIGWINCH anyway. Hence window change events can be handled
as well in the normal input processing function. This allows to remove
the SIGWINCH part of the signal handling code.

Another advantage of handling SIGWINCH in the same way as normal
input events is that it is easier to propagate the event. This will
turn out to be useful for the upcoming gui menu changes.

9 years agogui: Call waitpid() from exec and status task.
Andre Noll [Mon, 27 Jan 2014 10:35:08 +0000 (11:35 +0100)]
gui: Call waitpid() from exec and status task.

This commit changes signal_post_select() to not call waitpid() via
para_reap_child() any more. Instead it notifies all tasks using the
new error code E_GUI_SIGCHLD. The exec task and the status task honor
this notification and call waitpid() for their "own" pid to check
whether the executing process or the stat process has terminated and
to obtain the exit status.

Although neither task cares deeply about the exit code, the menu
commands, which will be implemented in subsequent patches, will
care. So it's good to have the option to get this information.

9 years agoDoxify para_gui.
Andre Noll [Sun, 16 Mar 2014 11:09:01 +0000 (12:09 +0100)]
Doxify para_gui.

Now that para_gui is in a much better shape, let's make it a first
class citizen and document all public functions and data structures.

9 years agogui: Speed up window refresh.
Andre Noll [Mon, 6 Jan 2014 20:12:38 +0000 (20:12 +0000)]
gui: Speed up window refresh.

We had way too many calls to wrefresh() which copies the named
window to the physical terminal screen. This slows down the display
considerably, especially on slow machines.

It is more efficient to perform the copy only once per scheduler
iteration. So this commit adds a flag "needs_update" to struct
gui_window, and all callers to wrefresh() are changed to call
refresh_window() instead. This new function is much cheaper since it
only turns on the needs_update flag but does nothing else.

In input_post_select() we check which windows have the flag set and
repaint those windows using wnoutrefresh() and then doupdate(). This
two-step approach is described in the curs_refresh(3X) man page as
more efficient then calling wrefresh() for each window separately
since it avoids alternating calls to wnoutrefresh() and doupdate().

9 years agogui: Rename cmd_task to exec_task.
Andre Noll [Sat, 4 Jan 2014 22:16:22 +0000 (22:16 +0000)]
gui: Rename cmd_task to exec_task.

The term "command" currently means either a gui command handler or
the process which is executing as a result of a defined key map. Avoid
this confusion by using the word only for command handlers.

This commit also simplifies exec_cmd() and exec_para() slightly by
moving the "hit any key to abort" message into the common function
exec_and_display().

9 years agogui: Move static variables of cmd_post_select() into struct cmd_task.
Andre Noll [Sat, 4 Jan 2014 06:48:36 +0000 (06:48 +0000)]
gui: Move static variables of cmd_post_select() into struct cmd_task.

For the same reason stated in the commit message of the previous patch,
these variables belong to the context structure of the command task,
so move them there.

The COMMAND_BUF_SIZE define had to be moved above the definition of
struct cmd_task since COMMAND_BUF_SIZE uses it.

9 years agogui: Move some variables into struct status_task.
Andre Noll [Sat, 4 Jan 2014 06:32:04 +0000 (06:32 +0000)]
gui: Move some variables into struct status_task.

pre_select and post_select methods should never define static variables
but store their state in the context structure which also contains
the task structure.

This commit moves the static variables of status_post_select() and the
global variables next_exec and stat_pipe into the context structure
of the status task.

9 years agogui: Switch to the standard paraslash scheduler.
Andre Noll [Sat, 4 Jan 2014 06:04:26 +0000 (06:04 +0000)]
gui: Switch to the standard paraslash scheduler.

Due to the preparations performed in previous patches, this is a
rather simple change. Note we don't need to define a struct signal_task
since this structure is already defined in signal.h.

9 years agogui: Use cpp magic to define command handlers.
Andre Noll [Fri, 10 Jan 2014 00:22:07 +0000 (00:22 +0000)]
gui: Use cpp magic to define command handlers.

This shortens the code a bit and avoids duplications. The command
handler for cancel_scroll had to be renamed from com_cancel_scrolling()
to com_cancel_scroll() since the old name did not match command name.