Andre Noll [Sun, 10 Oct 2010 19:37:03 +0000 (21:37 +0200)]
dccp_send: Fix com_off().
This command made para_server sefgault due to the FEC client structure being
freed, but still used from vss.c. Fix this serious bug by first calling
dccp_shutdown_clients() which removes all FEC clients.
Andre Noll [Sun, 10 Oct 2010 19:32:58 +0000 (21:32 +0200)]
audiod: Handle crashes of para_server more robustly.
In case para_server dies unexpectedly, para_audiod may still have a partial status
item in the buffer tree node of the client task which can lead to a busy loop.
Fix this by flushing the input queue and invalidate the current audio format to prevent
recreating a buffer tree before the status task resumes.
There is already flush_input_queue() in buffer_tree.c but that can't be called by audiod.c
as it is a static function. Make it public and rename it to btr_drain() which is shorter and
more to the point and has the usual btr_ prefix.
Andre Noll [Sun, 1 Aug 2010 17:56:10 +0000 (19:56 +0200)]
sched: Use built-in instead of open-coded timeout helpers.
In many places, sched_min_delay() or sched_request_timeout() are
open-coded. Use the corresponding helpers from sched.c instead and
rename the "timeout" parameter of sched_request_timeout() to avoid
warnings on old gcc versions.
Andre Noll [Mon, 9 Aug 2010 22:15:04 +0000 (00:15 +0200)]
Fix an invalid-free-bug in the ogg audio format handler code.
In process_ogg_packets(), if ogg_sync_pageout() fails, we jmp to
the out label where "stream" is being freed by ogg_stream_clear()
without being initialized.
This causes para_afh and para_server to segfault in libogg:
Andre Noll [Mon, 2 Aug 2010 07:12:16 +0000 (09:12 +0200)]
manual: Minor cleanups.
- Mention that OGG/Speex also needs periodic audio file headers, reword
this sentence.
- para_write now understands formats != 16 bit, so remove this restriction also
from the documentation. Also mention that the sample format is being read from
the wav header, if present.
Andre Noll [Sun, 1 Aug 2010 17:46:32 +0000 (19:46 +0200)]
Rename some variables to avoid warnings on old gcc versions.
Fortunately, gcc-4 no longer warns on these. However, gcc-3.3 is still supported
for compiling paraslash, so rename "index" to "idx" and "conf" to "config" to get
rid of warnings of the form
wmadec_filter.c:1013: warning: declaration of `index' shadows a global declaration
Add documentation of ->free_config() while we're at it.
Andre Noll [Tue, 27 Jul 2010 21:19:31 +0000 (23:19 +0200)]
Add missing documentation of rfds parameter of accept_sender_client().
Fixes
/home/work/maan/scm/paraslash/send_common.c:260: warning: The following parameters of accept_sender_client(struct sender_status *ss, fd_set *rfds) are not documented:
parameter 'rfds'
Andre Noll [Mon, 26 Jul 2010 11:05:42 +0000 (13:05 +0200)]
aacdec: Fix a brown paper bag bug.
Oops, we were using PARA_MAX() instead of PARA_MIN() to determine
the number of bytes to convert in the next run. This silly bug could
lead to a segfault in the aacdec filter. Moreover, the assertion in
buffer_tree.c that would have caught the bug was _also_ b0rken.
But it's not my fault. I blame Grover of the Sesame street for both
bugs. He did explain the difference between near and far, although
this knowledge is next to useless for a programmer. And he did not
say a single word about MIN and MAX, or true and false. No wonder
such bugs happen.
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
Andre Noll [Sun, 4 Jul 2010 09:23:28 +0000 (11:23 +0200)]
Use a perl script to create error2.h
This is *much* faster than the shell code in configure. Perl is
required anyway for help2man, so this patch does not introduce
additional requirements on the build system.
Andre Noll [Tue, 22 Jun 2010 22:53:46 +0000 (00:53 +0200)]
Add support for the speex codec.
This patch adds support for yet another audio format: speex, a
CELP-based codec designed for speech.
As speex is usually used in combination with the OGG container format,
we only support this combination. The new OGG/Speex audio format
handler provides a callback structure for the generic ogg code,
very similar to the OGG/Vorbis audio format handler.
The new speex code is split over three source files: spx_afh.c contains
the audio format handler, spxdec_filter.c the decoder and spx_common.c
common functions used by both audio format handler and decoder.
Many thanks to Jean-Marc Valin, the author of the reference
implementation of the speex decoder. Reusing parts of his code made
it easy to support speex within paraslash.
Andre Noll [Tue, 22 Jun 2010 21:14:03 +0000 (23:14 +0200)]
ogg: Separate ogg from vorbis code.
This moves vorbis-independent code from ogg_afh.c to the new file
ogg_afh_common.c so that it can be used also for the speex audio
format handler that is added by subsequent patches.
The patch introduces a generic callback structure which contains a
function pointer used to call back into the vorbis code once for each
of the three ogg packets of the audio file header.
Andre Noll [Tue, 22 Jun 2010 20:00:28 +0000 (22:00 +0200)]
Kill supported_audio_formats().
It's kind of silly to have a function that just returns a constant string
which is known at compile time. Even more silly is to contruct this string
using an #ifdef for each optional audio format when we already
constructed the space-separated list of supported audio formats during
configure.
So just use AC_DEFINE_UNQUOTED() in configure.ac to make the
list of supported audio formats available via config.h and get rid of
supported_audio_formats(). Rename it to SERVER_AUDIO_FORMATS
and kill a useless space character while we're at it.
Andre Noll [Mon, 12 Jul 2010 15:28:58 +0000 (17:28 +0200)]
write: Support audio formats != 16 bit little endian.
This adds the new --sample_format option to para_write and teaches
the check_wav_task to read the sample format from the wav header
rather than assuming 16 bit little endian.
The alsa, oss and osx writers all ask the upper buffer tree nodes
for the current audio format. For para_write the check_wav task
answers this query by using the value given at the command line,
looking at the wav header, or using 16 bit little endian as the
default answer.
For para_audiod, the current decoder answers this query. In this
case the audio format is either 16 bit little endian or 16 bit
big endian, depending on the endianness of the machine.
Andre Noll [Thu, 1 Jul 2010 09:44:16 +0000 (11:44 +0200)]
write: Make get_btr_value() return void.
Asking upper buffer tree nodes for the sample rate and the channels
count should never fail, because the writer only asks if there is
already some output data to process.
So, replace the tests by assertions, change the return value
of get_btr_value() to void and fix up all callers accordingly.
This simplifies the code a bit.
Andre Noll [Wed, 30 Jun 2010 17:04:30 +0000 (19:04 +0200)]
Introduce decoder_execute().
All four decoders support the same two commands: "sample_rate"
and "channels". This patch adds a public function to filter_common.c
which implements these two commands and is called by all decoders.
This allows to kill four copies of code with identical functionality.
Andre Noll [Wed, 30 Jun 2010 16:40:47 +0000 (18:40 +0200)]
Deduplicate --channels and --sample-rate.
These options are identical for all writers. Moreover, they only
make sense for para_write but are ignored for para_audiod.
So move these options from the writer-specific ggo file to write.m4,
the config file for para_write. The writers obtain the sample rate
and the channels count as before via the buffer tree exec mechanism,
but it is now the check_wav node rather than the btr node of the writer
that computes this information from the given option, the wav header
or the builtin default.
The new HANDLE_EXEC macro contains the logic for determining the
source of both the sample rate and the channels count.
Andre Noll [Sun, 4 Jul 2010 21:27:37 +0000 (23:27 +0200)]
audiod: Set the audio format restart barrier also when closing the receiver.
When the current audio file changes, it may happen that para_audiod's receiver
detects the EOF condition before the status has been updated to reflect the file
change. In this case, para_audiod might restart the old receiver even if a
different audio format is about to be streamed next.
This patch adds a per audio format 200ms delay which starts at receiver close time.
During this time interval the receiver for this audio format will not be started again.
Gerrit Renker [Sun, 13 Jun 2010 09:30:47 +0000 (11:30 +0200)]
fec: make max_slice_size optional
The default max_slice_size for FEC is the MTU. This patch changes the parser
to make the specification of the max_slice_size optional (for cases using a
slice size less than the MTU).
Other changes:
* added udp sender help documentation;
* simplified parse_fec_url() (no additional strlen() needed).
Gerrit Renker [Sun, 13 Jun 2010 09:30:47 +0000 (11:30 +0200)]
sender: miscellaneous cleanups
This collects various minor syntactical changes into a single patch:
* replace indirection 'ut->sc->xxx' by 'sc->xxx' where possible;
* more elegant way of duplicating sc->name string;
* udp_delete_target() now takes sender_client as argument;
* added IPv4-address:port example for udp_help();
* revised the definition of E_ADDRESS_LOOKUP (it means what it says)
and replaced two inappropriate uses by assert(): in each case this
error value was used to point to an unsupported adress family. But
since the only supported network protocol is IP, if the case happens,
it means a bug and should be marked as such.
--
error.h | 2 -
para_audioc |binary
error.h | 2 -
send_common.c | 2 -
udp_recv.c | 4 ---
udp_send.c | 64 +++++++++++++++++++++++++++++-----------------------------
4 files changed, 35 insertions(+), 37 deletions(-)
Gerrit Renker [Sun, 13 Jun 2010 09:30:47 +0000 (11:30 +0200)]
udp: integrate resolve hook
This integrates the new resolve hook into the UDP sender; exploiting the
invariant that the 'port' of sender_command_data structure is now always set.
It further reuses the new resolve_target() function for the pre-configured
sender targets. This is necessary to unify the syntax (otherwise the
server.conf would have to be limited to IP-addresses only), and allows to
use hostnames in the server configuration file.
The worst case that can here be anticipated is that unresolvable targets are
specified in server.conf. In this case the server hangs for circa 20 seconds
per unresolvable target, and then concludes with error messages such as:
(8355) init_vss_task: initializing udp sender
...
(8355) udp_add_target: adding to target list (10.0.0.2:8000)
(8355) makesock: can not resolve UDP address funzt.net#8000: Name or service not known.
(8355) udp_init_target_list: not adding requested target 'funzt.net'
(8355) makesock: can not resolve UDP address funzt.also.net#8000: Name or service not known.
(8355) udp_init_target_list: not adding requested target 'funzt.also.net'
(8355) udp_send_init: udp sender init complete
Gerrit Renker [Sun, 13 Jun 2010 09:30:46 +0000 (11:30 +0200)]
net: host/port string convention
This updates the implementation of host_and_port() in such a way that its
output can again be used as input of parse_url():
* the separator for host and port is now ':' instead of '#';
* port numbers (services) are now always represented as numbers
(reverting an earlier change);
* IPv6 addresses are enclosed in square brackets.
This convention makes it easier to copy&paste output from paraslash commands
(including scripting), and to store target information in a format that is
easy to resolve/reuse at a later stage.
Andre Noll [Fri, 18 Jun 2010 20:46:22 +0000 (22:46 +0200)]
Reduce decoder latency.
If large/many FEC slices are used, the decoder gets large amounts of
data in one chunk. Currently it decodes as much as it can which may
take several 100 milliseconds on slow machines -- enough to cause
buffer underruns for the alsa writer.
This patch teaches the decoders to convert only a small amount of data
in one go in order to give the other buffer tree nodes a chance to run.
Andre Noll [Fri, 18 Jun 2010 08:40:06 +0000 (10:40 +0200)]
dccp_send: Add command line options for FEC parameters.
ATM, these are hardcoded as MPS/3/4. This patch allows to impose
an upper bound on the slice size and to change the number of (data)
slices of a FEC group.
Andre Noll [Wed, 16 Jun 2010 20:39:57 +0000 (22:39 +0200)]
sched: Add debug mode.
This adds the compile-time switch SCHED_DEBUG to activate debug
mode for the scheduler. If activated, it measures the time spent in
each post_select() function and prints warning messages if this time
interval is too large.
This patch has no effect if SCHED_DEBUG is not set.
Andre Noll [Mon, 14 Jun 2010 15:09:04 +0000 (17:09 +0200)]
Print a log message if the sender command fails.
Currently there is no infrastructure for passing down a value from vss,
which runs in parent context, to the child process. In particular,
we can not pass the return value of the sender subcommand handlers
to com_sender() to propagate it to the client.
However, we may easily write a log message that explains the cause
of the error, which is not optimal, but better than nothing.
Thanks to Gerrit Renker who pointed out this flaw.
Gerrit Renker [Sun, 30 May 2010 16:10:42 +0000 (18:10 +0200)]
udp_send: add a time window for errors
This implements a grace period during which ICMP Destination Unreachable /
Port Unreachable are ignored from the peer, with the purpose of catching
* synchronisation problems (e.g., receiver started after sender);
* unforeseen events (e.g. delays, reboot, reconfiguration).
To avoid receiving persistent errors from unicast UDP clients, two time
windows are used:
(a) The 'error-allowed' period t_A
This time window starts when the first ECONNREFUSED error is seen
and ends after t_A seconds. The value of t_A is a guess which should
cover the expected time needed to sort any receiver problems out.
(b) The 'error-free' period t_B
During the t_B seconds following the interval t_A, no further
connection errors are accepted; if an ECONNREFUSED is seen it
will cause the target to be evicted from the list.
This windowing process restarts itself, i.e. the first error seen after
t_A+t_B will reset the counters.
The following examples illustrate the algorithm, where 'x' indicates
receipt of an ICMP error message.
1) Some errors received during initial receiver setup
Here the counter is reset at the first error after t_1. Since no more errors
were seen after t_1+t_A, streaming continues.
For simplicity, the implementation uses t_A = t_B = 30 seconds.
The behaviour with an unavailable receiver is now:
May 24 18:08:16 (0) (2702) vss_send: sending 123:0 (548 bytes)
May 24 18:08:18 (0) (2702) vss_send: sending 132:2 (548 bytes)
May 24 18:08:18 (2) (2702) udp_check_socket_state: Evicting 10.0.0.2#8000 after 31 seconds of connection errors.
May 24 19:34:55 (0) (2702) vss_send: sending 5:14 (1232 bytes)
May 24 19:35:10 (0) (2702) vss_send: sending 11:3 (1232 bytes)
May 24 19:35:10 (2) (2702) udp_check_socket_state: Evicting 3ffe::2#8000 after 31 seconds of connection errors.
Gerrit Renker [Sun, 30 May 2010 16:06:33 +0000 (18:06 +0200)]
udp: initialize common structure only once
When temporarily closing the UDP stream (e.g. due to 'next' or 'ff'
command), the UDP file descriptor need not be closed. Hence this
patch moves its initialization into the add_target() function.
The patch also factors global variables out of mcast_sender_setup() function.
Andre Noll [Sun, 23 May 2010 06:42:04 +0000 (08:42 +0200)]
Move send_chunk() from send_common.c to http_send.c.
Due to the previous changes, this function is no longer a generic function
as it is only used by the http sender. So move it to http_send.c and make it static,
along with the queue_chunk_or_shutdown() helper which is only called from
send_chunk().
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
cleanup: remove redundant 'max length' argument
This removes the redundant 'max_size_bytes' argument of
* write_nonblocking(),
* send_queued_chunks(), and
* send_chunk(),
since it was set to 0 in all cases.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
udp_send: send data in MMS-sized chunks
This determines the Maximum Message Size for the UDPv4/v6 layer; using
the earlier functions. The outcome is used to set the FEC slice size,
initialisation of the UDP client has also been moved to the init_fec()
function.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
dccp_send: send data in MPS-sized chunks
As mandated by RFC 4340, 14., DCCP maintains an internal variable called
'Maximum Packet Size', which can be queried via the DCCP_SOCKOPT_GET_CUR_MPS
socket option. This option has been available since 2007-10-04 (v2.6.23)
and is documented in Documentation/networking/dccp.txt.
The Maximum Packet Size takes into account the path MTU, size of headers and
the estimated overhead for DCCP options. The following table shows various
values that were determined experimentally between two hosts:
Notes:
(a) WiFi normally uses Ethernet MTU of 1500 bytes, but the medium
supports a much larger MTU (Fragmentation threshold) of up to
about 2300 bytes (system used 802.11g).
(b) 576 byte MTU not tested for IPv6 since IPv6 mandates a minimum
MTU of 1280 bytes, as per RFC 2460 section 5 (also RFC 5405, 3.2).
The patch implements the dccp init_fec() function based on the DCCP MPS.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
net: generic code to query the maximum message size
This adds a fallback routine to determine the address-family specific maximum
message size (MMS). This value is an over-estimation of the maximum payload
size that the network layer can take, i.e. it returns the maximum size for
transport-layer header and transport-layer payload.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
sender: clean up old FEC API
After the preceding two patches integrated the new function pointers, this
patch removes the now obsolete open() and send_fec() pointers which are no
longer referenced anywhere. It also reorders send.h to get rid of forward
declarations.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
udp: integrate new fec interaction
This patch implements the new UDP-FEC interface in two steps:
(1) updating the UDP sender analogously to the previous (DCCP sender) patch;
(2) unifying the struct udp_target by factoring out the fields it has in
common with 'struct sender_client'.
The open() function is deferred to a subsequent patch. The user can override
the MPS value by supplying a max_slice_bytes value not larger than the MPS.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
dccp: integrate new fec interaction
This updates the DCCP sender code to access and initialize the new fec_client
structs.
Particulars:
* the open() method has been removed, to be supplied in a later patch;
* the sender_client field became redundant, it is now available as fc->sc.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
vss: add state variable for fec client
This merges the two boolean/integer members 'error' and 'ready' into a
single state variable with the same effect:
* the specific value of 'error' was not evaluated within vss.c,
where error < 0 used to disable the fec_client;
* the ready/and error states are mutually exclusive;
* the assertion that compute_next_fec_slice() is not called when
the fec_client is disabled has been removed, since this function is only
called from vss_send(), which ensures that this condition holds;
* likewise, vss_playing() holds in compute_slice_timeout() since
this condition is tested earlier in the caller vss_compute_timeout().
Gerrit Renker [Sun, 23 May 2010 05:43:03 +0000 (07:43 +0200)]
vss: unify calls to the FEC layer
This reorganizes the internal vss data structures a bit to unify calls to the
FEC layer across different senders:
* each sender supplies its sender_client data via the 'sc' pointer;
* the init_fec()/send_fec() function pointers are now parameters
(so that a global variable is not needed);
* both these functions then operate on the supplied sender_client data;
* the transport layer can then interpret the sender_client data in
specific ways, e.g. by accessing sc->private_data;
* a new 'ready' flag has been added to track transport-layer state;
* max_slice_size as paramter has been restored (for overriding MPS value).
Note: this is one patch out of several. It comments out now-incompatible
changes in the API for the sake of being able to compile. However,
the new global API requires the whole set of patches to be applied.
Andre Noll [Tue, 27 Apr 2010 19:43:19 +0000 (21:43 +0200)]
Basic infrastructure changes for FEC/DCCP support.
This patch allows to add a FEC client without specifying the FEC
parameters. Instead, these parameters are set at stream start time
via the new ->open() method of the senders.
It is desirable to defer ssetting the FEC parameters to allow dynamic
determination of the slice size. We need an established connection
to find out the best value for the slice size, but the UDP sender
currently has to fix the slice size at target add time, which is
too early.
The slice size for the UDP and the DCCP sender are currently hardcoded
values; this will be fixed by subsequent patches.
Andre Noll [Fri, 21 May 2010 17:16:22 +0000 (19:16 +0200)]
Fix paraslash.ico.
Somehow this broke quite some time ago. The command
convert -colors 16 paraslash.png paraslash.ico
converts the png to an .ico File that is displayed nicely at least
with firefox. Of course, this should be generated on the fly, but
for now it's simpler to just check it in.
Andre Noll [Sun, 23 May 2010 17:21:02 +0000 (19:21 +0200)]
fecdec_filter: Detect and ingore duplicate slices.
This introduces a bit array to keep track of the slices of a FEC group
that have been received so far. This allows to quickly look up whether
the current slice is already present in the FEC group, in which case we
simply ignore it.
This avoids errors of the kind
unregister_task: unregistering fecdec (slot 0) (invalid index vector)
which have been observed with the UDP transport.
The patch also cleans up add_slice() a bit: It replaces the calls to para_malloc()
and memset() by a simple call to para_calloc() and initializes slice_num earlier
so that it can be used throughout the function.
Andre Noll [Sun, 23 May 2010 17:02:06 +0000 (19:02 +0200)]
fecdec_filter: Simplify clear_group().
There is no point in invalidating the index and data pointers if we are about
to free them anyway. So just set the whole thing to zero. This is easier and
does not require modifications if struct fecdec_group changes.
Gerrit Renker [Sun, 23 May 2010 05:43:04 +0000 (07:43 +0200)]
string: constant value
This replaces the LLONG_MAX constant with the value stolen
from limits.h (that value is only accessible when using
-std=c99). The value of 2^63-1 assumes 64-bit and can also
be computed as (1ULL << (sizeof(long long) * 8 - 1)) - 1).