paraslash.git
13 years agofd: Make two functions static.
Andre Noll [Mon, 21 Feb 2011 08:02:19 +0000 (09:02 +0100)]
fd: Make two functions static.

para_opendir() and para_fchdir() are only used inside fd.c.

13 years agopara_write: Fix memory leak.
Andre Noll [Mon, 21 Feb 2011 07:13:15 +0000 (08:13 +0100)]
para_write: Fix memory leak.

We missed to call the ->free_config() method of the writer(s).

13 years agoFix oss_init() error path.
Andre Noll [Sun, 20 Feb 2011 18:56:59 +0000 (19:56 +0100)]
Fix oss_init() error path.

A bug similar to the one fixed in the previous patch for the alsa
writer is also present in the oss writer: If oss_init() fails the
->private_data pointer is non-NULL, but its contents have already
been freed. glibc detects this, aborts the process and spits out

*** glibc detected *** ./para_write: double free or corruption (fasttop): 0x080622a0 ***

Fix this bug by initializing ->private_data only if oss_init()
succeeds.

13 years agoFix alsa_init() error path.
Andre Noll [Sun, 20 Feb 2011 16:01:15 +0000 (17:01 +0100)]
Fix alsa_init() error path.

If alsa_init() fails, alsa_write_post_select() removes the buffer tree
node and sets t->error to a negative value. para_audiod (or para_write)
then calls alsa->close() to deallocate any resources. At this point
wn->private_data is non-NULL while  pad->handle _is_ NULL. The
subsequent call to snd_pcm_nonblock() therefore triggers the assertion

para_audiod: pcm.c:724: snd_pcm_nonblock: Assertion `pcm' failed.

which aborts para_audiod. Fix this bug by freeing the ->private_data
pointer already in alsa_write_post_select() if alsa_init() fails. This
way, ->private_data and pad->handle are either both NULL or both
non-NULL, which meets the expectations of alsa_close().

13 years agoNEWS update.
Andre Noll [Sun, 20 Feb 2011 12:16:17 +0000 (13:16 +0100)]
NEWS update.

13 years agoMerge branch 't/gui_improvements'
Andre Noll [Sun, 20 Feb 2011 12:12:32 +0000 (13:12 +0100)]
Merge branch 't/gui_improvements'

13 years agoaudiod: Fix a memory leak in parse_receiver_args().
Andre Noll [Sun, 20 Feb 2011 11:50:37 +0000 (12:50 +0100)]
audiod: Fix a memory leak in parse_receiver_args().

If multiple receivers are given, we leak the config structure of
all but the last one.

Clean up a comment further down in the function while we're at it.

13 years agoMerge branch 'maint'
Andre Noll [Sun, 20 Feb 2011 11:44:05 +0000 (12:44 +0100)]
Merge branch 'maint'

Conflicts:
configure.ac

13 years agoMake autoconf-2.66 happy. v0.3
Andre Noll [Mon, 5 Jul 2010 21:42:31 +0000 (23:42 +0200)]
Make autoconf-2.66 happy.

This removes more lines than it adds and avoids the following warning;

configure.ac:689: warning: AC_DEFINE_UNQUOTED: `
configure.ac:689:       result=
configure.ac:689:       for i in $status_items; do
configure.ac:689:               result="$result SI_$(echo $i | tr 'a-z' 'A-Z')' is not a valid preprocessor define value
(cherry picked from commit 5842e3e7f2aa17fe16cb806b4ba955ce1f25ce53)

13 years agoSpeed up the oggdec filter and avoid wasting tons of memory.
Andre Noll [Wed, 9 Feb 2011 17:18:17 +0000 (18:18 +0100)]
Speed up the oggdec filter and avoid wasting tons of memory.

Calls to ov_read appear to return at most 4K, no matter how much data
was requested. We allocated 64K per output chunk, so 60K of that space
is wasted. On the other hand we need large output buffers in order to
not sacrifice performance when para_filter decodes to stdout.

Fix this flaw by increasing the oggdec output buffer size from 64K to
640K, calling ov_read() until the output buffer is full or there is
nothing left to read, and then reallocating the buffer to the amount
of bytes actually read.

Assuming CD audio, the 640K output buffer size roughly matches
the decoded size of the 32K input buffer used by the stdin task,
so each input buffer corresponds roughly to one output buffer. The
patched version performs almost identically to the oggdec reference
implementation while previous versions were up to a factor of 2 slower.

13 years agooggdec: Use local variable for the vorbis file struct.
Andre Noll [Mon, 7 Feb 2011 16:00:21 +0000 (17:00 +0100)]
oggdec: Use local variable for the vorbis file struct.

This way, the read callback knows whether we are about to open the
file or not.

13 years agooggdec: Replace stream start delay by minimum input queue size.
Andre Noll [Mon, 17 Jan 2011 07:32:52 +0000 (08:32 +0100)]
oggdec: Replace stream start delay by minimum input queue size.

Waiting 300ms at stream start is both ugly and unnecessary if playback
does not start in the middle of the stream. This patch removes the
->stream_start member of struct private_oggdec_data and delays plaback
only if ov_read returns OV_HOLE, i.e. if streaming does not start at
the beginning of the file.

This delay is enforced by setting the minimal input queue size.

13 years agoogg_afh: Compute chunk time more accurately.
Andre Noll [Mon, 17 Jan 2011 07:24:37 +0000 (08:24 +0100)]
ogg_afh: Compute chunk time more accurately.

The chunk table is constructed so that each chunk corresponds to
frames_per_chunk samples as determined by the granule position of
the ogg page. Use this exact value for computing the duration of a
chunk rather than the avaerage num_frames / num_chunks.

13 years agoogg_afh: Comment fix.
Andre Noll [Mon, 17 Jan 2011 07:18:36 +0000 (08:18 +0100)]
ogg_afh: Comment fix.

We are counting ogg pages, not ogg packets.

13 years agogui: Check return values of curses functions more strictly.
Andre Noll [Sun, 30 Jan 2011 15:22:05 +0000 (16:22 +0100)]
gui: Check return values of curses functions more strictly.

noecho(), cbreak() and init_pair() may fail. Detect these errors and exit
with a proper error message.

13 years agogui: Open-code check_geometry().
Andre Noll [Sun, 30 Jan 2011 12:25:13 +0000 (13:25 +0100)]
gui: Open-code check_geometry().

It is simple enough and has only one caller.

13 years agogui: Cosmetic cleanups for init_curses().
Andre Noll [Sun, 30 Jan 2011 12:23:14 +0000 (13:23 +0100)]
gui: Cosmetic cleanups for init_curses().

Remove some code which was commented out long ago, nicify a comment and
kill some unnecessary braces.

13 years agogui: Recognize "home" and "end" keys.
Andre Noll [Thu, 27 Jan 2011 07:44:38 +0000 (08:44 +0100)]
gui: Recognize "home" and "end" keys.

And map them to new functions which scroll to the top and the bottom of
the output window.

13 years agogui: Don't exit without shutting down curses on config reload.
Andre Noll [Tue, 18 Jan 2011 21:36:32 +0000 (22:36 +0100)]
gui: Don't exit without shutting down curses on config reload.

Currently, if a config file containing errors is being reloaded,
gui_cmdline_parser_ext() calls exit() which leaves the terminal
in an unusable state because para_gui had no chance to call
endwin() in order to reset the terminal.

Fix this flaw by instructing gengetopt to generate code that does
not exit on errors. We can still tell that the command line or the
config file contained errors by looking at the return value of the
various parsers.

13 years agogui: Don't fail silently on config file errors.
Andre Noll [Tue, 18 Jan 2011 20:23:50 +0000 (21:23 +0100)]
gui: Don't fail silently on config file errors.

We need to set ->print_errors non-zero in order to get the error message
from gengetopt.

13 years agogui: Check only once for invalid key maps.
Andre Noll [Tue, 18 Jan 2011 20:21:48 +0000 (21:21 +0100)]
gui: Check only once for invalid key maps.

No need to call check_key_map_args() twice.

13 years agogui: Remove pointless error message for invalid command line options.
Andre Noll [Tue, 18 Jan 2011 20:19:18 +0000 (21:19 +0100)]
gui: Remove pointless error message for invalid command line options.

This error message is never printed anyway because gui_cmdline_parser()
exits on errors.

13 years agogui: Help text improvements.
Andre Noll [Mon, 17 Jan 2011 22:19:50 +0000 (23:19 +0100)]
gui: Help text improvements.

- Fix default config file name
- Reformat ggo file
- Add detailed help fpr --stat_cmd
- Move description of key_map to --detailed-help output.

13 years agogui: Allow selecting a startup theme.
Andre Noll [Mon, 17 Jan 2011 22:00:40 +0000 (23:00 +0100)]
gui: Allow selecting a startup theme.

This implements the --theme option which allows to start para_gui
with a theme different than the default theme.

13 years agoCreate three ogg pages when skipping vorbis comments.
Andre Noll [Thu, 10 Feb 2011 20:06:27 +0000 (21:06 +0100)]
Create three ogg pages when skipping vorbis comments.

This works around a shortcoming in older versions of libogg. It
makes get_header() create a separate ogg page for each of the
three header packets in an ogg/vorbis stream instead of combining
packets #2 and #3.

The patch also adds a couple of debug log messages which print the
size of the individual ogg packets and ogg pages.

13 years agoUpdate Doxyfile to version 1.6.3.
Andre Noll [Mon, 7 Feb 2011 15:47:36 +0000 (16:47 +0100)]
Update Doxyfile to version 1.6.3.

The result of "doygen -u" on a Ubuntu lucid system.

13 years agobtr: Fix documentation of btr_consume().
Andre Noll [Mon, 7 Feb 2011 15:45:45 +0000 (16:45 +0100)]
btr: Fix documentation of btr_consume().

s/buffer tree/buffer pool/.

13 years agoMerge remote branch 'refs/remotes/meins/master'
Andre Noll [Thu, 3 Feb 2011 08:46:23 +0000 (09:46 +0100)]
Merge remote branch 'refs/remotes/meins/master'

13 years agoMerge branch 'maint'
Andre Noll [Thu, 3 Feb 2011 08:46:23 +0000 (09:46 +0100)]
Merge branch 'maint'

13 years agoMerge branch 'maint'
Andre Noll [Thu, 3 Feb 2011 08:15:58 +0000 (09:15 +0100)]
Merge branch 'maint'

13 years agoserver: Avoid invalid free() in com_help().
Andre Noll [Thu, 3 Feb 2011 08:12:39 +0000 (09:12 +0100)]
server: Avoid invalid free() in com_help().

If the argument to com_help is not a valid command, we try to free
uninitialized memory which may lead to a segfault.

This bug existed at least since day 1 of the git repo.

13 years agovss: Use the stripped header also at stream start.
Andre Noll [Mon, 1 Nov 2010 08:28:11 +0000 (09:28 +0100)]
vss: Use the stripped header also at stream start.

For ogg vorbis streams the stripped header is computed when a new audio file is
opened, but chunk zero, the unmodified header, is used for the first FEC group.
This not only wastes bandwidth but might cause vss to abort because the length
of the real header was not taken into account when computing the FEC
parameters.

Solve this by introducing vss_get_chunk() which returns either the stripped
header or calls afh_get_chunk() to obtain a reference to a "real" chunk.

13 years agoIntroduce get_header() for ogg/vorbis.
Andre Noll [Sun, 3 Oct 2010 13:37:02 +0000 (15:37 +0200)]
Introduce get_header() for ogg/vorbis.

Define the get_header() method for the ogg vorbis audio format handler
which replaces ogg packet #2 by a dummy packet which contains no meta
data.

We call ogg_get_file_info() with afhi == NULL which only passes the
first three ogg packets to the given callback but does not compute
the chunk table. Ogg packet #1 and #3 are copied unmodified into the
header.

13 years agovss: Introduce extra_header_buf.
Andre Noll [Sun, 24 Oct 2010 17:27:55 +0000 (19:27 +0200)]
vss: Introduce extra_header_buf.

For the same reasons the extra data buffer is necessary, we also need to reserve
an extra buffer for the header in order to not read-overflow the header buffer
provided by the new get_header() function.

13 years agoAdd Infrastructure for dynamic header computation.
Andre Noll [Sun, 3 Oct 2010 11:07:42 +0000 (13:07 +0200)]
Add Infrastructure for dynamic header computation.

vorbis allows to add arbitrary many comments to an audio file. These
comments are stored in ogg packet #2, which is part of the audio file
header of ogg vorbis files. Hence ogg/vorbis headers may be arbitrary
large. Since the header is sent periodically, this wastes bandwidth
and may cause FEC parameters to become unnecessary large.

This introductory patch paves the way for replacing ogg packet #2 at
stream time by a dummy packet with does not contain any comments and
is therefore of bounded size.

In order to do so, we need audio file headers which are not necessarily
an unmodified portion of the audio file. Therefore we call back into
the audio format handler code at stream time to compute an appropriate
audio file header.  Hence an optional new method ->get_header() is
added to struct audio_format_hander. If it is non-NULL, is is called
instead of using the first header_len bytes of the file.

Unfortunately, this implies that the virtual streaming system must
be aware of the audio format id in order to know which get_header()
method should be called. Thus we store the audio format id in struct
audio_file_data which is passed from the afs process to the server
process. Vss then calls afh_get_header() with the audio format id as
an additional argument.

ATM, the new functionality is not yet used as as no audio format
handler defines ->get_header() yet.

13 years agoKill afhi->header_offset.
Andre Noll [Wed, 6 Oct 2010 20:21:07 +0000 (22:21 +0200)]
Kill afhi->header_offset.

It is always zero, and stored _twice_ in the osl table. Since we must
not change the layout of the on-disk afhi structure, rename these
fields to AFHI_UNUSED1_OFFSET and AFHI_UNUSED2_OFFSET, and set them
to zero in save_afhi().

13 years agoafh: Fix a memory leak in stream mode.
Andre Noll [Sun, 3 Oct 2010 10:43:00 +0000 (12:43 +0200)]
afh: Fix a memory leak in stream mode.

We need to free the audio format handler info in both info and stream mode.

13 years agovss: Initialize all bytes of the FEC header.
Andre Noll [Sun, 24 Oct 2010 17:23:25 +0000 (19:23 +0200)]
vss: Initialize all bytes of the FEC header.

Does not matter much but makes valgrind happier.

13 years agoTrivial comment cleanups.
Andre Noll [Sat, 11 Sep 2010 23:58:52 +0000 (01:58 +0200)]
Trivial comment cleanups.

13 years agoNEWS update.
Andre Noll [Sat, 29 Jan 2011 10:40:40 +0000 (11:40 +0100)]
NEWS update.

13 years agoMerge branch 't/command_util_replace_tabs'
Andre Noll [Sat, 29 Jan 2011 10:37:34 +0000 (11:37 +0100)]
Merge branch 't/command_util_replace_tabs'

13 years agoMerge branch 't/color_cleanups'
Andre Noll [Sat, 29 Jan 2011 10:34:18 +0000 (11:34 +0100)]
Merge branch 't/color_cleanups'

13 years agoMerge branch 't/aacdec_cleanups'
Andre Noll [Sat, 29 Jan 2011 10:01:30 +0000 (11:01 +0100)]
Merge branch 't/aacdec_cleanups'

13 years agoChange year in version string to 2011.
Andre Noll [Thu, 27 Jan 2011 07:44:57 +0000 (08:44 +0100)]
Change year in version string to 2011.

13 years agoNEWS update.
Andre Noll [Sat, 22 Jan 2011 16:02:19 +0000 (17:02 +0100)]
NEWS update.

13 years agoMerge branch 't/periodic_header_optional'
Andre Noll [Sat, 22 Jan 2011 15:57:02 +0000 (16:57 +0100)]
Merge branch 't/periodic_header_optional'

13 years agoSuppress non-fatal bitstream error message at BOF/EOF.
Andre Noll [Sat, 18 Dec 2010 12:05:25 +0000 (13:05 +0100)]
Suppress non-fatal bitstream error message at BOF/EOF.

These errors occur frequently for 64KBit aac files. So print an
error message only if the error occurs in the middle of the stream.

13 years agoaacdec: Print error message only once.
Andre Noll [Sat, 18 Dec 2010 12:00:04 +0000 (13:00 +0100)]
aacdec: Print error message only once.

No need to call NeAACDecGetErrorMessage() twice.

13 years agoaacdec: Remove useless call to btr_get_input_queue_size().
Andre Noll [Sat, 18 Dec 2010 11:54:11 +0000 (12:54 +0100)]
aacdec: Remove useless call to btr_get_input_queue_size().

The returned input queue size is never used.

13 years agocommand_util: Replace tabs by \t.
Andre Noll [Wed, 24 Nov 2010 22:36:01 +0000 (23:36 +0100)]
command_util: Replace tabs by \t.

Probably does not matter much...

13 years agoReplace 2010 in copyright message by 2011.
Andre Noll [Mon, 17 Jan 2011 07:50:18 +0000 (08:50 +0100)]
Replace 2010 in copyright message by 2011.

13 years agoogg_afh_common.c: Remove pointless loop counter.
Andre Noll [Fri, 14 Jan 2011 18:51:22 +0000 (19:51 +0100)]
ogg_afh_common.c: Remove pointless loop counter.

The integer variable i is not used at all in the loop body.

13 years agohttp_recv.c: Trivial typo fix.
Andre Noll [Mon, 10 Jan 2011 22:34:12 +0000 (23:34 +0100)]
http_recv.c: Trivial typo fix.

13 years agoMerge remote-tracking branch 'fml/master'
Andre Noll [Sat, 18 Dec 2010 11:07:36 +0000 (12:07 +0100)]
Merge remote-tracking branch 'fml/master'

13 years agonew codename, reset version to git
Andre Noll [Fri, 17 Dec 2010 16:10:49 +0000 (17:10 +0100)]
new codename, reset version to git

13 years agothe paraslash-0.4.5 release tarball
Andre Noll [Fri, 17 Dec 2010 16:06:25 +0000 (17:06 +0100)]
the paraslash-0.4.5 release tarball

13 years agoparaslash 0.4.5 v0.4.5
Andre Noll [Fri, 17 Dec 2010 16:02:14 +0000 (17:02 +0100)]
paraslash 0.4.5

13 years agoweb: Remove server side includes.
Andre Noll [Thu, 9 Dec 2010 10:37:17 +0000 (11:37 +0100)]
web: Remove server side includes.

The new apache on systemlinux.org does not have this feature activated.
We don't need it anyway.

13 years agoMerge branch 't/kill_udp_cq'
Andre Noll [Wed, 8 Dec 2010 12:45:42 +0000 (13:45 +0100)]
Merge branch 't/kill_udp_cq'

13 years agoclient: Kill superfluous label "err".
Andre Noll [Mon, 6 Dec 2010 22:05:28 +0000 (23:05 +0100)]
client: Kill superfluous label "err".

The position of this label is identical to the "out" label, and "out"
is more to the point as we jump there not only in case of an error. So
jump always to "out" and remove the "err" label.

13 years agocolor: Simplify color error handling.
Andre Noll [Sun, 21 Nov 2010 20:48:42 +0000 (21:48 +0100)]
color: Simplify color error handling.

We exit on errors anyway, so get rid of the return value of
color_parse() and daemon_set_log_color() and abort immediately rather
than returning -1. Add the familiar "_or_die" suffix to these functions
to make it clear that no error handling is necessary in the caller.

13 years agoNEWS update.
Andre Noll [Sun, 5 Dec 2010 17:52:19 +0000 (18:52 +0100)]
NEWS update.

13 years agoMerge branch 't/writer_cleanups'
Andre Noll [Sun, 5 Dec 2010 17:41:36 +0000 (18:41 +0100)]
Merge branch 't/writer_cleanups'

13 years agoMinor documentation cleanups.
Andre Noll [Sun, 5 Dec 2010 17:38:06 +0000 (18:38 +0100)]
Minor documentation cleanups.

13 years agofecdec: Use a fixed buffer pool size of 64K.
Andre Noll [Sun, 28 Nov 2010 21:43:45 +0000 (22:43 +0100)]
fecdec: Use a fixed buffer pool size of 64K.

With the new variable sized FEC slices, it may happen that the
number of bytes per slice of the first FEC group is very small. It is
therefore no longer appropriate to base the size of the buffer pool
on this quantity. It happened to be much too small (< 1000 bytes)
for one aac file which caused the fecdec filter to abort early due
to a full buffer pool.

This patch uses a fixed buffer pool size of 64K for the fecdec filter,
which ought to be enough for everybody.

13 years agowrite_common: Don't abort if btr_exec_up() failed.
Andre Noll [Sun, 28 Nov 2010 21:32:13 +0000 (22:32 +0100)]
write_common: Don't abort if btr_exec_up() failed.

btr_exec_up() failure is unusual but possible if the upper btr node dies just in
the right moment.  It happened for an aac file due to another bug in the fecdec
filter (fixed in a subsequent patch)  which caused the fecdec and hence the aacdec
btr nodes to unregister themselves due to a full buffer tree pool.

So replace the assertion by a fat error message. This sets the sample rate,
channel count and the sample format to zero which makes the writer unregister
itsself. This is better than aborting.

13 years agofd.c: Fix typo in comment.
Andre Noll [Sun, 28 Nov 2010 21:17:39 +0000 (22:17 +0100)]
fd.c: Fix typo in comment.

13 years agovss: Avoid large FEC parameters for the DCCP transport.
Andre Noll [Mon, 1 Nov 2010 15:30:22 +0000 (16:30 +0100)]
vss: Avoid large FEC parameters for the DCCP transport.

Now that for DCCP streams the audio file header is sent only once at client
connect time, we can go one step further and send the header as its own FEC
group. Then all subsequent FEC groups contain data slices only, hence the
maximal required size for a FEC group reduces from

header_size + largest_chunk_size

to

max(header_size, largest_chunk_size)

This patch introduces a new helper function need_data_slices() which returns
false only at the beginning of a DCCP stream. In this case FEC group 0 consists
of the header only and an arbitrary time interval of 200ms is used for this
group.

13 years agovss: Let the transport specify whether periodic headers are necessary.
Andre Noll [Sun, 17 Oct 2010 09:45:57 +0000 (11:45 +0200)]
vss: Let the transport specify whether periodic headers are necessary.

This adds the new flag need_periodic_header to struct fec_client_parms. It is
true for the UDP transport and false for the DCCP transport.

vss checks this flag in need_audio_header() and does not send the header
periodically if the flag is false.

13 years agowriters: Kill ->open.
Andre Noll [Sat, 6 Nov 2010 10:48:12 +0000 (11:48 +0100)]
writers: Kill ->open.

Now that ->open is a dummy function for all writers, we may safely remove
this method from struct writer and kill the dummy functions.

13 years agoosx_write: Make osx_write_open() a no-op.
Andre Noll [Sat, 6 Nov 2010 10:43:59 +0000 (11:43 +0100)]
osx_write: Make osx_write_open() a no-op.

Move the allocation of the private_osx_write_data struct to core_audio_init()
and adjust the the check whether core audio has been initialized accordingly.

13 years agooss: Make oss_open() a no-op.
Andre Noll [Fri, 5 Nov 2010 18:45:00 +0000 (19:45 +0100)]
oss: Make oss_open() a no-op.

Move the allocation of the private_oss_write_data struct to oss_init() and
adjust the the check whether oss has been initialized accordingly.

13 years agofile_writer: Make file_write_open() a no-op.
Andre Noll [Fri, 5 Nov 2010 18:28:24 +0000 (19:28 +0100)]
file_writer: Make file_write_open() a no-op.

Move the allocation of the private_file_write_data struct to ->post_select()
and adjust the the check whether the output file has already been opened
accordingly.

If the output file has just been opened, pfwd->fd will never be set in
the write fd set of the scheduler, so we can skip this test.

13 years agoalsa: Make alsa_open() a no-op.
Andre Noll [Fri, 5 Nov 2010 18:07:39 +0000 (19:07 +0100)]
alsa: Make alsa_open() a no-op.

Move the allocation of the private_alsa_write_data struct to
->post_select() and adjust the the check whether alsa has
been initialialized accordingly.

13 years agowriters: Unify ->pre_select().
Andre Noll [Fri, 5 Nov 2010 07:45:20 +0000 (08:45 +0100)]
writers:  Unify ->pre_select().

Always treat the easy cases "nothing to do", "error", and "not yet initialized"
first. For the alsa writer,  this change fixes two minor bugs:

First, if data is available but alsa has not yet been initialized, we return
from ->pre_select() without setting a delay. This is wrong, we should init
the alsa handle ASAP in this case.

Second,  on errors we wait 20ms which is both ugly and unnecessary.
Requesting a minimal delay is the right thing to do here as well.

13 years agoChange the ->open method of writers to void.
Andre Noll [Thu, 4 Nov 2010 22:54:23 +0000 (23:54 +0100)]
Change the ->open method of writers to void.

These methods always succeed. Add missing documentation of the public
register_writer_node() function while we're at it.

13 years agofile_write: Fix NULL pointer dereference.
Andre Noll [Thu, 4 Nov 2010 22:34:33 +0000 (23:34 +0100)]
file_write: Fix NULL pointer dereference.

register_writer_node() is the only caller of the ->open method for paraslash
writers. It does not check its return value, which is OK for alsa, oss and osx
as these writer's ->open method always succeeds. However, the ->open() method
of the file writer may fail, for example because the output file could not be
opened. This error will be ignored and the writer node task is registered as
usual with ->fd being initialized to zero.

Fix this bug by splitting the ->open method of the file writer into the part which
merely allocates the private_file_write_data structure, hence always succeeds,
and the part which actually opens the output file. This second part is called later
from ->post_select as soon as there is data available to be written.

After this patch the ->open methods of all writers always succeed and we
may change its return value to void which is done in the next patch.

13 years agowrite_common: Remove check which is never true.
Andre Noll [Thu, 4 Nov 2010 08:12:57 +0000 (09:12 +0100)]
write_common: Remove check which is never true.

All writers have a config parser. This check was bogus anyway: If there was a writer
without config parser and we call it without arguments (i.e. "c" is NULL), this would lead
to a NULL pointer dereference.

13 years agowrite: Simplify config parsers.
Andre Noll [Thu, 4 Nov 2010 07:59:57 +0000 (08:59 +0100)]
write: Simplify config parsers.

These functions all call the gengetopt parser which aborts on errors. It is therefore
pointless to check the return value. Document this fact and make it explicit by renaming
->parse_config of struct writer to ->parse_config_or_die().

13 years agoMinor makesock() fixes.
Andre Noll [Sun, 10 Oct 2010 16:51:17 +0000 (18:51 +0200)]
Minor makesock() fixes.

On getaddrinfo() or setsockopt() errors, we leak the flowopts and/or
the local/remote address info structure. Fix this by jumping to the
cleanup section at the bottom of makesock() rather than returning
early without cleaning up.

Moreover, we can not rely on errno containing a valid error code in the
cleanup part of the function because flowopt_cleanup() calls free()
which usually resets errno. So use the error code provided via "rc"
if possible and fall back to the new -E_MAKESOCK if rc is non-negative
to make sure we return a negative value on errors.

13 years agoNEWS update.
Andre Noll [Sun, 14 Nov 2010 14:35:33 +0000 (15:35 +0100)]
NEWS update.

13 years agoMerge branch 't/server_optional'
Andre Noll [Sun, 14 Nov 2010 14:32:45 +0000 (15:32 +0100)]
Merge branch 't/server_optional'

13 years agomanual: Add a section on rebuild of the "next" branch.
Andre Noll [Sun, 31 Oct 2010 12:20:30 +0000 (13:20 +0100)]
manual: Add a section on rebuild of the "next" branch.

13 years agoNEWS update.
Andre Noll [Sun, 31 Oct 2010 11:59:11 +0000 (12:59 +0100)]
NEWS update.

13 years agoMake build of para_server optional.
Andre Noll [Sun, 12 Sep 2010 21:30:59 +0000 (23:30 +0200)]
Make build of para_server optional.

para_server is the only executables which requires libosl, so do not consider
it a fatal error if libosl could not be located. This allows to build the
paraslash package for example on client-only machines which do not need
para_server anyway.

13 years agochunk_queue: Remove cq_force_enqueue().
Andre Noll [Wed, 6 Oct 2010 22:08:48 +0000 (00:08 +0200)]
chunk_queue: Remove cq_force_enqueue().

It was only used by the UDP sender which does not use chunk queueing
any more.

13 years agoudp: Remove chunk queueing.
Andre Noll [Wed, 6 Oct 2010 22:08:31 +0000 (00:08 +0200)]
udp: Remove chunk queueing.

This was broken beyond repair for several reasons:

First of all, not each write to a UDP socket with no listener on
the remote leads to a write error. For a local connection on Linux,
only each second write yields ECONNREFUSED while all others seem to
succeed. So we would only queue each second FEC slice which is next
to useless.

Secondly, only buffer references are stored in the chunk queue, the
buffer contents are not copied for performance reasons. This works fine
if the buffers point to the read-only memory map of the audio file,
which is the case for the HTTP sender, but not for the UDP sender.
In fact, for UDP the buffer is always the same, namely ->enc_buf of
the FEC client struct for the UDP target.

Finally, it is not clear that the buffer references stored in the chunk
queue are still valid when the chunk queue is emptied by sending the
buffers since vss.c might have realloced the enc_buf.

So remove that broken code and be happy.

13 years agoudp: Also send the EOF packet when a target is removed.
Andre Noll [Wed, 6 Oct 2010 21:38:17 +0000 (23:38 +0200)]
udp: Also send the EOF packet when a target is removed.

This notifies the client of the EOF condition and causes it to remove
its buffer tree.  Without this patch, the client keeps listening
which can lead to problems when the target is added later while a
different audio file is being streamed.

Also there is no point to check twice whether the chunk queue exists.

13 years agoRemove unused field "sc" of struct udp_target.
Andre Noll [Wed, 6 Oct 2010 21:23:19 +0000 (23:23 +0200)]
Remove unused field "sc" of struct udp_target.

All functions get/pass a struct sender_client which contains a struct
udp_target as its private data, but we never need to get the struct
sender_client from a struct udp_target. So the sc pointer is unnecessary.

13 years agoudp_send: Add/remove the udp socket fd only once.
Andre Noll [Wed, 6 Oct 2010 20:56:23 +0000 (22:56 +0200)]
udp_send: Add/remove the udp socket fd only once.

Currently, we remove this fd from the close-on-fork list in
udp_close_target() and re-add it in udp_init_session(). This is wrong
because we want the fd being closed in the command handlers also if
the child process for the command is spawned while the udp sender
is inactive.

So add/delete the fd when the udp target is added/removed rather than
on a per session basis.

13 years agoFix a fd leak in the udp sender.
Andre Noll [Wed, 6 Oct 2010 20:51:30 +0000 (22:51 +0200)]
Fix a fd leak in the udp sender.

When deleting the UDP target, we forgot to close the socket fd.

13 years agovss: Avoid potential double free of FEC parameters.
Andre Noll [Mon, 16 Aug 2010 07:29:59 +0000 (09:29 +0200)]
vss: Avoid potential double free of FEC parameters.

If an error occurs in initialize_fec_client() we free the FEC parameter
structure but do not invalidate it. It's both easier and safer to
free this struct just before allocating it.

13 years agoIntroduce per group slice sizes.
Andre Noll [Sat, 7 Aug 2010 16:36:45 +0000 (18:36 +0200)]
Introduce per group slice sizes.

While the FEC parameters k and n are fixed, the size of a FEC slice may
be different for each FEC group. This patch exploits this freedom and
implements variable sized FEC slices for the DCCP and UDP transports.

Two new functions, compute_group_size() and compute_slice_size(),
are introduced which try to compute an optimal size for the entire
FEC group and the slice size of the group respectively.

The group size is chosen such that the group duration is approximately
150ms. Larger values cause too much latency while smaller groups use
the available bandwidth ineffectively. Several contraints such as
the maximal packet size are taken into account when computing the
group size.

Once the group size is known, a suitable slice size is chosen. It
should be as small as possible to avoid unnecessary FEC calculations
but must be large enough to guarantee that the k data slices suffice
to encode the header (if needed) and the data chunk(s).

13 years agovss: need_audio_header(): Change return value to bool.
Andre Noll [Sat, 7 Aug 2010 16:33:04 +0000 (18:33 +0200)]
vss: need_audio_header(): Change return value to bool.

Obviously an equivalent transformation.

13 years agoCompute the maximal chunk size only once.
Andre Noll [Sat, 7 Aug 2010 15:46:44 +0000 (17:46 +0200)]
Compute the maximal chunk size only once.

This patch adds the new field max_chunk_size to struct audio_file_data.
It is initialized in the afs process when the chunk table is saved,
just before the audio_file_data struct is passed to the server process.

The vss code benefits from this change since it can just use the
new information rather than calling afh_get_largest_chunk_size()
to recompute the maximal chunk size from scratch whenever a new
client connects.

Since vss.c was the only user of afh_get_largest_chunk_size(), we
may kill this function.

13 years agoReplace ROUND_UP by DIV_ROUND_UP and use it everywhere.
Andre Noll [Sat, 7 Aug 2010 15:07:12 +0000 (17:07 +0200)]
Replace ROUND_UP by DIV_ROUND_UP and use it everywhere.

13 years agoRemove FEC parameter max_slice_bytes.
Andre Noll [Sat, 24 Jul 2010 18:11:08 +0000 (20:11 +0200)]
Remove FEC parameter max_slice_bytes.

It is no longer a FEC parameter as its value is determined at runtime
from the MPS of the connection.

So replace ->max_slice_bytes of struct fec_client_parms by the new
->mps field of struct fec_client.

13 years agoSimplify vss_send().
Andre Noll [Sat, 24 Jul 2010 16:52:37 +0000 (18:52 +0200)]
Simplify vss_send().

13 years agoReplace check for stream_chunk < 0 by state == NONE.
Andre Noll [Sat, 24 Jul 2010 16:46:25 +0000 (18:46 +0200)]
Replace check for stream_chunk < 0 by state == NONE.

The two conditions are equivalent but the latter form is more readable.

13 years agoFEC initialization cleanups.
Andre Noll [Sat, 7 Aug 2010 14:50:59 +0000 (16:50 +0200)]
FEC initialization cleanups.

Initialization was performed in two steps: During vss_send and
during compute_next_fec_slice(). This patch moves the init code
for fec clients to the single location.