Andre Noll [Mon, 8 Oct 2012 20:54:44 +0000 (22:54 +0200)]
configure.ac: libflac also affects para_afh and para_server.
If libflac was not detected, there will be no flac support
whatsoever. The current warning message is misleading since
it only mentions para_audiod and para_filter.
Andre Noll [Sun, 29 Jul 2012 18:51:18 +0000 (20:51 +0200)]
Simplify ggo makefile.
Currently we have three different targets for creating *_cmdline.[ch]
files. This is because receivers, filters and writers need slightly
different command line options.
This patch defines the common options in the ggo makefile and moves
additional parameters to the individual .m4 files so that a single
target to create *_cmdline.[ch] is now sufficient.
The name of the command line parsers of some filters and writers
changed due to this unification, so these are updated accordingly.
Andre Noll [Sun, 29 Jul 2012 17:49:46 +0000 (19:49 +0200)]
write: Get rid of gengetopt's string parser.
It causes gengetopt to generate quite some additional code for
the string parsers of all writers. Moreover, this string parser is
inferior to create_argv() and create_shifted_argv() of string.c as
gengetopt's parser does not honor any quoting at all.
This commit changes the signature of the ->parse_config_or_die method
of struct writer to take an (argc, argv) pair instead of a string. All
writers can thus call the vanilla command line parser of gengetopt. The
single user in write_common.c now calls ->parse_config_or_die()
with an (argc, argv) pair obtained from create_shifted_argv().
Andre Noll [Sun, 29 Jul 2012 16:39:58 +0000 (18:39 +0200)]
Introduce create_shifted_argv().
In order to create argument vectors for the gengetopt parsers,
filter_common.c and recv_common.c call create_argv() on the given
--filter or --receiver option, then shift the returned array by one
to the right because gengetopt expects the program name in argv[0].
This commit creates a new helper function for this purpose and changes
the two callers to use the new function.
Andre Noll [Sun, 29 Jul 2012 14:28:28 +0000 (16:28 +0200)]
para_gui ggo: Do not pass --no-handle-error.
We are exiting anyway on errors. This change allows to skip
the check of the return value of gui_cmdline_parser() and
removes a line from the makefile.
Andre Noll [Sat, 28 Jul 2012 16:14:24 +0000 (18:14 +0200)]
Put dependency files to a separate directory.
Currently the dependency files are stored in the same directory as the
object files. This moves these files to the new build/deps directory
instead, and makes "make clean" remove the objects directory while
"make clean2" now removes the whole build directory.
As a side effect of this change, the $(all_objs) variable now contains
only the non-directory part of the objects, so we may get rid of the
directory-stripping in the test makefile.
Andre Noll [Sat, 28 Jul 2012 06:44:00 +0000 (08:44 +0200)]
configure: Replace AC_TRY_RUN and AC_TRY_LINK.
Both macros are considered obsolete. AC_TRY_RUN has been obsoleted
by AC_RUN_IFELSE while AC_TRY_LINK has been replaced by AC_LINK_IFELSE.
This patch replaces all occurrences of these two obsolete macros and
bumps the required autoconf version to 2.61 (which was released in
2006 and is shipped with Ubuntu Hardy).
Andre Noll [Sun, 22 Jul 2012 14:33:20 +0000 (16:33 +0200)]
Makefile: Clean up directory creation.
This combines all directory targets into a single target and executes
the contents of the new MKDIR_P variable (set to "mkdir -p") to create
the directory.
Andre Noll [Sun, 22 Jul 2012 14:11:11 +0000 (16:11 +0200)]
Move gengetopt input files to m4 directory.
This separates the gengetopt input directory from its output directory.
All gengetopt m4 file are moved to the new m4/gengetopt directory.
As a consequence of this cleanup, we may get rid of the .gitignore
file for the generated ggo files, which is a good thing as it was
hard to keep it up to date.
Andre Noll [Sun, 22 Jul 2012 13:15:52 +0000 (15:15 +0200)]
Treat all ggo files as m4 files.
Most input files for gengetopt are already generated from corresponding
m4 files. This renames the remaining ones, so that all .ggo files
are now generated and can be removed by the make clean variants.
Hence we do not need to track the set of generated ggo files any more.
Andre Noll [Tue, 14 Aug 2012 11:09:43 +0000 (13:09 +0200)]
signal: Improve documentation of para_signal_init().
para_signal_init() does not install any signal handlers, so this part of the
documentation is incorrect. The patch fixes this flaw, mentions which end of
the signal pipe is returned to the caller and improves the wording a bit.
Andre Noll [Mon, 23 Jul 2012 19:50:40 +0000 (21:50 +0200)]
server: Remove "foo" feature.
Oops, this feature was added only for testing feature negotiation
with multiple features and should have been deleted before 0.4.11 was
released. This was even mentioned in the commit message of e151dbb7,
which introduced the bogus "foo" feature..
Andre Noll [Tue, 24 Jul 2012 06:42:23 +0000 (08:42 +0200)]
com_init(): Send error message only for non-sideband connections.
If com_init() fails, this non-sideband error message is currently
sent also for sideband connections, which confuses the client. Send
it only for non-sideband connections.
Andre Noll [Mon, 23 Jul 2012 06:41:23 +0000 (08:41 +0200)]
fade: Fix command for switching moods.
It contained a newline, which was not a problem before the sideband
API was introduced. However, with sideband being the default, the
newline character is interpreted as part of the name of the mood or
playlist, causing the mood switch to fail.
The fix is simple: Just remove the trailing newline character.
Andre Noll [Sun, 8 Apr 2012 19:31:10 +0000 (21:31 +0200)]
btr_exec_up(): Also ask given node.
At the moment, the buffer tree walk starts at the parent of the given
node. Users of the btr API can not execute a command for a node unless
it has at least one child.
This unnecessary restriction is removed in this commit by letting
the tree walk start at the given node rather than its parent.
This actually simplifies the code a bit.
Andre Noll [Tue, 23 Aug 2011 19:04:02 +0000 (21:04 +0200)]
btr: Introduce btr_add_output_dont_free().
At the moment, all buffers which are fed to a buffer tree must be
allocated on the heap since the buffer tree code automatically frees
the buffer once its refcount dropped to zero.
The new afh receiver, however, mmaps the audio file and likes to feed
chunks of this memory map into the buffer tree. This is currently
impossible because such buffers must not be freed.
This patch adds the new public function btr_add_output_dont_free()
which works like btr_add_output() but sets the new dont_free bit
which prevents the buffer from being deallocated.
Also btr_inplace_ok() is changed to return "false" whenever there
exists a buffer in the input queue with the dont_free bit set.
Andre Noll [Mon, 9 Apr 2012 19:57:54 +0000 (21:57 +0200)]
btr: Remove btr_free_node().
This has turned out to be source for bugs. Deallocate everything
in btr_remove_node() hence making removing the node and freeing
its resources an atomic operation.
To avoid dangling pointers to freed btrn nodes, the argument of
btr_remove_node() is changed to to struct btr_node **btrnp.
Andre Noll [Mon, 9 Apr 2012 23:43:38 +0000 (01:43 +0200)]
command_util: Fix make dependencies for *_command_list.h.
The *_command_list.h files depend on the .c files listed in the SF
header line of the .cmd command file because command_util.sh gets
the declaration of the command handlers from these files.
Unfortunately, make does not know about these dependencies, so we
have to mention them in the Makefile as well.
Andre Noll [Sat, 7 Apr 2012 06:30:27 +0000 (08:30 +0200)]
Make (most) command handlers static.
Now that the array of commands for para_server and para_audiod are
read from a header file, the command handlers can be made static if
they are in the same file that defines the command array.
This patch makes all such handlers static and tweaks command_util.sh
to recognize also static functions.
Andre Noll [Thu, 28 Jun 2012 02:45:09 +0000 (04:45 +0200)]
command_util: Remove code for generating .c files.
Now that the *_command_list.c files are no longer needed we may remove
this mode from command_util.sh. This makes quite a few headers of
the .cmd files unused, so these can be removed as well.
Andre Noll [Thu, 28 Jun 2012 02:23:32 +0000 (04:23 +0200)]
command_util: Write array definition in header mode.
This modifies command_util.sh so that when it is called in header mode,
it also defines a macro for the array of all commands. command.c and
audiod_command.c are changed to use the new preprocessor macro.
This allows to get rid of the *command_list.c files completely. We may
hence remove these files from the various lists of errlist objects
in configure.ac. and from error.h. A subsequent patch will clean up
the parts that have become unused by this commit.
Andre Noll [Thu, 28 Jun 2012 01:08:00 +0000 (03:08 +0200)]
command_util: Output array members with backslashes.
This makes sure that the generated code for the definition of the
command array has backslashes at the end of each line. Currently
this does not matter because make_array_member() is only called when
generating C code where new lines don't matter.
However, ending each line with a backslash allows to use the same
output for a cpp #define which can go into the header file.
Andre Noll [Thu, 28 Jun 2012 00:51:28 +0000 (02:51 +0200)]
command_util: Avoid empty output lines.
Additional empty output lines do not matter for the generated C code or
the function declarations in the header files. However, a subsequent
commit changes command_util.sh to generate a preprocessor macro for
the header file, and there we can not afford empty lines unless they
end with a backslash to continue the line.
This patch makes sure that no superfluous newlines are printed in
the output.
Andre Noll [Fri, 1 Jun 2012 08:56:10 +0000 (10:56 +0200)]
wma: Remove exponent_sizes[] from struct private_wma_data.
This array is only used in compute_scale_factor_band_sizes(), and
even there we need only the current value. So it is enough to have
a single local variable in this function.
Andre Noll [Fri, 29 Jun 2012 14:28:11 +0000 (16:28 +0200)]
sideband: Fix use after free bug.
Commit 32ffc06c (Pass command exit status via sideband to client.)
made para_server's command handler send the exit status of the command
to the client as an RC4-encrypted sideband packet.
However, the encryption key has already been freed when this packet
is sent. This may result in client errors about invalid or unexpected
sideband designators, but these errors occurred rather infrequently,
which makes this bug hard to trigger. Presumably the freed memory is
usually not being reused since the command handler is going to dye
anyway after the packet is sent.
This patch fixes the bug by deferring to free the crypto keys until
the exit code has been sent.
Andre Noll [Tue, 26 Jun 2012 20:07:55 +0000 (22:07 +0200)]
Merge branch 't/decoder_fixes'
97dbfe wmadec: Only decode one superframe at a time.
d6e017 flacdec: Only process a single flac audio frame.
1e1968 flacdec_close(): Be liberal in what you accept.
3f96f9 oggdec: Fix EOF handling on repositioning.
c7e2f7 oggdec: Realloc buffer to save memory.
634e75 oggdec: Do not decode more than necessary.
These changes are well tested and there are no known problems.
Andre Noll [Wed, 13 Jun 2012 15:53:07 +0000 (17:53 +0200)]
alsa: Do not buffer more than 500ms.
In alsa_init() we set the buffer time to the maximum value supported
by the device. However, on some systems this time is more than 10
seconds, which is much too high.
This patch changes alsa_init() to use a buffer time of at most
0.5 seconds.
This is because clang can not prove that the "score" variable is
always initialized at this point. However, I can: The problematic
GET_NUM_DIGITS() statement is only executed if LS_FLAG_ADMISSIBLE_ONLY
is set in options->flags, but in this case "score" will be set by
get_score_and_aft_row() because this function only fails to do so if it
returns negative. In this case we return early from prepare_ls_row().
Let's make it easier for clang and initialize it anyway.
Andre Noll [Wed, 13 Jun 2012 14:38:10 +0000 (16:38 +0200)]
mood: Improve readability of get_item_score().
This function returns whether the given item matches, so make
it return bool rather than int. This improves readability of
compute_mood_score(), which calls get_item_score() three times,
quite a bit.
Andre Noll [Tue, 15 May 2012 21:19:29 +0000 (23:19 +0200)]
mood: Add score value only for admissible files.
mood.c:175:3: warning: Value stored to 'ret' is never read
ret = get_item_score(item, &afsi, &afhi, path, &item_score,
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Andre Noll [Tue, 15 May 2012 20:17:18 +0000 (22:17 +0200)]
client: Remove pointless assignment.
client.c:310:2: warning: Value stored to 'ret' is never read
ret = i9e_extract_completions(ci->word, sl, &cr->matches);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Andre Noll [Tue, 15 May 2012 20:15:41 +0000 (22:15 +0200)]
gcrypt: Remove dead stores.
gcrypt.c:502:2: warning: Value stored to 'cp' is never read
cp += ret;
^ ~~~
gcrypt.c:577:2: warning: Value stored to 'cp' is never read
cp += ret;
^ ~~~
Andre Noll [Sat, 7 Apr 2012 01:02:33 +0000 (03:02 +0200)]
wmadec: Only decode one superframe at a time.
Similar to the previous commit for the flac decoder, this commit
removes the loop in wmadec_post_select(). This gives other tasks a
chance to run and simplifies the code.
Also, if the buffer was not filled completely, it is truncated to
the proper size to reduce memory usage of the decoder.
Andre Noll [Sat, 7 Apr 2012 01:02:02 +0000 (03:02 +0200)]
flacdec: Only process a single flac audio frame.
This removes the loop in flacdec_post_select() which makes the
flac decoder decode as much as possible, but may starve other
tasks. Removing the loop gives other tasks a chance to run, thereby
avoiding buffer underruns. It simplifies the code too.
Also, resetting the number of unconsumed input bytes to zero at
each scheduler iteration has always been a mistake, so remove it.
Andre Noll [Tue, 10 Apr 2012 05:38:20 +0000 (07:38 +0200)]
flacdec_close(): Be liberal in what you accept.
Functions like close() which terminate an instance of some subsystem
should always be idempotent, i.e. when calling such a function twice
with the same argument, the second call should be a noop.
However, flacdec_close() violates this rule because it dereferences
its private pointer unconditionally. This patch makes the function
idempotent.
Andre Noll [Sun, 3 Jun 2012 09:59:42 +0000 (11:59 +0200)]
oggdec: Fix EOF handling on repositioning.
If playback starts near the end of the file, it might happen that (a)
the read callback consumes all the remaining part in one go (so the
node status is BTR_EOF) and (b) the last ov_read() returned OV_HOLE.
(b) makes the decoder wait for more data which will never arrive due to
(a). Currently we error out without playing the last part of the file.
This patch makes ogg_post_select() return an error only if additionally
fn->min_iqs == 0, which indicates we did not hit OV_HOLE during the
last ov_read().
Andre Noll [Sun, 13 May 2012 19:54:46 +0000 (21:54 +0200)]
oggdec: Realloc buffer to save memory.
The ogg/vorbis decoder always allocates 32K buffers for the decoded
output data. If the buffer could not be filled completely due to
insufficient input data being available, the partially filled 32K
buffer is added to the output buffer tree.
This patch truncates (reallocates) the buffer if this has happened,
thereby reducing the memory footprint of the decoder.
Andre Noll [Sat, 7 Apr 2012 22:25:42 +0000 (00:25 +0200)]
audiod: Check pointers passed to btr_get_node_start().
If the receiver or writer buffer tree node pointer is NULL, we'll segfault due
to a a NULL pointer dereference in btr_get_node_start(). Although this might
not be triggerable, it does not hurt to be defensive here.
Andre Noll [Wed, 11 Apr 2012 21:16:00 +0000 (23:16 +0200)]
oggdec: Do not decode more than necessary.
Currently the ogg vorbis decoder decodes at least one buffer per
scheduler iteration and checks only then if its output queue is already
full. This is bad for several reasons, increased memory footprint is
one of them.
This patch adds an additional check at the beginning of
ogg_post_select() that causes the function to return early if the
output queue is full.
Andre Noll [Wed, 16 May 2012 13:21:10 +0000 (15:21 +0200)]
oss: Add proper error message on init.
If the device node of the sound device (/dev/dsp) does not exist,
we currently fail with a "no such file or directory" error message
without mentioning the name of the device. This adds a log message
which clarifies what went wrong.