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: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.
Andre Noll [Sat, 19 Apr 2014 23:38:04 +0000 (23:38 +0000)]
build: Separate CPPFLAGS and CFLAGS.
The CPPFLAGS variable should consist of preprocessor options only and
should not contain any compiler options. Clearly this is not the case
at the moment.
This commit cleans up the mess and separates the per target CFLAGS
settings from the CPPFLAGS settings.
Andre Noll [Sat, 19 Apr 2014 23:22:53 +0000 (23:22 +0000)]
build: Rename DEBUG_CPPFLAGS to STRICT_CFLAGS.
This variable is a misnomer for two reasons: First, its purpose is
unrelated to debugging. We just prefer to compile our own source
files with more strict flags than the flags used for the generated
*.cmdline.c files. Compiling those with the strict flags would
result in warnings we can not fix anyway. Second, these flags are
no preprocessor flags but compiler flags. So STRICT_CFLAGS is more
appropriate than DEBUG_CPPFLAGS.
Andre Noll [Sat, 19 Apr 2014 23:22:18 +0000 (23:22 +0000)]
build: Only compile with osl_cppflags where necessary.
Currently we include $(osl_cppflags) in the CC command used to compile
all objects, regardless of whether the command needs these flags. This
commit changes Makefile.real to add the flags only for those objects
which actually include osl.h.
Andre Noll [Sat, 19 Apr 2014 22:53:00 +0000 (22:53 +0000)]
build: Run tr only once in configure.ac.
The configure script creates the subsystem error enums for config.h
from the list of object file names by turning the base name into
upper case and prepending "SS_". For the conversion to upper case we
currently execute the tr command once for each object.
This patch changes the corresponding shell code of configure.ac to
first build the full enum and then turn all words into upper case
in one go. This way tr is only executed once which should save us a
few cycles.
Andre Noll [Thu, 24 Jul 2014 20:05:56 +0000 (22:05 +0200)]
build: Remove duplicate -Wno-unused-function.
We compile the .c files generated by gengetopt with this option to
silence a compiler warning. The option is first added to CPPFLAGS
and then specified again in the rule for the *.cmdline.o target. This
gets rid of the second instance.
Andre Noll [Thu, 9 Oct 2014 21:37:09 +0000 (21:37 +0000)]
Merge branch 'refs/heads/t/server_cmds'
Was cooking for three weeks.
* Add sender subcommand "status".
* com_si(): Don't print git version string.
* Doxify the sender_subcommand enum.
* Overhaul help texts of server and afs commands.
* com_sender: Replace memcpy by struct copy.