Andre Noll [Mon, 6 Apr 2009 16:41:37 +0000 (18:41 +0200)]
Use para_sigaction() in command handlers.
This allows to get rid of an ugly hack for solaris. The patch also adds checks
for whether the signals were reset sucessfully in the command handler and
aborts early on errors.
Andre Noll [Mon, 6 Apr 2009 15:53:46 +0000 (17:53 +0200)]
Introduce para_sigaction().
This wrapper for sigaction() is public and may be used to setup
a handler different from the generic handler that gets installed
for the signal by para_install_sighandler().
Andre Noll [Mon, 6 Apr 2009 15:45:44 +0000 (17:45 +0200)]
signal: Switch from signal() to sigaction.
Use of signal() should be avoided because the behavior of signal() varies
across Unix versions, and has also varied historically across different
versions of Linux.
This patch rewrites para_install_sighandler so that it calls sigaction()
instead of signal(). The implementation is taken from good old APUE.
There are a couple of other users of signal() in the paraslash code. Most
of which are OK because they use signal() only to ignore/reset a signal which
happens to be the only portable use of signal(). All other users of signal()
have to be converted in subsequent patches.
Andre Noll [Sat, 21 Mar 2009 16:46:43 +0000 (17:46 +0100)]
server: Use a temporary SIGCHLD handler to catch afs init failures.
If afs dies immediately on startup (because of dirty tables) para_server
would not notice as the SIGCHLD handler is being intalled after the
call to afs_init().
Andre Noll [Thu, 19 Mar 2009 21:51:17 +0000 (22:51 +0100)]
audiod: Improve display of play time.
Keeping track of the offset, server stream start and the duration
of the audio file length at the time the receiver/writer was started
allows to compute the play time more accurately.
Andre Noll [Sun, 15 Mar 2009 16:35:37 +0000 (17:35 +0100)]
alsa: Split alsa_open().
Only perform what is absolutely necessary in alsa_open(). Call the
real alsa initialization from alsa_post_select(), when we actually
have audio data available to start streaming.
This should get rid of the sound artefacts that happen sometimes
at the beginning of the stream.
Andre Noll [Sun, 15 Mar 2009 14:29:12 +0000 (15:29 +0100)]
audiod: Improve receiver restart logic.
Use the vss status flags and the stream_start time announced by
para_server to decide when to start a new receiver.
This is better than basing this decision only on whether the vss status
equals "playing" as we did before. This allows to reliably detect when it
is safe to start a new receiver while the filter/writer of the current
stream are still active.
The old code would simply wait until filter/writer complete which, due to
buffering, might be much too late.
This was really a brain fart. Instead, introduce a small delay
in alsa_open() that defers audio data writing by 100ms. This seems
to be enough to get rid of the buffer underruns with the udp sender.
Andre Noll [Sun, 8 Mar 2009 20:41:27 +0000 (21:41 +0100)]
Make FEC work with oggvorbis streams.
Unfortunately, this required to rewrite large parts of the fec code
in vss.c. The new code behaves better if the FEC parameters are not
suitable for the current audio file, for example if the audio file header
does not fit into the desired number of slices. It detects this situation
and adjusts the given FEC parameters accordingly.
Andre Noll [Sun, 1 Mar 2009 22:09:51 +0000 (23:09 +0100)]
vss.c: Improve the fec timing code.
This patch
- Fixes a the bug where assert(start_buf) caused para_server
to abort.
- Gets rid of buffer underruns by introducing a quick hack that
sends all but the first slice a bit early.
- Moves some code from compute_next_fec_slice() to
setup_next_fec_group() where it belongs.
Andre Noll [Sat, 28 Feb 2009 13:55:46 +0000 (14:55 +0100)]
Add forward error correction code to the udp sender/receiver.
This patch adds the first draft of a FEC implementation based
on code by Luigi Rizzo.
On the server side, the FEC encoding is done within the virtual
streaming system which also contains the timing routines for sending
a FEC-encoded audio stream. Senders my request such an encoded stream
by calling vss_add_fec_client() with a fec_client_parms structure
that contains the FEC parameters and a callback function which is used
to actually send the data.
On the receiver side, the new fecdec filter is introduced which must
be used to decode a FEC-encoded stream. As the fec parameters are
contained in the header of each data slice of the encoded stream, no
options to this filter are necessary.
ATM, FEC is only used by the udp sender/receiver, but other protocols
can be easily changed to use FEC as well.
This new code is still experimental, lacks documentation and the fec
parameters can currently only be changed by editing the source code.
Gerrit Renker [Sat, 28 Feb 2009 12:40:01 +0000 (13:40 +0100)]
URL/UDPv6 support for the UDP sender.
This adds support for URL strings to support IPv4/IPv6 addresses, hostnames,
and optional port numbers to the UDP sender. The syntax is based on RFC 3986,
example URL strings to be used with the 'add'/'delete' commands are:
10.10.1.2:8000 # host:port
10.10.1.2 # host with default port 8000
localhost # hostname (for IPv4 or IPv6 host)
localhost:8001 # hostname with port
[::1]:8000 # same, but different syntax
[badc0de::1] # IPv6 host with default port 8000
The 'delete' command now also supports port-wildcarding, i.e. not specifying
the port in the 'delete' command removes all targets whose host names match.
The UDP sender has been tested to function with IPv6, including multicasting:
* server: para_server --udp_target=[ff05::beef]:8000 --udp_mcast_iface=eth1
* client: para_audiod -F -D -r 'ogg:udp -i ff05::beef -I eth0'
Gerrit Renker [Sat, 28 Feb 2009 12:40:01 +0000 (13:40 +0100)]
Auxiliary functions to parse and validate parts of URIs.
To support URI syntax in the manner of RFC 3986, this adds a self-contained set
of functions to parse (parts of) URIs and to validate such parts using basic
syntax checks.
To avoid blocking while resolving DNS strings, strings that do not have the
characteristics of native IPv4/v6 address strings always pass; a wrong hostname
will then be detected later when connecting.
Note: strictly speaking, this does not deal with URIs, since the 'scheme' part
is missing and only the "locator" part is parsed. It is possible to extend
this later, using something like dccp://host[:port], http://host[:port],
or udp://host[:port] to specify the transport protocols of paraslash.
Gerrit Renker [Sat, 7 Feb 2009 19:16:50 +0000 (20:16 +0100)]
Put IPv4-specific parts inside the ACL subsystem
The ACL subsystem performs access validation based on IPv4 address /
netmask pairs. Since the internals of this system are exposed via
struct sender_command_data, other subsystems can only use IPv4.
This patch migrates the IPv4-specific parts of the ACL subsystem inside
that system and replaces the 'struct in_addr' address with a host
string. A subsequent patch converts the remaining subsystems to also
use strings instead of AF-dependent addresses.
For the present purpose the string size (fixed) is over-dimensioned,
since a valid IPv4 address contains at most 15 = 4*3 + 3 + 1 bytes
(including the 3 dots and the '\0'). The size should also be sufficient
for hostnames, since RFC 1123, 2.1 suggests a maximum length of 255.
Since the conversion string -> struct in_addr now happens later,
syntax checks have been added for argument strings.
The option simplifies multicast streaming, which is now possible without
having to set a multicast route when there is more than one network interface.
This option works unconditionally for UDPv6. For UDPv4 it is only enabled
on hosts that support `struct ip_mreqn', support for which is detected
via configure.
On OSes that do not support this struct, a warning message is printed;
while it is possible to add the same functionality also in those cases,
it would complicate the implementation and thus has been left out.
Gerrit Renker [Mon, 2 Feb 2009 19:58:49 +0000 (20:58 +0100)]
Support for UDPv4/v6 multicast streaming
This provides self-contained support for UDPv4/v6 multicast:
* receiver joins multicast v4/v6 address;
* sender, on encountering a multicast address, sets TTL/IPv6
number of multicast hops, and (as a precaution) enables looping
back of multicast packets.
The use of the sender is still restricted to UDPv4, since it is also
necessary to perform changes to the (IPv4-based) udp_target struct,
which should be done in a separate patch.
Andre Noll [Wed, 4 Feb 2009 21:25:55 +0000 (22:25 +0100)]
afs: Fix a shm leak.
Even if the command handler stops to read the command output
afs must continue to read shmids from server fd so that it can
destroy all shared memory areas that the server created for afs.
Andre Noll [Tue, 3 Feb 2009 20:41:08 +0000 (21:41 +0100)]
Call shm(destroy) on the mmd shared memory area right after creating it.
It will only be destroyed when the last reference is gone, which
is when para_server exits. This allows to get rid of a global
variable. Moreover, the shared memory area will be destroyed even
in case para_server crashes.
Andre Noll [Mon, 26 Jan 2009 13:19:19 +0000 (14:19 +0100)]
Fix build as root.
As noted by Gerrit Renker, when trying to extract help text from
./para_audiod, the build stops when logged in as root because
para_audiod refuses to start as root if --user and --group are
not given.
This patch moves the check for UID==0 after the check for --help and
--detailed-help so that the help text may be extracted as root even
if no --user and --group options are given.
Gerrit Renker [Sat, 24 Jan 2009 22:37:04 +0000 (23:37 +0100)]
Build problem when no audiod.conf exists
This avoids stopping the build process and allows users to read
the detailed help before getting the error message about a missing
audiod.conf file - fixed by parsing after testing for the help text.