| Commit message (Collapse) | Author |
|
This makes para_client enter an interactive session when started with no
command. Command line history and command completion are available in
interactive sessions.
This populates the previously empty files interactive.h and interactive.c which
contain the readline/interactive specific part. Everything in these files is
independent of para_client. Conversely, client.c and client_common.c are
independent of readline.
The public API defined in interactive.h was designed to be reused from other
applications. In fact, a subsequent commit changes para_audioc to offer
interactive sessions as well.
|
|
The completion code needs to determine the word the curser is
currently on. Libreadline only provides the start and end position
of the current word in the line buffer, but not the word number.
This patch adds compute_word_num() to string.c which uses the same
algorithm as create_argv() to determine the word boundaries.
|
|
This adds interactive.o to the object list of para_client if readline
was found and links para_client against libreadline in this case.
The new source files interactive.c and interactive.h are empty for now.
|
|
For interactive para_client sessions, we set up the client
configuration from the values given at the command line and in the
config file just as we do for non-interactive mode. However, in
interactive mode we must be able to execute arbitrary many client
commands using the same configuration. client_open() sets up the
configuration from the command line arguments and client_close()
destroys the configuration, so both functions do more than what is
needed in interactive mode.
This patch splits client_open() into two functions
client_parse_config() and client_connect(). The old client_open()
remains with the same semantics as before, it just calls both of the
new functions().
In the same spirit, client_close() is split into client_disconnect(),
which closes the file descriptor and deallocates the ressources of
the current command but does not free the configuration.
This allows to re-use the client configuration multiple times for
interactive sessions.
|
|
The interactive completion code must be able to run a second,
independent scheduler instance for generating the possible completions.
This is currently not possible because the pre_select and post_select
list heads of the scheduler are defined globally in sched.c.
This patch moves these list heads from sched.c to struct sched. This
leaves only the global "now" variable in sched.c, but it is OK to
update this from all scheduler instances, so it can stay.
Moving the two list heads to struct sched requires that several
public functions, among them register_task(), grow an additional
parameter. The (mostly trivial) changes that update all callers to
provide the new argument make the patch rather invasive, unfortunately.
|
|
This adds completion mode to command_util.sh. When exectuted in this
mode, it prints array initializers for all supported commands. This
will be used to generate the array of completers for para_client and
para_audiod.
|
|
Currently, para_client defines its para_log function via the
INIT_STDERR_LOGGING() macro which generates a log function that
writes to stderr. However, we will need to switch to a different,
curses-aware logging function when operating in interactive mode.
To support more than one log method the type of para_log is changed
from a function to a (public) pointer variable. This variable is
supposed to point to the log function currently in use so that the
application can simply set para_log differently in order to switch
between log functions.
The patch also changes the INIT_STDERR_LOGGING() macro to receive the
name of the log function to be defined and to let para_log point to
the newly defined function.
|
|
Without this additional quoting, the command usage string is incorrect
in case the template contains square brackets. For example, the usage
of the lsblob commands was printed as
Usage: lspl [-i] [-l] [-r] t
rather than the desired
Usage: lspl [-i] [-l] [-r] [pattern]
because the command "echo [pattern]" prints "t" since there is a
subdirectory called "t" in the source tree.
|
|
Commit 25ca796b (daemon: Introduce parent_waits flag for
daemonize().) broke the compilation on FreeBSD due to signal.h not
being included. This patch adds the missing include.
|
|
|
|
This replaces the dummy functions in flacdec_filter.c by a working
implementation. Although it contains an ugly workaround for a
shortcoming in the flac library, see the comment in read_cb() for
details, it seems to work fine.
|
|
This adds another audio format to para_server and para_afh. Since
meta data tags flac are essentially vorbis comments, they are fully
supported. However, the audio format handler accepts only flac
files with fixed block size, and ogg/flac is not supported either at
this point.
|
|
This adds tests for flac headers and libraries to configure.ac and
adds configure options to override the default location of these files.
Moreover, a (non-working) implementation of the flac audio format
handler and the flac decoder are introduced. All new functions are
defined as empty dummies to be filled with content in subsequent
commits.
|
|
This function is useful for the flac decoder.
|
|
copy_comment() and copy_if_tag_type() are useful also to the new flac
audio format handler, so move these functions to string.c and make
them public.
Rename them to safe_strdup() and key_value_copy() respectively,
as this is more to the point.
|
|
Currently the field width for the audio format is hard-coded as three
as the name of each supported audio format (mp3, ogg, aac, wma, spx)
consists of three characters.
However, with the forthcoming flac support, this is no longer true
since "flac" consists of four characters. So the ls command must
calculate the maximal field width of the audio formats of all listed
files.
This is achieved by introducing the new audio_format_width member of
struct ls_widths.
|
|
Some flac files may contain the contain arbitrary large metadata
at the beginning and libflac wants to see this data in one go.
128K should be enough for most cases.
|
|
In daemon mode, para_server should not detach from the console
until it is listening on its command socket. The previous approach
turned out to be buggy and has been reverted in the previous commit.
This second attempt tries to get it right. It adds a boolean parameter
"parent_waits" to daemonize(). After daemonize() has forked, the
parent process does not exit immediately if parent_waits is true but
waits until the child process sends SIGTERM to its parent, or exits.
para_server makes use of the new flag in server_init(). The daemon
process (child) sends SIGTERM to its parent after the command socket
has been initialized. para_audiod, on the other hand, does not need
this feature, so it calls daemonize() with parent_waits == false to
get the old behaviour.
|
|
This reverts commit 7a4b6d5f19976ceac581f6dc235fcbd9b30c767f, which
was a rather bad idea because it caused the afs process to inherit
the open file descriptor of the command socket, so two processes
listened on the command socket at the same time.
Even worse, the afs process also inherited the command task in its
scheduler setup, causing it to answer incoming connections as well.
In fact it was more or less random which of the two processes served
an incoming connection.
If it was the afs process, interesting things happened in the command
handler due to its address space being a copy of the afs process,
where parts of what is needed for some commands not properly set
up. For example the si and the sender commands segfaulted due to a
NULL pointer dereference.
It's weird that this bug was not noticed earlier.
|
|
valgrind complains because of invalid reads/writes in vss.c:
==998== Invalid write of size 1
==998== at 0x8050B09: vss_post_select (vss.c:574)
==998== by 0x806106C: schedule (sched.c:71)
==998== by 0x804EE04: main (server.c:579)
==998== Address 0x46d99bc is 0 bytes after a block of size 548 alloc'd
==998== at 0x4028A3B: realloc (vg_replace_malloc.c:632)
==998== by 0x805356B: para_realloc (string.c:40)
==998== by 0x80506EC: vss_post_select (vss.c:331)
==998== by 0x806106C: schedule (sched.c:71)
==998== by 0x804EE04: main (server.c:579)
==998==
...
==5543== Invalid read of size 1
==5543== at 0x8050EBD: vss_post_select (vss.c:1099)
==5543== by 0x806108E: schedule (sched.c:71)
==5543== by 0x804EE04: main (server.c:579)
==5543== Address 0x47c70ac is 0 bytes after a block of size 3,956 alloc'd
==5543== at 0x4028A3B: realloc (vg_replace_malloc.c:632)
==5543== by 0x805358D: para_realloc (string.c:40)
==5543== by 0x80642AA: add_ogg_page (ogg_afh.c:78)
==5543== by 0x8064458: vorbis_get_header_callback (ogg_afh.c:132)
==5543== by 0x8063EF1: process_ogg_packets (ogg_afh_common.c:48)
==5543== by 0x8063F9A: ogg_get_file_info (ogg_afh_common.c:144)
==5543== by 0x8064200: vorbis_get_header (ogg_afh.c:149)
==5543== by 0x804FDD9: recv_afs_result (vss.c:1006)
==5543== by 0x80503F4: vss_post_select (vss.c:1124)
==5543== by 0x806108E: schedule (sched.c:71)
==5543== by 0x804EE04: main (server.c:579)
The problem is that for ogg streams chunk 0 points to a buffer on
the heap rather than to the mapped audio file, but we are checking
the buffer bounds against the memory map.
The fix consists of two parts. (a) We now treat a FEC group special
if it starts at chunk zero: Such a group now contains only this single
chunk. (b) When setting up the FEC group we always compare the buffer
bounds against the start of the first buffer in the group rather than
the memory map.
|
|
Commit 7bba6232 (vss: Mmap audio files using MAP_POPULATE.) introduced
read-ahead for chunks of the mmapped audio file. However, it missed
the fact that for ogg streams chunk 0 is created on the fly and stored
in a dynamically allocated buffer. Read-ahead on this buffer is likely
to access memory not owned by the process and might lead to a segfault.
Fix this bug by not performing read-ahead for chunk zero.
|
|
Just to be consistent with other commands.
|
|
In case at least one pattern was given and no matches were found,
the ls command returned with no output at all. This makes it print a
"no matches" error message instead.
|
|
The catblob commands are supposed to print this message only if none
of the given patterns matches any blob in the database. However, in
case all of the matching blobs are empty, we do print the message.
The problem is that the match count is not being increased due
to cat_blob() returning negative for empty blobs. This count is
computed in action_if_pattern_matches() which calls cat_blob() as
its action handler which in turn calls osl_open_disk_object(). But
this function returns -E_OSL_EMPTY for empty blobs, and cat_blob()
just passes through this value.
This patch changes cat_blob() so that it explicitly checks for
-E_OSL_EMPTY and returns zero in this case so that the match counter
will be increased.
|
|
This is straight-forward given the new generic num_matches
counter which was introduced in the previous patch.
|
|
Several afs commands implemented their own counters, often only to
find out whether they should print an error message because no rows
matched the given pattern(s).
This patch makes counting matching rows generic by increasing the new
pattern_match_data->num_matches counter in action_if_pattern_matches()
so that all commands which use this facility for iterating over all
audio files can evaluate the counter afterwards. This allows to remove
several per-command counters.
|
|
The git link to kernel.org was defunct and is probably not the best
pointer anyway. These days everybody knows git, so let's simply not
link to any git page.
This patch also reorders the three options for downloading (clone repo,
download snaphot, download release) so that git comes first.
|
|
This changes http_recv_post_select() to call readv_nonblock() rather
than read_nonblock() to read data from the socket, just like the udp
and dccp receivers do.
This saves one iteration of the scheduler loop if the end of the
buffer pool area is reached.
|
|
All three receivers maintain a file descriptor and a buffer tree
pool per connection. Currently these are part of the receiver node's
private_data structure, which is a needless code duplication.
This patch moves both fields to the generic struct receiver_node. Since
the private_data structure of the udp and dccp receivers contained
no other fields, this allows to get rid of it completely for these
two receivers.
|
|
Always print the alsa error string corresponding to the failed library
call. This allows to get rid of all but one alsa errors in error.h.
|
|
The two members buffer_frames and buffer_time of struct
private_alsa_data are only needed in alsa_init(), so make them
local. Rename buffer_frames to buffer_size since this is the value
returned by snd_pcm_hw_params_get_buffer_size().
|
|
Currently we log selected alsa parameters, but it is sometimes
useful to see the full configuration. This patch adds a call to
snd_pcm_dump() to alsa_init() which obtains the alsa hardware and
software configuration. It is printed for loglevels info and debug.
|
|
When using alsa's direct mixing plugin, the alsa poll fd might be ready
for IO even though nothing can be written to the alsa handle. This
leads to a busy loop in para_audiod and para_write and makes these
applications eat up considerable amounts of CPU time during playback.
This patch fixes the problem by reading from the alsa fd after a
failed write. It also adjusts the test for when to return early from
alsa_post_select(). The old code was not wrong, however, since we
should never reach the test if poll_fd is negative.
|
|
This variable is defined but never used, so it is safe to remove it.
|
|
It is enough to let para_audiod and para_server depend on their object
files only as these object files in turn depend on _command_list.[ch],
so Mr Transitivity does the work for us.
|