Andre Noll [Sat, 2 Apr 2016 15:22:00 +0000 (17:22 +0200)]
afs: Remove incorrect log message.
This was introduced in f8ed713d (com_select() callback: Return negative
on errors.) last year. It is incorrect for two reasons. First, arg
may well be NULL, and second, we might be about to open a mood rather
than a playlist.
Andre Noll [Sun, 10 Apr 2016 21:46:02 +0000 (23:46 +0200)]
Merge branch 'refs/heads/t/attribute_fix'
com_setatt() was broken if more than 32 attributes are defined. The
branch merged in this commit contains a fix for this bug, and a new
test that exercises the code related to attributes.
Was cooking in next for six weeks.
* refs/heads/t/attribute_fix:
manual: Add realpath to list of packages.
Add test that exercises attribute code.
test-lib: Canonicalize test_dir.
attribute: Avoid shifting 32 bit integers.
Andre Noll [Fri, 1 Apr 2016 23:12:08 +0000 (01:12 +0200)]
audiod: Improve get_time_string().
If the stream start time announced by para_server is newer than the
time para_audiod started the receiver, we assume that para_audiod
was started in the middle of an audio stream and adjust the play
time accordingly.
However, the server stream time can also be newer due to clock
differences or network hiccups. This patch changes audiod to apply
the adjustment only if the time difference is large.
Andre Noll [Tue, 22 Dec 2015 23:52:18 +0000 (23:52 +0000)]
udp_send.c: Send EOF packet only once.
Currently this can be sent many times, which is pointless and might
confuse clients. This patch adds a bool member to struct udp_target
to keep track whether the EOF packet has been sent.
Andre Noll [Sat, 2 Apr 2016 00:18:36 +0000 (02:18 +0200)]
NEWS: Re-add download link for current master.
This link on the main page got lost when paraslash-0.5.5 was
released. As explained on the download page, the master branch is
the version people should use, so we should really put back the link.
Andre Noll [Fri, 18 Mar 2016 22:44:15 +0000 (23:44 +0100)]
i9e: Replace assertion with warning.
The assertion in dispatch_key() can easily be triggered with keys
that map to multi-byte sequences. This patch prevents para_play from
aborting when such a key is pressed. It now issues a warning message,
but no longer aborts.
Andre Noll [Tue, 8 Mar 2016 23:25:12 +0000 (00:25 +0100)]
i9e: Fix compilation on Ubuntu-12.04.
Commit c0162946 (i9e: Avoid key binding macros) from half a year
ago broke compilation for readline-6.2, which ships at least with
Ubuntu-12.04. The problem is that c0162946 changed dispatch_key()
to use rl_executing_keyseq, a readline variable that was introduced
in readline-6.3. Compilation fails on systems with readline-6.2 or
older because the variable does not exist.
This patch modifies interactive.c to provide an equivalent of
rl_executing_keyseq and changes dispatch_key() to use this version
instead.
Andre Noll [Tue, 8 Mar 2016 23:23:17 +0000 (00:23 +0100)]
i9e: print warning if keyseq can not be mapped.
In i9e_open() we currently ignore errors from rl_generic_bind(), which
is OK, but we should at least let the user know that the binding
won't work. While at it, call rl_bind_keyseq_in_map() instead of
rl_generic_bind() as the former function provides all we need and
is simpler.
Andre Noll [Tue, 8 Mar 2016 23:21:15 +0000 (00:21 +0100)]
i9e: Zero out private pointer on open.
This should not matter at the moment since i9e_open() is only called
once and the i9e_private structure is static, so it's already zeroed
out by the first time the function is called. But since the ie9 API
is supposed to work across multiple open/close cycles, it seems wise
to be conservative here.
Andre Noll [Fri, 1 Apr 2016 23:33:47 +0000 (01:33 +0200)]
Merge branch 'maint'
A couple of overflow bugs and a aslignment issue, all detected by ubsan. Plus
two unrelated old bugs.
* maint:
client: Fix lsatt completer.
playlist: Do not update score if no playlist is open.
Avoid member access within misaligned address for ancillary data buffer.
mood.c: Avoid overflow in update_quadratic_deviation().
mood.c: Avoid integer underflow.
mood.c: Avoid integer overflow.
Andre Noll [Mon, 7 Mar 2016 15:10:05 +0000 (16:10 +0100)]
mp3_afh: Always create id3v2 tags.
When para_afh is asked to modify the tags of an mp3 file, it looks
at both version 1 and version 2 id3 tags. Currently, if the file
contains only id3v1 tags, para_afh will replace the tag contents but
will not create a version 2 tag. This is unfortunate if the length of
a given tag value exceeds the fixed-size byte limit of id3v1 because
it results in a truncated value and there is no way to specify that
an id3v2 tag should be created (which could store tags of any size).
This commit makes para_afh always write id3v2 tags. This actually
simplifies the code a bit because with this change the v2_tag variable
can never be NULL, allowing to get rid of a conditional.
Andre Noll [Mon, 14 Mar 2016 08:00:28 +0000 (09:00 +0100)]
opus: Make opus_common.[ch] independent of ogg.h.
The only reason opus_common.c includes ogg.h is that struct opus_header
contains a variable of type ogg_uint32_t. By using plain uint32_t
instead we may get rid of the include.
Andre Noll [Mon, 21 Mar 2016 19:51:08 +0000 (19:51 +0000)]
playlist: Do not update score if no playlist is open.
This bug caused the score of the current audio file to be updated
twice in mood mode since both the mood event handler and playlist
event handler honor afs events and update the score.
We fix the bug by moving the check whether a playlist is open to the
top of the playlist event handler, similar to the check in the mood
event handler of mood.c. If no playlist is open, we now return early
from the playlist event handler, ignoring all afs events.
In recv_cred_buffer(), pass_afd() and dispose_fds() the on-stack
ancillary data buffer is not necessarily aligned. The pointer is
cast to struct cmsghdr *, then dereferenced, resulting in undefined
behaviour due to the lack of alignment.
This patch asks the compiler to align the ancillary data buffers.
Andre Noll [Wed, 16 Mar 2016 21:48:54 +0000 (22:48 +0100)]
mood.c: Avoid overflow in update_quadratic_deviation().
The last multiplication of the expression returned can overflow. This
patch replaces the expression by an equivalent one which avoids to
multiply large numbers.
Andre Noll [Tue, 22 Dec 2015 22:28:46 +0000 (22:28 +0000)]
audiod: Avoid to report 100% time at startup.
This teaches get_time_string() to handle the case of zero values for
sss and wstime. These happen to be zero for a short time period when
para_server is changing its audio file.
Andre Noll [Fri, 18 Mar 2016 21:46:02 +0000 (22:46 +0100)]
gui.c: Improve description of signal task.
The comment to the main() function of para_gui contains a short
description of all tasks which are created on startup. The description
of the signal task was somewhat outdated because it referred to
SIGWINCH, which is not responsible for the handling of terminal size
changes any more.
This patch removes the outdated part from the comment and adds an
explanation of the action on SIGUSR1.
Andre Noll [Fri, 18 Mar 2016 21:40:12 +0000 (22:40 +0100)]
gui.c: Remove silly warning on SIGINT.
Sending SIGINT to para_gui has no effect, yet we print a strange
"reset" warning in this case. This patch removes the warning and the
outdated comment which referred to do_select(), a function which was
removed long ago.
Note that (a) we still catch SIGINT, and (b) hitting CTRL+C still
causes the status task to respawn the stat process because CTRL+C
sends SIGINT to the foreground process group, which includes the
stat process.
Andre Noll [Thu, 9 Apr 2015 13:27:16 +0000 (13:27 +0000)]
build: Let man pages depend on git-version.h.
This is necessary to always include the correct version number in
the man pages. For example, if the work tree becomes dirty because
an unrelated file has been modified, the version string changes and
we need to regenerate the man pages.
Andre Noll [Sat, 5 Mar 2016 21:10:32 +0000 (22:10 +0100)]
gui: Kill process group *before* shutting down curses.
Currently we perform shutdown on exit the other way round. Hence the
running external command may interfere with the shutdown of the curses
system. This patch changes die() to first signal the child processes,
then wait for them to terminate. This avoids the race.
Andre Noll [Tue, 15 Mar 2016 19:48:12 +0000 (20:48 +0100)]
mood.c: Avoid integer underflow.
The three variables x, s, n are all of unsigned type, and the
subtraction x - s / n may underflow, resulting in a very large positive
value. This should not matter since we square the difference, but on
the other hand, the underflow can easily be avoided. This patch uses
a temporary variable to do so.
Andre Noll [Tue, 15 Mar 2016 19:41:37 +0000 (20:41 +0100)]
mood.c: Avoid integer overflow.
The quadratic deviation qd can be very large, causing the
multiplication n * qd to overflow. The new code avoids the
multiplication at the cost of two calls to int_sqrt() instead of one.
Andre Noll [Sat, 5 Mar 2016 20:35:59 +0000 (21:35 +0100)]
gui.c: Reset terminal on shutdown in external mode.
If para_gui receives a terminating signal while an external program
is running, the terminal might be left in an unusable state. This
patch handles this case by first returning to program mode, which
sets the terminal to in-curses state, then calling endwin().
The def_prog_mode() call made no sense here at all.
Andre Noll [Sat, 5 Mar 2016 20:39:47 +0000 (21:39 +0100)]
gui: Avoid bad terminal state with xterm.
If para_gui is signalled in external mode, and the running program
has set the mouse mask to receive mouse events, mouse buttons
(copy and paste) might not work after para_gui exits. This has
been observed at least with xterm and aumix as the external program.
Setting an all-one mask seems to cure the problem.
Andre Noll [Mon, 29 Feb 2016 18:26:09 +0000 (19:26 +0100)]
string.c: Alloc space for terminating null wide character.
Should not matter since we already know the number of wide characters
and never look past the allocated buffer. But let's be conservative
here and allocate space for the terminating null wide character.
Andre Noll [Mon, 29 Feb 2016 21:10:09 +0000 (22:10 +0100)]
gui.c: Constify local variables of add_spaces().
There is no need to modify the all-spaces string as we can as well
print its end in order to output the desired number of spaces. This
allows to make the array variable const, along with "sz", which stores
the length of the string.
Andre Noll [Mon, 29 Feb 2016 21:10:05 +0000 (22:10 +0100)]
Introduce sanitize_str().
Currently we sanitize the status item strings for para_gui in
align_str() of gui.c. This implementation is flawed because it does
not work for wide character strings.
This patch provides an abstraction in string.c which works in both
the UFT-8 and non-UTF-8 case.
The flawed implementation of this function in gui.c is removed and
the surrounding code is changed to call the new function instead.
Andre Noll [Sun, 28 Feb 2016 21:13:20 +0000 (22:13 +0100)]
string.c: Simplify and rename wide character helpers.
Just assume non-printable characters are one character wide. This gives
a more reasonable approximation than the hack we have now.
This patch also renames mutt_wcwidth() to xwcwidth() and
mutt_wcswidth() to xwcswidth() since these functions have nothing in
common with mutt any more.
Andre Noll [Sat, 6 Feb 2016 14:11:51 +0000 (15:11 +0100)]
wmadec: Simplify wma_lsp_to_curve_init().
There's only one caller, and it passes pwd->frame_len as the second
argument to the function. Since we pass pwd as well, the second
argument of the function can be removed.
Andre Noll [Sat, 6 Feb 2016 06:07:10 +0000 (07:07 +0100)]
wmadec: Simplify get_vlc().
The last parameter is always bigger than 2, which is all the function
needs to know. Hence we may remove the parameter and get rid of some
macros that were only used to compute it.
Andre Noll [Sat, 2 Jan 2016 17:41:37 +0000 (17:41 +0000)]
client: Add completer for version command.
This command gained the -v flag but the commit that introduced it
last year (26dc18b2, Unify version command handlers) missed to provide
the corresponding completer for para_client.
Andre Noll [Sun, 7 Feb 2016 16:37:00 +0000 (17:37 +0100)]
attribute: Avoid shifting 32 bit integers.
att_logical_or() is called from com_check() to set up a bitmask where
a bit is set if and only if it corresponds to an existing attribute.
Doing "1 << i" is wrong in this context because the constant "1" is a
(signed) 32 bit quantity and we need to be able to shift by more than
31 bits for the attribute mask.
Andre Noll [Sun, 7 Feb 2016 16:33:15 +0000 (17:33 +0100)]
attribute: Avoid shifting 32 bit integers.
Doing "1UL << i" is wrong here, because the constant "1UL" is 32 bit
on 32 bit systems and we definitely need 64 bit quantities for the
attribute mask.
Andre Noll [Sat, 20 Jun 2015 21:32:13 +0000 (23:32 +0200)]
spxdec: Check frame sizes.
We pass a buffer of fixed size MAX_FRAME_SIZE (defined to 2000)
to the speex decoder. This sanity check makes sure we never overrun
the buffer. Although this adds one function call per output frame,
the overhead is in the noise.
Andre Noll [Sun, 13 Dec 2015 14:16:27 +0000 (15:16 +0100)]
Convert manual and NEWS from grutatxt to markdown.
Grutatext still works but the project seems to be dead, so we have
to switch to something else eventually.
This patch converts the two grutatext documents in the tree to the
markdown language, getting rid of the dependency on grutatext at
the expense of a new dependency on the markdown executable. Only the
discount markdown converter has been tested and is known to work.
The commit also changes the "Tools" section of the manual to list
discount instead of grutatext.
Andre Noll [Tue, 6 Oct 2015 02:32:31 +0000 (02:32 +0000)]
Constify struct filter access and introduce filter_get().
This modifies all users of the filter API to not access the filter
array directly. Instead all callers now obtain a const pointer to
the filter structure through the new filter_get() accessor function.
However, the filter array can not be made constant yet because the
->init methods modify the filter structure. This requires some casts
in filter_common.c unfortunately.
Andre Noll [Wed, 30 Sep 2015 01:09:24 +0000 (01:09 +0000)]
Fix documentation of check_receiver_arg().
Receiver name and options are NOT separated by a colon. Also, all three
receivers (http, udp, dccp) are always supported, so it's pointless
to talk about supported paraslash receivers. This patch simplifies
the comment accordingly.
Andre Noll [Wed, 9 Sep 2015 18:30:24 +0000 (20:30 +0200)]
afh_recv: Improve documentation of --begin-chunk.
The help text referred to --info, which was removed four years ago
in commit 06f33ca1. This patch also inlucdes a couple of minor other
improvements to the same paragraph.
Andre Noll [Sat, 4 Oct 2014 23:52:50 +0000 (23:52 +0000)]
afh: Make ->chunks_total and ->seconds_total fixed-size.
These members of struct afh_info are stored as 4-byte quantities in
the serialized afhi blob created by save_afhi(), so the structure
should declare them as uint32_t rather than unsigned long.
Fortunately, this bug is benign since save_afhi() uses the write_u32()
helper from portable_io.h which does the right thing, regardless of
the type of the variable passed.
Andre Noll [Sat, 5 Sep 2015 19:49:16 +0000 (21:49 +0200)]
aft.c: Prefer localtime() over localtime_r().
While localtime(3) is required to behave as though tzset(3) was
called, localtime_r(3) does not have this requirement, and portable
code should thus call tzset(3) before localtime_r(3). This is not
the case for get_local_time() of aft.c.
As we are single-threaded here, we don't need the thread-safe version,
so it is easiest to switch to localtime(3).
Andre Noll [Sun, 28 Jun 2015 18:05:13 +0000 (20:05 +0200)]
server: Add mood methods image_id and lyrics_id.
This rather simple patch allows to easily define a mood that selects
all files of an album through the image ID, or all versions of a song
(including cover and Live versions) through the lyrics ID.
The documentation is updated to list the two new mood methods.
Andre Noll [Mon, 28 Sep 2015 17:43:39 +0000 (17:43 +0000)]
Avoid duplication of sender subcommands.
The list of sender subcommands (add, delete, allow, deny, on, off)
is defined as an enumeration in send.h. This list is duplicated in
check_sender_args() of command.c which contains the six subcommands
as C-strings to be matched against the first word of the sender
command line.
For the code to work properly it is essential that the two subcommand
lists are identical, which is a bad design that is quite error
prone. Fortunately it is easy to avoid the duplication with a little
preprocessor fu.
Since the subcommands are spelled in lower case and there is no
toupper function in CPP, we need to change the subcommand part of the
enumeration constants to lower case. The bulk of the patch consists
in trivial changes of all the users of these constants.
Andre Noll [Sun, 4 Oct 2015 20:25:06 +0000 (20:25 +0000)]
build: Fix audiod_command.c dependency.
The effect of these typos is that the dependencies are effectively
ignored. That is, changes to audiod_command.c do not cause a rebuild
of the command_list files.
Andre Noll [Sat, 3 Oct 2015 22:48:38 +0000 (22:48 +0000)]
play: Handle empty arguments to --key-map gracefully.
Executing para_play with an empty argument to --key-map results in
a read which starts one byte past the allocated buffer:
==24163== Invalid read of size 1
==24163== at 0x402A1DA: index (mc_replace_strmem.c:223)
==24163== by 0x804DA22: main (play.c:187)
==24163== Address 0x498e331 is 0 bytes after a block of size 1 alloc'd
This patch fixes the issue by rejecting empty arguments as invalid.
Andre Noll [Sat, 3 Oct 2015 17:51:38 +0000 (17:51 +0000)]
i9e: Avoid key binding macros.
The key binding code of interactive.c is quite an ugly hack which is
marked with a FIXME comment since forever. We bind each key sequence
given in the ->bound_keyseqs array of struct i9e_client_info to a
key code which is then mapped to a command handler provoded by the
application. The bindings started at key 64 with an arbitrary limit
of 32 possible mappings.
Besides being ugly, the problem with this mapping scheme is that
upper case keys are also in this range and are hence also mapped to
the specified commands.
This commit takes another approach. We now bind key sequences to a
function instead of a macro, passing ISFUNC as the first parameter to
libreadline's rl_generic_bind(). All key sequences are bound to the
same function, dispatch_key(), which calls the application-defined
key handler.
This is still not optimal because we need to look up the key sequence
again in dispatch_key(). But since this is not a fast path anyway,
it should be OK.
* refs/heads/t/command_handler_cleanups: (39 commits)
com_addatt(): Return negative on errors
com_rm(): In force mode, don't complain if no paths matched.
aft: Unify handling of hash and path duplicates.
afs: Provide pbout para_buffer for each callback.
afs: Make afs callbacks more flexible.
afs: Rename callback_function to afs_callback.
com_check(): Add attribute checking.
Let afs_event() return int.
playlist_check_callback(): Return negative on errors
mood_check_callback(): Return negative on errors
com_mvblob(): Return negative on errors
com_addblob(): Return negative on errors
com_rmblob(): Return negative on errors, cleanup
com_catblob(): Return negative on errors
com_lsblob(): Return negative on errors
rmatt: Cleanup callback.
com_rmatt(): Return negative on errors
com_mvatt(): Return negative on errors
com_lsatt(): Return negative on errors
com_init(): Return negative on errors
...
Andre Noll [Sat, 17 Oct 2015 14:47:01 +0000 (16:47 +0200)]
build: Fix m4 dependencies for BSD m4.
FreeBSD and NetBSD ship an m4 version which does not understand
the --debug=i option which we use to generate the .m4d dependency
files. This results in empty dependency files on those systems.
This was broken since m4 dependencies were introduced two years ago
in commit e249d105 (Generate ggo dependencies automatically). The
bug went unnoticed for so long because the problematic m4 command
is the first command of a pipeline (hence the exit code is lost),
and because the command redirects stderr, so the error message is
not printed to the terminal.
This commit fixes the bug by using the (portable) -s option of
m4 rather than --debug. The -s option outputs line synchronization
directives which include the file name, so it is equally well suited
for generating the dependency files.