Andre Noll [Tue, 23 Oct 2007 18:30:42 +0000 (20:30 +0200)]
Get rid of mmd->audio_format.
The current audio format is also stored in mmd->afd.afsi.audio_format_id,
so use the value stored there. However, most users of mmd->audio_format
used this value only to detect whether an audio file is open ATM. In
vss.c, use the map pointer instead to find out whether an audio file is
open.
Andre Noll [Tue, 23 Oct 2007 16:13:21 +0000 (18:13 +0200)]
Remove para_sdl_gui, para_slider, para_krell.
These were all really crappy, probably not used by anybody,
and they broke due to the rename of the status item text or
the switch to the new afs. So let's get rid of them.
Andre Noll [Mon, 22 Oct 2007 20:23:31 +0000 (22:23 +0200)]
Switch to the new afs.
This obsoletes get_audio_file() of vss.c. It is being replaced
by a call to the afs layer from vss_post_select() which requests
a struct audio_format_data for the next audio file.
The afd struct, the chunk table and the path of the new audio file are
stored in a shared memory area. The id of that area is sent through
the afs-server socket. An open fd for the underlying audio file is
send to the server process as well using usual socket magic.
The vss task of the server process attaches the shared memory area
and mmaps the open fd to start audio streaming.
The code is still quite buggy, but let's do bug fixes and removal of
the old audio file selectors in susequent patches.
Andre Noll [Sun, 21 Oct 2007 13:25:55 +0000 (15:25 +0200)]
Move mmap_full_file from osl.c to fd.c.
To make it independent from osl.c, we must not pass
a pointer to struct osl_data. Replace it by void *, size_t *
pointers. Also add new int *fd_ptr parameter. If it's non-NULL
the file is not closed after mmap, and the open fd is returned
in fd_ptr.
Andre Noll [Sun, 21 Oct 2007 11:43:22 +0000 (13:43 +0200)]
Complete afs event handling.
Add blob event handling. This definitely needs some
more fine-tuning, but that can be changed gradually
thanks to the generic event handling code.
In playlist mode there's nothing to do, as we're
not interested in any blob events. So install only
a dummy handler for the scoring system and decide
whether to reload the score table in mood.c.
Andre Noll [Thu, 11 Oct 2007 12:35:28 +0000 (14:35 +0200)]
Add --gc-sections to LDFLAGS.
This, together with -fdata-sections and -ffunction-sections brought
nice size reductions. Before:
-rwxr-xr-x 1 maan fml 29K Oct 11 14:32 para_audioc*
-rwxr-xr-x 1 maan fml 42K Oct 11 14:32 para_client*
-rwxr-xr-x 1 maan fml 33K Oct 11 14:32 para_fade*
-rwxr-xr-x 1 maan fml 38K Oct 11 14:32 para_filter*
-rwxr-xr-x 1 maan fml 54K Oct 11 14:32 para_fsck*
-rwxr-xr-x 1 maan fml 52K Oct 11 14:32 para_gui*
-rwxr-xr-x 1 maan fml 42K Oct 11 14:32 para_recv*
-rwxr-xr-x 1 maan fml 216K Oct 11 14:32 para_server*
-rwxr-xr-x 1 maan fml 38K Oct 11 14:32 para_write*
After:
-rwxr-xr-x 1 maan fml 21K Oct 11 14:31 para_audioc*
-rwxr-xr-x 1 maan fml 33K Oct 11 14:31 para_client*
-rwxr-xr-x 1 maan fml 29K Oct 11 14:31 para_fade*
-rwxr-xr-x 1 maan fml 29K Oct 11 14:31 para_filter*
-rwxr-xr-x 1 maan fml 45K Oct 11 14:31 para_fsck*
-rwxr-xr-x 1 maan fml 47K Oct 11 14:31 para_gui*
-rwxr-xr-x 1 maan fml 30K Oct 11 14:31 para_recv*
-rwxr-xr-x 1 maan fml 208K Oct 11 14:31 para_server*
-rwxr-xr-x 1 maan fml 29K Oct 11 14:31 para_write*
Andre Noll [Sun, 7 Oct 2007 19:03:54 +0000 (21:03 +0200)]
Only declare error codes that are safe to use.
The following type of bug occurred frequently since the introduction
of error.h: An error code was defined for some file a.c and was used
in another file b.c. This is all good if each executable that contains
b.o also contains a.o.
If this is not the case, i.e. if there is an executable that contains
b.o but _not_ a.o, the error texts of all errors defined for a.c are
not included in the executable. This results in a segmentation fault
at runtime if PARA_STRERROR() is used for such an error code.
Unfortunately, this was hard to spot because all error codes were
visible everywhere. This patch gets rid of this flaw by making
only those error codes visible for b.c which are safe to use.
According to the above, the set of error codes which are safe to use
in b.c can be defined as follows. Let E_1, ... E_n be the set of
executables that contain b.o and let, for j=1,...n, S_j be the
set of files those files contained in E_j. Then, all errors defined
in the intersection
S_1 \cap S_2 \cap ... \cap S_n
are safe to use in b.c. The patch adds a function to configure.ac
That computes this intersection. Unfortunately, it is rather expensive.
The good news is that this simplifies error.h a bit and that it
already revealed a couple of bugs which are also fixed in the patch:
- afs.c used E_SIGNAL_CAUGHT which was only defined in audiod.
Introduce E_AFS_SIGNAL and change afs.c accordingly.
- audiod uses E_RECV_SYNTAX, which belonged to recv which is
not contained in audiod. Move it to recv_common instead.
This bug is also present in v0.2.x and needs a similar fix.
- E_NOTDIR was used in fd.c, but was defined in osl.c. Not all
executables that include fd.o also include osl.o. Move E_NOTDIR
to the set of errors for fd.
Andre Noll [Fri, 5 Oct 2007 18:18:22 +0000 (20:18 +0200)]
Make it compile on Solaris.
This required a bit of work as Solaris has gethostbyname() and
socket-related functions not in libc but in libsocket and libnsl.
So add corresponding checks to configure.ac.
Moreover, make para_gui optional and add configure options for
specifying the directory containing the curses headers and curses
lib.
Andre Noll [Thu, 4 Oct 2007 14:11:59 +0000 (16:11 +0200)]
afs.c: Introduce client list for afs (fixes dosable bug).
With the old code, a malicious local user could easily cause a DOS
by connecting to the local afs socket but never sending any data
through that socket. This caused afs to block on the read() from the
new client fd.
This patch fixes this flaw by introducing a doubly liked list of
connected clients. Each entry in this list contains an open file
descriptor and the time the client connected.
In command_pre_select() we add each fd in the list to the set of
fds to be checked for readability. In command_post_select() we loop
through that list and check each fd again. Whenever the fd for a
client is readable we read from that fd and execute an afs command
if the client sent the valid magic cookie.
However, if the fd is not ready, we close the connection if more than
AFS_CLIENT_TIMEOUT seconds (default: 3) have passed since the client
connected. This hopefully avoids another possible DOS: A malicious
user could try to flood us with connections until the limit of open
fds is reached.
Andre Noll [Tue, 2 Oct 2007 13:56:10 +0000 (15:56 +0200)]
Make it compile on FreeBSD.
This was easier than expected. Only two items needed fixing:
- signal.h has to be included for several files that use signals.
- The __used and __packed macros are already defined on FreeBSD which
leads to an error at compile time. Fortunately paraslash doesn't use
these macros at all, so we can simply remove them.
Andre Noll [Tue, 2 Oct 2007 12:04:46 +0000 (14:04 +0200)]
fsck.c: Fix several bugs in dump mode.
- Don't abort if a directory can't be created because it already exists.
- Use correct variable for the disk storage name column.
- If more than one table is to be dumped, use a directory for each table.
- Remove __a_unused for main()'s argc which _is_ being used.
Andre Noll [Sat, 29 Sep 2007 12:00:14 +0000 (14:00 +0200)]
attribute.c: Clear attribute bits already at remove time.
If an attribute gets removed, the old code deferred clearing the
corresponding attribute bit in the afsi of all audio files until
that bit got reclaimed by add_att. This is problematic because of
the new no_attribute_set mood method.
Andre Noll [Sat, 29 Sep 2007 11:39:34 +0000 (13:39 +0200)]
mood.c: Add no_attributes_set mood method.
Also fix a bug in mm_played_rarely_parser(): If no arg was
specified in the mood definition, a NULL pointer is passed to that
function, so it must not blindly dereference that pointer.
Andre Noll [Sat, 29 Sep 2007 11:13:50 +0000 (13:13 +0200)]
Speed up mood loading.
The old code passed a pointer to the row of the audio file table to the
mood scoring functions. The scoring functions had to obtain the afsi,
afhi, path from that row pointer. Thus, at mood load time, the afsi,
afhi, path was extracted N times for each audio file if there are N
mood lines that used this info.
This patch changes the mood scoring functions so that they take
three pointers to afsi, afhi, path instead of the row pointer.
add_item_score(), the single caller of the mood scoring functions,
provides these pointers, i.e. they get extracted from the row pointer
only once per audio file.
This is still not optimal as most scoring functions use only one of
the three pointers. But let's not over-engineer the thing.