paraslash.git
10 years agoplay: Fix prev command.
Andre Noll [Sun, 22 Sep 2013 14:45:10 +0000 (16:45 +0200)]
play: Fix prev command.

The command handler for com_prev() stores the number of the
previous (valid) file in ->next_file of struct play_task and sets
->rq to CRT_FILE_CHANGE. The real work is supposed to be done in
load_next_file() which is called from the main post_select() function.

However, load_next_file() ignores ->next_file and computes the number
of the next file itself. Hence the "prev" command acts exactly as
"next", i.e. it selects the next rather than the previous file.

Fix this by ignoring ->next_file only if ->rq is CRT_NONE, which
indicates a normal end of file condition.

10 years agobash_completion: Run client/audioc from PATH.
Andre Noll [Wed, 11 Sep 2013 00:46:26 +0000 (00:46 +0000)]
bash_completion: Run client/audioc from PATH.

This way it works for everybody.

10 years agoconfigure: Print opus audio file handler if opus lib was found.
Andre Noll [Wed, 4 Sep 2013 04:35:38 +0000 (04:35 +0000)]
configure: Print opus audio file handler if opus lib was found.

The variable is called $audio_format_handlers rather than
$server_audio_formats. The value is only used to display the supported
audio formats, so this bug is rather benign.

10 years agobtr: splice-out fix.
Andre Noll [Fri, 6 Sep 2013 23:21:44 +0000 (23:21 +0000)]
btr: splice-out fix.

When splicing out a node we set the ->parent pointer of all child
nodes to the parent of the given node, and move each child to the
->children list of the parent.

Except when there is no parent. If the given node was a root node
(or an internal node whose parent vanished), we leave the ->children
list untouched. In this case the assertion a few lines later triggers
and aborts the program. Fix this by removing the nodes from the list.
Such nodes have become root nodes themselves, so they should not be
on any list of children.

10 years agofecdec: Avoid fecdec output buffer overruns.
Andre Noll [Sun, 1 Sep 2013 17:48:46 +0000 (17:48 +0000)]
fecdec: Avoid fecdec output buffer overruns.

The size of the buffer tree pool of the amp filter is 64K, which
is smaller than BTRN_MAX_PENDING of buffer_tree.c (96K). The latter
value is used in btr_node_status() as follows. If input for a buffer
tree node is available and there is less than BTRN_MAX_PENDING bytes
in the output queue of the node, the function returns 1 to indicate
that the node should continue to process its input.

This can result in a fatal error condition when the buffer tree pool
fills up completely. Avoid this by increasing the pool size to 128K.

10 years agovss: Avoid assertion "i == g->num_header_slices - 1".
Andre Noll [Sun, 1 Sep 2013 15:54:25 +0000 (15:54 +0000)]
vss: Avoid assertion "i == g->num_header_slices - 1".

This fixes a very old bug in the timing code for fec slices. Depending
on the number of bytes to submit and on the number of slices of the
current fec group it may happen that we reserve more slices than
needed for the audio file header. This is not a problem per se, but the
above assertion hits in this case and aborts para_server.

Fix this by removing the assertion, and make sure that all reserved
header slices are properly initialized.

10 years agoconfigure: Fix restoring LDFLAGS.
Andre Noll [Thu, 29 Aug 2013 22:20:30 +0000 (22:20 +0000)]
configure: Fix restoring LDFLAGS.

The configure script saves the values of CPPFLAGS, CFLAGS and LDLFAGS
before each check and restores the old values afterwards. However,
for LDLFAGS this was broken at several places, since we used LD_FLAGS
(with an underscore) for saving the value and LDFLAGS for restoring it
(or vice versa).

This bug had the effect that a user-specified value of LDFLAGS was
ignored in some tests because LDFLAGS was restored to the empty
value LD_FLAGS during an earlier test.

This patch changes all occurrences of LD_FLAGS in configure.ac to
LDFLAGS.

10 years agoserver/gcrypt: Fix sending the empty status items.
Andre Noll [Mon, 29 Jul 2013 22:44:37 +0000 (00:44 +0200)]
server/gcrypt: Fix sending the empty status items.

When para_server enters the "stopped" state, it needs to inform all
clients which are executing the stat command that no audio file is
currently available.

To this aim the stat command handler calls empty_status_items(), which
creates a buffer containing empty values for most status items. This
function tries to be smart by computing the buffer only once. It
saves a reference in a static variable so that on subsequent calls
it can simply return the same buffer.

This works fine when para_server is compiled against the openssl
crypto library. However, it fails when libgcrypt is used because with
libgcrypt the send buffer is encrypted in-place. Hence on subsequent
calls the already encrypted buffer will be encrypted again, resulting
in garbage being sent to the client.

This patch avoids this bug by using a fresh buffer each time the
empty status items are sent.

10 years agonew codename, reset version to git
Andre Noll [Mon, 29 Jul 2013 13:08:32 +0000 (15:08 +0200)]
new codename, reset version to git

10 years agoparaslash 0.4.13 v0.4.13
Andre Noll [Mon, 29 Jul 2013 12:59:50 +0000 (14:59 +0200)]
paraslash 0.4.13

10 years agotime.c: Make declarations match definitions.
Andre Noll [Sat, 6 Jul 2013 13:02:10 +0000 (15:02 +0200)]
time.c: Make declarations match definitions.

Also fix some whitespace issues.

10 years agoAdd two missing GPL and doxygen file headers.
Andre Noll [Sun, 21 Jul 2013 14:40:56 +0000 (16:40 +0200)]
Add two missing GPL and doxygen file headers.

It's a pity that doxygen doesn't warn about this.

10 years agosched.h: Remove outdated comment.
Andre Noll [Sun, 21 Jul 2013 14:30:23 +0000 (16:30 +0200)]
sched.h: Remove outdated comment.

The term "these functions" is undefined here, and setting t->error
is deprecated.  The post_select() functions are supposed to return
an error code instead, but this is already mentioned further down in
the file, so let's just remove the comment.

10 years agoFix documentation of filter->post-select().
Andre Noll [Sun, 21 Jul 2013 14:25:10 +0000 (16:25 +0200)]
Fix documentation of filter->post-select().

The ->post_select() methods return an integer these days and should
*not* set the ->error field of the task struct directly.

10 years agoipc.c: Fix typo in comment.
Andre Noll [Sat, 20 Jul 2013 19:07:06 +0000 (21:07 +0200)]
ipc.c: Fix typo in comment.

10 years agoaft.c: Remove a stray "*" in a comment.
Andre Noll [Sun, 14 Jul 2013 11:13:03 +0000 (13:13 +0200)]
aft.c: Remove a stray "*" in a comment.

10 years agoMove com_select_callback() closer to com_select().
Andre Noll [Tue, 16 Jul 2013 05:38:33 +0000 (07:38 +0200)]
Move com_select_callback() closer to com_select().

It's considered good style to have the command handler and it's
callback next to each other. No actual changes.

10 years agobuffer_tree.c: Add documentation of btr_parent().
Andre Noll [Sat, 6 Jul 2013 18:25:17 +0000 (20:25 +0200)]
buffer_tree.c: Add documentation of btr_parent().

This function was introduced in commit 37e0dfe7 (check_wav: Ask parent
nodes before falling back to defaults) without documentation.

10 years agoggo.c: Document return value of printf_or_die().
Andre Noll [Sat, 6 Jul 2013 18:23:04 +0000 (20:23 +0200)]
ggo.c: Document return value of printf_or_die().

Commit b59a3c41 (filter: Wrap lines in the available filter list)
changed the return value of this function from void to int but missed
to update the documentation.

10 years agoMood: Document return value of moods_event_handler().
Andre Noll [Sat, 6 Jul 2013 18:21:19 +0000 (20:21 +0200)]
Mood: Document return value of moods_event_handler().

Just to make doxygen happy.

10 years agonet.c: Add documentation of flowopt_new().
Andre Noll [Sat, 6 Jul 2013 18:20:41 +0000 (20:20 +0200)]
net.c: Add documentation of flowopt_new().

It's not obvious that the returned structure does not need to
be freed by the caller, so let's document this fact.

10 years agonet: Remove unused flowopt_add_bool().
Andre Noll [Sat, 6 Jul 2013 18:00:57 +0000 (20:00 +0200)]
net: Remove unused flowopt_add_bool().

10 years agorecv.h: Fix comment indentation.
Andre Noll [Sat, 6 Jul 2013 20:02:56 +0000 (22:02 +0200)]
recv.h: Fix comment indentation.

10 years agoRemove some duplicate semicolons.
Andre Noll [Sun, 7 Jul 2013 16:47:36 +0000 (18:47 +0200)]
Remove some duplicate semicolons.

10 years agoRemove some unused error codes.
Andre Noll [Sun, 7 Jul 2013 19:14:21 +0000 (21:14 +0200)]
Remove some unused error codes.

Quite a few error codes have become unused, but the stale entries
of error.h remained. Unfortunately, we have no way to spot these
automatically.

10 years agoDoxyfile: Predefine HAVE_CLOCK_GETTIME.
Andre Noll [Sat, 6 Jul 2013 18:26:59 +0000 (20:26 +0200)]
Doxyfile: Predefine HAVE_CLOCK_GETTIME.

Fixes the following doxygen warning:

time.c:227: Warning: include file sys/time.h not found, perhaps you forgot to add its directory to INCLUDE_PATH?

10 years agoaudiod: Close filters in reverse order.
Andre Noll [Sat, 6 Jul 2013 21:00:14 +0000 (23:00 +0200)]
audiod: Close filters in reverse order.

Otherwise, a subsequent filter might refer to a buffer reference of
the previous filter, accessing freed memory. This is not a bug right
now, as audiod only closes filters after the full buffer tree has
become inactive, i.e. after all buffer tree nodes have unregistered
their task. It's cleaner to reverse the loop though, and it has no
additional cost.

10 years agoopusdec: Get rid of opusdec_pre_select().
Andre Noll [Sun, 7 Jul 2013 15:59:07 +0000 (17:59 +0200)]
opusdec: Get rid of opusdec_pre_select().

The generic one should do just fine and the additional 100ms timeout
should not be necessary.

10 years agoopusdec: avoid __STDC_VERSION__ warning.
Andre Noll [Fri, 12 Jul 2013 14:08:41 +0000 (16:08 +0200)]
opusdec: avoid __STDC_VERSION__ warning.

opusdec_filter.c indirectly includes opus_types.h which checks whether
__STDC_VERSION__ >= 199901L. However, at least some gcc versions
don't define __STDC_VERSION__ which results in

warning: "__STDC_VERSION__" is not defined

For example, this happens on Ubuntu lucid, which ships gcc-4.4.3.

This patch gets rid of the warning by defining __STDC_VERSION__
if necessary prior to including the opus_types header.

10 years agoafh: Initialize audio format handlers only once.
Andre Noll [Sun, 7 Jul 2013 11:22:48 +0000 (13:22 +0200)]
afh: Initialize audio format handlers only once.

afc.c calls afh_init() twice. This does not really hurt as this
function is idempotent, but it causes the initialization log messages
to be printed twice.

This gets rid of the additional call to afh_init() which crept in
in commit 042767ce (Use self-made help to avoid recompilations on
version changes).

10 years agomp3_afh: Use symbolic constants for id3 tag identifiers.
Andre Noll [Sun, 7 Jul 2013 08:44:50 +0000 (10:44 +0200)]
mp3_afh: Use symbolic constants for id3 tag identifiers.

10 years agoMerge branch 't/opus'
Andre Noll [Sat, 6 Jul 2013 00:24:48 +0000 (02:24 +0200)]
Merge branch 't/opus'

Was cooking for two weeks with no problems.

273756 The opus decoder.
7007ae The opus audio format handler.
8bcf75 ogg/opus: Infrastructure.
53133e speex: Don't export spx_ctl().

10 years agoMerge branch 't/versioning_improvements'
Andre Noll [Mon, 1 Jul 2013 19:06:48 +0000 (21:06 +0200)]
Merge branch 't/versioning_improvements'

Cooking for ~2 weeks.

15e99a version.c: Mark version_git() as const.
9bdebf Remove CODENAME macro.
be2f6b gui: Use version_single_line().
d60dae Improve man page layout.
5dbc9a afh/play: Include supported audio formats in help output.
042767 Use self-made help to avoid recompilations on version changes.
48f1fc Provide "purpose" texts.
aa74a9 Revamp ggo help.
9f7a49 afh_recv: Replace ggo text section by description.
b59e0e Make gengetopt descriptions work.
06b3e7 Introduce version.c to limit recompilation on version changes.
75feac Make all commands print git version and improve version string.
b01605 Avoid unwanted log messages during startup.
625fdb Don't check return value of command line parsers unnecessarily.
533b03 Build receivers, filters and writers without -h and -V support.
b59a3c filter: Wrap lines in the available filter list.
9e56d3 audioc: Print config file errors.
e5264d doc: Rewrite udp sender description
5ec373 client: Fix typo in comment.
6d5159 client: Remove duplicate include.

10 years agoversion.c: Mark version_git() as const.
Andre Noll [Mon, 1 Jul 2013 19:02:56 +0000 (21:02 +0200)]
version.c: Mark version_git() as const.

Fixes the following warning on gcc-4.8.1:

version.c:13:13: warning: function might be candidate for attribute 'const' [-Wsuggest-attribute=const]

10 years agoi9e: Fix memory leak in clear_bottom_line().
Andre Noll [Sat, 22 Jun 2013 15:20:15 +0000 (17:20 +0200)]
i9e: Fix memory leak in clear_bottom_line().

In clear_bottom_line() we call readline's rl_copy_text() which
allocates a buffer for the given range of the current input line. But
we never free this buffer, which results in a memory leak. This patch
plugs the leak.

10 years agoHandle empty command lines properly.
Andre Noll [Sat, 22 Jun 2013 14:59:04 +0000 (16:59 +0200)]
Handle empty command lines properly.

Both para_client and para_audioc create an argument vector from the
given command line using create_argv(). If the command line contains
only whitespace characters, this vector has length zero, and argv[0]
is NULL.

We missed to check for this at at least three places in audioc.c,
client.c and audiod_command.c, which resulted in crashes due to NULL
pointer dereferences or failed assertions.

These bugs can easily be triggered by starting para_client or
para_audioc in interactive mode, entering a single space character
and hitting return.

This patch adds the missing checks to prevent the crashes.

10 years agoMerge branch 't/interactive'
Andre Noll [Sat, 22 Jun 2013 13:58:29 +0000 (15:58 +0200)]
Merge branch 't/interactive'

Was cooking for almost two weeks.

f8931d Simplify i9e_line_handler.
f99dbe i9e: Fix a prompt display issue
cf39e4 audioc: Abstract out connection code.

10 years agoImprove text on the download web page.
Andre Noll [Sun, 19 May 2013 12:53:31 +0000 (14:53 +0200)]
Improve text on the download web page.

Enumerate the possible ways to download paraslash and explain when
each option is most suitable.

10 years agogui: Fix off-by-one in add_spaces().
Andre Noll [Sun, 16 Jun 2013 12:22:06 +0000 (14:22 +0200)]
gui: Fix off-by-one in add_spaces().

Commit e90c6c0a (Speed up add_spaces().) changed add_spaces() to print
space characters in chunks rather than one at a time. It introduced
space[], an array of whitespace characters, which is written entirely
if there are more spaces to print than the size of the array. However,
in the calculation of how much was printed so far, we missed the fact
that sizeof(space) includes the terminating NULL byte, so this number
is in fact the number of space characters *plus one*.

Consequently, we printed too few space characters. This resulted in
parts of the previous string still being visible in the top window
of para_gui.

10 years agoMerge branch 't/compress'
Andre Noll [Sun, 16 Jun 2013 11:09:20 +0000 (13:09 +0200)]
Merge branch 't/compress'

Well tested an cooked.

0a6c0e compress: Further optimize inner loop.
be761d compress: Remove log statement in inner loop.
15a54f compress: Avoid PARA_ABS and PARA_MAX in inner loop.
28c03c compress: Compile with -O3.

10 years agoMerge branch 't/oss_error_message_fix'
Andre Noll [Thu, 13 Jun 2013 16:34:04 +0000 (18:34 +0200)]
Merge branch 't/oss_error_message_fix'

9e32ff oss mixer: Improve error message.

10 years agoRemove CODENAME macro.
Andre Noll [Mon, 20 May 2013 20:30:53 +0000 (22:30 +0200)]
Remove CODENAME macro.

This macro is no longer used, so we may remove it from Makefile.in.

10 years agogui: Use version_single_line().
Andre Noll [Mon, 20 May 2013 20:12:40 +0000 (22:12 +0200)]
gui: Use version_single_line().

No need to reinvent the wheel.

10 years agoImprove man page layout.
Andre Noll [Mon, 20 May 2013 17:29:58 +0000 (19:29 +0200)]
Improve man page layout.

This changes the output of --help, --detailed-help and --version
so that the man pages generated from this output by help2man look
much nicer.

Specifically, name and purposes are printed in a single line and
the version text now contains also build data, build system and the
compiler version.

Also the codename is no longer printed in version_single_line(),
since this caused the top and bottom labels of the man pages to
look quite ugly.

10 years agoafh/play: Include supported audio formats in help output.
Andre Noll [Sun, 7 Apr 2013 00:24:13 +0000 (00:24 +0000)]
afh/play: Include supported audio formats in help output.

This is useful information, and it is simple to do, so include it in
the help.

10 years agoUse self-made help to avoid recompilations on version changes.
Andre Noll [Fri, 12 Apr 2013 12:24:54 +0000 (14:24 +0200)]
Use self-made help to avoid recompilations on version changes.

This provides print_help() for all remaining commands so that we can
get rid of the gengetopt generated help output completely.

Hence the *.cmdline.[ch] files no longer depend on git-version.h
which saves a lot of recompilations.

10 years agoProvide "purpose" texts.
Andre Noll [Sun, 7 Apr 2013 02:31:51 +0000 (02:31 +0000)]
Provide "purpose" texts.

This text will be printed right after the program name in the --help
output. For para_afh, the inline text becomes redundant, so this text
is removed.

Each executable gets a purpose text, and for receivers, filters,
writers the purpose will be printed as part of the help output of
para_audiod, para_filter. para_recv and para_write.

10 years agoRevamp ggo help.
Andre Noll [Fri, 12 Apr 2013 11:54:37 +0000 (13:54 +0200)]
Revamp ggo help.

This adds usage and description fields to struct ggo_help and
changes ggo_print_help() to optionally print these.

The boolean detailed_help flag of ggo_print_help() is replaced by a
bitmask which lets the caller specify what to print. Four pre-defined
masks are used to print the normal help, the detailed help, the help
for modules (receivers, filters, writers) and the detailed module help.

The new macro DEFINE_GGO_HELP can be employed to create a struct
ggo_help from a gengetopt structure.

10 years agoafh_recv: Replace ggo text section by description.
Andre Noll [Sat, 6 Apr 2013 22:27:51 +0000 (22:27 +0000)]
afh_recv: Replace ggo text section by description.

This way the text shows up only when --detailed-help is given.

10 years agoMake gengetopt descriptions work.
Andre Noll [Fri, 12 Apr 2013 11:54:12 +0000 (13:54 +0200)]
Make gengetopt descriptions work.

With gengetopt's text and description options it is not possible to
print a text only when --detailed-help was given, but not when only
--help is given.

Moreover, headers generated with old versions of gengetopt do not
export the description text.  However, declaring it unconditionally
causes compiler warnings on new systems.

To circumvent these problems, we introduce a new test for configure
which checks whether the description string is declared. If it is not,
we simply append the declaration to the *.cmdline.h files.

This change allows to move the description string of para_play to
the gengetopt source file.

10 years agoIntroduce version.c to limit recompilation on version changes.
Andre Noll [Fri, 12 Apr 2013 12:23:45 +0000 (14:23 +0200)]
Introduce version.c to limit recompilation on version changes.

Currently version.h includes git-version.h which changes whenever
a different commit is checked out or the working tree becomes dirty
because a file has been modified. Consequently, all .c files that
include this header must be recompiled in this case.

To limit the number of recompilations, this commit introduces
version.c, which contains functions that return the various types of
the version string. It is now the only file that includes version.h,
so only version.o must be rebuilt if git-version.h changes.

This also adds the build date, OS and CC version to the version output.

10 years agoMake all commands print git version and improve version string.
Andre Noll [Tue, 26 Mar 2013 23:30:49 +0000 (23:30 +0000)]
Make all commands print git version and improve version string.

Currently the format of the first line of the help output varies
between executables, for example:

para_afh git (0.4.12.12.g15a4: spectral gravity)
para_audioc git

This difference comes from the fact that para_afh has its own
->print_help method which uses the VERSION_SINGLE_LINE macro of
version.h while para_audioc relies on gengetopt's help output.

The latter uses the make variable PACKAGE_VERSION which gets
initialized at configure time through the second argument in AC_INIT
of configure.ac. This value is either the version number for or the
string "git".

It's a good thing to have the abbreviated git version encoded in
all executables, so this commit changes the argument of gengetopt's
--set-version to the git version string including the codename. With
the patch applied, the output of all commands looks like this if
--version was given:

para_filter 0.4.12.12.g11d7 (spectral gravity)

To make sure things stay consistent, the patch introduces the
VERSION_SINGLE_LINE macro and changes all commands to use it instead
of open coding the version string.

10 years agoAvoid unwanted log messages during startup.
Andre Noll [Mon, 1 Apr 2013 22:52:20 +0000 (22:52 +0000)]
Avoid unwanted log messages during startup.

Regardless of the given loglevel, para_recv currently prints log
messages like these at startup:

afh_init: initializing mp3 handler
afh_init: initializing ogg handler
afh_init: initializing aac handler
afh_init: initializing wma handler
afh_init: initializing spx handler
afh_init: initializing flac handler

That's because recv_init() is called before the command line arguments
are parsed, so the loglevel has not been set at this point. Other
programs have similar problems.

Fix these problems by always setting the loglevel right after a parser
has been called so that the init functions run *after* loglevel has
been set.

10 years agoDon't check return value of command line parsers unnecessarily.
Andre Noll [Sat, 6 Apr 2013 18:59:12 +0000 (18:59 +0000)]
Don't check return value of command line parsers unnecessarily.

All gengetopt parsers except the one for para_client are generated
without the --no-handle-error option, i.e. these parsers exit on errors.
Hence it is pointless to check return values.

10 years agoBuild receivers, filters and writers without -h and -V support.
Andre Noll [Fri, 5 Apr 2013 18:58:03 +0000 (18:58 +0000)]
Build receivers, filters and writers without -h and -V support.

This is not needed since the help is printed by the driving application.
It allows to get rid of an ugly "p += 3" statement in ggo.c.

10 years agofilter: Wrap lines in the available filter list.
Andre Noll [Sat, 6 Apr 2013 19:25:18 +0000 (19:25 +0000)]
filter: Wrap lines in the available filter list.

Currently para_filter -h and para_audiod -h print the available
filters in a single line which exceeds 80 characters if many
filters are supported.

This patch makes printf_or_die() return the number of characters
printed.  This allows to add line breaks to format the filter list.

10 years agoaudioc: Print config file errors.
Andre Noll [Sun, 7 Apr 2013 01:05:56 +0000 (01:05 +0000)]
audioc: Print config file errors.

Currently para_audioc fails silently if the config file contains
errors. This patch makes it print a proper error message in this case.

10 years agodoc: Rewrite udp sender description
Andre Noll [Sun, 7 Apr 2013 03:06:39 +0000 (03:06 +0000)]
doc: Rewrite udp sender description

This text was rather badly written. Replace it with better English.

10 years agoclient: Fix typo in comment.
Andre Noll [Sat, 6 Apr 2013 19:43:53 +0000 (19:43 +0000)]
client: Fix typo in comment.

10 years agoclient: Remove duplicate include.
Andre Noll [Fri, 12 Apr 2013 11:30:17 +0000 (13:30 +0200)]
client: Remove duplicate include.

The client.cmdline.h header file was included twice.

10 years agoMerge branch 't/stdin_stdout_fixes'
Andre Noll [Tue, 11 Jun 2013 18:41:49 +0000 (20:41 +0200)]
Merge branch 't/stdin_stdout_fixes'

Was cooking for almost a month.

b99b4a stdin/stdout: Restore fd flags on shutdown.

Conflicts:
stdin.c
stdout.c

10 years agoFix help text of com_touch().
Andre Noll [Tue, 11 Jun 2013 18:36:23 +0000 (20:36 +0200)]
Fix help text of com_touch().

It is the amp filter rather than the compress filter that makes use
of the amplification value stored in the audio file table.

10 years agoSimplify i9e_line_handler.
Andre Noll [Tue, 2 Apr 2013 14:30:06 +0000 (14:30 +0000)]
Simplify i9e_line_handler.

The line handlers of all three users of the i9e API (play, client
and audioc) return immediately if the passed line is NULL or the
empty string. Hence we may call the line handler only if there is a
non-empty line to dispatch.

Moving the check for a non-empty line to generic i9e code simplifies
the three line handlers a bit and avoids code duplication.

10 years agoi9e: Fix a prompt display issue
Andre Noll [Tue, 2 Apr 2013 04:05:59 +0000 (04:05 +0000)]
i9e: Fix a prompt display issue

If a line handler calls PARA_XXX_LOG() to write a log message before
attaching a buffer tree node, the prompt is not displayed properly.

Fix this by attaching a dummy btrn before the line handler is called.

10 years agoaudioc: Abstract out connection code.
Andre Noll [Tue, 2 Apr 2013 02:02:21 +0000 (02:02 +0000)]
audioc: Abstract out connection code.

This way we get a nice error message in interactive mode when
para_audiod is down. Before:

para_audioc> help
i9e_line_handler: No such file or directory

After:

para_audioc> help
connect_audiod: could not connect /var/paraslash/audiod_socket.schubert
i9e_line_handler: No such file or directory

10 years agoMerge branch 't/gui_improvements'
Andre Noll [Fri, 7 Jun 2013 19:34:51 +0000 (21:34 +0200)]
Merge branch 't/gui_improvements'

Was cooking for more than one month.

bf1831 string: Speed up xvasprintf().
bcc083 string: Add discard feature for for_each_line().
e3868d string: Simplify return value of for_each_line().
d1f0f0 string: Simplify for_each_line().
23b121 string: Clean up for_each_line() and related functions.
6256ed string: Replace the for_each_line_modes enum by a bitmap.
14e689 gui: Don't sleep before executing the status command.
e90c6c gui: Speed up add_spaces().
20e2c6 gui: Rename do_exit().
ef0508 gui: Remove superfluous cmd_died.
d7562b gui: Check stdin for readability.
a44fa6 gui: Discard overlong input lines.

Conflicts:
gui.c

10 years agoThe opus decoder.
Andre Noll [Sun, 14 Oct 2012 19:18:58 +0000 (21:18 +0200)]
The opus decoder.

Implementation is similar to the speex decoder, in particular meta
data handling is almost identical.

10 years agoThe opus audio format handler.
Andre Noll [Sun, 14 Oct 2012 16:44:57 +0000 (18:44 +0200)]
The opus audio format handler.

This fills the dummy files opus_afh.c and opus_common.c which were
introduced in the previous commit with content.  One function,
opus_parse_header(), will also be needed by the decoder to
be introduced in the next commit. So this function belongs to
opus_common.c and must be public.

10 years agoogg/opus: Infrastructure.
Andre Noll [Sun, 14 Oct 2012 14:17:44 +0000 (16:17 +0200)]
ogg/opus: Infrastructure.

This adds tests for libopus to configure.ac and minimal (non-working)
implementations of the ogg/opus decoder and audio format handler.

10 years agospeex: Don't export spx_ctl().
Andre Noll [Sun, 14 Oct 2012 14:27:13 +0000 (16:27 +0200)]
speex: Don't export spx_ctl().

This is only used from spx_common.c, so make it static and kill
the prototype in spx.h.

10 years agoMerge branch 't/doc'
Andre Noll [Sat, 25 May 2013 12:37:41 +0000 (14:37 +0200)]
Merge branch 't/doc'

Simple enough and cooking since 2013-05-05.

e82be0 manual: Add a new paragraph for installing dependencies.
1d6f5f manual: Add missing references of two optional packages.
4a6061 check_wav.c: Fix documentation of check_wav_post_select().
f9c625 Add two missing Copyright headers and file annotations.
16af9d Add documentation of public functions in check_wav.c.

10 years agoMerge remote-tracking branch 'mpi/master'
Andre Noll [Sun, 19 May 2013 21:05:00 +0000 (23:05 +0200)]
Merge remote-tracking branch 'mpi/master'

10 years agoFix compilation on Ubuntu precise.
Andre Noll [Sun, 19 May 2013 20:09:52 +0000 (22:09 +0200)]
Fix compilation on Ubuntu precise.

This distro ships glibc-2.15 where clock_gettime() is part of the
realtime library librt. So all executables which call clock_gettime()
must be linked with -lrt. The configure script detects this and adds
-lrt to LDFLAGS. However, -lrt must come *after* the objects to be
linked together, which is currently not the case.

Fix this by moving $(LDFLAGS) to the end of the recipe for the targets
of all executables.

10 years agofilter_common.c: Fix two typos in comment.
Andre Noll [Sun, 19 May 2013 19:25:13 +0000 (21:25 +0200)]
filter_common.c: Fix two typos in comment.

10 years agoalsa writer: Do not print uninitialized data.
Andre Noll [Wed, 15 May 2013 20:33:24 +0000 (22:33 +0200)]
alsa writer: Do not print uninitialized data.

ALSA's snd_output_buffer_string() returns the current size of valid
data in the returned data buffer, but this buffer is not guaranteed
to be zero-terminated.

Currently alsa_init() ignores this fact and prints the buffer up to
the first NULL byte.  Therefore it may print garbage that follows the
valid data in the buffer. If there is no zero byte after the data,
it may even segfault.

Fix this bug by using memchr() instead of strchr() and carefully
tracking the number of bytes processed.

10 years agofile writer: Use xwrite() instead of plain write().
Andre Noll [Sat, 30 Mar 2013 19:12:40 +0000 (19:12 +0000)]
file writer: Use xwrite() instead of plain write().

Currently the file writer's ->post_select() sets t->error to -1 on
errors, rather than using a proper error code. This may result in
a segfault when this number is passed to para_strerror().

Replacing the call to write() by xwrite() not only gives a proper
error code but also treats EAGAIN as a non-fatal error.

10 years agoMerge branch 't/sched_improvements'
Andre Noll [Sat, 18 May 2013 12:06:22 +0000 (14:06 +0200)]
Merge branch 't/sched_improvements'

This topic has been cooking for a month. During this period, one
problem on BSD has been found and fixed.

3ad5b0 Fix build on FreeBSD
484e75 sched: Rename new_post_select back to post_select.
74c880 sched: Kill old ->post_select variant.
c77e19 grab client: Switch to the alternative post select method.
38aeac client supervisor: Switch to the alternative post select method.
e009fa client exec: Switch to the alternative post select method.
742718 i9e: Switch to the alternative post select method.
2e6b8f vss: Switch to the alternative post select method.
6e83b4 stdout: Switch to the alternative post select method.
1995ce stdin: Switch to the alternative post select method.
88b0ec audioc: Switch to the alternative post select method.
b210e8 afs command task: Switch to the alternative post select method.
12f683 afs signal task: Switch to the alternative post select method.
ccef24 server signal task: Switch to the alternative post select method.
a6dabd server command task: Switch to the alternative post select method.
855c53 write: Switch to the alternative post select method.
58b74b play: Switch to the alternative post select method.
cf4982 afh_recv:  Switch to the alternative post select method.
4dc05b client: Switch to the alternative post select method.
043fd6 audiod: Switch command_task to the alternative post select method.
ce462a audiod: Switch the status task to the alternative post select method.
a7f2d1 audiod: Switch signal task to the alternative post select method.
ba2f65 osx writer: Switch to the alternative post select method.
3642d2 oss writer: Switch to the alternative post select method.
c29db3 file writer: Switch to the alternative post select method.
36875c ao: Switch to the alternative post select method.
3b3049 alsa: Switch to the alternative post select method.
60b853 wmadec: Switch to the alternative post select method.
6c8719 wav filter: Switch to the alternative post select method.
03e915 spxdec: Switch to the alternative post select method.
24bbc5 resample: Switch to the alternative post select method.
4ca80f prebuffer: Switch to the alternative post select method.
a55083 oggdec: Switch to the alternative post select method.
806d26 mp3dec: Switch to the alternative post select method.
7dcaf5 flacdec: Switch to the alternative post select method.
4dc9b9 fecdec: Switch to the alternative post select method.
f6e2cb compress: Switch to the alternative post select method.
ac3371 amp: Switch to the alternative post select method.
7c2c68 aacdec: Switch to the alternative post select method.
b333e0 dccp_recv: Switch to the alternative post select method.
00e793 udp_recv: Switch to the alternative post select method.
9c00a7 sched: Provide alternative post_select variant.
24758c Replace gettimeofday() by clock_gettime().
01f802 sched: Get rid of (pre)select shortcuts.
5bb44a audiod: Avoid delay when closing slot.

Conflicts:
string.c

10 years agoconfigure.ac: Do not print play objects.
Andre Noll [Fri, 17 May 2013 09:00:38 +0000 (11:00 +0200)]
configure.ac: Do not print play objects.

This is a debug statement from the early days of development of
para_play. It can safely be removed.

10 years agoFix build on FreeBSD
Andre Noll [Fri, 17 May 2013 08:49:10 +0000 (10:49 +0200)]
Fix build on FreeBSD

Commit 24758c5f (Replace gettimeofday() by clock_gettime()) removed
the inclusion of sys/time.h from several files since this header was
believed to be needed only for gettimeofday(), which was removed in
the same commit.

However, this broke the build on FreeBSD since sys/time.h
also pulled in the declaration of u_short, which is required by
/usr/include/netinet/udp.h. Therefore the compilation of udp_send.c
failed with

/usr/include/netinet/udp.h:42: error: expected specifier-qualifier-list before 'u_short'

This patch changes udp_send.c to include sys/types.h, which provides
the missing declaration.

10 years agoMerge branch 't/utf8'
Andre Noll [Tue, 14 May 2013 20:01:21 +0000 (22:01 +0200)]
Merge branch 't/utf8'

Was cooking since 2013-03-10.

a946af string.c: Fix typo in documentation of skip_cells().
251394 Switch to HTF-8 for web pages.
09c6bc gui: Try to link against libncursesw.
36f38a UTF-8 support for para_gui.
a99804 mp3_afh: Switch to UTF-8 encoding.
f78b53 gui: Don't compute string length unnecessarily.
6224f7 Get rid of unused HAVE_NCURSES define.
6cd788 Fix --with-curses configure option.

10 years agooss mixer: Improve error message.
Andre Noll [Mon, 6 May 2013 12:36:15 +0000 (14:36 +0200)]
oss mixer: Improve error message.

If /dev/mixer does not exist, para_fade fails with

main: No such file or directory

This is a rather bad error message, since the name of the missing file
is not mentioned. This patch makes oss_mix.c print the additional line

 oss_mix_open: could not open /dev/mixer

10 years agomanual: Add a new paragraph for installing dependencies.
Andre Noll [Sat, 4 May 2013 15:14:42 +0000 (17:14 +0200)]
manual: Add a new paragraph for installing dependencies.

This allows to install all required and optional packages with
a single command.

10 years agostdin/stdout: Restore fd flags on shutdown.
Andre Noll [Mon, 18 Mar 2013 22:51:46 +0000 (23:51 +0100)]
stdin/stdout: Restore fd flags on shutdown.

The stdin/stdout code should restore the flags to the old value to
avoid surprises, for example in shell scripts.

This changes stdin.c and stdout.c to save the old value. It is
restored in ->post_select when the buffer tree node is removed and
no more I/O takes place.

10 years agowma: Fix sparse error.
Andre Noll [Sat, 4 May 2013 18:39:54 +0000 (20:39 +0200)]
wma: Fix sparse error.

wma_common.c defines wma_log2() with __attribute__ ((const)), but the
declaration in wma.h lacks this attribute. Sparse does not like that
and fails with

wma_common.c:147:15: error: symbol 'wma_log2' redeclared with different type (originally declared at wma.h:28) - different modifiers

Add the const attribute also to wma.h.

10 years agoaacdec: Fix check of return value of NeAACDecInit2().
Andre Noll [Sat, 4 May 2013 16:13:56 +0000 (18:13 +0200)]
aacdec: Fix check of return value of NeAACDecInit2().

This function returns (char)-1 on errors and zero on success. Checking
whether the return value is negative is incorrect on systems where
char is unsigned.  On raspberry/ARM, gcc complains:

aacdec_filter.c:126:6: warning: comparison is always false due to limited range of data type [-Wtype-limits]

Fix this by checking agains zero instead.

10 years agomanual: Add missing references of two optional packages.
Andre Noll [Sat, 4 May 2013 15:07:56 +0000 (17:07 +0200)]
manual: Add missing references of two optional packages.

The curses lib and libsamplerate are both optional but were not
mentioned in the "Requirements" section. This patch adds both.

10 years agostring: Speed up xvasprintf().
Andre Noll [Mon, 25 Mar 2013 19:05:05 +0000 (19:05 +0000)]
string: Speed up xvasprintf().

This avoids to call vsnprintf() twice in the common case where the
result is small.

The running time of a simple test case that called this function in
a loop improved from 13s to 8s due to this change.

10 years agostring: Add discard feature for for_each_line().
Andre Noll [Mon, 25 Mar 2013 18:02:54 +0000 (18:02 +0000)]
string: Add discard feature for for_each_line().

This adds the new FELF_DISCARD_FIRST flag which instructs
for_each_line() to discard everything up to the next newline.

The new feature is only used by para_gui. When para_gui detects
a partial overlong input line, it ignores this data and passes the
FELF_DISCARD_FIRST flag in subsequent calls to for_each_line(). Hence
output continues at the next line.

10 years agostring: Simplify return value of for_each_line().
Andre Noll [Mon, 25 Mar 2013 17:30:56 +0000 (17:30 +0000)]
string: Simplify return value of for_each_line().

No caller used this function for counting lines, so simplify it by always
returning the number of bytes not processed.

10 years agostring: Simplify for_each_line().
Andre Noll [Mon, 25 Mar 2013 17:16:14 +0000 (17:16 +0000)]
string: Simplify for_each_line().

No user calls this with line_hander == NULL, so remove the special treatment
of this case.

10 years agostring: Clean up for_each_line() and related functions.
Andre Noll [Mon, 25 Mar 2013 16:10:28 +0000 (16:10 +0000)]
string: Clean up for_each_line() and related functions.

While for_each_complete_line() is a static function, there are two
public functions, for_each_line() and for_each_line_ro(), which are
implemented as simple wrappers for the static one. The only difference
between the two is that for_each_line_ro() sets the FELF_READ_ONLY
bit while for_each_line() does not.

Since we are about to add another bit of information soon, let's make
the bitmap and the static function public, and remove the two wrappers.
All callers are changed to pass an additional "unsigned flags" to
indicate whether they want the read-only behavior.

Documentation is updated accordingly.

10 years agostring: Replace the for_each_line_modes enum by a bitmap.
Andre Noll [Mon, 25 Mar 2013 15:36:10 +0000 (15:36 +0000)]
string: Replace the for_each_line_modes enum by a bitmap.

Currently we pass an "enum for_each_line_modes" as the first argument
to for_each_complete_line(). The parameter is effectively a boolean
since the enumeration defines only two possible values.

For the upcoming discard feature of for_each_line_modes() we'll need
to pass another bit of information, so this patch changes the type of
the first argument to for_each_complete_line() to unsigned and treats
it as a bit array. The only bit defined so far is LINE_MODE_RO, with
unchanged semantics.

The two callers are updated to reflect this change.

10 years agogui: Don't sleep before executing the status command.
Andre Noll [Wed, 27 Mar 2013 20:49:40 +0000 (20:49 +0000)]
gui: Don't sleep before executing the status command.

This results in uncacceptable delays when the status command fails
for any reason, for example because the server is down.

Replace this code by introducing a struct timeval variable "next_exec",
which stores the earliest possible time to restart the status command.

Move all status fetching code before the select() call in do_select()
to open_stat_pipe() and rename the function to status_pre_select(),
which is more appropriate.

10 years agogui: Speed up add_spaces().
Andre Noll [Mon, 25 Mar 2013 19:08:12 +0000 (19:08 +0000)]
gui: Speed up add_spaces().

The calls to waddstr() in this function showed up in profiles. So
print the full string at once instead of calling waddstr() for each
character.

10 years agogui: Rename do_exit().
Andre Noll [Mon, 25 Mar 2013 03:08:12 +0000 (03:08 +0000)]
gui: Rename do_exit().

This function sends SIGTERM to every process in the process group of
para_gui and dies thereafter. So kill_pg_and_die() is more descriptive
than the old name.

10 years agogui: Remove superfluous cmd_died.
Andre Noll [Mon, 25 Mar 2013 02:22:24 +0000 (02:22 +0000)]
gui: Remove superfluous cmd_died.

We might as well directly refer to cmd_pid which is set to zero in the
signal handling code after the process exits.

10 years agogui: Check stdin for readability.
Andre Noll [Mon, 25 Mar 2013 02:14:06 +0000 (02:14 +0000)]
gui: Check stdin for readability.

If the select_loop of para_gui runs in getch or command mode we
currently wait a full timeout period before checking for pending
input.

This patch adds stdin to the set of file descriptors monitored by
select so that a key press causes select() to return immediately.

10 years agogui: Discard overlong input lines.
Andre Noll [Mon, 18 Mar 2013 19:13:35 +0000 (20:13 +0100)]
gui: Discard overlong input lines.

If an external command produces output without newlines, the current
code ends up calling read_nonblock() with a buffer size of zero which
triggers the assertion in readv_nonblock().

Increase the output buffer to 32K and fix the problem by simply
discarding all input if the input buffer is full and contains no
newline character.

A better fix would be to discard everything until the next newline
character is read, but this requires more work, so let's go with this
simple fix for now.

10 years agoMerge branch 't/allow_zero_btr_add'
Andre Noll [Thu, 2 May 2013 17:55:18 +0000 (19:55 +0200)]
Merge branch 't/allow_zero_btr_add'

Was cooking for over a month.

10 years agosched: Rename new_post_select back to post_select.
Andre Noll [Sun, 31 Mar 2013 19:47:35 +0000 (19:47 +0000)]
sched: Rename new_post_select back to post_select.