7 years agoThe opus decoder.
Andre Noll [Sun, 14 Oct 2012 19:18:58 +0000 (21:18 +0200)]
The opus decoder.

Implementation is similar to the speex decoder, in particular meta
data handling is almost identical.

7 years agoThe opus audio format handler.
Andre Noll [Sun, 14 Oct 2012 16:44:57 +0000 (18:44 +0200)]
The opus audio format handler.

This fills the dummy files opus_afh.c and opus_common.c which were
introduced in the previous commit with content.  One function,
opus_parse_header(), will also be needed by the decoder to
be introduced in the next commit. So this function belongs to
opus_common.c and must be public.

7 years agoogg/opus: Infrastructure.
Andre Noll [Sun, 14 Oct 2012 14:17:44 +0000 (16:17 +0200)]
ogg/opus: Infrastructure.

This adds tests for libopus to and minimal (non-working)
implementations of the ogg/opus decoder and audio format handler.

7 years agospeex: Don't export spx_ctl().
Andre Noll [Sun, 14 Oct 2012 14:27:13 +0000 (16:27 +0200)]
speex: Don't export spx_ctl().

This is only used from spx_common.c, so make it static and kill
the prototype in spx.h.

7 years agoMerge branch 't/doc'
Andre Noll [Sat, 25 May 2013 12:37:41 +0000 (14:37 +0200)]
Merge branch 't/doc'

Simple enough and cooking since 2013-05-05.

e82be0 manual: Add a new paragraph for installing dependencies.
1d6f5f manual: Add missing references of two optional packages.
4a6061 check_wav.c: Fix documentation of check_wav_post_select().
f9c625 Add two missing Copyright headers and file annotations.
16af9d Add documentation of public functions in check_wav.c.

7 years agoMerge remote-tracking branch 'mpi/master'
Andre Noll [Sun, 19 May 2013 21:05:00 +0000 (23:05 +0200)]
Merge remote-tracking branch 'mpi/master'

7 years agoFix compilation on Ubuntu precise.
Andre Noll [Sun, 19 May 2013 20:09:52 +0000 (22:09 +0200)]
Fix compilation on Ubuntu precise.

This distro ships glibc-2.15 where clock_gettime() is part of the
realtime library librt. So all executables which call clock_gettime()
must be linked with -lrt. The configure script detects this and adds
-lrt to LDFLAGS. However, -lrt must come *after* the objects to be
linked together, which is currently not the case.

Fix this by moving $(LDFLAGS) to the end of the recipe for the targets
of all executables.

7 years agofilter_common.c: Fix two typos in comment.
Andre Noll [Sun, 19 May 2013 19:25:13 +0000 (21:25 +0200)]
filter_common.c: Fix two typos in comment.

7 years agoalsa writer: Do not print uninitialized data.
Andre Noll [Wed, 15 May 2013 20:33:24 +0000 (22:33 +0200)]
alsa writer: Do not print uninitialized data.

ALSA's snd_output_buffer_string() returns the current size of valid
data in the returned data buffer, but this buffer is not guaranteed
to be zero-terminated.

Currently alsa_init() ignores this fact and prints the buffer up to
the first NULL byte.  Therefore it may print garbage that follows the
valid data in the buffer. If there is no zero byte after the data,
it may even segfault.

Fix this bug by using memchr() instead of strchr() and carefully
tracking the number of bytes processed.

7 years agofile writer: Use xwrite() instead of plain write().
Andre Noll [Sat, 30 Mar 2013 19:12:40 +0000 (19:12 +0000)]
file writer: Use xwrite() instead of plain write().

Currently the file writer's ->post_select() sets t->error to -1 on
errors, rather than using a proper error code. This may result in
a segfault when this number is passed to para_strerror().

Replacing the call to write() by xwrite() not only gives a proper
error code but also treats EAGAIN as a non-fatal error.

7 years agoMerge branch 't/sched_improvements'
Andre Noll [Sat, 18 May 2013 12:06:22 +0000 (14:06 +0200)]
Merge branch 't/sched_improvements'

This topic has been cooking for a month. During this period, one
problem on BSD has been found and fixed.

3ad5b0 Fix build on FreeBSD
484e75 sched: Rename new_post_select back to post_select.
74c880 sched: Kill old ->post_select variant.
c77e19 grab client: Switch to the alternative post select method.
38aeac client supervisor: Switch to the alternative post select method.
e009fa client exec: Switch to the alternative post select method.
742718 i9e: Switch to the alternative post select method.
2e6b8f vss: Switch to the alternative post select method.
6e83b4 stdout: Switch to the alternative post select method.
1995ce stdin: Switch to the alternative post select method.
88b0ec audioc: Switch to the alternative post select method.
b210e8 afs command task: Switch to the alternative post select method.
12f683 afs signal task: Switch to the alternative post select method.
ccef24 server signal task: Switch to the alternative post select method.
a6dabd server command task: Switch to the alternative post select method.
855c53 write: Switch to the alternative post select method.
58b74b play: Switch to the alternative post select method.
cf4982 afh_recv:  Switch to the alternative post select method.
4dc05b client: Switch to the alternative post select method.
043fd6 audiod: Switch command_task to the alternative post select method.
ce462a audiod: Switch the status task to the alternative post select method.
a7f2d1 audiod: Switch signal task to the alternative post select method.
ba2f65 osx writer: Switch to the alternative post select method.
3642d2 oss writer: Switch to the alternative post select method.
c29db3 file writer: Switch to the alternative post select method.
36875c ao: Switch to the alternative post select method.
3b3049 alsa: Switch to the alternative post select method.
60b853 wmadec: Switch to the alternative post select method.
6c8719 wav filter: Switch to the alternative post select method.
03e915 spxdec: Switch to the alternative post select method.
24bbc5 resample: Switch to the alternative post select method.
4ca80f prebuffer: Switch to the alternative post select method.
a55083 oggdec: Switch to the alternative post select method.
806d26 mp3dec: Switch to the alternative post select method.
7dcaf5 flacdec: Switch to the alternative post select method.
4dc9b9 fecdec: Switch to the alternative post select method.
f6e2cb compress: Switch to the alternative post select method.
ac3371 amp: Switch to the alternative post select method.
7c2c68 aacdec: Switch to the alternative post select method.
b333e0 dccp_recv: Switch to the alternative post select method.
00e793 udp_recv: Switch to the alternative post select method.
9c00a7 sched: Provide alternative post_select variant.
24758c Replace gettimeofday() by clock_gettime().
01f802 sched: Get rid of (pre)select shortcuts.
5bb44a audiod: Avoid delay when closing slot.


7 years Do not print play objects.
Andre Noll [Fri, 17 May 2013 09:00:38 +0000 (11:00 +0200)] Do not print play objects.

This is a debug statement from the early days of development of
para_play. It can safely be removed.

7 years agoFix build on FreeBSD
Andre Noll [Fri, 17 May 2013 08:49:10 +0000 (10:49 +0200)]
Fix build on FreeBSD

Commit 24758c5f (Replace gettimeofday() by clock_gettime()) removed
the inclusion of sys/time.h from several files since this header was
believed to be needed only for gettimeofday(), which was removed in
the same commit.

However, this broke the build on FreeBSD since sys/time.h
also pulled in the declaration of u_short, which is required by
/usr/include/netinet/udp.h. Therefore the compilation of udp_send.c
failed with

/usr/include/netinet/udp.h:42: error: expected specifier-qualifier-list before 'u_short'

This patch changes udp_send.c to include sys/types.h, which provides
the missing declaration.

7 years agoMerge branch 't/utf8'
Andre Noll [Tue, 14 May 2013 20:01:21 +0000 (22:01 +0200)]
Merge branch 't/utf8'

Was cooking since 2013-03-10.

a946af string.c: Fix typo in documentation of skip_cells().
251394 Switch to HTF-8 for web pages.
09c6bc gui: Try to link against libncursesw.
36f38a UTF-8 support for para_gui.
a99804 mp3_afh: Switch to UTF-8 encoding.
f78b53 gui: Don't compute string length unnecessarily.
6224f7 Get rid of unused HAVE_NCURSES define.
6cd788 Fix --with-curses configure option.

7 years agomanual: Add a new paragraph for installing dependencies.
Andre Noll [Sat, 4 May 2013 15:14:42 +0000 (17:14 +0200)]
manual: Add a new paragraph for installing dependencies.

This allows to install all required and optional packages with
a single command.

7 years agowma: Fix sparse error.
Andre Noll [Sat, 4 May 2013 18:39:54 +0000 (20:39 +0200)]
wma: Fix sparse error.

wma_common.c defines wma_log2() with __attribute__ ((const)), but the
declaration in wma.h lacks this attribute. Sparse does not like that
and fails with

wma_common.c:147:15: error: symbol 'wma_log2' redeclared with different type (originally declared at wma.h:28) - different modifiers

Add the const attribute also to wma.h.

7 years agoaacdec: Fix check of return value of NeAACDecInit2().
Andre Noll [Sat, 4 May 2013 16:13:56 +0000 (18:13 +0200)]
aacdec: Fix check of return value of NeAACDecInit2().

This function returns (char)-1 on errors and zero on success. Checking
whether the return value is negative is incorrect on systems where
char is unsigned.  On raspberry/ARM, gcc complains:

aacdec_filter.c:126:6: warning: comparison is always false due to limited range of data type [-Wtype-limits]

Fix this by checking agains zero instead.

7 years agomanual: Add missing references of two optional packages.
Andre Noll [Sat, 4 May 2013 15:07:56 +0000 (17:07 +0200)]
manual: Add missing references of two optional packages.

The curses lib and libsamplerate are both optional but were not
mentioned in the "Requirements" section. This patch adds both.

7 years agoMerge branch 't/allow_zero_btr_add'
Andre Noll [Thu, 2 May 2013 17:55:18 +0000 (19:55 +0200)]
Merge branch 't/allow_zero_btr_add'

Was cooking for over a month.

7 years agosched: Rename new_post_select back to post_select.
Andre Noll [Sun, 31 Mar 2013 19:47:35 +0000 (19:47 +0000)]
sched: Rename new_post_select back to post_select.

7 years agosched: Kill old ->post_select variant.
Andre Noll [Sun, 31 Mar 2013 19:23:18 +0000 (19:23 +0000)]
sched: Kill old ->post_select variant.

It has no more users.

7 years agograb client: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 19:11:04 +0000 (19:11 +0000)]
grab client: Switch to the alternative post select method.

7 years agoclient supervisor: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:54:10 +0000 (18:54 +0000)]
client supervisor: Switch to the alternative post select method.

7 years agoclient exec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:47:50 +0000 (18:47 +0000)]
client exec: Switch to the alternative post select method.

7 years agoi9e: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:38:39 +0000 (18:38 +0000)]
i9e: Switch to the alternative post select method.

7 years agovss: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:30:03 +0000 (18:30 +0000)]
vss: Switch to the alternative post select method.

7 years agostdout: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:24:32 +0000 (18:24 +0000)]
stdout: Switch to the alternative post select method.

7 years agostdin: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:22:08 +0000 (18:22 +0000)]
stdin: Switch to the alternative post select method.

7 years agoaudioc: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:17:41 +0000 (18:17 +0000)]
audioc: Switch to the alternative post select method.

7 years agoafs command task: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 18:11:48 +0000 (18:11 +0000)]
afs command task: Switch to the alternative post select method.

7 years agoafs signal task: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:58:26 +0000 (17:58 +0000)]
afs signal task: Switch to the alternative post select method.

7 years agoserver signal task: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:47:26 +0000 (17:47 +0000)]
server signal task: Switch to the alternative post select method.

7 years agoserver command task: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:42:17 +0000 (17:42 +0000)]
server command task: Switch to the alternative post select method.

7 years agowrite: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:34:52 +0000 (17:34 +0000)]
write: Switch to the alternative post select method.

7 years agoplay: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:27:28 +0000 (17:27 +0000)]
play: Switch to the alternative post select method.

7 years agoafh_recv: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 17:03:15 +0000 (17:03 +0000)]
afh_recv:  Switch to the alternative post select method.

7 years agoclient: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 16:46:08 +0000 (16:46 +0000)]
client: Switch to the alternative post select method.

7 years agoaudiod: Switch command_task to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 16:44:57 +0000 (16:44 +0000)]
audiod: Switch command_task to the alternative post select method.

7 years agoaudiod: Switch the status task to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 15:52:57 +0000 (15:52 +0000)]
audiod: Switch the status task to the alternative post select method.

7 years agoaudiod: Switch signal task to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 14:11:59 +0000 (14:11 +0000)]
audiod: Switch signal task to the alternative post select method.

7 years agoosx writer: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 14:03:19 +0000 (14:03 +0000)]
osx writer: Switch to the alternative post select method.

7 years agooss writer: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 14:01:35 +0000 (14:01 +0000)]
oss writer: Switch to the alternative post select method.

7 years agofile writer: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:59:41 +0000 (13:59 +0000)]
file writer: Switch to the alternative post select method.

7 years agoao: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:56:49 +0000 (13:56 +0000)]
ao: Switch to the alternative post select method.

7 years agoalsa: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 22:40:48 +0000 (22:40 +0000)]
alsa: Switch to the alternative post select method.

7 years agowmadec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:43:34 +0000 (13:43 +0000)]
wmadec: Switch to the alternative post select method.

7 years agowav filter: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 22:44:38 +0000 (22:44 +0000)]
wav filter: Switch to the alternative post select method.

7 years agospxdec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:37:13 +0000 (13:37 +0000)]
spxdec: Switch to the alternative post select method.

7 years agoresample: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:34:37 +0000 (13:34 +0000)]
resample: Switch to the alternative post select method.

7 years agoprebuffer: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:30:57 +0000 (13:30 +0000)]
prebuffer: Switch to the alternative post select method.

7 years agooggdec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:28:48 +0000 (13:28 +0000)]
oggdec: Switch to the alternative post select method.

7 years agomp3dec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:25:02 +0000 (13:25 +0000)]
mp3dec: Switch to the alternative post select method.

7 years agoflacdec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:20:13 +0000 (13:20 +0000)]
flacdec: Switch to the alternative post select method.

7 years agofecdec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:15:41 +0000 (13:15 +0000)]
fecdec: Switch to the alternative post select method.

7 years agocompress: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:14:08 +0000 (13:14 +0000)]
compress: Switch to the alternative post select method.

7 years agoamp: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:11:46 +0000 (13:11 +0000)]
amp: Switch to the alternative post select method.

7 years agoaacdec: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 13:08:46 +0000 (13:08 +0000)]
aacdec: Switch to the alternative post select method.

7 years agodccp_recv: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 22:45:58 +0000 (22:45 +0000)]
dccp_recv: Switch to the alternative post select method.

7 years agoudp_recv: Switch to the alternative post select method.
Andre Noll [Sun, 31 Mar 2013 12:49:42 +0000 (12:49 +0000)]
udp_recv: Switch to the alternative post select method.

7 years agosched: Provide alternative post_select variant.
Andre Noll [Sun, 31 Mar 2013 12:32:07 +0000 (12:32 +0000)]
sched: Provide alternative post_select variant.

Code which accesses the ->error field of another task has been
a source of bugs in the past. This patch is a first step to make
->error private to sched.c.

Currently the ->post_select() methods of all tasks are supposed
to set ->error to a negative value to indicate that the task
should be terminated, i.e. t->error being negative instructs the
scheduler to not call t->pre_select() or t->post_select() any more
in subsequent iterations.  An equivalent way to achieve the same
is to let ->post_select() return an error code instead. Benefits

* It reduces the use of ->error outside of sched.c
* It's impossible to miss setting the error code
* It simplifies code slightly

Therefore we'd like to change the prototype of the ->post_select()
methods from

void (*post_select)(struct sched *s, struct task *t);
int (*post_select)(struct sched *s, struct task *t);

Changes to struct sched affects many parts of the code base,
hence converting all users at once would result in a very
large patch. Therefore we temporarily introduce an additional
->new_post_select() method according to the second declaration
above. The scheduler calls the new method if it is defined and falls
back to the old variant otherwise. This approach allows to switch
over one task after another without breaking things.

This patch introduces the infrastructure just described and switches
over the http receiver. Subsequent commits will change all other tasks
in the same way. After all tasks have been switched over we can get
rid of the old ->post_select variant and rename ->new_post_select()
back to ->post_select().

7 years agoReplace gettimeofday() by clock_gettime().
Andre Noll [Sun, 31 Mar 2013 02:03:04 +0000 (02:03 +0000)]
Replace gettimeofday() by clock_gettime().

POSIX.1-2008 marks gettimeofday() as obsolete, so let's switch to

clock_gettime() operates on timespecs rather than on timevals like
gettimeofday() does. Since timevals are extensively used in all
parts of paraslash, and select() takes a timeval pointer as the
timeout parameter, it seems to be easiest to add a new wrapper,
clock_get_realtime(). It calls clock_gettime(), performs error
checking (all errors are treated fatal and abort the program), and
converts the result to a timeval.

Another difference between gettimeofday() and clock_gettime()
is that sys/time.h needs to be included for gettimeofday(), while
clock_gettime() is declared in time.h which gets included from para.h.
Hence we can remove the include statement for sys/time.h everywhere.

Programs which call clock_gettime need to be linked against librt on
glibc versions before 2.17 while BSD and newer glibc-based systems
have no such requirement. To make matters more interesting,
MacOS lacks clock_gettime() completely although this function conforms
to SUSv2 and POSIX.1-2001.

We'd like to avoid the unnecessary dependence on librt on systems that
have clock_gettime() in -lc, and we must fall back to gettimeofday()
on MacOS. Hence this commit also introduces a check in
which determines whether clock_gettime() is available and, if it is,
whether -lrt is needed. Executables are only linked with -lrt if
configure found that this is necessary.

7 years agocheck_wav.c: Fix documentation of check_wav_post_select().
Andre Noll [Sun, 14 Apr 2013 09:57:12 +0000 (11:57 +0200)]
check_wav.c: Fix documentation of check_wav_post_select().

This function does not take a pointer to a buffer tree node, yet the
comment referred to "btrn". Simply drop this part of the sentence.

7 years agosched: Get rid of (pre)select shortcuts.
Andre Noll [Sat, 30 Mar 2013 22:43:38 +0000 (22:43 +0000)]
sched: Get rid of (pre)select shortcuts.

These shortcuts let the scheduler skip any subsequent ->pre_select()
calls as well as the actual call to select(2) if the current task's
->pre_select() requested a zero timeout.

This idea turned out to be dubios at best. The main problem is that
->post_select no longer knows whether ->pre_select() and select()
have been called. For example, if ->pre_select() monitors some file
descriptor, ->post_select() might find it not ready for I/O even when
it actually is because ->pre_select() or select() was optimized away.

Another problem are tasks whose ->post_select() method expects that
->pre_select() sets some variable in a shared data structure.

This patch removes the scheduler optimizations so that all
->pre_select() methods of all tasks are called once per scheduler

7 years agoaudiod: Avoid delay when closing slot.
Andre Noll [Sun, 31 Mar 2013 14:58:18 +0000 (14:58 +0000)]
audiod: Avoid delay when closing slot.

Currently we might wait up to a full scheduler interval until a slot
is closed.

This commit changes the pre_select method of the status task to check
whether some slot can be closed. In this case it requests a minimal
delay from the scheduler.

The current try_to_close_slot() is split into two functions,
must_close_slot() and close_unused_slots(). The former function is
called from ->pre_select(). It only checks whether a slot must be
closed but performs no action.

The latter function, close_unused_slots() probes all slots and closes
those for which must_close_slot() returns true.

8 years agoAdd two missing Copyright headers and file annotations.
Andre Noll [Thu, 4 Apr 2013 20:58:48 +0000 (20:58 +0000)]
Add two missing Copyright headers and file annotations.

Andre Noll [Sat, 6 Apr 2013 15:42:54 +0000 (15:42 +0000)]

The audio format handlers are used by para_server, para_afh and
para_play, so the old name was misleading.

8 years Shorten config summary.
Andre Noll [Wed, 27 Mar 2013 02:51:38 +0000 (02:51 +0000)] Shorten config summary.

With many filters/writers the output line becomes rather long.
Moreover, filters and writers are also used by para_play but para_play
is not mentionend in the prefix. Just skip the prefix.

8 years agomanual: Don't try to enumerate audio formats.
Andre Noll [Mon, 25 Mar 2013 23:08:59 +0000 (23:08 +0000)]
manual: Don't try to enumerate audio formats.

This is a high-level description where no details
are needed. Flac was missing anyway.

8 years agoamp: Remove stray comment.
Andre Noll [Fri, 5 Apr 2013 20:10:56 +0000 (20:10 +0000)]
amp: Remove stray comment.

8 years agoAdd documentation of public functions in check_wav.c.
Andre Noll [Thu, 4 Apr 2013 17:00:01 +0000 (17:00 +0000)]
Add documentation of public functions in check_wav.c.

The init, shutdown, pre_select and post_select functions of this
file are exported via check_wav.h, so they should be documented. This
commit adds doxygen comments for all of them.

8 years agostring.c: Fix typo in documentation of skip_cells().
Andre Noll [Wed, 27 Mar 2013 14:47:39 +0000 (14:47 +0000)]
string.c: Fix typo in documentation of skip_cells().

8 years agoMerge branch 't/mood_fix'
Andre Noll [Tue, 26 Mar 2013 00:07:08 +0000 (00:07 +0000)]
Merge branch 't/mood_fix'

8 years agoChange copyright year to 2013.
Andre Noll [Sun, 24 Mar 2013 18:00:05 +0000 (18:00 +0000)]
Change copyright year to 2013.

Better late than never.

8 years agoafs.c: Fix some spelling mistakes in comments.
Andre Noll [Tue, 1 Jan 2013 16:30:58 +0000 (16:30 +0000)]
afs.c: Fix some spelling mistakes in comments.

8 years agoImprove documentation of readv_nonblock().
Andre Noll [Mon, 18 Mar 2013 19:22:31 +0000 (20:22 +0100)]
Improve documentation of readv_nonblock().

Define the meaning of "sz".

8 years agobtr: Handle zero-sized buffers gracefully.
Andre Noll [Sun, 23 Dec 2012 22:58:17 +0000 (23:58 +0100)]
btr: Handle zero-sized buffers gracefully.

There is no need to abort on the attempt to add a zero sized buffer.
Let's be gentle and make this condition a noop rather than a fatal

8 years agoFix mood reload.
Andre Noll [Sun, 27 Jan 2013 18:12:57 +0000 (19:12 +0100)]
Fix mood reload.

There was some confusion about how to determine whether the dummy mode
is currently active. At some places we tested if current_mood is NULL,
at others if current_mood->name is NULL. In fact neither check works:

* if a playlist is open, current_mood is NULL (but the dummy
mood is not loaded),

* loading the dummy mood currently sets current_mood->name to

This patch makes the latter variant the official one and fixes up
the code accordingly.

This also fixes the critical log message

Jan 27 18:57:29 (5) (13487) afs_event: table moods, event 9: key not found in rbtree

which occured if the dummy mood was active while an event caused the
mood to be reloaded.

8 years agoafs: Add assertion to afs_cb_result_handler().
Andre Noll [Tue, 1 Jan 2013 23:20:04 +0000 (23:20 +0000)]
afs: Add assertion to afs_cb_result_handler().

If cc is NULL we always have a bug, so it's OK to dereference this
pointer unconditionally. However, if the command handler crashes
due to cc being NULL, it is not obvious what has happened, so make
this explicit.

8 years agoclient: Don't print the same error message twice.
Andre Noll [Mon, 23 Jul 2012 17:03:48 +0000 (19:03 +0200)]
client: Don't print the same error message twice.

Currently, if the client task exits, the corresponding error
message is printed both by client_post_select() and by main()
of client.c.

This patch makes main() print a generic "command failed" error
message instead.

8 years agotrivial: Fix typo in client.h.
Andre Noll [Mon, 23 Jul 2012 19:51:03 +0000 (21:51 +0200)]
trivial: Fix typo in client.h.

8 years agoSwitch to HTF-8 for web pages.
Andre Noll [Sun, 10 Feb 2013 10:22:04 +0000 (11:22 +0100)]
Switch to HTF-8 for web pages.

This sets the charset in the html header section to UTF-8 and
converts the CREDITS file from ISO-8859-1 to UTF-8.

8 years agosignal: Restore errno on exit from signal handler.
Andre Noll [Sat, 9 Feb 2013 18:29:14 +0000 (19:29 +0100)]
signal: Restore errno on exit from signal handler.

This probably is not necessary since generic_signal_handler() calls
exit(3) if the write to the signal pipe fails. However, nobody is
going to stop write(2) from setting errno also on success, so let's
play safe and always restore its value on exit.

8 years agoSpeed up dep target.
Andre Noll [Mon, 31 Dec 2012 00:10:50 +0000 (00:10 +0000)]
Speed up dep target.

By default "make" removes intermediate files during the build. However,
some of the files generated by gengetopt are needed again later for
a different target.

This patch declares these generated files as "precious", so they
will no longer be removed. On one system the build time went down
from 30s to 25s due to this one-liner.

8 years Fix two typos in comment.
Andre Noll [Sun, 30 Dec 2012 14:08:37 +0000 (14:08 +0000)] Fix two typos in comment.

8 years agogui: Try to link against libncursesw.
Andre Noll [Sun, 3 Jun 2012 21:22:13 +0000 (23:22 +0200)]
gui: Try to link against libncursesw.

This variant of the curses library supports wide characters so we
should link against it if it is available. If it is not, we may still
fall back to libcurses instead.

8 years agoUTF-8 support for para_gui.
Andre Noll [Sun, 3 Jun 2012 12:08:55 +0000 (14:08 +0200)]
UTF-8 support for para_gui.

This adds two public helper functions to string.c which operate on
multibyte strings if the character encoding used in the selected
locale is UTF-8.

The first new helper, strwidth(), computes the width of the UTF-8
string while skip_cells() determines the number of bytes the given
multibyte string must be advanced in order to skip the given number
of cells.

para_gui is changed to use the new functions to properly display
UTF-8 encoded data in its top and bottom windows.

8 years agomp3_afh: Switch to UTF-8 encoding.
Andre Noll [Sun, 3 Jun 2012 20:00:31 +0000 (22:00 +0200)]
mp3_afh: Switch to UTF-8 encoding.

The interface of libid3tag allows to get the tag contents in various
formats. Currently, we always call the latin1 variants of these
library functions.

However, as UTF-8 encoding is more widespread these days and almost
all distributions, including the two year old Ubuntu lucid, have
switched to UTF-8, UTF-8 is probably a better choice today.

This patch changes mp3_afh.c to use the UTF-8 variants instead.

8 years agogui: Don't compute string length unnecessarily.
Andre Noll [Sun, 3 Jun 2012 17:25:06 +0000 (19:25 +0200)]
gui: Don't compute string length unnecessarily.

We already know the length because it was computed earlier and stored
in the ring buffer structure, so use this "cached" value instead where

8 years agoGet rid of unused HAVE_NCURSES define.
Andre Noll [Sun, 3 Jun 2012 20:58:13 +0000 (22:58 +0200)]
Get rid of unused HAVE_NCURSES define.

If no suitable curses library was found, para_gui will not be built. So
we don't need this define in config.h.

8 years agoFix --with-curses configure option.
Andre Noll [Sun, 3 Jun 2012 20:42:42 +0000 (22:42 +0200)]
Fix --with-curses configure option.

We only honored the provided -L<dir> for the tests in configure but
not when linking para_gui. This patch creates an output variable,
gui_ldflags, which is used in the Makefile for linking para_gui.

8 years agonew codename, reset version to git
Andre Noll [Thu, 20 Dec 2012 12:42:19 +0000 (13:42 +0100)]
new codename, reset version to git

8 years agoparaslash 0.4.12 v0.4.12
Andre Noll [Thu, 20 Dec 2012 12:27:14 +0000 (13:27 +0100)]
paraslash 0.4.12

8 years agoFix 'install' target.
Andre Noll [Thu, 20 Dec 2012 12:16:17 +0000 (13:16 +0100)]
Fix 'install' target.

This broke in commit 7024574d, where the AC_SUBST() was moved above
the AC_PROG_INSTALL on which it depends.  This resulted in an empty
$install_sh variable, breaking 'make install'.

Fix this bug by moving the AC_SUBST() below AC_PROG_INSTALL.

8 years agoNEWS update.
Andre Noll [Wed, 19 Dec 2012 19:56:45 +0000 (20:56 +0100)]
NEWS update.

8 years agoFix compilation MacOS.
Andre Noll [Mon, 17 Dec 2012 15:49:48 +0000 (16:49 +0100)]
Fix compilation MacOS.

The resolution of the conflict in commit 83ab4b5d introduced the
following error:

osx_write.c:329:9: error: use of undeclared label 'remove_btrn'
                        goto remove_btrn;
Fix is trivial.

8 years agoMerge branch 't/resample'
Andre Noll [Sun, 16 Dec 2012 23:09:22 +0000 (00:09 +0100)]
Merge branch 't/resample'

Was cooking for quite some time. The merge conflicted slightly,
but this was easy to fix.

However, even with the conflict resolved, the merged tree would not
compile because after the merge para_play depends on libsamplerate,
but this dependency was not encoded in

There was no way to fix this issue in either of the two branches
involved without rewriting history: The recently merged t/afh_receiver
branch (which introduced para_play) had no idea of libsamplerate
while t/resample has no idea of para_play.

This merge commit fixes both issues.

0eb69b resample filter: Implementation.
cad284 resample filter: Infrastructure.
37e0df check_wav: Ask parent nodes before falling back to defaults.
216399 Replace check_wav_task by write_task.
1af65c Move wav detection code to a separate file.
d5dc1c write: Make wav-related config options modular.
c25d04 para_filter: Call proper ->free_config method on shutdown.


8 years agoDo the RC4_ALIGN dance also for sideband connections.
Andre Noll [Mon, 12 Nov 2012 14:15:43 +0000 (15:15 +0100)]
Do the RC4_ALIGN dance also for sideband connections.

In commit 1199398 (March 2011) sc_send_bin_buffer() and
sc_recv_bin_buffer() received a fix for invalid reads/writes in
RC4(). The same fix is needed also for sc_crypt(), which was introduced
later in 2830b9f8 as part of the sideband API.

Without the fix, valgrind complains like this:

==14435== Invalid read of size 8
==14435==    at 0x510A03A: RC4 (in /ebio/maan/arch/Linux_x86_64/lib/
==14435==    by 0x40937E: sc_crypt (crypt.c:333)
==14435==    by 0x407233: sb_received (sideband.c:249)
==14435==    by 0x40770F: recv_sb (client_common.c:215)
==14435==    by 0x407FF3: client_post_select (client_common.c:427)
==14435==    by 0x406BE8: schedule (sched.c:70)
==14435==    by 0x404AE7: execute_client_command (client.c:115)
==14435==    by 0x404B77: extract_matches_from_command (client.c:133)
==14435==    by 0x404C16: generic_blob_complete (client.c:163)
==14435==    by 0x404E13: complete_lsblob (client.c:181)
==14435==    by 0x409AB0: create_matches (interactive.c:100)
==14435==    by 0x409BD0: completion_generator (interactive.c:134)
==14435==  Address 0x608bfd0 is 0 bytes inside a block of size 6 alloc'd
==14435==    at 0x4C274A8: malloc (vg_replace_malloc.c:236)
==14435==    by 0x405E64: para_malloc (string.c:65)
==14435==    by 0x40935E: sc_crypt (crypt.c:330)
==14435==    by 0x407233: sb_received (sideband.c:249)
==14435==    by 0x40770F: recv_sb (client_common.c:215)
==14435==    by 0x407FF3: client_post_select (client_common.c:427)
==14435==    by 0x406BE8: schedule (sched.c:70)
==14435==    by 0x404AE7: execute_client_command (client.c:115)
==14435==    by 0x404B77: extract_matches_from_command (client.c:133)
==14435==    by 0x404C16: generic_blob_complete (client.c:163)
==14435==    by 0x404E13: complete_lsblob (client.c:181)
==14435==    by 0x409AB0: create_matches (interactive.c:100)

See also 54cf5827.

8 years agoclient: Fix double free bug in interactive mode.
Andre Noll [Mon, 12 Nov 2012 12:52:50 +0000 (13:52 +0100)]
client: Fix double free bug in interactive mode.

This can easily be reproduced: Enter "select" and type "<tab>" twice
to complete on all moods and playlists, then hit enter to trigger
the bug. On newer glibc-based systems para_client aborts due to the
double free, and valgrind outputs the following:

==10084== Invalid read of size 4
==10084==    at 0x804CA24: free_argv (string.c:813)
==10084==    by 0x804E86A: client_disconnect (client_common.c:46)
==10084==    by 0x804BF24: client_i9e_line_handler (client.c:448)
==10084==    by 0x8050140: i9e_line_handler (interactive.c:245)
==10084==    by 0x428DCF8: rl_callback_read_char (callback.c:217)
==10084==    by 0x8050264: i9e_post_select (interactive.c:265)
==10084==    by 0x804D183: schedule (sched.c:70)
==10084==    by 0x804A0C2: main (client.c:502)
==10084==  Address 0x452a928 is 0 bytes inside a block of size 8 free'd
==10084==    at 0x4028BDC: free (vg_replace_malloc.c:446)
==10084==    by 0x804E86A: client_disconnect (client_common.c:46)
==10084==    by 0x804B6B8: execute_client_command (client.c:118)
==10084==    by 0x804BA5E: select_completer (client.c:387)
==10084==    by 0x80503BF: create_matches (interactive.c:100)
==10084==    by 0x80504D0: completion_generator (interactive.c:134)
==10084==    by 0x4280B1F: rl_completion_matches (complete.c:1992)
==10084==    by 0x4280BBD: gen_completion_matches (complete.c:1062)
==10084==    by 0x4281539: rl_complete_internal (complete.c:1830)
==10084==    by 0x42819C1: rl_complete (complete.c:401)
==10084==    by 0x4278E9C: _rl_dispatch_subseq (readline.c:774)
==10084==    by 0x427917E: _rl_dispatch (readline.c:724)

The bug happens since we did not set the ->features pointer of
struct client task to NULL after the feature list was freed. The fix
is trivial.

8 years agoMerge branch 't/afh_receiver'
Andre Noll [Sun, 2 Dec 2012 21:23:43 +0000 (22:23 +0100)]
Merge branch 't/afh_receiver'

57d75e play: Fix segfault if decoder is not supported.
98f192 Interactive support depends on curses lib.
3e3d8e para_play, implementation.
d02f88 para_play, infrastructure.
3b2ee2 Make writer nodes honor notifications.
e541d7 interactive: Introduce i9e_print_status_bar().
901f66 interactive: Implement single key mode.
6cb789 interactive: Add producer to struct i9e_client_info.
c31982 Interactive: Introduce i9e_get_error().
be1074 interactive: Fix wipe_bottom_line() on MacOS.
3ba772 interactive: Honor SIGWINCH.
56561c interactive: Honor SIGTERM.
06f33c para_afh: remove streaming mode.
4a30c5 The afh receiver, documentation.
b84e37 The afh receiver, implementation.
618a25 The afh_receiver, infrastructure.
4fa8cb Add execute mechanism to receiver nodes.
7c8931 Introduce afh_get_afhi_txt().
3f1510 audiod: Replace kill_btrn() by task notifications.
5edb8f sched: Replace sched_shutdown() by task_notify_all().
58ce61 sched: Introduce task notifications.
b56199 i9e_attach_to_stdout(): Don't insist on btrn == NULL.
7867cd Interactive: Assorted whitespace/newline fixes.
b654be interactive: kill i9ep->line_handler_running.
77b607 interactive: Do not close stderr in i9e_close().
099ef4 Add missing documentation of send_strerror().


8 years agoresample filter: Implementation.
Andre Noll [Sun, 28 Oct 2012 14:10:59 +0000 (15:10 +0100)]
resample filter: Implementation.

The resample filter allows to change the sample rate of a stream on the
fly. All the magic happens within libsamplerate, so the implementation
is quite simple.

However, one tricky thing to consider is how wav headers are treated:
Although the resample filter creates only a single task, it adds
two different nodes to the buffer tree, one for the wav detector and
another one for the resample filter itself.

At startup the generic code of para_filter or para_audiod adds only
the resample filter node, which in turn inserts the wav detector as
its own parent node. This requires to insert a new internal node to
the buffer tree which is currently not supported by the buffer tree
API. It is easy to implement this feature though, so this commit adds
the missing functionality to buffer_tree.c.