Andre Noll [Mon, 24 Mar 2008 14:20:28 +0000 (15:20 +0100)]
make send_callback_request() and friends take a result handler.
This is a first step to overcome a design flaw in the afs
callback code: The output of the commands is currently
stored in an osl object that is copied to a shared memory
area whose shmid is passed back to the command handler
via the local socket. This method limits the size of the
command output to the maximal size that can be stored in
a shared memory area which is not enough to hold large
outputs like that of ls -c.
This patch allows the command handlers to pass a result handler
function instead of an osl object. This result handler is
called for each shared memory area that gets sent through the
local socket.
Further patches will change the callbacks so that they pass
multiple result buffers instead of returning a single buffer.
This has the additional advantage that partial command output
produced by the callback can be sent even before the callback
returns. This parital output is seen immediately by the command
handler.
Andre Noll [Wed, 19 Mar 2008 20:51:46 +0000 (21:51 +0100)]
Fix use of uninitialized afhi->header_len.
In aft's add_one_audio_file() we set the header len and
the header offset to zero so that the get_file_info()
functions of the audio format handlers that do not use
headers don't need to zero these fields.
However, this is not the right place to do that as para_afh
also calls get_file_info() via compute_afhi() but missed to
clear these fields which leads to a segmentation fault.
Fix this bug by moving the zeroing to compute_afhi().
Andre Noll [Sat, 16 Feb 2008 14:33:50 +0000 (15:33 +0100)]
Sender code consolidation, on/off commands for the dccp sender.
This patch moves a bunch of code from the http sender to
send_common.c to make it available also for the dccp sender.
To this aim a new structure sender_status is introduced which
holds the configuration and the current status of the http/dccp
sender. Most of the new functions in send_common.c take a pointer
to such a structure.
This allows to implement the off/on/allow/deny/info commands
as a one-liner for both the dccp and the http sender.
The new server config option dccp_max_clients allows to restrict the
number of simultaneous connections to the dccp sender.
Andre Noll [Sun, 10 Feb 2008 11:49:29 +0000 (12:49 +0100)]
Speed up open_current_receiver().
To my surprise, this function showed up in the profiling info.
This is due to the fact that the old code was parsing the
FORMAT status item in audiod_pre_select() which gets called
on each iteration of the sheduler. However, this status item
gets only modified on audio file change.
So parse the status item string only once, when we receive it,
and store the current audio format number in the new field of
struct status_task.
Andre Noll [Sat, 9 Feb 2008 19:32:36 +0000 (20:32 +0100)]
compress.c: Simplify volume adjusting code.
There's no need to distinguish the cases sample > 0 and
sample < 0. Work with its absolute value instead and get
rid of some similar code in the hot path.
Andre Noll [Mon, 4 Feb 2008 19:41:00 +0000 (20:41 +0100)]
http_send.c: Fix a bug in http_post_select().
If the accept() on the listen_fd fails, we don't have a valid
file descriptor but tried to close it anyway. Even worse, the
old code dereferenced and then freed the "sc" pointer which
isn't inititialized at that point.
Andre Noll [Sat, 2 Feb 2008 20:28:51 +0000 (21:28 +0100)]
Intoduce send_common.c and use it from the dccp sender.
This new file contains code that was identical for the
dccp and the http sender. A subsequent patch will convert
the http sender to also use the shared code in send_common.c
Andre Noll [Sat, 2 Feb 2008 11:20:22 +0000 (12:20 +0100)]
dccp_send.c: Fix a header sending bug.
If the dccp sender is asked to send out an empty chunk, it
returns immediately without doing anything. However, we
might want to send the audio file header or the queued chunks
in this case. So always loop over all connected clients to see
if we can send something.
Moreover, if we are not listending on the dccp port, there can
not be any dccp clients, so the loop over all clients will be
an empty loop. Thus we may skip the initial check for an early
return completely.
Andre Noll [Sat, 2 Feb 2008 10:50:42 +0000 (11:50 +0100)]
http_send.c: Get rid of HTTP_READY_TO_STREAM.
The only reason for this state was to know whether we
already sent the audio file header. Store this info in
the new header_sent member of struct http_client.
This simplifies the code a bit and makes it more similar
to the dccp sending code.
Andre Noll [Mon, 21 Jan 2008 08:24:16 +0000 (09:24 +0100)]
Be more careful on command exit.
If the callback returned zero, there's nothing to do.
If it returned positive, we have to send out the result
buffer and must free it afterwards. Sending the buffer may
well lead to an error condition, so always check the return
value of the corresponding call to send_buffer(). Finally,
it the command handler returned a negative value, we have
to send an error message to the client which might give rise
to another error (if sending the errror message failed). In this
case, ignore the send errror and return the previous error value.