paraslash.git
7 years agomanual: Fix typo in description of blob tables.
Andre Noll [Sun, 5 Jun 2016 18:00:31 +0000 (20:00 +0200)]
manual: Fix typo in description of blob tables.

Blob indices start at one, so "positive" is correct.

7 years agoRemove explicit uses of _GNU_SOURCE.
Andre Noll [Sun, 27 Mar 2016 02:22:40 +0000 (02:22 +0000)]
Remove explicit uses of _GNU_SOURCE.

The best way to add these flags is to use the autoconf helper
AC_USE_SYSTEM_EXTENSIONS. This macro adds defines to config.h, so we
must include config.h (via para.h) before anything else. The two files
for which this matters are fixed by moving the include directive for
para.h to the top.

The AC_USE_SYSTEM_EXTENSIONS macro was introduced in Autoconf 2.60,
which was released ten years ago. The existing AC_PREREQ([2.61])
check in configure.ac makes sure the macro is defined.

7 years agobuild: Remove duplicate para_fade in configure summary.
Andre Noll [Sun, 12 Jun 2016 10:44:07 +0000 (12:44 +0200)]
build: Remove duplicate para_fade in configure summary.

7 years agoMerge branch 'refs/heads/t/opus_cleanup'
Andre Noll [Sun, 12 Jun 2016 07:29:21 +0000 (09:29 +0200)]
Merge branch 'refs/heads/t/opus_cleanup'

Was cooking for two months.

* refs/heads/t/opus_cleanup:
  opus: Make opus_common.[ch] independent of ogg.h.
  opus: Use uint16_t for preskip and gain.

7 years agogcc-compat.h: Remove gcc-3 workaround.
Andre Noll [Sun, 8 May 2016 23:10:54 +0000 (01:10 +0200)]
gcc-compat.h: Remove gcc-3 workaround.

Since b0e2c4a9 we require gcc-4.2 or later, so this is no longer
needed.

7 years agoMerge branch 'refs/heads/t/audiod-time-string'
Andre Noll [Sat, 4 Jun 2016 17:39:01 +0000 (19:39 +0200)]
Merge branch 'refs/heads/t/audiod-time-string'

Was cooking for several months.

* refs/heads/t/audiod-time-string:
  audiod: Improve get_time_string().
  audiod: Force status dump on slot changes.
  audiod: Avoid to report 100% time at startup.
  audiod: Simplify get_time_string()

7 years agoplay: Print hex representation of key sequence in help.
Andre Noll [Sun, 27 Mar 2016 03:39:47 +0000 (03:39 +0000)]
play: Print hex representation of key sequence in help.

Some predefined keys of para_play, for example the four cursor keys,
are mapped to key sequences which should not be printed verbatim to
the console in com_help().

This patch introduces get_key_map_seq_safe(), an alternative to
get_key_map_seq() which returns the hexadecimal representation of the
bytes in the sequence of the given key. Single character sequences,
however, are printed verbatim if the character is printable. com_help()
is changed to call get_key_map_seq_safe() instead of get_key_map_seq().

7 years agoserver: Fix --autoplay-delay.
Andre Noll [Wed, 1 Jun 2016 16:59:09 +0000 (18:59 +0200)]
server: Fix --autoplay-delay.

init_vss_task() is called before the scheduler has initialized the
timeval available everywhere through the global now pointer. Hence,
in this function ->now is {0, 0}, and the computed autoplay barrier
will be in the past, effectively making --autoplay-delay a no-op.

Fix this by calling clock_get_realtime() to get the current time.

7 years agoRemove support for compile-time loglevel.
Andre Noll [Sat, 19 Mar 2016 22:18:50 +0000 (22:18 +0000)]
Remove support for compile-time loglevel.

Setting the compile-time loglevel to a non-default value (i.e.,
greater than zero) results in many compile time warnings due to
unused variables. These are not easy to fix, and the feature isn't
very important anyway. Remove it.

7 years agoMerge branch 'refs/heads/t/gui-improvements'
Andre Noll [Sun, 15 May 2016 13:30:20 +0000 (15:30 +0200)]
Merge branch 'refs/heads/t/gui-improvements'

Improved wide-character support and fixes related to signal
handling. This topic branch was cooking in next for two months.

* refs/heads/t/gui-improvements:
  gui.c: Constify argument to find_cmd_byname().
  gui.c: Improve description of signal task.
  gui.c: Remove pointless return statement.
  gui.c: Remove silly warning on SIGINT.
  gui: Kill process group *before* shutting down curses.
  gui.c: Reset terminal on shutdown in external mode.
  gui: Avoid bad terminal state with xterm.
  gui.c: Constify local variables of add_spaces().
  Introduce sanitize_str().
  string.c: Simplify and rename wide character helpers.

7 years agomanual: Rewrite section on score table.
Andre Noll [Sun, 27 Mar 2016 04:28:31 +0000 (04:28 +0000)]
manual: Rewrite section on score table.

This streamlines the text a bit and adds a starting sentence which
describes the purpose of the score table.

7 years agoplay.c: Simplify get_mapped_keyseqs().
Andre Noll [Sun, 27 Mar 2016 03:07:52 +0000 (03:07 +0000)]
play.c: Simplify get_mapped_keyseqs().

Removing the debug log message allows to get rid of three
local variables and an allocation.

7 years agobuild: Insist on m4 being installed.
Andre Noll [Thu, 12 May 2016 18:55:26 +0000 (20:55 +0200)]
build: Insist on m4 being installed.

Unlike stated in the manual, m4 is not an optional package that is
only needed on developer machines to build the html version of the
manual. Rather, the m4 macro processor is an essential requirement
because the gengetopt input files are generated with m4 from their
templates in m4/gengetopt.

This patch moves the documentation item on m4 from the development
section of the manual to the list of required packages for building
the paraslash package. It also adds a check for the m4 executable
to configure.ac to let the generated configure script fail the build
early on systems where m4 is not installed.

7 years agowmadec: Fix left shift of negative value.
Andre Noll [Thu, 28 Apr 2016 19:57:13 +0000 (21:57 +0200)]
wmadec: Fix left shift of negative value.

gcc-6.1 complains about this:

wmadec_filter.c:819:33: warning: left shift of negative value [-Wshift-negative-value]
   mult1 = mult * exponents[((-1 << bsize)) >> esize];

The new code still looks wrong because we now shift a negative value
to the right. Moreover, it is not clear that the resulting value
is within array bounds. On the other hand, ffmpeg has the same fix
(commit a48b24e5 in the ffmpeg repository), so..

7 years agoMakefile.real: Remove duplicate $build_date.
Andre Noll [Sat, 7 May 2016 08:59:33 +0000 (10:59 +0200)]
Makefile.real: Remove duplicate $build_date.

This was introduced one year ago in commit e080d112.

7 years agogui: Improve documentation of --stat-cmd.
Andre Noll [Sun, 3 Apr 2016 02:32:50 +0000 (04:32 +0200)]
gui: Improve documentation of --stat-cmd.

The new text is shorter and more to the point.

7 years agoConstify argument of playlist_open() and change_current_mood().
Andre Noll [Mon, 21 Mar 2016 22:17:22 +0000 (22:17 +0000)]
Constify argument of playlist_open() and change_current_mood().

The only reason these arguments are not const is that we create an
osl object out of it, which contains a non-constant data pointer.

The osl library functions we call here will not touch this memory,
so it's safe to let both functions take a const pointer and cast it at
initialization of the non-constant ->data pointer of struct osl object.

The single caller of each function is activate_mood_or_playlist()
whose argument can now also me made to point to constant memory.

Finally, the arg pointer of com_select_callback() is passed to
activate_mood_or_playlist(), so the variable can be of type const
char * as well.

7 years agofilter.c: Use EXIT_SUCCESS.
Andre Noll [Tue, 5 Apr 2016 21:19:46 +0000 (23:19 +0200)]
filter.c: Use EXIT_SUCCESS.

Trivial change, since POSIX requires EXIT_SUCCESS to be zero.

7 years agoMerge branch 'refs/heads/t/wmadec'
Andre Noll [Thu, 5 May 2016 13:37:51 +0000 (15:37 +0200)]
Merge branch 'refs/heads/t/wmadec'

This topic branch was cooking in next for two months.

* refs/heads/t/wmadec:
  wmadec: Simplify wma_lsp_to_curve_init().
  wmadec: Make pwd->reset_block_lengths a boolean.
  bitstream.h: Remove some superflous parentheses.
  wmadec: Simplify get_vlc().

7 years agoplay.c: Check whether filter ->close() is NULL.
Andre Noll [Sun, 28 Jun 2015 14:21:23 +0000 (16:21 +0200)]
play.c: Check whether filter ->close() is NULL.

While audiod.c and filter.c test whether ->close is NULL
before they attempt to call the function, play.c calls ->close()
unconditionally. This does not matter because all filters provide the
close method. But it is documented in filter.h that ->close may be
NULL. To avoid future surprises and to be consistent with para_audiod
and para_filter, let's change play.c to check for NULL as well.

7 years agoafh: Make ->suffixes array const.
Andre Noll [Sun, 7 Feb 2016 22:22:52 +0000 (23:22 +0100)]
afh: Make ->suffixes array const.

Not only the individual strings are constant, but also the array itself.

7 years agoblob_get_name_by_id(): Treat id of dummy row as invalid.
Andre Noll [Sat, 26 Mar 2016 22:28:27 +0000 (22:28 +0000)]
blob_get_name_by_id(): Treat id of dummy row as invalid.

If the given id equals the id of the dummy row, the function currently
returns an empty object. This is unfortunate, since blob table users
should not know about the dummy row implementation detail. This patch
makes the function return -E_DUMMY_ROW instead.

In error.h, the E_DUMMY_ROW error code was defined in the section
for mood.c because this file contains the only user of the error
code. With another user in blob.c it seems appropriate to move it to
the blob section instead.

8 years agoMerge branch 'refs/heads/t/markdown'
Andre Noll [Sun, 17 Apr 2016 12:32:53 +0000 (14:32 +0200)]
Merge branch 'refs/heads/t/markdown'

The topich branch was started on 2015-12-13, and has been cooking
in next since 2016-01-30. The merge resulted in conflicts for both
files which were easy to resolve.

* refs/heads/t/markdown:
  Convert manual and NEWS from grutatxt to markdown.

8 years agodoc: Remove systemlinux links from documentation.
Andre Noll [Sun, 6 Mar 2016 18:21:19 +0000 (19:21 +0100)]
doc: Remove systemlinux links from documentation.

The systemlinux.org server is still up, but the paraslash web page
just redirects to people.tuebingen.mpg.de, so only mention the latter
in the documentation.

8 years agomanual: Bump required gcc version to 4.1.
Andre Noll [Sun, 6 Mar 2016 15:43:05 +0000 (16:43 +0100)]
manual: Bump required gcc version to 4.1.

gcc-3 is not good enough any more since it has no support for weak
references, which were introduced half a year ago in commit 9bf6dc2e
(error.h: Never call (para_)strerror() on osl errors).

gcc-3.3 was released in 2003, gcc-4.2 in 2007. It should be OK to
require gcc-4.2 from now on.

8 years agoMake dates in ls output align nicely again.
Andre Noll [Mon, 4 Apr 2016 22:23:30 +0000 (00:23 +0200)]
Make dates in ls output align nicely again.

Commit 3c978d34 "fixed" a whitespace issue by replacing two consecutive
space characters in a format string by a single space. However,
the duplicated space character actually had a purpose. This commit
re-adds the additional space character and explains through a comment
why it is needed.

8 years agoafs: Remove incorrect log message.
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.

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

8 years agoaudiod: Improve get_time_string().
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.

8 years agoudp_send.c: Send EOF packet only once.
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.

8 years agoNEWS: Re-add download link for current master.
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.

8 years agoMerge branch 'refs/heads/t/image_id_mm'
Andre Noll [Fri, 1 Apr 2016 23:59:11 +0000 (01:59 +0200)]
Merge branch 'refs/heads/t/image_id_mm'

A single commit that was cooking for several months.

* refs/heads/t/image_id_mm:
  server: Add mood methods image_id and lyrics_id.

8 years agoi9e: Replace assertion with warning.
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.

8 years agoi9e: Fix compilation on Ubuntu-12.04.
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.

8 years agoi9e: print warning if keyseq can not be mapped.
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.

Also fix the typo in the comment.

8 years agoi9e: Zero out private pointer on open.
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.

8 years agoMerge branch 'maint'
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.

8 years agoclient: Fix lsatt completer.
Andre Noll [Tue, 29 Mar 2016 16:16:33 +0000 (16:16 +0000)]
client: Fix lsatt completer.

The lsatt command does not take any non-option arguments. So it is wrong
to complete on the available attributes.

8 years agomp3_afh: Always create id3v2 tags.
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.

8 years agomp3_afh: Let free_tag() accept NULL pointer.
Andre Noll [Mon, 7 Mar 2016 15:11:53 +0000 (16:11 +0100)]
mp3_afh: Let free_tag() accept NULL pointer.

This way it is more similar to free(3) and related functions. It
also allows to replace two checks in mp3_afh.c by a single check
in free_tag().

8 years agoopus: Make opus_common.[ch] independent of ogg.h.
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.

8 years agoopus: Use uint16_t for preskip and gain.
Andre Noll [Sun, 7 Feb 2016 21:52:55 +0000 (22:52 +0100)]
opus: Use uint16_t for preskip and gain.

These values are obtained by reading a 16 bit value from a buffer,
so uint16_t is the right type for these fields.

8 years agoopus_afh.c: Trivial whitespace fix.
Andre Noll [Mon, 14 Mar 2016 08:01:11 +0000 (09:01 +0100)]
opus_afh.c: Trivial whitespace fix.

Just an overlong line.

8 years agoopus_common.c: Fix trival whitespace issue.
Andre Noll [Sun, 7 Feb 2016 21:47:10 +0000 (22:47 +0100)]
opus_common.c: Fix trival whitespace issue.

8 years agoplaylist: Do not update score if no playlist is open.
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.

8 years agoAvoid member access within misaligned address for ancillary data buffer.
Andre Noll [Wed, 16 Mar 2016 22:05:56 +0000 (23:05 +0100)]
Avoid member access within misaligned address for ancillary data buffer.

For glibc-2.23, the CMSG_FIRSTHDR macro is defined as

#define CMSG_FIRSTHDR(mhdr) \
  ((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr)                 \
   ? (struct cmsghdr *) (mhdr)->msg_control : (struct cmsghdr *) 0)

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.

8 years agomood.c: Avoid overflow in update_quadratic_deviation().
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.

8 years agoaudiod: Force status dump on slot changes.
Andre Noll [Tue, 22 Dec 2015 23:24:47 +0000 (23:24 +0000)]
audiod: Force status dump on slot changes.

This makes para_gui report such changes immediately. Without these
extra dumps, it may take up to 500ms for the stat client to notice.

8 years agoaudiod: Avoid to report 100% time at startup.
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.

8 years agoaudiod: Simplify get_time_string()
Andre Noll [Tue, 22 Dec 2015 21:26:28 +0000 (21:26 +0000)]
audiod: Simplify get_time_string()

The function does the right thing if audiod is on but there is no
slot info available. Kill the special casing.

8 years agoi9e: Remove pointless call to rl_set_keymap() in i9e_open().
Andre Noll [Tue, 8 Mar 2016 07:48:27 +0000 (08:48 +0100)]
i9e: Remove pointless call to rl_set_keymap() in i9e_open().

The call to rl_set_keymap() can be removed since i9e_attach_to_stdout()
already activates the bare key map.

8 years agoi9e: Remove stale comment for dispatch_key().
Andre Noll [Tue, 8 Mar 2016 07:46:52 +0000 (08:46 +0100)]
i9e: Remove stale comment for dispatch_key().

Should have been removed when we switched to key sequences.

8 years agoi9e: Remove stale comment for i9e_signal_dispatch().
Andre Noll [Tue, 8 Mar 2016 07:45:30 +0000 (08:45 +0100)]
i9e: Remove stale comment for i9e_signal_dispatch().

The function also cares about SIGWINCH.

8 years agoi9e: Remove unused member of struct i9e_private.
Andre Noll [Tue, 8 Mar 2016 07:44:52 +0000 (08:44 +0100)]
i9e: Remove unused member of struct i9e_private.

8 years agogui.c: Constify argument to find_cmd_byname().
Andre Noll [Fri, 18 Mar 2016 22:46:24 +0000 (23:46 +0100)]
gui.c: Constify argument to find_cmd_byname().

8 years agogui.c: Improve description of signal task.
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.

8 years agogui.c: Remove pointless return statement.
Andre Noll [Fri, 18 Mar 2016 21:40:59 +0000 (22:40 +0100)]
gui.c: Remove pointless return statement.

In signal_post_select() we call die() on SIGTERM which never returns.

8 years agogui.c: Remove silly warning on SIGINT.
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.

8 years agobuild: Let man pages depend on git-version.h.
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.

8 years agogui: Kill process group *before* shutting down curses.
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.

8 years agomood.c: Avoid integer underflow.
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.

8 years agomood.c: Avoid integer overflow.
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.

8 years agomanual: Add realpath to list of packages.
Andre Noll [Sun, 13 Mar 2016 17:43:04 +0000 (18:43 +0100)]
manual: Add realpath to list of packages.

It's a pity that this useful utility seems not to be installed by
default on Ubuntu systems.

8 years agogui.c: Reset terminal on shutdown in external mode.
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.

8 years agogui: Avoid bad terminal state with xterm.
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.

8 years agostring.c: Alloc space for terminating null wide character.
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.

8 years agogui.c: Constify local variables of add_spaces().
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.

8 years agogui.c: Remove condition which is always true.
Andre Noll [Sat, 5 Mar 2016 20:30:31 +0000 (21:30 +0100)]
gui.c: Remove condition which is always true.

If top.win is NULL, curses_active() is false so we return early.

8 years agoIntroduce sanitize_str().
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.

8 years agogui: Remove pointless special casing in align_str().
Andre Noll [Sun, 28 Feb 2016 21:04:33 +0000 (22:04 +0100)]
gui: Remove pointless special casing in align_str().

Regardless of whether str[0] is the null byte, passing str is correct
(and done for left and right alignment).

8 years agostring.c: Simplify and rename wide character helpers.
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.

8 years agoMerge branch 'refs/heads/t/com_sender'
Andre Noll [Sun, 6 Mar 2016 20:36:21 +0000 (21:36 +0100)]
Merge branch 'refs/heads/t/com_sender'

A single commit which was cooking in next for several months.

* refs/heads/t/com_sender:
  Avoid duplication of sender subcommands.

8 years agowmadec: Simplify wma_lsp_to_curve_init().
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.

8 years agowmadec: Make pwd->reset_block_lengths a boolean.
Andre Noll [Sat, 6 Feb 2016 06:19:53 +0000 (07:19 +0100)]
wmadec: Make pwd->reset_block_lengths a boolean.

This field is already used as such. Improve the documentation while at it.

8 years agobitstream.h: Remove some superflous parentheses.
Andre Noll [Sat, 6 Feb 2016 06:11:44 +0000 (07:11 +0100)]
bitstream.h: Remove some superflous parentheses.

8 years agowmadec: Simplify get_vlc().
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.

8 years agoRemove unused error code E_NO_AUDIO_TRACK.
Andre Noll [Thu, 26 Nov 2015 07:51:54 +0000 (08:51 +0100)]
Remove unused error code E_NO_AUDIO_TRACK.

It was introduced last year in commit 741c19c2 (The mp4 tagger)
and has always been unused.

8 years agoclient: Add completer for version command.
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.

8 years agoAdd test that exercises attribute code.
Andre Noll [Sun, 7 Feb 2016 16:01:12 +0000 (17:01 +0100)]
Add test that exercises attribute code.

This test would fail without the previous fix that changed the
shifted integers to 64 bit.

8 years agotest-lib: Canonicalize test_dir.
Andre Noll [Sun, 7 Feb 2016 15:59:38 +0000 (16:59 +0100)]
test-lib: Canonicalize test_dir.

This makes it easier to write tests. The realpath command is
available at least on Linux and *BSD.

8 years agoattribute: Avoid shifting 32 bit integers.
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.

Fix this by using an uint64_t variable instead.

8 years agoMerge branch 'maint'
Andre Noll [Sun, 21 Feb 2016 10:58:39 +0000 (11:58 +0100)]
Merge branch 'maint'

A single fix that avoids to shift 32 bit integers for attribute
bitmasks where 64 bit quantities are necessary.

8 years agoattribute: Avoid shifting 32 bit integers.
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.

Fix this by using an uint64_t variable instead.

8 years agospxdec: Check frame sizes.
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.

Also document MAX_FRAME_SIZE while at it.

8 years agoConvert manual and NEWS from grutatxt to markdown.
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.

8 years agoMerge branch 'refs/heads/t/para_play_fixes'
Andre Noll [Sat, 30 Jan 2016 12:07:11 +0000 (13:07 +0100)]
Merge branch 'refs/heads/t/para_play_fixes'

Was cooking in next since 2015-10-25.

* refs/heads/t/para_play_fixes:
  i9e: Avoid key binding macros.
  play: Fix off-by-one in jmp 100.

8 years agopara.h: Fix typo in comment.
Andre Noll [Tue, 26 Jan 2016 13:33:05 +0000 (14:33 +0100)]
para.h: Fix typo in comment.

The option is called --sample-format rather than --format.

8 years agostring.c: Handle invalid loglevels gracefully.
Andre Noll [Sun, 27 Dec 2015 23:03:38 +0000 (23:03 +0000)]
string.c: Handle invalid loglevels gracefully.

Public functions should always return a proper error code on
failure. Returning -1 is asking for trouble.

8 years agot0005: Split audiod man page tests.
Andre Noll [Sun, 18 Oct 2015 09:27:26 +0000 (11:27 +0200)]
t0005: Split audiod man page tests.

This makes it easier to diagnose potential problems due to missing
man page sections.

8 years agoConstify struct filter access and introduce filter_get().
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.

8 years agoDeactivate implicit make rules.
Andre Noll [Sat, 3 Oct 2015 01:58:43 +0000 (01:58 +0000)]
Deactivate implicit make rules.

Without this, make might execute commands defined by implicit
rules. This can cause subtle build errors that are hard to debug.

To make this work we need to define CC though, and RM must not be
defined through the =? operator.

8 years agoMake FOR_EACH_SUPPORTED_FILTER() local to filter_common.c.
Andre Noll [Tue, 6 Oct 2015 01:54:02 +0000 (01:54 +0000)]
Make FOR_EACH_SUPPORTED_FILTER() local to filter_common.c.

The macro is only used in this .c file, so it should not be
public. This patch moves the macro from filter.h to filter_common.c.

8 years agoFix documentation of check_receiver_arg().
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.

8 years agoplay.c: Remove bogus __a_unused attribute for session_open().
Andre Noll [Sun, 4 Oct 2015 00:06:34 +0000 (00:06 +0000)]
play.c: Remove bogus __a_unused attribute for session_open().

The play task pointer IS used in this function.

8 years agot0004: Switch to new syntax for ls command.
Andre Noll [Sun, 27 Dec 2015 22:04:58 +0000 (22:04 +0000)]
t0004: Switch to new syntax for ls command.

The old way of specifying ls options is deprecated and should no
longer be used.

8 years agobuild: Remove arch_cppflags.
Andre Noll [Sun, 20 Sep 2015 21:33:45 +0000 (23:33 +0200)]
build: Remove arch_cppflags.

This workaround for Solaris is no longer needed as Solaris is
unsupported for years.

8 years agocommand.c: Open-code mmd_dup().
Andre Noll [Mon, 28 Dec 2015 17:47:46 +0000 (17:47 +0000)]
command.c: Open-code mmd_dup().

This function is short and has only a single caller. The code becomes
clearer by open-coding it in the caller.

8 years agocommand.c: Improve documentation of vss_status_tohuman().
Andre Noll [Mon, 28 Dec 2015 17:48:06 +0000 (17:48 +0000)]
command.c: Improve documentation of vss_status_tohuman().

At the time the function is called, we already took a copy of the
mmd struct.

8 years agofilter.h: Improve documentation of ->pre_select().
Andre Noll [Sat, 17 Oct 2015 17:22:07 +0000 (19:22 +0200)]
filter.h: Improve documentation of ->pre_select().

Fix a grammar issue ("it only allowed") and explain the purpose of
the fd sets.

8 years agoafh_recv: Improve documentation of --begin-chunk.
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.