Link properly against the math library; this does not happen automatically when e.g. linking statically.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Remove some unused parameters from autoconf_definite_end.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Small cleanup in the signal handling.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Early-abort from log_message().

Previously, we could use as much as 10% of one core just formatting debug
lines that would never get output anyway. Check the verbosity as the first
thing we're doing to save that CPU.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Use recv() instead of read() when getting DVBAPI data.

There's no guarantee that read() won't coalesce multiple neighboring
UDP packets into one, whereas recv() is different.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Round up to the nearest power of two using bit-fiddling tricks.

log2() is not available in uclibc, and abusing floating-point functions
can have scary numeric effects anyway. Replace it with a bit-wise
sequence (which should also be slightly faster; not that it matters).

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Do not use timed pthread joins on uclibc, as they are not supported.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Make all the shutdown variables volatile.

If they are not volatile, there is no guarantee that the compiler does not
simply cache the accesses. Strictly speaking, there's no guarantee int will
be atomic, but on all relevant platforms, it probably is.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Give a more easily understandable message on DVB buffer overruns.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Make now_time non-global.

There's no good reason to have non_time global, except to create a huge amount
of races; and worse, uint64_t is a non-atomic type on 32-bit x86, causing
potentially invalid values to be read as the time. Simply make it local to
each function that needs it, since they were updating it for every read anyway.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Protect autoconf_vars with a mutex.

This is read and written from multiple threads, so it's an obvious
candidate.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Make autoconf_services_to_channels() take in a pointer to the parameters.

This function does not need a full copy of the autoconf parameters,
and making one copies a lock, which confuses Helgrind. Just send down
a const pointer instead.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Hard-code program_invocation_short_name if on uclibc, which does not have the feature.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>
Introduce a temporary variable "channel" in some cases.

Some places, some long expression such as params->chan_and_pids->channels[curr_channel]
is used over and over again; simply add a temporary variable holding the pointer to the
channel in those cases. This removes a lot of unneccessary clutter that's in the way
when trying to understand the code.

Signed-off-by: Brice DUBOST <mumudvb@braice.net>