paraslash.git
12 years agoalsa: Dump the configuration on startup.
Andre Noll [Tue, 26 Jul 2011 20:47:20 +0000 (22:47 +0200)]
alsa: Dump the configuration on startup.

Currently we log selected alsa parameters, but it is sometimes
useful to see the full configuration. This patch adds a call to
snd_pcm_dump() to alsa_init() which obtains the alsa hardware and
software configuration. It is printed for loglevels info and debug.

12 years agoalsa: Avoid busy loop with dmix.
Andre Noll [Sat, 8 Oct 2011 17:16:14 +0000 (19:16 +0200)]
alsa: Avoid busy loop with dmix.

When using alsa's direct mixing plugin, the alsa poll fd might be ready
for IO even though nothing can be written to the alsa handle. This
leads to a busy loop in para_audiod and para_write and makes these
applications eat up considerable amounts of CPU time during playback.

This patch fixes the problem by reading from the alsa fd after a
failed write. It also adjusts the test for when to return early from
alsa_post_select(). The old code was not wrong, however, since we
should never reach the test if poll_fd is negative.

12 years agodoc: Add some missing doxygen comments.
Andre Noll [Sat, 15 Oct 2011 19:21:07 +0000 (21:21 +0200)]
doc: Add some missing doxygen comments.

12 years agoMerge branch 't/clang_analyzer_fixes'
Andre Noll [Sat, 15 Oct 2011 13:36:38 +0000 (15:36 +0200)]
Merge branch 't/clang_analyzer_fixes'

12 years agopara_filter: Decode also small ogg vorbis files properly.
Andre Noll [Thu, 13 Oct 2011 14:10:11 +0000 (16:10 +0200)]
para_filter: Decode also small ogg vorbis files properly.

ogg_post_select() returns after initializing the decoder without
decoding anything, which is usually OK. However, if the file is smaller
than half of the size of the stdin buffer tree area, the whole file
is going to be fed to the decoder during the first iteration of the
scheduler loop. Currently this results in an empty output file.

The problem with small files is that the post select function of the
stdin buffer tree node encounters EOF on the next read and returns
EOF. This causes oggdec_post_select() to abort without producing any
output since its parent (stdin) is gone and there is no input pending.

This patch fixes the problem by setting the "have_more" flag after
ogg_init() returned successfully. oggdec_post_select() checks this
flag and only returns negative if it is unset.

12 years agoMerge branch 't/uptime_cleanup'
Andre Noll [Mon, 10 Oct 2011 20:01:22 +0000 (22:01 +0200)]
Merge branch 't/uptime_cleanup'

12 years agoMerge branch 't/shmmax'
Andre Noll [Tue, 4 Oct 2011 19:41:47 +0000 (21:41 +0200)]
Merge branch 't/shmmax'

12 years agodoc: Minor doxygen fixes.
Andre Noll [Sat, 1 Oct 2011 21:35:18 +0000 (23:35 +0200)]
doc: Minor doxygen fixes.

doxygen's \cond and \endcond commands treat the word after the
command as the name of the section which should be excluded from the
documentatation. So it is wrong to put an arbitrary comment there.

This fixes a couple of doxygen warnings about unknown loglevel defines
and makes these defines actually show up in the generated HTML.

12 years agoMerge branch 't/distcc'
Andre Noll [Mon, 26 Sep 2011 21:53:35 +0000 (23:53 +0200)]
Merge branch 't/distcc'

12 years agoopenssl RC4: Fix another invalid read.
Andre Noll [Mon, 26 Sep 2011 12:34:29 +0000 (14:34 +0200)]
openssl RC4: Fix another invalid read.

Commit 11993981 fixed this bug for the RC4 sending function
but missed to change sc_recv_bin_buffer() accordingly.

This patch avoids the following invalid read detected by valgrind:

==23299== Invalid read of size 8
==23299==    at 0x510A020: RC4 (in /lib/libcrypto.so.0.9.8)
==23299==    by 0x408771: sc_recv_bin_buffer (crypt.c:313)
==23299==    by 0x40837F: sc_recv_buffer (crypt_common.c:331)
==23299==    by 0x4073C2: T.41 (client_common.c:139)
==23299==    by 0x407758: client_post_select (client_common.c:268)
==23299==    by 0x406A34: schedule (sched.c:71)
==23299==    by 0x405625: main (client.c:572)
==23299==  Address 0x613ccb8 is 3,992 bytes inside a block of size 3,999 alloc'd
==23299==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==23299==    by 0x405D9F: para_malloc (string.c:65)
==23299==    by 0x408741: sc_recv_bin_buffer (crypt.c:309)
==23299==    by 0x40837F: sc_recv_buffer (crypt_common.c:331)
==23299==    by 0x4073C2: T.41 (client_common.c:139)
==23299==    by 0x407758: client_post_select (client_common.c:268)
==23299==    by 0x406A34: schedule (sched.c:71)
==23299==    by 0x405625: main (client.c:572)

12 years agocommand: Remove two dead stores.
Andre Noll [Mon, 15 Aug 2011 18:20:02 +0000 (20:20 +0200)]
command: Remove two dead stores.

command.c:771:2: warning: Value stored to 'ret' is never read
        ret = -E_BAD_USER;
        ^     ~~~~~~~~~~~
command.c:765:2: warning: Value stored to 'numbytes' is never read
        numbytes = ret;
        ^          ~~~

12 years agoaac_afh: Don't compute the number of milliseconds twice.
Andre Noll [Mon, 15 Aug 2011 18:16:38 +0000 (20:16 +0200)]
aac_afh: Don't compute the number of milliseconds twice.

aac_afh.c:194:16: warning: Value stored to 'ms' during its initialization is never read
        long unsigned ms = 1000.0 * afhi->chunks_total * tmp
                      ^    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

12 years agoogg_afh: Kill dead store.
Andre Noll [Mon, 15 Aug 2011 18:15:05 +0000 (20:15 +0200)]
ogg_afh: Kill dead store.

ogg_afh.c:108:3: warning: Value stored to 'ret' is never read
                ret = -E_OGG_PACKET_IN;
                ^     ~~~~~~~~~~~~~~~~

12 years agocrypt: Streamline get_asymmetric_key().
Andre Noll [Mon, 15 Aug 2011 18:05:11 +0000 (20:05 +0200)]
crypt: Streamline get_asymmetric_key().

The clang analyzer says

crypt.c:202:9: warning: Function call argument is an uninitialized value
        ret2 = para_munmap(map, map_size);
               ^                ~~~~~~~~
And right it is. This is not a bug though as map_size is only undefined
if map is NULL and in this case para_munmap does not look at its second
argument. However, this is rather subtle, so introduce a new label out_unmap
and jump there only if we really must unmap the file.

12 years agowmadec: Fix two dead stores.
Andre Noll [Mon, 15 Aug 2011 17:42:15 +0000 (19:42 +0200)]
wmadec: Fix two dead stores.

wmadec_filter.c:772:3: warning: Value stored to 'mult1' is never read
                mult1 = mult;
                ^       ~~~~
wmadec_filter.c:1015:3: warning: Value stored to 'n' is never read
                n = pwd->block_len;
                ^   ~~~~~~~~~~~~~~

Also convert a statement of the form x = x * y to x *= y;

12 years agoimdct: Remove dead store.
Andre Noll [Mon, 15 Aug 2011 17:36:46 +0000 (19:36 +0200)]
imdct: Remove dead store.

imdct.c:296:2: warning: Value stored to 'output' is never read
        output += n4;
        ^         ~~

12 years agodccp_recv: Avoid NULL pointer dereference.
Andre Noll [Thu, 15 Sep 2011 12:33:14 +0000 (14:33 +0200)]
dccp_recv: Avoid NULL pointer dereference.

dccp_recv.c:48:16: warning: Access to field 'btrp' results in a dereference of a null pointer (loaded from variable 'pdd')
        btr_pool_free(pdd->btrp);
                      ^~~

In dccp_recv_close(), if pdd is NULL, we avoid closing pdd->fd but
dereference pdd nevertheless one line later. Fix this by returning
early if pdd is NULL.

12 years agorecv: Improve documentation of generic_recv_pre_select().
Andre Noll [Tue, 20 Sep 2011 20:27:18 +0000 (22:27 +0200)]
recv: Improve documentation of generic_recv_pre_select().

Make it clear that this function returns the state of the given buffer
tree node, i.e. > 0 on success, == 0 if there is nothing to do and <
0 on errors.

12 years agoafh: Fix two typos in the man page.
Andre Noll [Sun, 18 Sep 2011 14:23:34 +0000 (16:23 +0200)]
afh: Fix two typos in the man page.

12 years agoOverhaul the daemon uptime functions.
Andre Noll [Wed, 10 Aug 2011 22:01:11 +0000 (00:01 +0200)]
Overhaul the daemon uptime functions.

The public interface of daemon.c offers some helpers for maintaining
and printing the uptime of the service. This interface consists of
the "uptime" enumeration and the public functions server_uptime()
and uptime_str(). The former function takes an uptime enum which is
either 'UPTIME_GET' or 'UPTIME_SET'.

It is cleaner to avoid the enumeration and have two separate
functions for getting and setting the uptime, so this patch
replaces server_uptime() by two new functions get_server_uptime()
and set_server_start_time(), renames uptime_str() to
get_server_uptime_str() and gets rid of the uptime enum.

All three new functions take an optional struct timeval * type argument
for the common case where the caller already knows the current time, or
wishes to specify another time for whatever reason. This allows to save
one time() system call per scheduler loop in para_server since with
this patch status_refresh() can pass the global "now" pointer (which
us updated by the scheduler once per loop) to get_server_uptime().

12 years agoserver: Kill an unused variable.
Andre Noll [Wed, 10 Aug 2011 22:06:20 +0000 (00:06 +0200)]
server: Kill an unused variable.

In status_refresh(), ret is set to 1 and never changed. Remove this
variable and get rid of the check which is always true.

12 years agoipc: Determine maximal size of a shared memory area at runtime.
Andre Noll [Wed, 10 Aug 2011 17:50:38 +0000 (19:50 +0200)]
ipc: Determine maximal size of a shared memory area at runtime.

During command dispatch, the afs process allocates shm areas for the
query result and passes the identifiers via the local socket to the
child process of para_server which is executing the command. If the
write to the (non-blocking) local socket fails, for example because
the call would block, afs closes the connection to the child process
immediately to avoid deadlocks.

Therefore the maximal output size of an (afs) command depends
linearly on the size of the shared memory areas, so it is desirable
to allocate areas as large as possible. Currently, we use the SHMMAX
if it is defined and fall back to the safe default value of 64K
otherwise. However, this default is much smaller than the typical limit
of 32M on Linux. Moreover, the maximal size of a shared memory area
(shmmax) can be set at any time on most if not all operating systems,
so runtime detection of shmmax is to be preferred.

Unfortunately the way to obtain shmmax varies between operating
systems. On Linux, the value is available as the contents of a file
in /proc while on {Free,Net}BSD and Darwin sysctlbyname() must be
called. Moreover, BSD and Darwin use different identifiers for the
sysctlbyname() call.

So any code that determines shmmax at runtime and works on all
of the above systems must necessarily be ugly. This patch tries to
concentrate all ugliness in the new shm_get_shmmax() function, so that
the changes outside of ipc.c consist only of replacements SHMMAX ->
shm_get_shmmax() and of the removal of the default SHMMAX setting.

The new function only determines shmmax once when it is called for
the first time.

12 years agotime.c: Fix typo in comment.
Andre Noll [Fri, 16 Sep 2011 18:58:30 +0000 (20:58 +0200)]
time.c: Fix typo in comment.

12 years agoautogen: Run parallel make if compiling with distcc.
Andre Noll [Thu, 21 Apr 2011 21:33:06 +0000 (23:33 +0200)]
autogen: Run parallel make if compiling with distcc.

This adjusts the value of the make -j option in case the DISTCC_HOSTS
environment variable is set. There is no way to determine the number of
processing units (cores) for the remote hosts listed in DISTCC_HOSTS,
so we set the number of jobs to run simultaneously to

n + 2 * n * d

where n is the number of cores on the local system and d is the
number of hosts in DISTCC_HOSTS. This seems to work fine on one such
distributed setup.

12 years agodoc: Fix database name in server manual page.
Andre Noll [Sat, 10 Sep 2011 20:07:39 +0000 (22:07 +0200)]
doc: Fix database name in server manual page.

Bugs are like mushrooms said Al Viro. Right he is.

12 years agomp3dec: Avoid possible endless loop.
Andre Noll [Wed, 31 Aug 2011 03:32:04 +0000 (05:32 +0200)]
mp3dec: Avoid possible endless loop.

If an error occurs during frame decode at the end of an 8K buffer,
the code in mp3dec.c might loop forever because we miss to consume
the data of all frames that have been decoded so far during this
iteration of the scheduler loop.

The two callers of used_mad_buffer_bytes() both call btr_consume()
next, and this fix requires to call the same two function once more
from another location. So it is natural to move the btr_consume()
call into used_mad_buffer_bytes() and rename the latter function
to mp3dec_consume().

12 years agostring: Set result pointer to NULL on errors.
Andre Noll [Sun, 28 Aug 2011 04:35:37 +0000 (06:35 +0200)]
string: Set result pointer to NULL on errors.

...and be strict in what you return.

12 years agostring: Allow passing NULL to free_argv().
Andre Noll [Fri, 26 Aug 2011 23:47:13 +0000 (01:47 +0200)]
string: Allow passing NULL to free_argv().

After all, free() also allows NULL pointers. Be liberal in what you
accept...

12 years agostring: Fix trivial whitespace issue.
Andre Noll [Fri, 2 Sep 2011 02:55:19 +0000 (04:55 +0200)]
string: Fix trivial whitespace issue.

12 years agoaudioc: Trivial cosmetic cleanups.
Andre Noll [Fri, 2 Sep 2011 01:54:59 +0000 (03:54 +0200)]
audioc: Trivial cosmetic cleanups.

Only whitespace and spelling fixes.

12 years agoserver: Fix typo in help text of the stat command.
Andre Noll [Tue, 30 Aug 2011 01:26:28 +0000 (03:26 +0200)]
server: Fix typo in help text of the stat command.

The "=" is necessary.

12 years agobash_completion: Update database name.
Andre Noll [Sat, 27 Aug 2011 14:25:01 +0000 (16:25 +0200)]
bash_completion: Update database name.

Oops, this should have been done in v0.4.0..

12 years agonew codename, reset version to git
Andre Noll [Fri, 19 Aug 2011 09:29:38 +0000 (11:29 +0200)]
new codename, reset version to git

12 years agothe paraslash-0.4.8 release tarball
Andre Noll [Fri, 19 Aug 2011 09:19:59 +0000 (11:19 +0200)]
the paraslash-0.4.8 release tarball

12 years agoparaslash 0.4.8 v0.4.8
Andre Noll [Fri, 19 Aug 2011 09:16:43 +0000 (11:16 +0200)]
paraslash 0.4.8

12 years agomp3dec: Fix possible endless loop.
Andre Noll [Wed, 17 Aug 2011 17:08:17 +0000 (19:08 +0200)]
mp3dec: Fix possible endless loop.

If the header of the last frame of a (corrupt) mp3 file can be decoded
but the rest of the frame can not, the mp3 decoder may end up in a
busy loop.

Fix this by performing the same check as for errors during header
decode. This adds some code duplication but as we are late in the
release cycle, let's go for the minimal fix for now.

12 years agosched: Zero-out fd sets on min delay.
Andre Noll [Mon, 15 Aug 2011 20:56:01 +0000 (22:56 +0200)]
sched: Zero-out fd sets on min delay.

If at least one pre_select method requests a minimal delay, we don't
call select() anymore as it would return immediately anyway. However,
the fds that have already been set by previous pre_select methods are
then treated as ready for IO in post_seelect which they most likely
are not. This causes unnecessary calls to readv() and friends which
returned EAGAIN.

Fix this by clearing all fd sets in case of minimal timeouts.

12 years agoMerge branch 't/oggdec_cleanups'
Andre Noll [Thu, 18 Aug 2011 20:12:07 +0000 (22:12 +0200)]
Merge branch 't/oggdec_cleanups'

12 years agoMerge branch 't/writer_setup_cleanup'
Andre Noll [Thu, 18 Aug 2011 13:26:34 +0000 (15:26 +0200)]
Merge branch 't/writer_setup_cleanup'

12 years agoMerge branch 't/alsa_poll_fd'
Andre Noll [Thu, 18 Aug 2011 13:19:41 +0000 (15:19 +0200)]
Merge branch 't/alsa_poll_fd'

12 years agocrypt: Really set result to NULL if get_asymmetric_key() fails.
Andre Noll [Mon, 15 Aug 2011 18:09:54 +0000 (20:09 +0200)]
crypt: Really set result to NULL if get_asymmetric_key() fails.

The error path of this function sets the local variable "result"
is set to NULL, which is useless. We must store NULL in the pointer
variable whose address was passed to the function, so "*result =
NULL" is correct.

12 years agooggdec: Take internal state into account.
Andre Noll [Sun, 29 May 2011 10:27:43 +0000 (12:27 +0200)]
oggdec: Take internal state into account.

It is incorrect to look only at the node status of the oggdec buffer
tree node and do nothing if the status is zero. In case the previous
call to ogg_post_select() returned early because it hit the maximal
output buffer size limit, the node status is zero if there is no more
input available, but ov_read() will nevertheless return data which
should be fed to the children of the decoder node as soon as possible.

Fix this by remembering whether we hit the limit.

12 years agoogg_pre_select(): Remove __a_unused.
Andre Noll [Sun, 29 May 2011 08:34:43 +0000 (10:34 +0200)]
ogg_pre_select(): Remove __a_unused.

The scheduler task struct _is_ used in this function.

12 years agooggdec: Trivial cleanups.
Andre Noll [Sun, 22 May 2011 09:20:30 +0000 (11:20 +0200)]
oggdec: Trivial cleanups.

12 years agoSimplify ogg_post_select().
Andre Noll [Sat, 21 May 2011 19:06:01 +0000 (21:06 +0200)]
Simplify ogg_post_select().

Currently, in each invocation of post_select(), we allocate a
640K buffer and shrink it afterwards to the actual size of the
decoded data. This is ugly and unnecessary.

This patch changes ogg_post_select() to allocate and fill 32K
buffers until the maximal output size is reached or there is
nothing left to decode.

12 years agowrite_common: Make check_writer_arg() exit on syntax errors.
Andre Noll [Sat, 6 Aug 2011 20:32:49 +0000 (22:32 +0200)]
write_common: Make check_writer_arg() exit on syntax errors.

This function parses the argument of the --writer option to extract
the name of the writer, which is the first word of the argument. If
this word is not the name of a supported writer, the function
returns NULL to indicate that the given writer does not exist.
Otherwise check_writer_arg() calls the ->parse_config_or_die method
of this writer which parses the remaining part of the argument and
exits on errors.

It is more consistent and simpler to let this function exit also
in case the writer was not found. This simplifies the callers a bit
since they do not have to check the return value any more. It also
allows to kill E_WRITE_COMMON_SYNTAX.

12 years agowrite: Kill E_WRITE_SYNTAX.
Andre Noll [Sat, 6 Aug 2011 20:11:57 +0000 (22:11 +0200)]
write: Kill E_WRITE_SYNTAX.

This value was used but no code path existed that would actually
return this error, so remove it.

12 years agowrite: Rename main_btr() to setup_and_schedule().
Andre Noll [Sat, 6 Aug 2011 20:01:48 +0000 (22:01 +0200)]
write: Rename main_btr() to setup_and_schedule().

The old name was a leftover from the long ago when para_write
started to use the buffer tree API.

12 years agoMove setup_writer_node() from write_common.c to write.c.
Andre Noll [Sat, 6 Aug 2011 19:48:22 +0000 (21:48 +0200)]
Move setup_writer_node() from write_common.c to write.c.

This function is only called from write.c, so move it there and make
it static.

12 years agoaudiod: Fix writer setup info message.
Andre Noll [Sat, 6 Aug 2011 19:39:08 +0000 (21:39 +0200)]
audiod: Fix writer setup info message.

In the non-default case the wrong variable was used as the array index.

12 years agoaudiod: Fix memory leak in writer setup.
Andre Noll [Sat, 6 Aug 2011 19:44:24 +0000 (21:44 +0200)]
audiod: Fix memory leak in writer setup.

If no writers are given, the default writer is used for each supported
audio format. In this case, we called the writer's command line parser
on each open, rather than once at startup as we fo for the non-default
case. This resulted in a memory leak which is fixed in this patch by
setting up the default writer only once, in the same way the default
receivers and filters are set up.

12 years agoMerge branch 't/mp3_frame_padding'
Andre Noll [Sat, 13 Aug 2011 10:56:21 +0000 (12:56 +0200)]
Merge branch 't/mp3_frame_padding'

12 years agoalsa: Select on the alsa poll fd.
Andre Noll [Tue, 26 Jul 2011 18:51:24 +0000 (20:51 +0200)]
alsa: Select on the alsa poll fd.

This teaches the post_select method of the alsa writer to get a control
file descriptor from the alsa library via snd_pcm_poll_descriptors().
This file descriptor becomes readable when a buffer period has passed
and new samples can be written to the alsa handle. We add the fd to
the read fd set so that the select() call of the main scheduler loop
returns just in time.

This is more precise and simpler than the previous approach to compute
the time until a buffer underrun occurs.

12 years agoalsa: Kill useless log message.
Andre Noll [Sat, 6 Aug 2011 19:44:56 +0000 (21:44 +0200)]
alsa: Kill useless log message.

This message does not add much information and looks strange in case
no alsa option was given.

12 years agomp3_afh: Take padding into account when computing frame duration.
Andre Noll [Sat, 30 Jul 2011 16:14:25 +0000 (18:14 +0200)]
mp3_afh: Take padding into account when computing frame duration.

Without this fix, the computed duration of a frame can be slightly
larger than its actual duration. If this happens for many frames of
an mp3 file, the chunk size will be slightly too large, which leads
to buffer underruns during streaming.

12 years agoMerge branch 't/smaller_tarball'
Andre Noll [Sat, 13 Aug 2011 10:21:18 +0000 (12:21 +0200)]
Merge branch 't/smaller_tarball'

12 years agoMerge branch 't/timing_improvements'
Andre Noll [Sat, 13 Aug 2011 10:17:51 +0000 (12:17 +0200)]
Merge branch 't/timing_improvements'

12 years agoMerge branch 't/sched_improvements'
Andre Noll [Sat, 13 Aug 2011 10:15:10 +0000 (12:15 +0200)]
Merge branch 't/sched_improvements'

12 years agoMerge branch 't/mad_sync_fix'
Andre Noll [Sat, 13 Aug 2011 10:07:14 +0000 (12:07 +0200)]
Merge branch 't/mad_sync_fix'

12 years agomanual: A couple of minor improvements.
Andre Noll [Tue, 9 Aug 2011 22:58:58 +0000 (00:58 +0200)]
manual: A couple of minor improvements.

Rewording, an external link to libosl, removal of duplicate information
and a typo fix.

12 years agomp3dec: Handle decode errors gracefully.
Andre Noll [Sun, 7 Aug 2011 10:33:03 +0000 (12:33 +0200)]
mp3dec: Handle decode errors gracefully.

Currently decoding damaged mp3 files leads to very audible artefacts
even if only a single frame is corrupt. This patch instructs the mp3
decoder to synchronize the stream on decode errors and to continue the
decode process. Only on fatal errors the input buffer is discarded.

12 years agomp3dec: Kill need_bad_data_delay().
Andre Noll [Sun, 7 Aug 2011 10:08:39 +0000 (12:08 +0200)]
mp3dec: Kill need_bad_data_delay().

This added quite some complexity for no real gain.

12 years agomp3dec: Allocate correct output buffer size also for mono files.
Andre Noll [Sat, 16 Jul 2011 13:21:57 +0000 (15:21 +0200)]
mp3dec: Allocate correct output buffer size also for mono files.

Currently the buffer size is chosen to hold 4 bytes per sample
even for mono files where 2 bytes per sample suffice.

Since the channel count does not change within a frame, use the
cached value in pmd->channels rather than the MAD_NCHANNELS
macro for each sample.

12 years agoAdd/fix some doxygen comments.
Andre Noll [Tue, 9 Aug 2011 20:40:19 +0000 (22:40 +0200)]
Add/fix some doxygen comments.

12 years agoafh.h: Remove unused declaration.
Andre Noll [Tue, 9 Aug 2011 20:37:59 +0000 (22:37 +0200)]
afh.h: Remove unused declaration.

This function was removed long ago, but we missed to remove the
declaration back then.

12 years agocrypt: Don't use plain integer as NULL pointer.
Andre Noll [Tue, 9 Aug 2011 19:54:44 +0000 (21:54 +0200)]
crypt: Don't use plain integer as NULL pointer.

Found by sparse.

12 years agogui: Fix sparse warning.
Andre Noll [Tue, 9 Aug 2011 19:53:12 +0000 (21:53 +0200)]
gui: Fix sparse warning.

Fixes:

gui.c:1373:24: error: symbol 'com_quit' redeclared with different type (originally declared at gui.c:102) - different modifiers

12 years agowma: Make log2_tab static.
Andre Noll [Sun, 7 Aug 2011 21:35:50 +0000 (23:35 +0200)]
wma: Make log2_tab static.

This table is only used in wma_common.c.

12 years agogcrypt: Check return value of unpad_oaep().
Andre Noll [Sun, 7 Aug 2011 19:19:21 +0000 (21:19 +0200)]
gcrypt: Check return value of unpad_oaep().

unpad_oaep() may fail, so we have to check the return value.

12 years agogcrypt: Fix return value of pad_oaep().
Andre Noll [Sun, 7 Aug 2011 19:18:18 +0000 (21:18 +0200)]
gcrypt: Fix return value of pad_oaep().

This function returned an uninitialized variable on success.

12 years agovss: Clean up timeout computations.
Andre Noll [Thu, 14 Jul 2011 06:17:08 +0000 (08:17 +0200)]
vss: Clean up timeout computations.

By passing the sched struct to vss_compute_timeout() we can get
rid of the static the_timeout struct in vss_compute_timeout(). The
previous patch, which made the timeout helper functions of sched.c
return whether the given barrier is in the past, allows to simplify
the timeout code of vss.c a bit.

The patch also combines the general timeout computations and the
computation for FEC slices into a single function.

12 years agosched: Improve sched_request_barrier() and friends.
Andre Noll [Wed, 13 Jul 2011 19:13:32 +0000 (21:13 +0200)]
sched: Improve sched_request_barrier() and friends.

Make these functions tell its caller whether the given barrier
was in the past. This is useful for vss because for certain
barriers, no other actions should be performed before the barrier
has passed.

12 years agoMerge branch 't/crypto'
Andre Noll [Sun, 7 Aug 2011 11:13:43 +0000 (13:13 +0200)]
Merge branch 't/crypto'

12 years agoMerge branch 't/osx_overhaul'
Andre Noll [Sat, 6 Aug 2011 12:32:30 +0000 (14:32 +0200)]
Merge branch 't/osx_overhaul'

12 years agomanual: Mention that clang is also a supported compiler.
Andre Noll [Fri, 5 Aug 2011 11:13:19 +0000 (13:13 +0200)]
manual: Mention that clang is also a supported compiler.

And add a link to the clang home page.

12 years agogcrypt: Return key size in bytes.
Andre Noll [Fri, 5 Aug 2011 10:53:46 +0000 (12:53 +0200)]
gcrypt: Return key size in bytes.

The crypto API requires get_asymmetric_key() to return the size of
the RSA key in bytes on success.  The return value is evaluated in
populate_user_list() where keys which are too short to encrypt a
challenge buffer are rejected right away.

However, for ASN.1 keys, the gcrypt implementation returned the number
of *bits* instead. This caused para_server to accept keys which are
in fact not suitable for authentication.

The fix is trivial.

12 years agoafs: Fix long-standing bug in add command.
Andre Noll [Sun, 31 Jul 2011 12:40:10 +0000 (14:40 +0200)]
afs: Fix long-standing bug in add command.

Before the add command handler adds a given audio file to the database
it asks the afs process to check whether the file already exists.

The afs process looks for rows in the audio file table with path
and/or hash identical to the given file. If a match is found a
pointer to the matching row is passed from afs to the command handler.
The get_row_pointer_from_result() helper is then called by the command
handler to extract the row pointer from the result returned by afs.

However, this helper incorrectly dereferenced the pointer which caused
the command handler to examine an address rather than the content of
the address to tell whether the file already exists and whether path
or content has changed. This could lead to changed/moved files being
ignored as well as existing files being added again.

This bug was introduced in commit 0a3b9b83, back in 2008.

12 years agosched: Optimize the case of zero timeouts.
Andre Noll [Thu, 21 Jul 2011 17:59:46 +0000 (19:59 +0200)]
sched: Optimize the case of zero timeouts.

If a pre_select method calls sched_min_delay() there is no
point in calling the pre_select hooks of the other tasks since
these can not decrease the timeout any further, and adding file
descriptors to the fd sets makes no sense either. So we may
break out early in sched_preselect() in this case.

If the timeout is zero we may even omit the entire select call as
well as the subsequent gettimeofday() since select() will return
immediately anyway. This patch teaches sched_postselect() to do so
which saves at least two system calls (plus locking in case of
para_server) in a rather hot path.

12 years agosched: Kill unnecessary check in sched_pre_select().
Andre Noll [Thu, 21 Jul 2011 17:39:03 +0000 (19:39 +0200)]
sched: Kill unnecessary check in sched_pre_select().

The only two callers of sched_shutdown() call this function
from post_select context, so we may safely remove the check
whether the pre_select list is empty.

Add a comment to sched_shutdown() which mentions that this
function must be called from post_select.

12 years agosched: Use (0,0) as the timeval for a minimal delay.
Andre Noll [Thu, 21 Jul 2011 17:18:41 +0000 (19:18 +0200)]
sched: Use (0,0) as the timeval for a minimal delay.

The select(2) man page says:

If both fields of the timeval structure are zero,
then select() returns immediately.

This is exactly what is desired for sched_min_delay().

12 years agoMerge branch 't/client_memory_leak_fix'
Andre Noll [Sat, 30 Jul 2011 18:22:47 +0000 (20:22 +0200)]
Merge branch 't/client_memory_leak_fix'

12 years agoconfigure: Check for help2man.
Andre Noll [Sat, 4 Jun 2011 11:18:05 +0000 (13:18 +0200)]
configure: Check for help2man.

help2man is required for generating the man pages, so we should print
a proper error message at configure time if help2man is not installed.

12 years agoconfigure: Check for gengetopt.
Andre Noll [Sat, 4 Jun 2011 10:09:26 +0000 (12:09 +0200)]
configure: Check for gengetopt.

Print an error message at configure time if gengetopt is not installed.

This patch also modifies the commands that call gengetopt in
ggo/makefile to use the executable which was found by configure.

12 years agomanual: Move gengetopt section.
Andre Noll [Fri, 3 Jun 2011 05:42:11 +0000 (07:42 +0200)]
manual: Move gengetopt section.

As gengetopt is now required also for building the tarball, move
the section on gengetopt from "Tools" to Requirements".

12 years agoDon't ship generated *cmdline.[ch] files in tarball.
Andre Noll [Fri, 3 Jun 2011 04:58:45 +0000 (06:58 +0200)]
Don't ship generated *cmdline.[ch] files in tarball.

These files increase the size of the tarball considerably for no real
gain. Gengetopt is available as a package on all major distributions,
so simply require gengetopt.

12 years agoalsa: Avoid busy loop.
Andre Noll [Sun, 24 Jul 2011 20:18:42 +0000 (22:18 +0200)]
alsa: Avoid busy loop.

It is possible that snd_pcm_writei() returns zero rather than -EAGAIN
in case nothing was written because the alsa buffer was already full.

Currently we try again, and eventually succeed. However, this is
ugly, burns CPU cycles and might even lead to an endless loop for
misconfigured alsa devices. So simply return from alsa_post_select()
if snd_pcm_writei() returned zero.

12 years agoMerge branch 't/clang'
Andre Noll [Thu, 21 Jul 2011 20:40:40 +0000 (22:40 +0200)]
Merge branch 't/clang'

12 years agofecdec: Kill an unused variable.
Andre Noll [Mon, 11 Jul 2011 21:37:52 +0000 (23:37 +0200)]
fecdec: Kill an unused variable.

The variable "p" is set, but the assigned value is never used.

12 years agoclient: Do not leak buffer tree node on exit.
Andre Noll [Thu, 9 Jun 2011 22:01:09 +0000 (00:01 +0200)]
client: Do not leak buffer tree node on exit.

Currently we deallocate the buffer tree node of the client
task in case the connect fails and in audiod.c's close_stat_pipe()
but miss to free it for para_client in case of a regular connection
shutdown.

Fix this memory leak by freeing the buffer tree node in
client_close().

12 years agoRewrite of the osx writer.
Andre Noll [Thu, 3 Feb 2011 16:15:39 +0000 (17:15 +0100)]
Rewrite of the osx writer.

This replaces most of the code taken from mosx-mpg123 and should
make osx_write.c much more readable, shorter and more reliable.

Since coreaudio creates a new thread which periodically calls our
callback function, some kind of coordination between the two threads
of execution is necessary.

This implementation employs a new buffer tree node and a mutex to
serialize access to the data buffers.  The parent thread pushes
down all data to the child thread which consumes this data in the
callback function.  Both threads grab the new mutex whenever they
access or modify the data buffers.

12 years agoaudiod get_play_time_slot_num(): Avoid possible NULL pointer dereference.
Andre Noll [Thu, 3 Feb 2011 16:12:53 +0000 (17:12 +0100)]
audiod get_play_time_slot_num(): Avoid possible NULL pointer dereference.

The pointer to the buffer tree node is dereferenced unconditionally
in btr_get_node_start(). This patch makes sure we never pass a NULL
pointer to this function.

12 years agoaudiod: Kill noisy debug message.
Andre Noll [Thu, 3 Feb 2011 16:10:36 +0000 (17:10 +0100)]
audiod: Kill noisy debug message.

Debug output is noisy enough even without this.

12 years agoaudiod: Use non-blocking writes for stat clients.
Andre Noll [Sun, 12 Jun 2011 11:58:49 +0000 (13:58 +0200)]
audiod: Use non-blocking writes for stat clients.

This allows to kill the call to write_ok() which involves
a select system call.

12 years agonet.c: Use proper socket type for __get_sock_name().
Andre Noll [Fri, 10 Jun 2011 14:03:30 +0000 (16:03 +0200)]
net.c: Use proper socket type for __get_sock_name().

This patch gets rid of

net.c:652:33: warning: incompatible pointer types passing 'int (int, __SOCKADDR_ARG, socklen_t *restrict)', expected 'int (*)(int, struct sockaddr *, socklen_t *)' [-pedantic]
        return __get_sock_name(sockfd, getsockname);
                                       ^~~~~~~~~~~

when compiling with clang.

12 years agoAvoid warning when compiling with clang.
Andre Noll [Fri, 10 Jun 2011 13:35:01 +0000 (15:35 +0200)]
Avoid warning when compiling with clang.

Apparently clang does not recognize the

#pragma GCC visibility push(default)

lines in osl.h and complains for each file which includes this
header. Compliling without -Wno-unknown-pragmas fixes this.

12 years agoWork around some clang warnings.
Andre Noll [Thu, 9 Jun 2011 15:52:13 +0000 (17:52 +0200)]
Work around some clang warnings.

This fixes a bunch of warnings of the form

command.c:126:2: warning: expression result unused [-Wunused-value]
WRITE_STATUS_ITEM(&b, SI_MTIME, "%s\n", mtime);

when compiling with clang. This warning is bogus, because the underlying call
to para_printf() can only return failure if the max_size_handler fails, but
this handler is never called here because the size of this para_buffer is
unlimited.

Casting to void makes the warning go away.

12 years agoMakefile: Place -Wno-sign-compare _after_ -Wall.
Andre Noll [Tue, 17 May 2011 11:55:27 +0000 (13:55 +0200)]
Makefile: Place -Wno-sign-compare _after_ -Wall.

Without this, clang still complains about comparisons between
signed and unsigned variables which produces lots of noise.

12 years agogcrypt: Optionally use internal OAEP padding.
Andre Noll [Mon, 4 Jul 2011 23:04:34 +0000 (01:04 +0200)]
gcrypt: Optionally use internal OAEP padding.

libgcrypt supports OAEP padding since version 1.5.0, which has just
been released. Since want the paraslash gcrypt code to work also
for older gcrypt libraries, we check the library version at runtime
and fall back to the internal OAEP padding code if an old library
was detected.

This patch moves much of the rather ugly OAEP padding code into new
new helper decode_rsa() which reduces to a mere memcpy for newer
gcrypt versions. Much of the old code can be removed once all major
distributions ship libgcrypt-1.5.0 or later.

12 years agogcrypt: Use GCRYMPI_FMT_USG for gcry_sexp_nth_mpi().
Andre Noll [Mon, 4 Jul 2011 22:08:14 +0000 (00:08 +0200)]
gcrypt: Use GCRYMPI_FMT_USG for gcry_sexp_nth_mpi().

The manual says: If you use this function to parse results of
a public key function, you most likely want to use `GCRYMPI_FMT_USG'.

12 years agocrypt: Fix typo in configure warning.
Andre Noll [Mon, 27 Jun 2011 16:25:36 +0000 (18:25 +0200)]
crypt: Fix typo in configure warning.