| Commit message (Collapse) | Author | Age |
| |
|
|
|
|
|
|
|
|
| |
If this directory does not exist, para_play creates it at startup. However,
para_client and para_audioc do not do that, hence they fail to write the
history file on exit.
Teach para_client and para_audioc to create ~/.paraslash just as para_play
does. Replace para_mkdir() by create_dot_paraslash() as this is what all
callers need.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Switch to SPDX licence identifiers
A single patch which replaces the first comment line of most .c and .h files
containing the copyright notice by standardized SPDX (Software/System Package
Data Exchange) nomenclature.
* t/spdx:
Switch to SPDX identifiers.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
Generated with
sed -i 's|Copyright.*Andre Noll.*|SPDX-License-Identifier: GPL-2.0 */|g' *.c *.h
followed by manually tweaking the result a bit. No license change intended.
|
| |/
|
|
|
| |
Valgrind correctly complains about these, although all of them are
harmless. But it is also easy to fix them, so..
|
| |
|
|
|
| |
The file comment for play.c, some dedox, and the improved documentation text
for main().
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This moves the declaration of the structure from sched.h to sched.c because
the information stored in this structure has almost no users outside of the
scheduler core.
As a result, the size of the structure is no longer known outside of sched.c.
To initialize a scheduler instance, users now must call the new sched_new(),
passing an alternative poll function if needed, We don't let applications
set the default timeout anymore because the value is kind of arbitrary anyway
and most users specified one second. So hardcode this as the default.
Besides allocating the scheduler structure, sched_new() also initializes the
task list and the poll function pointer. Thanks to these initializations,
the two conditions of sched.c removed in this patch are never true.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The completers for para_client and para_audioc handle some cases incorrectly
or not at all. This series improves on that.
* refs/heads/t/completion:
Revamp bash_completion.
bash completion: Fix help option parsing.
audioc: Fix option completion of version and stat.
i9e: Introduce i9e_get_nonopt_argnum().
i9e: Introduce i9e_cword_is_option_arg().
i9e: Constify i9e_complete_option().
|
| | |
| |
| |
| |
| |
| | |
i9e_extract_completions() and i9e_complete_option() both take a char **
argument for the option/string list although they do not modify the pointers
of the list. This commit marks these pointer variables constant.
|
| | |
| |
| |
| | |
This way the array of completers goes into the rodata section.
|
| | |
| |
| |
| |
| |
| | |
The former is part of the C99 standard, while the latter is only provided
for backward compatibility. This change also silences many gcc warnings when
compiling with -Wpendantic (disabled in the default build).
|
| | |
| |
| |
| | |
The signature of the function pointer is too simple to warrant a typedef.
|
| |\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
A medium sized series for the build system which improves the way the git
version string is stored in the executables and man pages. Subsequent patches
of the series remove some warts from the makefile: we no longer use order-only
dependencies and the .PRECIOUS target.
The merge results in a conflict against the "remove regex include" commit
67388cd4fae0. This is trivial to resolve, though.
* refs/heads/t/build:
Doxify version functions.
Doxify OV_EXCLUDE_STATIC_CALLBACKS #define.
Makefile: Fix braino in tarball target.
build: Remove superfluous dependency in Makefile.real.
build: Remove the .PRECIOUS target.
build: Improve clean targets.
build: Get rid of directory order-only dependencies.
build: Compile with -Wunused -Wall also on BSD.
build: Revamp git versioning.
build: Merge version.{c,h} into string.{c,h}.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This is a preparatory patch for the upcoming revamp of the git
version script. The revamped script generates version.c, a file
which is currently tracked by git. We can easily get rid of it (and
of version.h) since all paraslash executables link in both string.o
and version.o. So let's move the three small functions of version.c
to string.c and their declarations from version.h to string.h.
|
| | |/
|/|
| |
| | |
Every .c file includes it anyway.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
| |
This function fails if an invalid command name is passed as the argument, yet
all callers ignore the error. Modify the callers to print the strerror text as
appropriate and no longer do that in lsu_lopsub_error(). Rename this function
and introduce the error type argument to print more meaningful error messages.
One visible consequence is that
para_client help does-not-exist
used to succeed while it now exits with status 1.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This small series contains a few minor tweaks for para_play. The most
obvious change is that para_play is no longer built on systems which
lack libreadline.
The merge conflicted badly in configure.ac due to the changes
introduced by the earlier merge of the "built" topic branch. The
resolution needs to modify the non-conflicting Makefile.real to exclude
para_play from the list of executables if libreadline is not present
while the corresponding commit of the "play" topic branch implemented
the logic in configure.ac.
Cooking for a month.
* refs/heads/t/play:
play: Shut down alsa on input EOF.
play: Simplify and improve get_key_map_seq().
play: Remove pointless goto in play_post_monitor().
Return from filter_setup() so callers can reset the terminal.
Let para_play depend on libreadline.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
para_play leaks a lot of memory on exit because we didn't bother
to shut down the alsa subsystem. While this is harmless from the
correctness point of view, it does make it harder to spot real
memory leaks.
Rework the error handling to always shut down alsa via kill_stream().
Combine play_post_monitor() and session_post_monitor() because they
are small enough and the latter was badly named anyway.
|
| | |
| |
| |
| |
| |
| |
| | |
Combine it with get_user_key_map_seq() and replace the NULL check
with an assertion since the condition can never be true here. This
makes gcc's static analyzer happy, which complained about a possible
NULL pointer dereference.
|
| | |
| |
| |
| | |
We may as well return directly.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This function of filter_common.c calls exit(3) on errors. This is OK
for para_filter and para_audiod, but not for para_play because there
the function is called after readline has initialized the terminal for
its own use. If the function calls exit(3), the terminal settings are
not reset as they should have been. This can be observed for example
on the attempt to open an mp3 file with an para_play executable that
lacks mp3 support.
This commit changes the function to return an error code instead and
deals with the fallout in the three callers. Although play.c already
had error checking for calls to filter_setup(), it still needs a minor
tweak because we now have to deal with the fact that the filter and
writer node don't exist in eof_cleanup().
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
While para_client and para_audioc are suitable for non-interactive
use, e.g. in scripts, para_play can only be used interactively,
and its non-readline version is barely usable.
Rather than building a crippled version, teach the build and test
systems to skip para_play if the readline library is not installed.
|
| |\ \
| |/
|/|
| |
| |
| |
| | |
The merge conflicted due to an integer overflow fix in com_jmp().
* maint:
play: Fix some integer overflows().
|
| | |
| |
| |
| |
| |
| |
| |
| | |
If one factor of a product is a chunk number, we need to be careful
with respect to integer overflows. This patch adds casts which force
64 bit arithmetics to avoid that.
The overflows were observed while navigating a ~4 hour mp3 file.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
If p is NULL, kma contains no colon, and we should not be here in the
first place. Instead, we should have errored out much earlier in the
command line parser.
Suggested-by: gcc(1)
|
| | |
| |
| |
| |
| |
| | |
It has two callers which both pass the mode value 0777 and contain
extra code to regard the EEXIST error case as a success. Move the
common bits into the wrapper and improve the documentation.
|
| | |
| |
| |
| |
| |
| | |
Currently we have ~15 error codes which indicate an EOF condition. One
should suffice, so drop all codes except the generic E_EOF and use
that everywhere.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We leak one filter parse result per audio file played. Valgrind reports:
==24559== 24 (12 direct, 12 indirect) bytes in 1 blocks are definitely lost in loss record 34 of 104
==24559== at 0x4044B0B: calloc (vg_replace_malloc.c:1328)
==24559== by 0x453A997: lls_parse (lopsub.c:768)
==24559== by 0x8057612: filter_setup (filter_common.c:98)
==24559== by 0x80500A4: load_file (play.c:377)
==24559== by 0x80500A4: load_next_file (play.c:454)
==24559== by 0x80500A4: play_post_monitor (play.c:1154)
==24559== by 0x8051110: call_post_monitor (sched.c:80)
==24559== by 0x8051110: sched_post_monitor (sched.c:106)
==24559== by 0x8051110: schedule (sched.c:148)
==24559== by 0x804EB80: main (play.c:1217)
|
| | |
| |
| |
| |
| | |
Expand and reword this text a bit, and move it into the documentation
of main() so that it appears in the generated html.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently get_play_time() throws away the subsecond part of the
timeval and returns a number in seconds. We can improve on that
by letting the function return milliseconds instead. However, with
milliseconds we must perform multiplications using 64 bit integers
to avoid integer overflows.
This also affects the pause and play commands, which should now
reposition the stream more accurately. It still won't be perfect,
though, because play.c has no way of knowing the number of the chunk
which is currently being decoded.
|
| |\ \
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This series implements a new memory allocation API which checks
for overflows. The first part of the series just renames the main
allocation functions. Later patches in the series implement allocators
which take two size_t arguments (like calloc(3)) and check whether the
multiplication overflows by employing the __builtin_mul_overflow()
primitive supported by gcc and clang. This requires us to bump the
lowest supported gcc and clang version.
* refs/heads/t/overflow:
build: Compile with -ftrapv.
string: Introduce arr_zalloc().
string: Introduce arr_alloc().
string: Introduce arr_realloc() and check for integer overflow.
string: Rename para_calloc() -> zalloc().
string: Rename para_malloc() -> alloc().
string: Overhaul para_strdup().
|
| | | |
| | |
| | |
| | |
| | |
| | | |
Adjust all callers which pass a product of two integers to zalloc()
to call the new function instead and reduce zalloc() to a one-line
wrapper.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Change all callers of alloc() which pass a product of two integers as
the allocation size to call the new function instead. This function
aborts if the multiplication overflows. With arr_alloc() in place,
alloc() reduces to a trivial wrapper which calls new arr_alloc()
with the first argument equal to one.
|
| | | |
| | |
| | |
| | |
| | | |
Reword the documentation a bit since the function has never been a
wrapper for calloc(3). No code changes.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | | |
Just because it's shorter and matches the naming of the new allocators
we are about to introduce. The bulk of this patch was created with
sed -i 's/para_malloc/alloc/g' *.c *.h yy/mp.y
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The select(2) API is kind of obsolete because it does not work for
file descriptors greater or equal than 1024, The general advice is
to switch to poll(2), which offers equivalent functionality and does
not suffer from this restriction. This patch implements this switch.
The fd sets of select(2) have one nice feature: One can determine in
O(1) time whether the bit for a given fd is turned on in an fd set.
For poll(2), the monitored file descriptors are organized in an array
of struct pollfd. Without information about the given fd's index in the
pollfd array, one can only perform a linear search which requires O(n)
time, with n being the number of fds being watched. Since this would
have to be done for each fd, the running time becomes quadratic in
the number of monitored fds, which is bad. Keeping the pollfd array
sorted would reduce that to n * log(n) at the cost of additional work
at insert time.
This patch implements a different approach. The scheduler now maintains
an additional array of unsigned integers which map fds to indices
into the pollfd array. This new index array is transparent to the
individual tasks, which still simply pass one or more fds from their
->pre_monitor() method to the scheduler. The length of the index array
equals the highest fd given. This might become prohibitive in theory,
but should not be an issue for the time being.
Care needs to be taken in order to deal with callers which ask for
the readiness of an fd without having called sched_monitor_readfd() or
sched_monitor_writefd() in the ->pre_monitor() step. Before the patch,
thanks to the FD_ZERO() call at the beginning of each iteration of
the scheduler's main loop, both sched_read_ok() and sched_write_ok()
returned false for fds which were not asked to be watched. We need
to keep it this way for a seamless transition.
We achieve this by replacing the FD_ZERO() call by a memset(3) call
which fills the index array with 0xff bytes. Both sched_read_ok() and
sched_write_ok() call the new get_revents() helper, where we check the
fd argument against the allocation sizes of the two arrays. If either
function is called with an fd that was not asked to be monitored in
the ->pre_monitor() step, the checks notice that the index of this
fd, 0xffffffff, is larger than the highest open fd and we return
"not ready for I/O".
Another issue is the case where the same file descriptor is submitted
twice in ->pre_monitor() to check for readiness with respect to both
reading and writing. The code in client_comon.c currently does that.
To keep it working, the scheduler needs to detect this case and re-use
the existing slot in both arrays.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | | |
The word "monitor" is neutral and continues to be correct after the
switch from select(2) to poll(2).
Pure rename, nothing to see here.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This preparatory patch for replacing select() renames para_fd_set()
to sched_fd_set(), moves it to sched.c and makes it static. All
users are modified to call either of the two new public functions
sched_monitor_{read,write}fd() which take a pointer to struct sched
rather than an fd set pointer.
|
| | | |
| | |
| | |
| | |
| | | |
Two trivial wrappers for FD_ISSET() which hide the fact that we're
still using the select(2) API.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This modifies the public struct sched so that users pass in the
default timeout as an integer value in milliseconds rather than
a struct timeval. This simplifies the code a little and eases the
transition from select(2) to poll(2) because poll(2) also takes a
plain integer for the timeout.
Since para_select() of fd.c now calls ms2tv() to convert the timeout
back to a struct timeval, all executables which link with fd.o must
also link with time.o. This was not the case for para_mixer and
para_audioc, so configure.ac needs to be adjusted accordingly.
|
| |/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When para_play enters pause mode, playback is stopped by notifying
the writer node, causing it to terminate in the next iteration of the
main loop. Until then the play time is computed incorrectly because
we add the running time of the moribund writer node to the start time
computed from the *new* start chunk set in com_pause().
Fortunately, the fix is simple. We just need to enqueue a reposition
request in the same way the ff and jmp commands do.
|
| |/
|
|
|
|
|
| |
It's weird that this was not noticed for so long.
Fixes: e541d7bea7febed8cb9f8a65ae4bd9bdd1b5c8a0
Fixes: 3e3d8e1b48bbd8dbf46adf517c311b5e78dc820f
|
| |
|
|
|
|
|
|
|
|
| |
The EXPORT_PLAY_CMD_HANDLER() macro is only used when READLINE support
is enabled, which leads to
play.c:112: warning: macro "EXPORT_PLAY_CMD_HANDLER" is not used [-Wunused-macros]
Define the macro only when HAVE_READLINE is defined by moving down
the definition to the first user, com_quit().
|
| |
|
|
|
| |
Currently para_play won't save its history if this directory does
not exist. This patch makes it create the directory at startup.
|
| |\
| |
| |
| |
| |
| |
| |
| |
| |
| | |
A single patch which adds --end-of-playlist to control the behaviour
of para_play when the end of the playlist is reached.
Cooking for three weeks.
* refs/heads/t/para_play:
play: New option: --end-of-playlist.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
If the end of the playlist is reached, para_play starts over with the
first file of the playlist. This commit provides the --end-of-playlist
option to control the behaviour. The new option has three pre-defined
values: stop, loop, quit with "loop" being the default. Since lopsub
features multi-valued options, the implementation is pretty simple.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| | |
The previous patch removed the ->init() method of the afh receiver.
Since the afh receiver was the only receiver that defined an init
method, the method can now be removed from struct receiver.
As a consequence, recv_init(), which calls each receiver's init method
has become a no-op and can also be removed.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The audio_format_handler structure contains only pointers, and the
->init method of each instance initializes these pointers to constant
values. The ->init() method is thus useless at best, and it prevents
the structures from being declared constant.
This patch removes ->init() of struct audio_format_handler and the
public afh_init() which iterates over all audio formats to call each
->init() method. The audio format handlers are modified to define an
instance of the structure rather than an init function which fills the
fields of the given structure. The structure can be declared constant,
but not static because afh_common.c needs a way to refer to it.
We rely on weak symbols to deal with audio format handlers which are
not compiled in. The codec-independent code in afh_common.c defines
a weak instance of the audio_format_handler structure for each audio
format. The command handlers which are compiled in override the weak
symbol with their own definition.
The afh receiver used to define afh_init() as its (receiver!) init
function, which no longer exists. Since receiver init functions are
optional, we don't need to supply a replacement. However, play.c
calls ->init() of the afh_receiver unconditionally. This call needs
to be removed to avoid a null pointer dereference.
|
| |
|
|
|
|
|
|
| |
Besides parsing the command line options and the config file,
parse_config_or_die() also checks the key map arguments
syntactically. This check needs to be kept of course.
play.c already includes lsu.h because it calls lsu_com_help().
|
| |
|
|
|
| |
Most completers call the completion result pointer "cr", but some use
"result" instead. Let's be consistent and rename those to cr.
|
| |
|
|
|
|
|
| |
Also para_play benefits from the conversion to the generic
lsu_com_help(). After this patch, the three help commands of server,
audiod and play have the same syntax and their output is formatted
in the same way.
|