]> git.tuebingen.mpg.de Git - paraslash.git/log
paraslash.git
9 years agoconfigure.ac: Fix list of command line objects for OS X.
Andre Noll [Thu, 10 Jul 2014 19:06:19 +0000 (21:06 +0200)]
configure.ac: Fix list of command line objects for OS X.

The additional .cmdline suffix causes the build to fail.

This bug was introduced 10 months ago in commit 0f4790f2.

9 years agoMerge branch 't/gui_sched'
Andre Noll [Sun, 13 Jul 2014 14:20:56 +0000 (16:20 +0200)]
Merge branch 't/gui_sched'

Was cooking for two months, since 2014-05-11.

* t/gui_sched: (53 commits)
  gui: Always initialize theme.
  gui: Simplify color handling.
  gui: Dont catch SIGWINCH.
  gui: Call waitpid() from exec and status task.
  Doxify para_gui.
  gui: Speed up window refresh.
  gui: Rename cmd_task to exec_task.
  gui: Move static variables of cmd_post_select() into struct cmd_task.
  gui: Move some variables into struct status_task.
  gui: Switch to the standard paraslash scheduler.
  gui: Use cpp magic to define command handlers.
  gui: Execute stat command in status_post_select().
  gui: Rename COMMAND/EXTERNAL/GETCH mode.
  gui: Get rid of do_select()'s mode parameter and call it only once.
  gui: Reorder functions.
  gui: Move signal handling code out of do_select().
  gui: Move input related code out of do_select().
  gui: Move external command handling out of do_select().
  gui: Introduce status_post_select().
  gui: Improve config reload.
  ...

9 years agoMerge branch 't/cpsi_improvement'
Andre Noll [Thu, 10 Jul 2014 17:53:06 +0000 (19:53 +0200)]
Merge branch 't/cpsi_improvement'

Cooking since 2014-05-03.

* t/cpsi_improvement:
  com_cpsi(): Tell the user if nothing was copied.

9 years agomanual: Mention that audio format handlers are part
Andre Noll [Fri, 18 Apr 2014 03:20:55 +0000 (03:20 +0000)]
manual: Mention that audio format handlers are part
of para_recv and para_play.

9 years agoerror.h: Remove obsolete RBTREE_ERRORS
Andre Noll [Fri, 18 Apr 2014 01:50:23 +0000 (01:50 +0000)]
error.h: Remove obsolete RBTREE_ERRORS

9 years agoFix two typos in comments of attribute.c.
Andre Noll [Sun, 8 Jun 2014 10:23:52 +0000 (12:23 +0200)]
Fix two typos in comments of attribute.c.

9 years agoMerge branch 't/bitstream_improvements'
Andre Noll [Thu, 26 Jun 2014 16:58:27 +0000 (18:58 +0200)]
Merge branch 't/bitstream_improvements'

Cooking since 2014-04-22.

* t/bitstream_improvements:
  bitstream: Improve documentation.
  wma: Store ASF header info in afhi->techinfo.
  bitstream: Replace check for impossible condition by assertion.
  bitstream: Remove pointless variable "code_prefix2".
  bitstream: Micro-optimization.
  bitstream: Kill pointless variable "symbol".
  bitstream: Trivial coding style fixes.
  bitstream: Trivial spelling fix auxillary -> auxiliary.

9 years agoMerge branch 't/audiod_com_version'
Andre Noll [Thu, 19 Jun 2014 13:39:33 +0000 (15:39 +0200)]
Merge branch 't/audiod_com_version'

Cooking since 2014-04-03.

* t/audiod_com_version:
  audiod: Implement version command.
  audiod: Trival spelling fix for com_tasks().

9 years agocrypt: Simplify base64_decode().
Andre Noll [Mon, 16 Dec 2013 21:58:39 +0000 (22:58 +0100)]
crypt: Simplify base64_decode().

We never call this function with target == NULL.

9 years agoMerge branch 't/ao_fixes'
Andre Noll [Sun, 25 May 2014 13:31:07 +0000 (15:31 +0200)]
Merge branch 't/ao_fixes'

Cooking since 2014-03-22.

* t/ao_fixes:
  ao_write: Call ao_initialize() only once.
  ao_write: Join threads before returning an error from aow_post_select().
  ao_write: Simplify locking.
  Don't unlock and lock the thread mutex unnecessarily.
  ao_write: Check return value of pthread functions.
  ao_write: Avoid segfault on exit.
  ao_write: Avoid pthread_join().
  ao_write: Enforce a 20ms timeout.
  ao_write: Fix spurious segfault.

9 years agogui: Always initialize theme.
Andre Noll [Mon, 12 May 2014 15:51:49 +0000 (17:51 +0200)]
gui: Always initialize theme.

parse_config_file_or_die() contains the following bug: If the
configuration file ~/.paraslash/gui.conf does not exist, the current
code not only skips the gengetopt config file parser (which is correct)
but also omits to call theme_init(), which is incorrect.

The bug was introduced recently in commit 18d37e (Unify config
file parsing). Fix it by moving the call to theme_init() to
the bottom of the function so that it is called if and only if
parse_config_file_or_die() succeeds.

9 years agoMerge branch 't/test_man'
Andre Noll [Sun, 11 May 2014 10:19:12 +0000 (12:19 +0200)]
Merge branch 't/test_man'

Cooking since 2014-03-16.

* t/test_man:
  test-lib: Make colors work on FreeBSD.
  test suite: Add sanity check for generated man pages.

9 years agogui: Simplify color handling.
Andre Noll [Sat, 8 Mar 2014 20:18:21 +0000 (21:18 +0100)]
gui: Simplify color handling.

Various gui elements of para_gui can be customized through struct
gui_theme. Currently this structure contains two integers for each
each element, one for the foreground and one for the background color
of the element. This is a bit clumsy and repetitive.

This commit cuts down the number of fields of struct gui_theme by
a factor of two by introducing struct gui_color_spec as a pair of
integers.

The patch is quite large but also simple.

9 years agogui: Dont catch SIGWINCH.
Andre Noll [Thu, 13 Feb 2014 18:59:49 +0000 (19:59 +0100)]
gui: Dont catch SIGWINCH.

This is unnecessary since the curses library generates a KEY_RESIZE
event on SIGWINCH anyway. Hence window change events can be handled
as well in the normal input processing function. This allows to remove
the SIGWINCH part of the signal handling code.

Another advantage of handling SIGWINCH in the same way as normal
input events is that it is easier to propagate the event. This will
turn out to be useful for the upcoming gui menu changes.

9 years agogui: Call waitpid() from exec and status task.
Andre Noll [Mon, 27 Jan 2014 10:35:08 +0000 (11:35 +0100)]
gui: Call waitpid() from exec and status task.

This commit changes signal_post_select() to not call waitpid() via
para_reap_child() any more. Instead it notifies all tasks using the
new error code E_GUI_SIGCHLD. The exec task and the status task honor
this notification and call waitpid() for their "own" pid to check
whether the executing process or the stat process has terminated and
to obtain the exit status.

Although neither task cares deeply about the exit code, the menu
commands, which will be implemented in subsequent patches, will
care. So it's good to have the option to get this information.

9 years agoDoxify para_gui.
Andre Noll [Sun, 16 Mar 2014 11:09:01 +0000 (12:09 +0100)]
Doxify para_gui.

Now that para_gui is in a much better shape, let's make it a first
class citizen and document all public functions and data structures.

9 years agogui: Speed up window refresh.
Andre Noll [Mon, 6 Jan 2014 20:12:38 +0000 (20:12 +0000)]
gui: Speed up window refresh.

We had way too many calls to wrefresh() which copies the named
window to the physical terminal screen. This slows down the display
considerably, especially on slow machines.

It is more efficient to perform the copy only once per scheduler
iteration. So this commit adds a flag "needs_update" to struct
gui_window, and all callers to wrefresh() are changed to call
refresh_window() instead. This new function is much cheaper since it
only turns on the needs_update flag but does nothing else.

In input_post_select() we check which windows have the flag set and
repaint those windows using wnoutrefresh() and then doupdate(). This
two-step approach is described in the curs_refresh(3X) man page as
more efficient then calling wrefresh() for each window separately
since it avoids alternating calls to wnoutrefresh() and doupdate().

9 years agogui: Rename cmd_task to exec_task.
Andre Noll [Sat, 4 Jan 2014 22:16:22 +0000 (22:16 +0000)]
gui: Rename cmd_task to exec_task.

The term "command" currently means either a gui command handler or
the process which is executing as a result of a defined key map. Avoid
this confusion by using the word only for command handlers.

This commit also simplifies exec_cmd() and exec_para() slightly by
moving the "hit any key to abort" message into the common function
exec_and_display().

9 years agogui: Move static variables of cmd_post_select() into struct cmd_task.
Andre Noll [Sat, 4 Jan 2014 06:48:36 +0000 (06:48 +0000)]
gui: Move static variables of cmd_post_select() into struct cmd_task.

For the same reason stated in the commit message of the previous patch,
these variables belong to the context structure of the command task,
so move them there.

The COMMAND_BUF_SIZE define had to be moved above the definition of
struct cmd_task since COMMAND_BUF_SIZE uses it.

9 years agogui: Move some variables into struct status_task.
Andre Noll [Sat, 4 Jan 2014 06:32:04 +0000 (06:32 +0000)]
gui: Move some variables into struct status_task.

pre_select and post_select methods should never define static variables
but store their state in the context structure which also contains
the task structure.

This commit moves the static variables of status_post_select() and the
global variables next_exec and stat_pipe into the context structure
of the status task.

9 years agogui: Switch to the standard paraslash scheduler.
Andre Noll [Sat, 4 Jan 2014 06:04:26 +0000 (06:04 +0000)]
gui: Switch to the standard paraslash scheduler.

Due to the preparations performed in previous patches, this is a
rather simple change. Note we don't need to define a struct signal_task
since this structure is already defined in signal.h.

9 years agogui: Use cpp magic to define command handlers.
Andre Noll [Fri, 10 Jan 2014 00:22:07 +0000 (00:22 +0000)]
gui: Use cpp magic to define command handlers.

This shortens the code a bit and avoids duplications. The command
handler for cancel_scroll had to be renamed from com_cancel_scrolling()
to com_cancel_scroll() since the old name did not match command name.

9 years agogui: Execute stat command in status_post_select().
Andre Noll [Sat, 4 Jan 2014 05:38:23 +0000 (05:38 +0000)]
gui: Execute stat command in status_post_select().

pre_select methods should only deal with fd sets and select timeouts,
so the part of status_pre_select() which restarts the status command
belongs to status_post_select().

Unfortunately, after this change both status_pre_select() and
status_post_select() need to know when to restart the stat command.
Therefore we had to add a new global variable next_exec.

The patch also moves status_pre_select() up so that the two functions
are close to each other.

9 years agogui: Rename COMMAND/EXTERNAL/GETCH mode.
Andre Noll [Sat, 29 Mar 2014 17:31:41 +0000 (18:31 +0100)]
gui: Rename COMMAND/EXTERNAL/GETCH mode.

This value tells if there is a command executing, and if so, whether
it is an external command or a display command. Hence "cmd_status"
is to be more to the point.

9 years agogui: Get rid of do_select()'s mode parameter and call it only once.
Andre Noll [Sat, 29 Mar 2014 12:48:03 +0000 (13:48 +0100)]
gui: Get rid of do_select()'s mode parameter and call it only once.

The current code calls do_select() from three different locations. The
mode parameter indicates whether a command is currently running
and if it is a display command or an external command (where curses
is disabled).  This is unnecessarily complex as we can tell from the
values of the command_fd[] array and the cmd_pid variable which mode
we are in.

This commit introduces get_select_mode() which looks at these variables
and returns the current mode. This allows to get rid of the mode
parameter of do_select() and to call do_select() only once at startup
from main(). It now runs in an endless loop, checking the current mode
in each iteration. The other two call sites, exec_and_display_cmd()
and external_cmd(), don't need to call do_select() any more.

This change removes more lines than it adds and makes the logic
of para_gui much simpler to follow. It is also the last big step
to replace the do_select() loop in favor of the standard paraslash
scheduler.

9 years agogui: Reorder functions.
Andre Noll [Sat, 29 Mar 2014 10:34:02 +0000 (11:34 +0100)]
gui: Reorder functions.

As a preparation for the removal of do_select() we need various
functions of gui.c to be in a different order. Specifically,
input_post_select() will soon call handle_command(), so the latter
function will need to be declared before the former.

Patches which move functions around are generally hard to
read, so this commit performs pure code movement only. However,
as exec_and_display_cmd() still calls do_select() we introduce a
temporary forward declaration for do_select(). It will be removed
in the next patch.

9 years agogui: Move signal handling code out of do_select().
Andre Noll [Fri, 3 Jan 2014 19:03:22 +0000 (19:03 +0000)]
gui: Move signal handling code out of do_select().

As a further preparation for employing the standard paraslash scheduler
within para_gui, this simple patch introduces signal_pre_select()
and renames handle_signal() to signal_post_select().

The signal related part of do_select() is moved to these two functions
so that do_select() is reduced to the bare minimum: one call to each
of the two new functions.

9 years agogui: Move input related code out of do_select().
Andre Noll [Fri, 3 Jan 2014 18:49:19 +0000 (18:49 +0000)]
gui: Move input related code out of do_select().

This moves the relevant part of do_select() into the new functions
input_pre_select() and input_post_select().

9 years agogui: Move external command handling out of do_select().
Andre Noll [Fri, 3 Jan 2014 18:16:51 +0000 (18:16 +0000)]
gui: Move external command handling out of do_select().

This commit moves the part of do_select() that deals with
external commands to separate functions, command_pre_select() and
command_post_select().

This change shortens do_select() considerably and is another step
towards the goal of using the paraslash scheduling system also for
para_gui.

One thing to note is that the new command_post_select() returns -1 if
both both fds are closed, i.e. when the currently running command has
terminated. This value gets translated back to zero in do_select(),
preserving the current semantics.

9 years agogui: Introduce status_post_select().
Andre Noll [Sun, 26 Jan 2014 17:14:34 +0000 (18:14 +0100)]
gui: Introduce status_post_select().

This moves stat pipe error handling into read_stat_pipe() and renames
the function to status_post_select(), which is more to the point. It
shortens do_select() a bit.

Since status_post_select() now calls print_all_items() and
clear_all_items() it had to be moved down to avoid a forward
declaration.

9 years agogui: Improve config reload.
Andre Noll [Thu, 13 Mar 2014 08:41:44 +0000 (09:41 +0100)]
gui: Improve config reload.

There are two ways to make para_gui reload its config file: Sending
SIGUSR1 and running the internal reread_conf command. When SIGUSR1
is received, signal_post_select() calls com_reread_conf(). This is
a layer violation since command handlers should only be called from
the input task.

This patch provides the generic function reread_conf() which is called
from both the command handler and from signal_post_select().

9 years agogui: Unify config file parsing.
Andre Noll [Tue, 7 Jan 2014 22:04:21 +0000 (22:04 +0000)]
gui: Unify config file parsing.

The gui config file is parsed on startup, when the reload command
is executed or when SIGUSR1 is received. In all cases we set up a
gengetopt params structure and pass its address to the gengetopt
command line parser.

This commit moves the common code to the new parse_config_file_or_die()
which does the right thing for both the startup and the reload
case. The new function also contains the logic of configfile_exists(),
so this latter function can be removed.

9 years agogui: Remove ->cols and ->lines of struct gui_window.
Andre Noll [Thu, 9 Jan 2014 23:34:11 +0000 (23:34 +0000)]
gui: Remove ->cols and ->lines of struct gui_window.

The curses library provides the getmaxyx() macro to obtain the window
geometry. It's better to use these instead of storing the number of
lines and columns in the gui_window structure because with getmaxyx()
there is no risk to have stale values gui_window structure.

While the ncurses implementation provides getmaxx() and getmaxy()
to get only the number of lines or columns, respectively, only
getmaxyx() is described in the XSI Curses standard. Hence we provide
our own version of the former two functions. These call getmaxyx()
and return one of the two numbers.

With the ->cols and ->lines fields of struct gui_window gone, all
callers had to be adjusted to use either getmaxyx() or one of the
new functions.

9 years agogui: Move call to print_all_items() into init_wins().
Andre Noll [Sun, 26 Jan 2014 19:08:05 +0000 (20:08 +0100)]
gui: Move call to print_all_items() into init_wins().

All three callers of init_wins() called print_all_items() directly
thereafter. init_wins() had to be moved below print_all_items().

9 years agogui: Improve check_key_map_args().
Andre Noll [Tue, 7 Jan 2014 18:52:26 +0000 (18:52 +0000)]
gui: Improve check_key_map_args().

Simplify the code a bit, make it call die() on errors and print
the invalid key map in the error case.

9 years agogui: Combine exit functions.
Andre Noll [Tue, 7 Jan 2014 17:35:08 +0000 (17:35 +0000)]
gui: Combine exit functions.

Currently we have kill_pg_and_die(), finish(), msg_n_exit(), which
is kind of excessive. This patch replaces these three functions by
the single die() which does the right thing in all cases.

9 years agogui: Make curses_log() work also when curses is not active.
Andre Noll [Tue, 7 Jan 2014 16:55:32 +0000 (16:55 +0000)]
gui: Make curses_log() work also when curses is not active.

This allows to get rid of all fprintf(stderr, ...) constructs and
simplifies the code a bit.

9 years agogui: Parse command line options only once.
Andre Noll [Tue, 7 Jan 2014 15:59:27 +0000 (15:59 +0000)]
gui: Parse command line options only once.

There is no point in calling gui_cmdline_parser_ext() when rereading
the configuration since this parser only looks at the command line
options which never change.

Removing the call in com_reread_conf() also allows to get rid of the
global _argc and _argv variables.

9 years agogui: Clear top window only once on resize.
Andre Noll [Mon, 6 Jan 2014 18:08:16 +0000 (18:08 +0000)]
gui: Clear top window only once on resize.

init_wins() already clears the top window.

9 years agogui: Replace global variable curses_active by a function.
Andre Noll [Sun, 5 Jan 2014 20:48:29 +0000 (20:48 +0000)]
gui: Replace global variable curses_active by a function.

There is no need to store this information as we can easily compute it.

shutdown_curses() needed to be changed to cope with early failures:
On fatal errors that happen after initscr() was called but before
the top window exists, we must shut down the curses subsystem albeit
curses_active() returns false in this case.

9 years agogui: Kill struct gui_window->beg{xy}.
Andre Noll [Mon, 6 Jan 2014 16:11:56 +0000 (16:11 +0000)]
gui: Kill struct gui_window->beg{xy}.

These values are only needed in init_wins(), so we might as well use
local variables for them.

9 years agogui: Remove change_theme().
Andre Noll [Tue, 7 Jan 2014 22:08:00 +0000 (22:08 +0000)]
gui: Remove change_theme().

It's silly to have a function for this.

9 years agogui: Move windows *after* resizing them.
Andre Noll [Sun, 26 Jan 2014 19:18:00 +0000 (20:18 +0100)]
gui: Move windows *after* resizing them.

This appeared to be the reason why refresh() was needed twice.

9 years agogui: Rename public gui theme functions.
Andre Noll [Tue, 7 Jan 2014 00:40:20 +0000 (00:40 +0000)]
gui: Rename public gui theme functions.

Prefix all functions related to themes with "theme_".

9 years agoRemove chop().
Andre Noll [Tue, 7 Jan 2014 00:25:38 +0000 (00:25 +0000)]
Remove chop().

In curses_log() we currently we call chop(), which calls strlen()
to find the last character of the given string. This is unnecessary
since xvasprintf() returns this information anyway, we just have to
remember it.

With this change the last user of chop() is gone, so this patch
removes chop() from string.c.

9 years agogui: Use whline() for drawing the separator.
Andre Noll [Mon, 6 Jan 2014 02:45:28 +0000 (02:45 +0000)]
gui: Use whline() for drawing the separator.

This should be slightly more efficient.

This patch also changes the type of struct gui_theme->sep_str from
const char * to plain char and renames the field to sep_char. It must
be a single-character string anyway.

For the colorful blackness theme we now use the default character
from curses.h rather than '-'. This looks nicer. Tested with ncurses
on Linux and the curses implementation that ships with NetBSD.

9 years agogui: Remove welcome message.
Andre Noll [Tue, 7 Jan 2014 19:20:13 +0000 (19:20 +0000)]
gui: Remove welcome message.

The only information shown by print_welcome() that is not already
contained in the status bar is the name of the current theme. This
is not very interesting, so remove the function and the corresponding
color pair.

9 years agogui: Simplify print_status_bar().
Andre Noll [Sun, 26 Jan 2014 17:39:56 +0000 (18:39 +0100)]
gui: Simplify print_status_bar().

Curses is always active at this point, so remove the check. Moreover,
refreshing of all other windows is performed in init_wins(), so move
the call to wrefresh() there to be consistent. Finally, the comment
of this function is rather pointless, so remove that as well.

9 years agogui: Print the status bar only once.
Andre Noll [Mon, 6 Jan 2014 17:56:20 +0000 (17:56 +0000)]
gui: Print the status bar only once.

Currently we print it twice on startup. Remove the redundant call
to print_status_bar().

9 years agogui: Remove macro STANDARD_STATUS_BAR.
Andre Noll [Sun, 5 Jan 2014 05:03:32 +0000 (05:03 +0000)]
gui: Remove macro STANDARD_STATUS_BAR.

It's only referenced once in print_status_bar(), so we may as well
print the text there without defining a macro for it.

9 years agogui: Simplify display command execution.
Andre Noll [Fri, 3 Jan 2014 20:58:24 +0000 (20:58 +0000)]
gui: Simplify display command execution.

para_cmd() and display_cmd() are almost identical. Move the
command part into send_output() and rename this function to
exec_and_display_cmd().

9 years agogui: Don't close command fds if a key was pressed.
Andre Noll [Fri, 3 Jan 2014 18:25:44 +0000 (18:25 +0000)]
gui: Don't close command fds if a key was pressed.

Killing the command is enough, as command_post_select() will notice
the EOF condition and close these fds.

9 years agogui: Avoid magic number in enum gui_color_pair.
Andre Noll [Tue, 7 Jan 2014 17:43:58 +0000 (17:43 +0000)]
gui: Avoid magic number in enum gui_color_pair.

This way it works also if the set of status items is extended.

9 years agogui: Kill pointless initialization of top.lines in main().
Andre Noll [Mon, 6 Jan 2014 16:24:13 +0000 (16:24 +0000)]
gui: Kill pointless initialization of top.lines in main().

init_curses() sets this value anyway.

9 years agogui: Make curses_active a bool.
Andre Noll [Fri, 3 Jan 2014 22:24:25 +0000 (22:24 +0000)]
gui: Make curses_active a bool.

This variable is only used as a boolean.

9 years agogui: Rename label of check_key_map_args()
Andre Noll [Tue, 7 Jan 2014 17:47:20 +0000 (17:47 +0000)]
gui: Rename label of check_key_map_args()

The old name is misleading since the code starting at this label will
be executed unconditionally.

9 years agogui: Rename struct win_data to gui_window.
Andre Noll [Mon, 6 Jan 2014 03:33:03 +0000 (03:33 +0000)]
gui: Rename struct win_data to gui_window.

We will pass around pointers to these structures eventually, so let's
choose a better name.

9 years agogui: Add trailing newline to all log messages.
Andre Noll [Sun, 26 Jan 2014 16:00:20 +0000 (17:00 +0100)]
gui: Add trailing newline to all log messages.

Currently we have a funny mixture of the two styles. This is no problem
since curses_log() will chop the trailing newline. But let's better
be consistent.

9 years agogui: Fix some trivial whitespace and spelling issues.
Andre Noll [Sat, 29 Mar 2014 12:49:16 +0000 (13:49 +0100)]
gui: Fix some trivial whitespace and spelling issues.

9 years agogui: Remove unused struct stat_item.
Andre Noll [Sat, 4 Jan 2014 15:45:47 +0000 (15:45 +0000)]
gui: Remove unused struct stat_item.

9 years agogui: Initialize command_fds to -1.
Andre Noll [Sat, 29 Mar 2014 12:48:40 +0000 (13:48 +0100)]
gui: Initialize command_fds to -1.

We check at various locations whether the two members of the
command_fds array are negative to tell if an external command or a
display command is currently running. At startup, there is no such
command, hence the two integers of the array should be initialized
to a negative value.

9 years agogui: Use proper column number in print_in_bar().
Andre Noll [Mon, 6 Jan 2014 17:54:59 +0000 (17:54 +0000)]
gui: Use proper column number in print_in_bar().

This function modifies the input window, not the status bar
window. This bug is benign because both windows have the same number
of columns.

9 years agogui: Reset command buf offset on errors.
Andre Noll [Fri, 3 Jan 2014 23:42:38 +0000 (23:42 +0000)]
gui: Reset command buf offset on errors.

On read errors or EOF we close the pipe that corresponds to
stdout/stderr of the current display command. However, we miss to
reset the offset value of the command buffer in this case. If this
offset was positive at the time the read error occurred, we skip the
first part of the output of the next command.

Fix this by always resetting the offset after closing the pipe.

9 years agogui: Shut down curses before rereading the config file.
Andre Noll [Tue, 7 Jan 2014 16:14:12 +0000 (16:14 +0000)]
gui: Shut down curses before rereading the config file.

If the config file contains errors, gui_cmdline_parser_config_file()
calls exit() while curses is still active, leading to messed up
terminal settings. Fix this by calling shutdown_curses() before
parsing the config file, and init_curses() thereafter.

9 years agoMerge branch 't/alsa_improvements'
Andre Noll [Sat, 3 May 2014 17:56:01 +0000 (19:56 +0200)]
Merge branch 't/alsa_improvements'

Was cooking for almost two months.

* t/alsa_improvements:
  alsa: Remove pointless initialization.
  alsa_mix: Allow non-positive mixer values.
  alsa: New writer option: --buffer-time.
  alsa: Work around poll fd problems.
  alsa: Set period time.
  alsa: Also dump hardware params.
  alsa: Improve help text of --device.
  alsa: Improve documentation of struct private_alsa_write_data.
  alsa: Don't set t->error in ->pre_select().

9 years agocom_cpsi(): Tell the user if nothing was copied.
Andre Noll [Sun, 23 Feb 2014 09:57:04 +0000 (10:57 +0100)]
com_cpsi(): Tell the user if nothing was copied.

All but the first argument to the cpsi command are treated as patterns.
Currently, if no file matches any given pattern, the command exits
silently.  This patch makes it print a "nothing copied" message in
this case.

9 years agoRemove client_disconnect().
Andre Noll [Tue, 31 Dec 2013 15:44:24 +0000 (15:44 +0000)]
Remove client_disconnect().

Everything this function does can be done as well when the task
terminates by returning negative in ->post_select().

This also avoids to leak the stream cipher structure of the previous
connection when running in interactive mode.

1,032 bytes in 1 blocks are definitely lost in loss record 61 of 85
   at 0x402994A: malloc (vg_replace_malloc.c:263)
   by 0x804C689: para_malloc (string.c:71)
   by 0x804FF87: sc_new (crypt.c:268)
   by 0x804E204: client_post_select (client_common.c:370)
   by 0x804D203: schedule (sched.c:59)
   by 0x804A2E7: main (client.c:500)

1,032 bytes in 1 blocks are definitely lost in loss record 62 of 85
   at 0x402994A: malloc (vg_replace_malloc.c:263)
   by 0x804C689: para_malloc (string.c:71)
   by 0x804FF87: sc_new (crypt.c:268)
   by 0x804E217: client_post_select (client_common.c:371)
   by 0x804D203: schedule (sched.c:59)
   by 0x804A2E7: main (client.c:500)

9 years agoFix memory leak in btr_splice_out_node().
Andre Noll [Tue, 31 Dec 2013 13:29:16 +0000 (13:29 +0000)]
Fix memory leak in btr_splice_out_node().

Commit 072391fc (Improve btr_splice_out_node(), 2013-03) modified this
function to take a pointer to a buffer tree node pointer so that the
node pointer can be invalidated after it is spliced out. However, this
also means the caller can no longer free its resources. Hence we must
free the btrn in btr_splice_out_node() in order to avoid memory leaks.

10 years agoMerge branch 't/rl_free_keymap'
Andre Noll [Tue, 22 Apr 2014 00:30:02 +0000 (02:30 +0200)]
Merge branch 't/rl_free_keymap'

Cooking since 2014-03-10.

* t/rl_free_keymap:
  build: Check whether rl_free_keymap is declared.

10 years agobitstream: Improve documentation.
Andre Noll [Sat, 8 Mar 2014 12:34:54 +0000 (13:34 +0100)]
bitstream: Improve documentation.

Mention that the bitstream API is only used for the WMA decoder,
avoid overlong descriptions of function parameters and add some
doxygen \ref commands.

10 years agowma: Store ASF header info in afhi->techinfo.
Andre Noll [Wed, 8 Jan 2014 18:38:06 +0000 (18:38 +0000)]
wma: Store ASF header info in afhi->techinfo.

This changes the wma audio format handler and decoder to store
the ASF header bits we care about (exp_vlc, bit reservoir, and
variable block length) in struct asf_header_info instead of struct
private_wmadec_data.

This way the wma audio format handler can print this information in
its ->techinfo string for the audio file.

10 years agobitstream: Replace check for impossible condition by assertion.
Andre Noll [Sat, 28 Dec 2013 17:16:18 +0000 (17:16 +0000)]
bitstream: Replace check for impossible condition by assertion.

No big deal because behaviour is unchanged (abort). Calling assert()
is a bit shorter and will print a better error message.

10 years agobitstream: Remove pointless variable "code_prefix2".
Andre Noll [Sat, 28 Dec 2013 17:02:55 +0000 (17:02 +0000)]
bitstream: Remove pointless variable "code_prefix2".

This variable is only used at one place. Using the computed value
directly in the conditional allows to get rid of it.

10 years agobitstream: Micro-optimization.
Andre Noll [Sat, 28 Dec 2013 17:01:40 +0000 (17:01 +0000)]
bitstream: Micro-optimization.

Subtract n_prefix right away, and don't get the next code if n becomes
non-positive. This is equivalent and saves one comparison.

10 years agobitstream: Kill pointless variable "symbol".
Andre Noll [Sat, 28 Dec 2013 16:58:12 +0000 (16:58 +0000)]
bitstream: Kill pointless variable "symbol".

It is just a copy of the loop index i. Since i is never modified
we may simply use i instead.

10 years agobitstream: Trivial coding style fixes.
Andre Noll [Sat, 28 Dec 2013 16:56:18 +0000 (16:56 +0000)]
bitstream: Trivial coding style fixes.

10 years agobitstream: Trivial spelling fix auxillary -> auxiliary.
Andre Noll [Sat, 8 Mar 2014 12:16:10 +0000 (13:16 +0100)]
bitstream: Trivial spelling fix auxillary -> auxiliary.

10 years agoversion.c: Fix year in version_text().
Andre Noll [Mon, 21 Apr 2014 04:39:52 +0000 (04:39 +0000)]
version.c: Fix year in version_text().

We want a single year here. The string got converted to a range by
mistake in commit 027f2c12.

10 years agoflac afh: Fix off-by-one bug in meta_eof_cb().
Andre Noll [Tue, 24 Dec 2013 17:49:41 +0000 (17:49 +0000)]
flac afh: Fix off-by-one bug in meta_eof_cb().

After the full file has been read, the file position equals the number
of available bytes. The eof callback did not report EOF in this case.

10 years agowma afh: Read the description field as the comment tag.
Andre Noll [Fri, 1 Nov 2013 18:11:23 +0000 (19:11 +0100)]
wma afh: Read the description field as the comment tag.

The wma audio format handler parses the entries of the ASF content
description object and interprets its fifth field as the comment tag.

This is wrong, since this field actually corresponds to the rating
information, which is usually unused. The correct field to examine
is #4.

10 years agooggdec: Remove noisy debug message.
Andre Noll [Tue, 15 Apr 2014 12:22:06 +0000 (12:22 +0000)]
oggdec: Remove noisy debug message.

Also improve the comment for this code block.

10 years agoreset version to 'git'
Andre Noll [Fri, 11 Apr 2014 12:18:57 +0000 (14:18 +0200)]
reset version to 'git'

10 years agoparaslash 0.5.2 v0.5.2
Andre Noll [Fri, 11 Apr 2014 11:52:04 +0000 (13:52 +0200)]
paraslash 0.5.2

10 years agoMerge branch 't/oggdec_latency_improvements'
Andre Noll [Wed, 9 Apr 2014 18:07:07 +0000 (20:07 +0200)]
Merge branch 't/oggdec_latency_improvements'

A single commit which was cooking since 2014-03-11.

* t/oggdec_latency_improvements:
  oggdec: Decode only OGGDEC_OUTPUT_CHUNK_SIZE many bytes per iteration.

10 years agoMerge branch 't/opusdec_busy_loop_fix'
Andre Noll [Tue, 8 Apr 2014 17:20:35 +0000 (19:20 +0200)]
Merge branch 't/opusdec_busy_loop_fix'

A single fix that was cooking since 2014-03-02.

* t/opusdec_busy_loop_fix:
  opusdec: Fix busy loop.

10 years agoRevert "Add -Wdeclaration-after-statement."
Andre Noll [Sun, 6 Apr 2014 16:52:31 +0000 (18:52 +0200)]
Revert "Add -Wdeclaration-after-statement."

This reverts commit cf517575ef0e501c963964ba4fd62aadaf795af8. It
broke our promise that paraslash still compiles with gcc-3.3.3.

10 years agoao_write: Call ao_initialize() only once.
Andre Noll [Sun, 9 Mar 2014 14:21:48 +0000 (15:21 +0100)]
ao_write: Call ao_initialize() only once.

It is possible that another instance of the ao writer is active
when aow_close() is called. Calling ao_shutdown() in ao_close()
might disturb the other instance and lead to a segmentation fault.

Fix this by calling ao_initialize() only once during aow_init()
and never call ao_shutdown() any more.

10 years agoao_write: Join threads before returning an error from aow_post_select().
Andre Noll [Sun, 9 Mar 2014 14:21:00 +0000 (15:21 +0100)]
ao_write: Join threads before returning an error from aow_post_select().

This guarantees the play thread is not active any more in aow_close().

10 years agoao_write: Simplify locking.
Andre Noll [Sun, 9 Mar 2014 12:23:56 +0000 (13:23 +0100)]
ao_write: Simplify locking.

Currently we lock the mutex at the beginnint of each iteration
of the main loop of aow_play() and drop the lock before calling
ao_play(). On errors we leave the loop either with the mutex locked
locked or unlocked, depending on the error condition that caused us
to break out of the loop.

This is unnecessarily complex. This patch simplifies the locking
by always leave the loop with the mutex locked.

10 years agoDon't unlock and lock the thread mutex unnecessarily.
Andre Noll [Mon, 3 Feb 2014 19:45:15 +0000 (20:45 +0100)]
Don't unlock and lock the thread mutex unnecessarily.

10 years agoao_write: Check return value of pthread functions.
Andre Noll [Thu, 30 Jan 2014 21:51:44 +0000 (22:51 +0100)]
ao_write: Check return value of pthread functions.

Although pthread_cond_wait() and pthread_cond_signal() should never
fail on our setup, let's be conservative here and check the return
value anyway.

This patch also adds some comments and removes a few lines of code
which were commented out since day one of the ao writer.

10 years agoao_write: Avoid segfault on exit.
Andre Noll [Mon, 3 Feb 2014 20:06:00 +0000 (21:06 +0100)]
ao_write: Avoid segfault on exit.

If para_audiod is terminated by a signal it calls the ->close() method
of each active writer. In this method the ao writer calls ao_close()
and frees all resources but leaves the play thread active. So the
thread continues to run, prints

ao_alsa ERROR: write error: File descriptor in bad state

and probably crashes afterwards due to accessing freed memory. Fix this
by cancelling the thread in ->close() if it exists. Ironically enough,
this re-introduces a call to pthread_join(), but it's OK here since
we the cancelled thread should exit immediately (so we don't block),
and we are about to exit anyway.

10 years agoao_write: Avoid pthread_join().
Andre Noll [Mon, 3 Feb 2014 19:30:11 +0000 (20:30 +0100)]
ao_write: Avoid pthread_join().

The call to pthread_join() may block for hundreds of milliseconds,
depending of the amount of buffered data. This is not acceptable in
a post_select hook. Among other problems this leads to an incorrect time
display and fake "time jump" warnings.

This patch drops the call to pthread_join() and makes ->post_select()
return non-negative until the play thread has terminated. In order to
have a way to tell if the thread is still running we let the thread
(i.e. aow_play()) remove its own buffer tree node on exit instead
of doing this in ->post_select() after pthread_join(). Hence if
->thread_btrn is NULL, we know the thread has terminated. It would
be easier to use pthread_tryjoin_np() but this would not be portable,
as this function is a non-standard GNU extension.

10 years agoao_write: Enforce a 20ms timeout.
Andre Noll [Sun, 2 Feb 2014 19:21:35 +0000 (20:21 +0100)]
ao_write: Enforce a 20ms timeout.

Without this, the ao writer frequently complained about buffer
underruns.

10 years agoao_write: Fix spurious segfault.
Andre Noll [Thu, 30 Jan 2014 21:49:45 +0000 (22:49 +0100)]
ao_write: Fix spurious segfault.

Both btr_node_status() and btr_consume() access the buffer tree of
the ao writer, so these functions must be called with the pthread
mutex locked.

10 years agoMerge branch 'maint'
Andre Noll [Sun, 6 Apr 2014 06:19:26 +0000 (08:19 +0200)]
Merge branch 'maint'

10 years agoaudiod: Avoid segfault on exit.
Andre Noll [Fri, 4 Apr 2014 12:23:44 +0000 (14:23 +0200)]
audiod: Avoid segfault on exit.

When para_audiod terminates, it calls clean_exit() which closes
all slots unconditionally, regardless of whether they are in use.
This may lead to a segfault due to an invalid read:

==25253== Invalid read of size 4
==25253==    at 0x40EBEA: close_slot (audiod.c:443)
==25253==    by 0x40FCE8: clean_exit (audiod.c:1163)
==25253==    by 0x40FD7D: signal_post_select (audiod.c:1014)
==25253==    by 0x41490A: schedule (sched.c:65)
==25253==    by 0x406BC3: main (audiod.c:1436)
==25253==  Address 0x5c19d8 is not stack'd, malloc'd or (recently) free'd

This bug was introduced 9 month ago in commit eec23a69 (audiod:
Fix memory leak on exit: close slots). Fix it by calling
close_unused_slots(). This also simplifies clean_exit() a bit.

10 years agoaudiod: Implement version command.
Andre Noll [Sat, 1 Mar 2014 17:56:31 +0000 (18:56 +0100)]
audiod: Implement version command.

It's sometimes useful to tell the git version of a running instance of
para_audiod. This commit adds the "version" subcommand to para_audiod
which prints this information. A completer for the "-v" option of
the new command is provided as well.

Since the infrastructure is already in place, all of this is rather
simple.

10 years agoaudiod: Trival spelling fix for com_tasks().
Andre Noll [Sat, 1 Mar 2014 17:59:49 +0000 (18:59 +0100)]
audiod: Trival spelling fix for com_tasks().

10 years agoMerge branch 't/misc'
Andre Noll [Sun, 30 Mar 2014 16:31:57 +0000 (18:31 +0200)]
Merge branch 't/misc'

Various fixes, improvements, cleanups. Cooking since 2014-02-22.

* t/misc: (29 commits)
  build: Don't link with -lreadline if readline was not found.
  audiod: Skip NULL pointer check in compute_time_diff().
  audiod: Make compute_time_diff() return void.
  com_stat(): Remove pointless uptime variable.
  gcrypt: Fix gcc warning on Ubuntu Lucid.
  flac: Try to link also without -logg.
  version.c: Fix comment of version_single_line().
  doxygen: Expand all macros, in particular config.h.
  recv_common.c: Improve documentation of check_receiver_arg().
  audiod: get_time_string() comment fix.
  configure: Really print opus audio file handler if opus lib was found.
  Overhaul doxygen main page.
  afs.h: Don't try to list all supported audio formats.
  Change copyright year to 2014.
  Add link to sideband.h in doxygen main page.
  Doxify error2.c and add GPL header.
  Add -Wdeclaration-after-statement.
  Add some missing includes.
  Makefile.real: Add clean2 to the list of phony targets.
  mood.c: Fix a trivial whitespace issue.
  ...