Andre Noll [Mon, 22 Dec 2014 18:05:38 +0000 (18:05 +0000)]
aft: Update status items on afs events.
When a paraslash command changes the afs or afh info structures of the
current audio file, for example by re-adding the file with modified
meta tags, the stat output still reports the old values. With this
patch applied, the status items are updated immediately.
This is achieved by letting aft.c honor the AFSI_CHANGE and AFHI_CHANGE
events. If the audio file which triggered the event is the one
currently being streamed, the event handler recreates the status items.
We need two new global static variables in aft.c to track the row of
the audio file table which corresponds to the current file.
Andre Noll [Sun, 21 Dec 2014 15:24:18 +0000 (15:24 +0000)]
afs: Simplify open_next_audio_file().
This function of afs.c is called whenever the virtual streaming
system requests a new audio file. It determines the row of the audio
file table that corresponds to the audio file with highest score,
according to the current mood or playlist. The function passes this
information to open_and_update_audio_file() of aft.c which sets up
an afd structure to be passed back to the server process.
Letting open_and_update_audio_file() determine which file to
open is shorter, and it allows to get rid of two arguments to
open_and_update_audio_file().
Andre Noll [Tue, 10 Mar 2015 18:03:01 +0000 (19:03 +0100)]
Doxygen: Fix references on main page.
Newer doxygen versions render the main page incorrectly: the second
set of references is shown as a table, with no hyperlinks at all.
This commit should fix it.
Andre Noll [Sat, 14 Feb 2015 19:45:29 +0000 (20:45 +0100)]
gui: Fix config file reloading.
Without this, all key-map arguments found in the config file are
appended to the existing ones, duplicating these options in the help
output. Fix this by invalidating the key-map entry prior to the call
to gui_cmdline_parser_config_file().
Andre Noll [Sun, 8 Mar 2015 18:32:37 +0000 (19:32 +0100)]
Merge branch 'refs/heads/t/abtract_sockets'
Was cooking for almost one month and seems to work fine.
manual: Move /var/paraslash instructions to Troubleshooting.
Abstract sockets for server and audiod.
create_local_socket(): Avoid code duplication.
net.c: Combine remote_name() and __get_sock_name().
Remove socket address parameter of create_local_socket().
Andre Noll [Sat, 7 Feb 2015 14:14:43 +0000 (15:14 +0100)]
interactive.c does not depend on curses.h.
On systems where libreadline is installed but curses headers are not,
the build fails because interactive.c, which includes curses.h, is
attempted to be compiled. Fortunately, it is unnecessary to include
this header, so this commit removes the include directive. However,
we must include para.h before the readline headers because the latter
depend on stdio.h.
Andre Noll [Tue, 7 Oct 2014 19:56:01 +0000 (19:56 +0000)]
Improve signal init and shutdown.
Currently all users of the signal subsystem define their own
signal_task structure and initialize the ->fd field from the return
value of para_signal_init(). It is more natural to let the signal
subsystem perform the allocation and the initialization.
This commit renames para_signal_init() to signal_init_or_die() and
changes the function to allocate, initialize and return a signal
task structure (rather than only the file descriptor of the signal
pipe as para_signal_init() did). Similarly, para_signal_shutdown()
is renamed to signal_shutdown() and now takes a pointer to the
signal_task structure which was obtained in an earlier call to
signal_init_or_die(), and frees it. Conversion of all users is
straight forward.
The patch also adds a missing call to signal_shutdown() to audiod.c,
closing an fd leak.
Andre Noll [Mon, 12 Jan 2015 00:07:19 +0000 (01:07 +0100)]
Abstract sockets for server and audiod.
Currently para_server and para_audiod won't start if the socket
specials can not be created, for example because /var/paraslash does
not exist or has insufficient permissions.
The abstract namespace feature for local sockets allows to go
without socket specials, as implemented in this commit. The feature
is a non-portable Linux extension though, so a fallback to pathname
sockets is necessary for other operating systems and for backward
compatibility.
For para_server the situation is simple because the socket is created
by the afs process, and only command handlers are supposed to connect.
Since afs and the command handlers are part of the same executable
(para_server), there are no compatibility issues. Hence we simply
use an abstract socket on Linux and a pathname socket elsewhere.
For para_audiod things are more complicated because two executables
are involved: para_audioc and para_audiod. To allow older versions
of para_audioc to connect to recent versions of para_audiod, we let
audiod listen on one socket of either type. Startup fails only if
neither socket can be created.
As for the implementation, we make use of the fact that it makes
not much sense to call create_local_socket() with permission mode
equal to 0, and that there are no permission modes for abstract
sockets. With the patch applied, specifying the mode as zero instructs
create_local_socket() to create an abstract socket. In this case we
also use the given pathname but prepend a zero byte at the front of
the ->sun_path member of struct sockaddr_un to bind(2) the socket to
an address in the abstract namespace.
On the client side (connect_local_socket()) we first try to connect to
an abstract address and fall back to pathnames sockets on errors. This
change is transparent to the callers of connect_local_socket. Hence
para_audioc and afs command handlers need no modifications at all.
The patch also adds a section on abstract sockets to the user manual.
Andre Noll [Sun, 11 Jan 2015 23:40:22 +0000 (00:40 +0100)]
create_local_socket(): Avoid code duplication.
The two users of create_local_socket(), afs.c and audiod.c, both
call mark_fd_nonblocking() and listen(2) on the returned socket file
descriptor. This patch moves the code for this additional work to
create_local_socket(), simplifying the callers.
Andre Noll [Sun, 11 Jan 2015 22:21:13 +0000 (23:21 +0100)]
Remove socket address parameter of create_local_socket().
The two callers of create_local_socket() are not interested in
the sockaddr_un structure at all. So we may define the structure
in create_local_socket() rather than in each caller, and kill the
function parameter.
Andre Noll [Tue, 7 Oct 2014 19:16:16 +0000 (19:16 +0000)]
signal: Provide generic signal_pre_select().
Identical copies of this function exist in afs.c, gui.c, audiod.c and
server.c. This commit defines a generic version as an inline function
in signal.h and gets rid of the copies.
Andre Noll [Tue, 7 Oct 2014 19:50:25 +0000 (19:50 +0000)]
gui: Shutdown scheduler after schedule() returns.
This makes sure all resources allocated by the scheduler are released.
Since we exit anyway when schedule() returns, this is not a serious
memory leak. The fix helps to identify real leaks though.
Andre Noll [Fri, 23 Jan 2015 12:17:38 +0000 (13:17 +0100)]
Merge branch 'refs/heads/t/afh_improvements'
Was cooking for about a week.
mp3_afh: Detect both v1 and v2 tags.
ogg: Improve documentation of struct ogg_afh_callback_info.
ogg_afh: Add a comment about the three vorbis header packets.
afh_common.c: Avoid ifdefs.
afh loglevel adjustments.
wma: Rename comment_header.
afh: Fix fd leak.
afh: Unmap the audio file on errors.
Andre Noll [Mon, 19 Jan 2015 21:49:01 +0000 (22:49 +0100)]
build: Use curses_cppflags also for compiling gui.c.
The make pattern rule gui%.o does not match gui.o because there
must be at least one character to match the ‘%’. Consequently,
the curses cppflags are ignored for compiling gui.c.
Fix this by explicitly adding gui.o to the list of object files for
which $(curses_cppflags) must be added to CPPFLAGS.
This happens for example if the user is not allowed to connect to
para_audiod.
The problem is that the (non-positive) value -ret is passed to
para_strerror() as the error code rather than -ret2. This commit
fixes the bug. It was introduced one year ago in commit f840be8d
(gui: Introduce status_post_select()).
Andre Noll [Fri, 27 Dec 2013 03:14:57 +0000 (03:14 +0000)]
mp3_afh: Detect both v1 and v2 tags.
Currently the mp3 audio format handler first looks at id3v2 tags and
ignores any id3v1 tags if a version 2 tag is present. This patch makes
it look at both types of tags, and combine the result if necessary.
We use the opportunity to also get rid of the file descriptor mess
in mp3_get_id3(). It is completely unnecessary as lib3d3tag can make
a id3_t structure from a memory buffer. We simply pass (a part of)
the memory map of the audio file and are done.
The techinfo field of struct audio_format_handler_info is changed
to show which tag versions the various tags were extracted. Possible
values are none, v1, v2 and v1+v2.
Andre Noll [Wed, 25 Jun 2014 22:11:31 +0000 (00:11 +0200)]
ogg: Improve documentation of struct ogg_afh_callback_info.
Explain how the possible return values from the callback handler relate
to the header chunk. Also avoid to speak about vorbis and speex,
as the callbacks are also used by the opus audio format handler and
could in theory be used by any codec.
Andre Noll [Sun, 29 Jun 2014 09:39:28 +0000 (11:39 +0200)]
afh_common.c: Avoid ifdefs.
For each optional audio format we currently have two #ifdefs in
afh_common.c: the first one controls whether cpp emits the declaration
of the corresponding init function of the audio format handler while
the second #ifdef prevents the ->init pointer from being initialized
for unsupported audio formats.
Declaring also those init functions which end up as undefined symbols
causes no problems because we never refer to them due to the second set
of #ifdefs.
Hence let's just get rid of the first set of #ifdefs and declare all
xxx_init() functions unconditionally.
Andre Noll [Fri, 27 Dec 2013 22:39:11 +0000 (22:39 +0000)]
afh loglevel adjustments.
The list of supported audio formats is kind of important, so increase
the loglevel of the corresponding message. On the other hand, all the
"initializing xxx handler" messages do not really deserve the NOTICE
loglevel, so downgrade those to INFO.
Andre Noll [Sun, 4 Jan 2015 23:12:07 +0000 (23:12 +0000)]
GIT-VERSION-GEN: Recognize git version in gitweb snapshots.
gitweb prepends the repo name and the git version number to all paths
of the snapshot tarballs (example: paraslash-32a81d7/). This commit
teaches GIT-VERSION-GEN to make use of this information. The patched
script reports the git version thusly encoded in the current directory,
rather than resort to "unnamed_version" as before.
Andre Noll [Sat, 20 Dec 2014 11:36:11 +0000 (12:36 +0100)]
build: Avoid git warning when building from tarball.
The "git describe" command which is removed by this commit caused the
following warning when running "make" on a tree without .git directory
(extracted tarball or gitweb snapshot):
fatal: Not a git repository (or any of the parent directories): .git
This commit avoids the warning. Of course "make tarball" still fails
in this case, but this is expected.
Andre Noll [Sun, 15 Dec 2013 21:39:21 +0000 (22:39 +0100)]
afh: Fix fd leak.
The main() function of para_afh obtains the open file descriptor from
mmap_full_file() which is then passed to compute_afhi(). If this file
descriptor is never closed, we have an fd leak.
Unfortunately it depends on the audio format handler whether fd
gets closed or not: the mp3 audio format handler closes it through
libid3tag's id3_file_close() while all other audio format handlers
leave it open.
Fix this by changing mp3_get_id3() to operate on a copy of the fd
instead so that the original fd remains open. The newly added close()
in afh.c thus fixes the fd leak and never closes an invalid fd.
Andre Noll [Fri, 2 Jan 2015 02:14:03 +0000 (02:14 +0000)]
Update year in copyright headers.
Done with
files=$(git grep -l 'Copyright (C) [0-9]\{4\}\(-2014\)* Andre Noll')
sed --in-place= -e 's/Copyright (C) \([0-9]\{4\}\)-2014 Andre Noll/Copyright (C) \1 Andre Noll/1' $files
In previous years we ran a similar script to set the second year in
the range to the current year. This is kind of silly, so let's get
rid of this useless information.
This commit replaces "Copyright (C) A-B" by "Copyright (C) A" in
all file headers, i.e. only the first year (A) is left in. Accurate
information including time stamps for each change can be obtained
from the git history.
Andre Noll [Sat, 3 Jan 2015 04:27:21 +0000 (04:27 +0000)]
manual: Shorten Installation section.
This section contains some information which is already mentioned in
the previous section on required and optional packages. This patch
gets rid of the redundant parts.
Andre Noll [Mon, 5 Jan 2015 03:07:49 +0000 (03:07 +0000)]
manual: Simplify keygen command.
Specifying an empty passphrase with -N '' is simpler than asking
the user to press enter twice. This commit also improves the note on
short keys slightly.
Andre Noll [Thu, 1 Jan 2015 22:30:30 +0000 (22:30 +0000)]
Remove some unused error codes.
Although E_AMP_SYNTAX and E_PREBUFFER_SYNTAX are assigned to a
variable, in both cases the variable is set to a different value
later without being used in between (detected by cppcheck).
Andre Noll [Wed, 24 Dec 2014 15:10:43 +0000 (15:10 +0000)]
aft: Generate a remove event when adding duplicate files.
Consider the following scenario:
add /foo.mp3
add /bar.mp3 # assume foo and bar differ
cp /foo.mp3 /bar.mp3
add /bar.mp3
In the last add command, the path being added (/bar.mp3) already exists
in the audio file table, and its hash also exists for a different path
(/foo.mp3).
The code in aft.c is smart enough to detect this. It first removes
the existing entry for /bar.mp3 and then considers the addition of
/bar.mp3 as a file rename /foo.mp3 -> /bar.mp3.
Unfortunately, we miss to generate the remove event in this case. This
patch should fix it. It also improves the message a bit.
Andre Noll [Sun, 21 Dec 2014 14:35:19 +0000 (14:35 +0000)]
aft.c: Don't call osl_close_disk_object() on failure.
If osl_open_disk_object() fails, we branch to the "err" label where
osl_close_disk_object() is called although no disk object exists. Fix
this by simply returning the osl error code in this case.
Andre Noll [Sun, 21 Dec 2014 14:28:34 +0000 (14:28 +0000)]
Add missing osl() wrapper calls.
Some calls to osl library functions were missing the osl() wrapper
which transforms the osl error code into a paraslash error code.
This results in an incorrect error message on failure or worse.
print_chunk_table() and open_and_update_audio_file() of aft.c are
affected as well as the xxx_create() functions of blob.c.
Andre Noll [Sun, 7 Dec 2014 19:33:57 +0000 (20:33 +0100)]
build: Add missing cpp flags.
The directories passed as arguments to --with-flac-headers,
--with-samplerate-headers and --with-readline-headers are searched
for header files at configure time, but we ignore these directories
when compiling the source tree. This commit should fix this.
Andre Noll [Sun, 7 Dec 2014 14:29:17 +0000 (15:29 +0100)]
Merge branch 'refs/heads/t/build_system'
Cooking for more than a month.
* t/build_system:
Add message to target maintainer-clean.
Use git version for tarball and AC_INIT().
Run autom4te instead of autoconf.
Remove depend.sh.
Simplify make clean.
Do not create .d files for gengetopt source files.
Introduce cmdlist_dir.
Remove pointless autoconf checks.
Avoid excessive dep generation on Makefile changes.
Add -Wformat to STRICT_CFLAGS.
Compile with -Wall -Wunused only on linux.
Separate CPPFLAGS and CFLAGS.
Rename DEBUG_CPPFLAGS to STRICT_CFLAGS.
Only compile with osl_cppflags where necessary.
Remove pointless -r option to cp for target tarball.
Make tarball commands quiet.
Do not opencode $(tarball).
Run tr only once in configure.ac.
Silence ggo_descriptions_declared command.
Call AC_CONFIG_HEADERS rather than AM_CONFIG_HEADER.
Remove duplicate -Wno-unused-function.
Honor --with-xxx-headers also for dependencies.
Andre Noll [Sun, 28 Sep 2014 17:02:46 +0000 (17:02 +0000)]
server: Add com_tasks().
It is sometimes useful to see the task list of para_server. The
infrastructure for obtaining this information is already in sched.c,
so this is a rather simple matter.
Andre Noll [Sun, 26 Oct 2014 10:36:35 +0000 (11:36 +0100)]
command.c: Replace usleep() by nanosleep().
POSIX.1-2001 declares usleep() obsolete and POSIX.1-2008 removes the
specification. Fortunately, there is only a single user of usleep()
in the tree: com_sender() which needs to retry the command if another
sender command is currently running. This commit changes com_sender()
to call nanosleep() instead of usleep() and adds a comment which
explains why we are going to sleep at this point.
Andre Noll [Sun, 3 Aug 2014 09:44:48 +0000 (11:44 +0200)]
build: Use git version for tarball and AC_INIT().
It's kind of silly to use "git" as the version string at all times
except for releases. This commit changes the name of the generated
tarball to use the output of git describe. Hence the "tarball"
target creates a tarball named according to the current git HEAD. For
compatibility we provide a symlink with the old name.
Andre Noll [Sun, 20 Apr 2014 02:03:39 +0000 (02:03 +0000)]
build: Run autom4te instead of autoconf.
This is equivalent, except we have the option to disable the autom4te
cache. This cache does not give significant speedups but creates the
annoying directory.
Andre Noll [Sat, 12 Jul 2014 11:40:44 +0000 (13:40 +0200)]
build: Remove depend.sh.
This script was rather clumsy, and it referred to gcc rather than
$(CC) as it should be. This commit adds a command to Makefile.real
that generates the .d files directly, which is not more complicated.
Use the opportunity to add -MP to the $(CC) command which generates
the dependency files. This option works around make errors in case
a header file is removed from the tree.
This change gives another speedup of ~15% for make dep.
Andre Noll [Sun, 20 Apr 2014 02:03:09 +0000 (02:03 +0000)]
build: Introduce cmdlist_dir.
This puts all files generated by command_util.bash into a new
subdirectory inside the build directory. This way we don't need
to special-case these files any more in .gitignore, Doxyfile, make
clean. The compiler and depend.sh need to know this directory, so
we add -I$(cmdlist_dir) to CPPFLAGS and introduce a new parameter
for depend.sh.
To prevent cpp from including stale versions of the *command_list.h
files in the top level directory (left over from a previous build)
this commit renames the generated files slightly. For example,
audiod_completion.h becomes audiod.completion.h.
Andre Noll [Sun, 20 Apr 2014 00:20:12 +0000 (00:20 +0000)]
build: Remove pointless autoconf checks.
These checks never fail on any reasonably current system and
probably have never failed on any system this software was ever
compiled. Removing the checks reduces the configure time to 60%, so..
Andre Noll [Sun, 20 Apr 2014 00:55:12 +0000 (00:55 +0000)]
build: Avoid excessive dep generation on Makefile changes.
Letting error2 depend on config.h instead of Makefile should be no
worse, and it does not cause all dependencies to be recreated in the
common case where config.h remains unchanged after reconfiguration.
Andre Noll [Sun, 4 May 2014 19:27:21 +0000 (21:27 +0200)]
build: Compile with -Wall -Wunused only on linux.
On *BSD the old set of CFLAGS causes warnings of the form
/usr/pkg/include/vorbis/vorbisfile.h:75:21: warning: 'OV_CALLBACKS_DEFAULT' defined but not used
/usr/pkg/include/vorbis/vorbisfile.h:82:21: warning: 'OV_CALLBACKS_NOCLOSE' defined but not used
/usr/pkg/include/vorbis/vorbisfile.h:89:21: warning: 'OV_CALLBACKS_STREAMONLY' defined but not used
/usr/pkg/include/vorbis/vorbisfile.h:96:21: warning: 'OV_CALLBACKS_STREAMONLY_NOCLOSE' defined but not used
This commit avoids these warnings by enabling -Wall and -Wunused only
on Linux systems. Let's also collect these flags in STRICT_CFLAGS
rather than CFLAGS to avoid warnings when compiling the *.cmdline.c
files.