paraslash.git
8 years agoaac: Fix compilation without libmp4v2.
Andre Noll [Sun, 26 Apr 2015 13:59:26 +0000 (15:59 +0200)]
aac: Fix compilation without libmp4v2.

This was broken for two reasons: First, the aac audio format handler
depends on libmp4v2 rather than libfaad. Second, we must include
aac_common if either libfaad or libmp4v2 (or both) were found. The
logic in configure.ac got this wrong.

8 years agoThe mp4 tagger.
Andre Noll [Thu, 17 Apr 2014 21:16:11 +0000 (21:16 +0000)]
The mp4 tagger.

This commit adds support for editing meta tags of mp4 files. We
employ the mp4v2 library to do the work, so fairly little code has
to be added to the aac audio format handler.

We could deactivate tag editing for mp4 files if libmp4v2 was not
detected, but since subsequent commits for the aac audio format
handler will be based on the mp4v2 library as well, we keep it simple
and deactivate aac support completely in this case.

8 years agoThe mp3 tagger.
Andre Noll [Thu, 26 Dec 2013 20:22:12 +0000 (20:22 +0000)]
The mp3 tagger.

This commit adds support for adding and modifying the ID3 tags of mp3
files. Both ID3 version 1 and version 2 are supported. If no tags
were found, a version 2 tag is added, otherwise only the existing
tags are modified.

The documentation is updated to mention that libid3tag is required
for the new feature.

8 years agoThe flac tagger.
Andre Noll [Wed, 25 Dec 2013 02:49:00 +0000 (02:49 +0000)]
The flac tagger.

This commit adds support to modify the vorbis comments of a flac
file. As usual, only the artist, title, album, year and comment tags
are supported.

As for the implementation, we first locate the vorbis comment
block by iterating over all metadata blocks. In this block
we replace each comment by the tags provided as an argument to
flac_rewrite_tags(). To work around a bug in old flac versions we
avoid to call FLAC__metadata_object_vorbiscomment_replace_comment(),
which would not replace tags as advertised. Instead we first delete
the comment and then append a new tag.

Once all tags have been replaced this way, we write out the temporary
file using FLAC__metadata_chain_write_with_callbacks_and_tempfile().
To do this we needed to convince libflac to not modify the original
file in place, which turned out to be more difficult than it should be.

8 years agoThe ogg/speex tagger.
Andre Noll [Fri, 27 Dec 2013 00:22:01 +0000 (00:22 +0000)]
The ogg/speex tagger.

This commit adds support for editing meta information of ogg/speex
files. As for ogg/opus and ogg/vorbis we make use of the generic
ogg_rewrite_tags() to write out an ogg file with modified tags. Hence
this patch only adds the speex-specific part, spx_make_meta_packet(),
which creates a meta data packet for the altered tags.

8 years agoThe ogg/vorbis tagger.
Andre Noll [Mon, 16 Dec 2013 07:35:59 +0000 (08:35 +0100)]
The ogg/vorbis tagger.

Thanks to the previous commit which implemented the generic
ogg_rewrite_tags() as part of the the ogg/opus tagger, it is rather
simple to provide the same functionality also for the ogg/vorbis
audio format.

This patch adds a new function to ogg_afh.c which creates
a vorbis-specific metadata ogg packet and passes it to
ogg_rewrite_tags().

8 years agoThe ogg/opus tagger.
Andre Noll [Sun, 15 Dec 2013 20:01:57 +0000 (21:01 +0100)]
The ogg/opus tagger.

This adds support for modifying meta tags of ogg/opus files. The heart
of this patch is ogg_rewrite_tags(), a codec-independent function
which replaces the meta packet of an ogg stream. This function will
also be used in subsequent patches which add support for ogg/vorbis
and ogg/speex files.

In order to create identically sized ogg pages for the output, the
new ogg_rewrite_tags() function calls ogg_stream_flush_fill() if it
is available. This function was introduced in libogg version 1.3.0.
So this commit adds a configure check and makes ogg_rewrite_tags()
fall back to ogg_stream_flush() on systems where libogg lacks
ogg_stream_flush_fill().

8 years agoThe wma tagger.
Andre Noll [Sun, 27 Oct 2013 17:50:14 +0000 (18:50 +0100)]
The wma tagger.

This adds infrastructure to support meta tag editing. If the new
--modify option is given to para_afh, the arguments to --title,
--artist, --album and --comment are used to alter the meta information
of the audio file. Only the wma audio format handler is extended
to support the new feature. Patches for other audio format handlers
follow.

As for the implementation, this commit adds the function pointer
->rewrite_tags to struct audio_format_handler.  This function takes
a file descriptor to a newly opened temporary file. The individual
audio format handlers are supposed to write the altered contents to
this file descriptor. On success, the temporary file is renamed on
top of the original file unless --backup is given.

Since meta tags in wma files are encoded in UTF-16 we need primitives
to convert from UTF8 to UTF16 and vice versa. These are provided by
libiconv, so we check for this library and deactivate the new features
on systems that lack libiconv.

Unfortunately the signatures of iconv() are different between Linux
and FreeBSD. To deal with this incompatibility this patch adds a
configure check to determine if the cast is necessary.

8 years agoMerge branch 'refs/heads/t/immediate-si-update'
Andre Noll [Sun, 26 Apr 2015 12:11:56 +0000 (14:11 +0200)]
Merge branch 'refs/heads/t/immediate-si-update'

Cooking in next for four weeks.

* aft: Store resolved paths when adding files.
* aft: Update mtime and file size on afhi changes.
* aft: Update status items on afs events.
* aft.c: Pass struct ls_data pointer to make_status_items().
* afs: Simplify open_next_audio_file().

Conflicts:
aft.c

9 years agoversion.c: Update copyright year to range 2002-2015.
Andre Noll [Tue, 7 Apr 2015 18:34:05 +0000 (18:34 +0000)]
version.c: Update copyright year to range 2002-2015.

Although we don't update the year in each source file any more,
version.c contains the text that is printed with --version. So this
text should be up to date, and it should be a range. This commit
changes it from "2014" to "2002-2015".

2002 seems appropriate for the first year in the range since the
initial cvs commit was in 2002. Some code is older than that, but
that's probably not important.

9 years agotouch, rm, cpsi, init: Fix initialization of para_buffer.
Andre Noll [Tue, 7 Apr 2015 23:56:11 +0000 (23:56 +0000)]
touch, rm, cpsi, init: Fix initialization of para_buffer.

Three years ago, in commit 68cb0aef (Introduce
afs_max_size_handler_data and afs_max_size_handler()) the afs callbacks
were converted to pass a pointer to an afs_max_size_handler_data
structure to the dispatcher. This structure is defined as

struct afs_max_size_handler_data {
int fd;
uint8_t band;
};

However, we missed to convert the callbacks of the three commands
mentioned in the subject. All these commands except init pass
a pointer to an int as they did before commit 68cb0aef. Since
afs_max_size_handler_data stores one additional byte (the band
designator) after the file descriptor, the dispatcher will read one
byte past the allocated space.

This bug is benign because the max size handler is usually not called
for the affected commands, since they never have more than SHMMAX
bytes of output. For com_init() we even set the private_data pointer
to NULL, so the max size handler will never be called.

Let's fix it anyway.

9 years agoaft.c: Simplify load_afd().
Andre Noll [Wed, 24 Dec 2014 02:52:03 +0000 (02:52 +0000)]
aft.c: Simplify load_afd().

Remove the pointless variable "buf".

9 years agoMerge branch 't/lib_arg_with'
Andre Noll [Sun, 19 Apr 2015 11:49:54 +0000 (13:49 +0200)]
Merge branch 't/lib_arg_with'

Was cooking in next for three weeks.

* t/lib_arg_with:
  build: Fix curses detection.
  build: Convert curses detection to new macros.
  build: Convert libreadline detection to new macros.
  build: Convert oss detection to new macros.
  build: Convert libsamplerate detection to new macros.
  build: Convert libao detection to new macros.
  build: Convert alsa detection to new macros.
  build: Convert flac detection to new macros.
  build: Convert libid3tag detection to new macros.
  build: Convert mad detection to new macros.
  build: Convert faad detection to new macros.
  build: Convert crypto detection/selection to new macros.
  build: Convert opus detection to new macros.
  build: Convert speex detection to new macros.
  build: convert vorbis detection to new macros.
  build: Convert ogg detection to new macros.
  build: Reduce redundancy in configure.ac, convert osl detection.

9 years agoMerge branch 'maint'
Andre Noll [Sun, 19 Apr 2015 11:42:14 +0000 (13:42 +0200)]
Merge branch 'maint'

9 years agogcrypt: Initialize key size of public ASN keys.
Andre Noll [Wed, 18 Feb 2015 15:40:40 +0000 (16:40 +0100)]
gcrypt: Initialize key size of public ASN keys.

This bug could make applications acccept short keys. Not a serious
problem since (a) ASN keys are deprecated in favor of ssh keys and
(b) encrypting a 256 byte buffer fails anyways on short keys. Let's
fix it anyway.

9 years agogcrypt: Some trivial fixes.
Andre Noll [Wed, 18 Feb 2015 15:40:01 +0000 (16:40 +0100)]
gcrypt: Some trivial fixes.

Some whitespace issues, but also a typo and two instances of
superfluous parentheses.

9 years agoaft: Rename label "err" of open_and_update_audio_file().
Andre Noll [Sun, 21 Dec 2014 14:54:18 +0000 (14:54 +0000)]
aft: Rename label "err" of open_and_update_audio_file().

We also execute this on success.

9 years agoaudiod: Make struct slot_info local to audiod.c.
Andre Noll [Sun, 4 Jan 2015 04:55:43 +0000 (04:55 +0000)]
audiod: Make struct slot_info local to audiod.c.

Thanks to the previous commit there is only one user of struct
slot_info left in audiod_command.c: decoder_flags(). Moving this
function to audiod.c allows to make the structure private to audiod.c,
along with the slot array and the MAX_STREAM_SLOTS and FOR_EACH_SLOT
macros.

Since audiod_command still needs the decoder flags for the stat command,
the function is made public and renamed to audiod_get_decoder_flags().

9 years agoaudiod: Move get_play_time_slot_num() to audiod.c.
Andre Noll [Sun, 4 Jan 2015 04:39:15 +0000 (04:39 +0000)]
audiod: Move get_play_time_slot_num() to audiod.c.

audiod_status_dump() sends the play time string that corresponds
to the current slot to all connected stat clients. It first calls
the get_play_time_slot_num() helper to obtain the slot number, then
calls get_time_string(slot_num).

Currently the helper function is part of audiod_command.c, hence
we expose the slot_info structure to audiod_command.c. Moving the
helper from audiod_command.c to audiod.c is a first step to make this
structure local to audiod.c.  It also allows to remove the slot_num
parameter from get_time_string().

9 years agoalsa: Avoid alloca().
Andre Noll [Fri, 2 Jan 2015 20:10:56 +0000 (20:10 +0000)]
alsa: Avoid alloca().

It is not in POSIX.1-2001, and its use is discouraged. Fortunately,
the alsa library provides also variants which call ordinary malloc(),
so use these instead.

9 years agocommand: Make struct command_context->cmd_ptr const.
Andre Noll [Mon, 5 Jan 2015 03:28:58 +0000 (03:28 +0000)]
command: Make struct command_context->cmd_ptr const.

The fields of struct server command never need to be modified so they
can be const.

9 years agoafs.c: Trivial whitespace cleanup.
Andre Noll [Wed, 1 Apr 2015 01:34:26 +0000 (01:34 +0000)]
afs.c: Trivial whitespace cleanup.

9 years agoserver.h: Trivial whitespace/language cleanup.
Andre Noll [Wed, 1 Apr 2015 00:25:50 +0000 (00:25 +0000)]
server.h: Trivial whitespace/language cleanup.

9 years agobuild: Fix curses detection.
Andre Noll [Tue, 31 Mar 2015 21:11:10 +0000 (21:11 +0000)]
build: Fix curses detection.

We need to append to the $curses_ldflags variable rather than
overwriting it. Without this fix, --with-curses-libs is effectively
ignored.

9 years agoaft: Store resolved paths when adding files.
Andre Noll [Wed, 24 Dec 2014 03:07:48 +0000 (03:07 +0000)]
aft: Store resolved paths when adding files.

Currently the add command performs some sanity checks on the given
paths, but stores them unmodified in the audio file table if they
pass the checks. This commit removes the checks in favor of a call to
realpath(3) to get the canonicalized absolute pathname to be stored
in the audio file table.

The new code relies on POSIX.1-2008 semantics. That is, it calls
realpath() with second argument NULL to let the function allocate a
suitably sized buffer. This should not be a problem, since the old
POSIX.1-2001 version is broken by design, and all moderately recent
systems support the new semantics.

This change breaks t0004 which expects the ls -p command to print
the same paths that were used earlier to add audio files, which is
no longer true. We fix the test by simply running ls without the
-p option.

9 years agoaft: Update mtime and file size on afhi changes.
Andre Noll [Tue, 23 Dec 2014 12:52:03 +0000 (12:52 +0000)]
aft: Update mtime and file size on afhi changes.

If the current audio file is re-added to the osl database, for example
because meta tags have changed, file size and modification time change.
However, the paraslash stat command still shows the old values because
currently the virtual streaming system calls fstat(2) only once when
the audio file is opened and keeps reporting the resulting mtime and
file size values until the file is closed.

This commit introduces make_inode_status_items() which is called
from make_status_items() on AFSI_CHANGE and AFHI_CHANGE events for
the current audio file. The new function calls stat(2) on the path
obtained from the current aft row. We can't use fstat(2) since (a)
we don't have an open file descriptor any more and (b) this would
not work anyway if the original file was overwritten.

Due to the new helper, mmd->mtime can be removed. We must keep
mmd->size though, since we need the original file size for the call
to munmap().

9 years agoaft: Update status items on afs events.
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.

9 years agoaft.c: Pass struct ls_data pointer to make_status_items().
Andre Noll [Sun, 21 Dec 2014 18:07:40 +0000 (18:07 +0000)]
aft.c: Pass struct ls_data pointer to make_status_items().

We essentially already do that, with each field of the structure
spelled out in the argument list of make_status_items().

9 years agoafs: Simplify open_next_audio_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().

9 years agobuild: Convert curses detection to new macros.
Andre Noll [Sun, 28 Sep 2014 15:38:35 +0000 (15:38 +0000)]
build: Convert curses detection to new macros.

9 years agobuild: Convert libreadline detection to new macros.
Andre Noll [Sun, 21 Sep 2014 14:48:01 +0000 (16:48 +0200)]
build: Convert libreadline detection to new macros.

9 years agobuild: Convert oss detection to new macros.
Andre Noll [Mon, 25 Aug 2014 21:50:01 +0000 (23:50 +0200)]
build: Convert oss detection to new macros.

This also adds the missing oss_cppflags autoconf variable and the
corresponding make rule for building the oss writer.

9 years agobuild: Convert libsamplerate detection to new macros.
Andre Noll [Sun, 24 Aug 2014 22:24:29 +0000 (00:24 +0200)]
build: Convert libsamplerate detection to new macros.

9 years agobuild: Convert libao detection to new macros.
Andre Noll [Sun, 24 Aug 2014 22:00:51 +0000 (00:00 +0200)]
build: Convert libao detection to new macros.

Splits the old check into two checks for pthread and libao.

9 years agobuild: Convert alsa detection to new macros.
Andre Noll [Sun, 24 Aug 2014 20:57:29 +0000 (22:57 +0200)]
build: Convert alsa detection to new macros.

Adds alsa_cppflags.

9 years agobuild: Convert flac detection to new macros.
Andre Noll [Wed, 30 Jul 2014 08:11:15 +0000 (10:11 +0200)]
build: Convert flac detection to new macros.

9 years agobuild: Convert libid3tag detection to new macros.
Andre Noll [Tue, 3 Jun 2014 17:42:52 +0000 (19:42 +0200)]
build: Convert libid3tag detection to new macros.

9 years agobuild: Convert mad detection to new macros.
Andre Noll [Tue, 3 Jun 2014 17:03:32 +0000 (19:03 +0200)]
build: Convert mad detection to new macros.

9 years agobuild: Convert faad detection to new macros.
Andre Noll [Sun, 4 May 2014 17:22:22 +0000 (19:22 +0200)]
build: Convert faad detection to new macros.

9 years agobuild: Convert crypto detection/selection to new macros.
Andre Noll [Fri, 2 May 2014 21:01:53 +0000 (23:01 +0200)]
build: Convert crypto detection/selection to new macros.

9 years agobuild: Convert opus detection to new macros.
Andre Noll [Sun, 20 Apr 2014 23:27:19 +0000 (23:27 +0000)]
build: Convert opus detection to new macros.

9 years agobuild: Convert speex detection to new macros.
Andre Noll [Sun, 20 Apr 2014 23:08:24 +0000 (23:08 +0000)]
build: Convert speex detection to new macros.

9 years agobuild: convert vorbis detection to new macros.
Andre Noll [Mon, 2 Jun 2014 20:24:50 +0000 (22:24 +0200)]
build: convert vorbis detection to new macros.

Also introduces NEED_OGG_OBJECTS() and NEED_VORBIS_OBJECTS(). These
two macros are identical at the moment, but they will start to differ
when opus and speex will be converted.

9 years agobuild: Convert ogg detection to new macros.
Andre Noll [Sun, 20 Apr 2014 22:18:25 +0000 (22:18 +0000)]
build: Convert ogg detection to new macros.

9 years agobuild: Reduce redundancy in configure.ac, convert osl detection.
Andre Noll [Sun, 20 Apr 2014 04:33:11 +0000 (04:33 +0000)]
build: Reduce redundancy in configure.ac, convert osl detection.

We've had a fair number of bugs in configure.ac due to the fact that
most parts of it were created by copy+paste from an existing part.
This commit is an attempt to reduce this redundancy by factoring out
the reappearing parts to common macros. This will also reduce the
number of lines of configure.ac considerably, although this first
patch naturally adds more lines than it removes.

This commit introduces four new macros in configure.ac:

* AC_ARG_WITH: handles --with-xxx-headers and --with-xxx-libs
options for configure. The generated options are identical
to the old ones, so there are no compatibility issues.

* LIB_SUBST_FLAGS: creates preprocessor defines and make
variables

* STASH_FLAGS: saves copies of the CPPFLAGS, LDFLAGS and
LIBS variables

* UNSTASH_FLAGS restores stashed values

Only libosl detection is converted to use the new macros.  Subsequent
patches will convert other libraries.

9 years ago.gitignore: Ignore *~ and *.rej files.
Andre Noll [Mon, 23 Feb 2015 08:12:15 +0000 (09:12 +0100)]
.gitignore: Ignore *~ and *.rej files.

These should never be under version control.

9 years agoerror.h: Change type of return value of is_errno() to bool.
Andre Noll [Sun, 4 Jan 2015 02:48:08 +0000 (02:48 +0000)]
error.h: Change type of return value of is_errno() to bool.

There is only a single caller in afs.c which is OK with this change.

9 years agoMerge branch 't/gui_reload_fix'
Andre Noll [Sun, 22 Mar 2015 20:45:11 +0000 (21:45 +0100)]
Merge branch 't/gui_reload_fix'

Was cooking for two weeks.

* t/gui_reload_fix:
  gui: Fix config file reloading.

9 years agoDoxygen: Fix references on main page.
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.

9 years agogui: Fix config file reloading.
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().

This bug was present since "day one".

9 years agoMake struct ls_data local to aft.c.
Andre Noll [Sun, 21 Dec 2014 17:32:20 +0000 (17:32 +0000)]
Make struct ls_data local to aft.c.

This structure is only used in aft.c, so there is no need to make it
visible to other files which include afs.h.

9 years agoblob.c: Make table descriptions static.
Andre Noll [Fri, 2 Jan 2015 01:47:29 +0000 (01:47 +0000)]
blob.c: Make table descriptions static.

These descriptions are only used in blob.c.

9 years agoMerge branch 'refs/heads/t/abtract_sockets'
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().

9 years agointeractive.c does not depend on curses.h.
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.

9 years agoImprove signal init and shutdown.
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.

9 years agomanual: Move /var/paraslash instructions to Troubleshooting.
Andre Noll [Mon, 12 Jan 2015 22:15:46 +0000 (23:15 +0100)]
manual: Move /var/paraslash instructions to Troubleshooting.

Not needed in quick start anymore, since with the abstract sockets
Linux users won't see these problems any more.

9 years agoAbstract sockets for server and audiod.
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.

9 years agocreate_local_socket(): Avoid code duplication.
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.

9 years agonet.c: Combine remote_name() and __get_sock_name().
Andre Noll [Sun, 11 Jan 2015 22:38:21 +0000 (23:38 +0100)]
net.c: Combine remote_name() and __get_sock_name().

remote_name() is a simple wrapper, and it is the only caller of
__get_sock_name(). This commit gets rid of the wrapper.

9 years agoRemove socket address parameter of create_local_socket().
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.

9 years agosignal: Provide generic signal_pre_select().
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.

9 years agodaemon: Introduce daemon_init_colors_or_die().
Andre Noll [Tue, 7 Oct 2014 16:16:14 +0000 (16:16 +0000)]
daemon: Introduce daemon_init_colors_or_die().

The log color logic is already contained in para_server and
para_audiod. Let's use a single function in daemon.c for this
purpose.

daemon_set_default_log_colors() and daemon_set_log_color_or_die()
can be made static since they are only called from daemon.c now.

9 years agogui: Shutdown scheduler after schedule() returns.
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.

9 years agolist.h: Remove unused list_for_each_safe().
Andre Noll [Sat, 21 Jun 2014 17:20:23 +0000 (19:20 +0200)]
list.h: Remove unused list_for_each_safe().

9 years agoalsa_write: Use NULL instead of 0.
Andre Noll [Thu, 9 Oct 2014 03:06:15 +0000 (03:06 +0000)]
alsa_write: Use NULL instead of 0.

This silences the following sparse warning:

sparse: alsa_write.c:128:31: warning: Using plain integer as NULL pointer

9 years agoparaslash 0.5.4 v0.5.4
Andre Noll [Fri, 23 Jan 2015 12:37:38 +0000 (13:37 +0100)]
paraslash 0.5.4

9 years agoMerge branch 'refs/heads/t/afh_improvements'
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.

9 years agoMerge branch 'refs/heads/t/tarball-build-fix'
Andre Noll [Fri, 23 Jan 2015 12:17:10 +0000 (13:17 +0100)]
Merge branch 'refs/heads/t/tarball-build-fix'

9 years agoMerge branch 'maint'
Andre Noll [Thu, 22 Jan 2015 17:45:38 +0000 (18:45 +0100)]
Merge branch 'maint'

Was cooking for a week and seems to be regression-free.

aft: Generate a remove event when adding duplicate files.
command.c: Add missing items to EMPTY_STATUS_ITEMS.
aft.c: Don't call osl_close_disk_object() on failure.
Add missing osl() wrapper calls.
fd.c: Add missing va_end().

The conflict in aft.c was trivial to fix up.

9 years agostring.c: Fix typo in comment.
Andre Noll [Sat, 21 Jun 2014 17:20:43 +0000 (19:20 +0200)]
string.c: Fix typo in comment.

9 years agobuild: Use curses_cppflags also for compiling gui.c.
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.

9 years agogui.c Fix error handling of for_each_stat_item().
Andre Noll [Mon, 19 Jan 2015 20:17:20 +0000 (21:17 +0100)]
gui.c Fix error handling of for_each_stat_item().

In status_post_select(), if read_nonblock() succeeds (ret >= 0)
but for_each_stat_item() fails (ret2 < 0), para_gui aborts with

para_gui: error.h:639: para_strerror: Assertion `num > 0' failed.

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()).

9 years agomood.c: Fix typo in comment of struct afs_statistics.
Andre Noll [Tue, 30 Sep 2014 22:37:19 +0000 (22:37 +0000)]
mood.c: Fix typo in comment of struct afs_statistics.

9 years agoscore.c: Add OSL_UNIQUE to storage flags of score column.
Andre Noll [Sun, 4 Jan 2015 02:50:02 +0000 (02:50 +0000)]
score.c: Add OSL_UNIQUE to storage flags of score column.

The comparator for this column never returns 0 unless the objects
being compared coincide.

9 years agostring.c: Simplify and improve for_each_line().
Andre Noll [Thu, 2 Oct 2014 21:12:34 +0000 (21:12 +0000)]
string.c: Simplify and improve for_each_line().

Much faster for large buffers. Idea: Search for zero byte
only until next cr.

9 years agoclient: Fix return value check for sb_received().
Andre Noll [Thu, 9 Oct 2014 00:33:06 +0000 (00:33 +0000)]
client: Fix return value check for sb_received().

This bug can cause the client to segfault if it is fed invalid data.

9 years agomp3_afh: Detect both v1 and v2 tags.
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.

9 years agoogg: Improve documentation of struct ogg_afh_callback_info.
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.

9 years agoogg_afh: Add a comment about the three vorbis header packets.
Andre Noll [Sun, 15 Dec 2013 22:37:45 +0000 (23:37 +0100)]
ogg_afh: Add a comment about the three vorbis header packets.

With this information at hand, it's easier to understand how the
vorbis packet callback works.

9 years agoafh_common.c: Avoid ifdefs.
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.

9 years agoafh loglevel adjustments.
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.

9 years agowma: Rename comment_header.
Andre Noll [Fri, 1 Nov 2013 13:03:59 +0000 (14:03 +0100)]
wma: Rename comment_header.

The correct term for this header is "content description header".

9 years agoGIT-VERSION-GEN: Recognize git version in gitweb snapshots.
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.

9 years agobuild: Avoid git warning when building from tarball.
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.

9 years agoafh: Fix fd leak.
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.

9 years agoafh: Unmap the audio file on errors.
Andre Noll [Sun, 27 Oct 2013 10:24:43 +0000 (11:24 +0100)]
afh: Unmap the audio file on errors.

If compute_afhi() returns negative we miss to call para_munmap()
to unmap the audio file. This is not a serious bug since we exit
anyway in this case.

9 years agoUpdate year in copyright headers.
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.

9 years agomanual: Shorten Installation section.
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.

9 years agomanual: Simplify keygen command.
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.

9 years agomanual: Shorten section on generating RSA keys.
Andre Noll [Sat, 3 Jan 2015 04:31:47 +0000 (04:31 +0000)]
manual: Shorten section on generating RSA keys.

Remove the text about keys generated with "openssl genrsa". Such keys
are deprecated and support for them will eventually be removed.

This also removes the sentence about 0.3.x keys.

9 years agosync_filter: Document sync_parse_config().
Andre Noll [Sat, 3 Jan 2015 05:46:42 +0000 (05:46 +0000)]
sync_filter: Document sync_parse_config().

This should help to understand the lifetime of the various structures
of the sync filter.

9 years agofilter.c: Add documentation of stat_item_values[].
Andre Noll [Fri, 2 Jan 2015 01:38:06 +0000 (01:38 +0000)]
filter.c: Add documentation of stat_item_values[].

9 years agoafs.c: Improve documentation of send_option_arg_callback_request().
Andre Noll [Sun, 11 Jan 2015 13:24:14 +0000 (14:24 +0100)]
afs.c: Improve documentation of send_option_arg_callback_request().

The new text tries to emphasize that arbitrary structures may be
passed from the command handler to the callback (*not* the parent
process).

9 years agomood.c: Improve documentation of struct admissible_file_info.
Andre Noll [Fri, 2 Jan 2015 01:27:15 +0000 (01:27 +0000)]
mood.c: Improve documentation of struct admissible_file_info.

9 years agoaft.c: Improve documentation of struct ls_widths.
Andre Noll [Sun, 21 Dec 2014 17:42:00 +0000 (17:42 +0000)]
aft.c: Improve documentation of struct ls_widths.

9 years agotime.c: Remove unused d2tv().
Andre Noll [Thu, 1 Jan 2015 18:12:25 +0000 (18:12 +0000)]
time.c: Remove unused d2tv().

Found by cppcheck.

9 years agoversion.c: Remove unused version_git().
Andre Noll [Thu, 1 Jan 2015 18:21:55 +0000 (18:21 +0000)]
version.c: Remove unused version_git().

Found by cppcheck.

9 years agosched.c: Remove unused timeout_is_zero().
Andre Noll [Thu, 1 Jan 2015 18:20:39 +0000 (18:20 +0000)]
sched.c: Remove unused timeout_is_zero().

Found by cppcheck.

9 years agonet.c: Remove unused local_name().
Andre Noll [Thu, 1 Jan 2015 18:19:13 +0000 (18:19 +0000)]
net.c: Remove unused local_name().

Found by cppcheck.

9 years agodaemon.c: Remove unused daemon_clear_flag().
Andre Noll [Thu, 1 Jan 2015 18:15:21 +0000 (18:15 +0000)]
daemon.c: Remove unused daemon_clear_flag().

Found by cppcheck.