]> git.tuebingen.mpg.de Git - paraslash.git/log
paraslash.git
2 weeks agovss: Fix (harmless) memory leak. master
Andre Noll [Wed, 23 Jul 2025 16:25:16 +0000 (18:25 +0200)]
vss: Fix (harmless) memory leak.

Without the call to afh_close(), if an mp4 file is being streamed when a
server command is executed, valgrind reports many memory leaks such as this:

32,384 bytes in 1 blocks are still reachable in loss record 10 of 10
   at 0x4047BE2: realloc (vg_replace_malloc.c:1801)
   by 0x8052A99: arr_realloc (string.c:40)
   by 0x8052AC8: arr_alloc (string.c:61)
   by 0x8069CE7: read_stsz (mp4.c:244)
   by 0x8069CE7: parse_sub_atoms (mp4.c:563)
   by 0x806A3A6: parse_sub_atoms (mp4.c:575)
   by 0x806A3A6: parse_sub_atoms (mp4.c:575)
   by 0x806A3A6: parse_sub_atoms (mp4.c:575)
   by 0x806A3A6: parse_sub_atoms (mp4.c:575)
   by 0x806A524: open_file (mp4.c:622)
   by 0x806A5B0: mp4_open (mp4.c:669)
   by 0x8069593: aac_afh_open (aac_afh.c:69)
   by 0x804E7DF: afh_get_chunk (afh_common.c:249)

This only affects aac/mp4 because this is the only supported audio format
which employs dynamic chunks.

2 weeks agocompress: Make "clip" message less noisy.
Andre Noll [Thu, 17 Jul 2025 14:53:14 +0000 (16:53 +0200)]
compress: Make "clip" message less noisy.

It's perfectly normal for this message to happen, so log this with lower
severity.

2 weeks agoaft: Don't leak status_item_ls_data.path.
Andre Noll [Wed, 9 Jul 2025 21:33:47 +0000 (23:33 +0200)]
aft: Don't leak status_item_ls_data.path.

Currently we initialize this pointer variable by creating a copy of the memory
mapped osl object on the heap, and leak this copy on exit. We may avoid the
copy since we may as well look up the path again in make_status_items(). This
is cheap because we already know the row of the audio file table at this point.

2 weeks agoaft: Simplify make_inode_status_items().
Andre Noll [Sun, 6 Jul 2025 23:00:47 +0000 (01:00 +0200)]
aft: Simplify make_inode_status_items().

This function calls get_audio_file_path_of_row() although the path is already
known at this point. Moreover, since the function is called twice to produce
the human-readable and the parser-friendly status items, we perform identical
work in each call. We can easily avoid a system call by calling stat(2)
only once in the caller, The mtime string is also computed twice, so move
the computation into the caller as well.

2 weeks agocall_callback(): Fix error text.
Andre Noll [Mon, 28 Jul 2025 16:08:43 +0000 (18:08 +0200)]
call_callback(): Fix error text.

It was clearly intended to print the error text which corresponds to ret2
here because the function returns ret but discards the value of ret2 after
logging the error.

2 weeks agoModify para_hostname() to return a static buffer.
Andre Noll [Wed, 9 Jul 2025 23:54:11 +0000 (01:54 +0200)]
Modify para_hostname() to return a static buffer.

All but one caller immediately free the result after using it. The exception
is daemon.c, which maintains a copy in struct daemon, and leaks it on exit.

All users can trivially be converted to use the new version, which does not
require to free the result.

2 weeks agoaudiod: Free status items on exit.
Andre Noll [Wed, 9 Jul 2025 23:38:01 +0000 (01:38 +0200)]
audiod: Free status items on exit.

In close_stat_pipe() we call clear_and_dump_items(), then dump the
status items again for no good reason. Rename clear_and_dump_items() to
clear_status_items(), stop dumping items there, and call the new function
also from audiod_cleanup() to avoid the memory leaks at exit.

2 weeks agoaudiod: Free receiver/filter/writer configurations.
Andre Noll [Wed, 9 Jul 2025 23:18:59 +0000 (01:18 +0200)]
audiod: Free receiver/filter/writer configurations.

We allocate a bunch of arrays, configurations and lopsub parse results.
Teach audiod_cleanup() to free those to avoid memory leaks on exit.

2 weeks agoaudiod: Fix a trivial memory leak at exit.
Andre Noll [Wed, 9 Jul 2025 22:34:35 +0000 (00:34 +0200)]
audiod: Fix a trivial memory leak at exit.

The buffer for the socket name is allocated on the heap at startup and
never freed.

2 weeks agoopenssl: Fix a memory leak.
Andre Noll [Wed, 9 Jul 2025 22:34:24 +0000 (00:34 +0200)]
openssl: Fix a memory leak.

This leak happens only with openssl-1.1, where we call RSA_free() which does
not free the coefficient for the Chinese remainder theorem we extracted from
the key file.

3 weeks agofec: Don't oversize gf_exp[].
Andre Noll [Tue, 8 Jul 2025 19:00:32 +0000 (21:00 +0200)]
fec: Don't oversize gf_exp[].

Apart from the initialization code, there is only one user of the Galois
field exponential table. This user passes a value modulo GF_SIZE, so we
never access the second half of the array.

5 weeks agoserver: Allocate the scheduler structure after calling afs_init().
Andre Noll [Mon, 30 Jun 2025 18:27:11 +0000 (20:27 +0200)]
server: Allocate the scheduler structure after calling afs_init().

Since the audio file selector allocates its own scheduler instance, we
currently allocate two instances and free only one. Avoid this memory leak
by delaying the allocation until after the afs process is born.

The latest possible point to allocate the scheduler instance is in
server_init(), just before the signal task is initialized, so move the call
to sched_new() there. Since that passes a pointer to server_poll() and this
function calls status_refresh() we have to move those two functions up.

5 weeks agoserver: Kill global variable sched.
Andre Noll [Mon, 2 Jun 2025 18:10:54 +0000 (20:10 +0200)]
server: Kill global variable sched.

Make it local to main() and pass the pointer to the few functions that need it.

5 weeks agoMake struct sched private, introduce sched_new().
Andre Noll [Tue, 10 Jun 2025 14:06:03 +0000 (16:06 +0200)]
Make struct sched private, introduce sched_new().

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.

5 weeks agoerror.h: Remove some macros.
Andre Noll [Sun, 29 Jun 2025 17:55:16 +0000 (19:55 +0200)]
error.h: Remove some macros.

Each is only used once in the same file, and they are all rather obvious,
so open-code them.

The exception is ERRNO_TO_PARA_ERROR() which is used pervasively, so
leave this macro unmodified.

5 weeks agoKill OSL_ERRNO_TO_PARA_ERROR.
Andre Noll [Sun, 29 Jun 2025 17:47:30 +0000 (19:47 +0200)]
Kill OSL_ERRNO_TO_PARA_ERROR.

The users outside of error.h may as well call osl(), which leaves only
a single caller in error.h. Open-code the macro there and remove it.

5 weeks agobtr: Fix buffer tree merging.
Andre Noll [Tue, 8 Jul 2025 20:28:24 +0000 (22:28 +0200)]
btr: Fix buffer tree merging.

The merge case of add_btrb_to_children() is rather broken. For one, if
the node has more than one child and we end up freeing the btr buffer in
the first iteration, we read stale contents when calling may_merge_btrb()
in the next iteration of the loop.

Secondly, not all callers of add_btrb_to_children() cope with btrb being
freed after merging occurred. In particular, the alsa writer triggers an
invalid read such as:

at 0x804C7AC: btr_drop_buffer_reference (buffer_tree.c:351)
by 0x804CD4A: btr_pushdown_br (buffer_tree.c:520)
by 0x804CD4A: btr_pushdown (buffer_tree.c:539)
by 0x804D948: check_wav_post_monitor (check_wav.c:194)
by 0x804C31B: call_post_monitor (sched.c:118)
by 0x804C31B: sched_post_monitor (sched.c:144)
by 0x804C31B: schedule (sched.c:184)
by 0x804A9CE: setup_and_schedule (write.c:97)
by 0x804A9CE: main (write.c:149)

The problem is that btr_pushdown_br() calls add_btrb_to_children(), followed
by btr_drop_buffer_reference(). The first function frees br->btrb in the
may-merge case and the second function reads from this pointer.

This patch addresses both issues. It renames may_merge_btrb() to
try_merge_btrb(), checks more carefully if a merge is possible, and performs
the merge. This function needs to return whether the buffer was merged because
the callers have to clean up in different ways depending on whether or not
buffers were merged.

This retains the nice speedup of f64cbcc03484 at the cost of even more
complicated buffer tree code.

Reproducer (must run on a slow machine or under valgrind to trigger):

para sender udp add 224.0.1.38:8000
para_recv -r udp > fec-encoded-data
./para_filter -f fecdec -f mp3dec < fec-encoded-data | ./para_write

Fixes: f64cbcc034844628b7e7817e27205cc6b48e9a18
5 weeks agoaudiod: Remove buffer tree node of status task on errors.
Andre Noll [Wed, 9 Jul 2025 23:45:44 +0000 (01:45 +0200)]
audiod: Remove buffer tree node of status task on errors.

This is a real memory leak since due to the missing call to btr_remove_node()
we leak one buffer tree node each time we reconnect to the server.

6 weeks agofilter.c: Remove pointless variable and assignment.
Andre Noll [Tue, 8 Jul 2025 19:39:11 +0000 (21:39 +0200)]
filter.c: Remove pointless variable and assignment.

6 weeks agowrite.c: Make stdin task variable local.
Andre Noll [Tue, 8 Jul 2025 20:53:58 +0000 (22:53 +0200)]
write.c: Make stdin task variable local.

The variable is not used outside of setup_and_schedule(), so there is no
reason for it to be global.

6 weeks agoFix (benign) memory leak at exit in para_filter.
Andre Noll [Tue, 8 Jul 2025 19:37:04 +0000 (21:37 +0200)]
Fix (benign) memory leak at exit in para_filter.

We missed to free the filter-specific lopsub parse result.

6 weeks agostdin: Only read from stdin if fd 0 is ready.
Andre Noll [Wed, 9 Jul 2025 15:23:52 +0000 (17:23 +0200)]
stdin: Only read from stdin if fd 0 is ready.

If fd 0 refers to a tty, this file descriptor is blocking. So make sure we
don't read unless we know that the read operation won't block.

6 weeks agoaft: Reload afhi before creating the status items.
Andre Noll [Sun, 6 Jul 2025 22:27:48 +0000 (00:27 +0200)]
aft: Reload afhi before creating the status items.

make_status_items() accesses the audio format handler information via
status_item_ls_data.afhi, which was set when the current audio file was
loaded. However, the pointers of the ahfi structure might have become stale
if the server reloads the afs tables in between, for example when SIGHUP
was received. This may lead to a crash or worse.

6 weeks agoaft: Improve error path of open_and_update_audio_file().
Andre Noll [Sun, 6 Jul 2025 21:20:16 +0000 (23:20 +0200)]
aft: Improve error path of open_and_update_audio_file().

On errors that occur after status_item_ls_data->path has been initialized, we
return without setting ->path to NULL. This is bad because a subsequent event
could call make_status_items(), which then proceeds using the invalid path.

This commit adds a few labels to improve the error handling and to clean
up properly in all cases. A side effect of this change is that on certain
errors where we used to fail we now continue, trying the next best file as
long as there are entries left in the score table.

6 weeks agoaft.c: Shorten comment on memory-mapped files.
Andre Noll [Tue, 8 Jul 2025 17:29:09 +0000 (19:29 +0200)]
aft.c: Shorten comment on memory-mapped files.

There is no reason to go into this much detail.

6 weeks agoImprove documentation of para_printf().
Andre Noll [Mon, 7 Jul 2025 20:31:34 +0000 (22:31 +0200)]
Improve documentation of para_printf().

This was quite hard to read due to the many \a directives. Remove those
and improve the wording.

6 weeks agoImprove error diagnostics of add server command.
Andre Noll [Mon, 30 Jun 2025 17:46:14 +0000 (19:46 +0200)]
Improve error diagnostics of add server command.

If a file whose path does not match any known ending is attempted to be
added, we silently ignore the file even if --verbose is given. This happens
for example, if the audio format handler for the given file was not compiled
in. Make this case more obvious by sending a message if --verbose is given.

7 weeks agomood: Don't abort the check if an empty mood exists.
Andre Noll [Mon, 16 Jun 2025 19:36:19 +0000 (21:36 +0200)]
mood: Don't abort the check if an empty mood exists.

It's perfectly valid to define a mood whose definition is empty. Nevertheless,
the osl loop callback mood_get_name_and_def_by_row(), which is called by the
check subcommand, returns an error in this case because it cannot map the
empty file. This terminates the osl loop and results in a rather cryptic
error about loop termination. To improve on this, detect this case, print
a more decent message, and continue the loop.

Empty playlists were handled correctly, but the name of the empty playlist
was not shown in the message. Fix this as well.

7 weeks agoaft: Avoid unnecessary allocation of current hash buffer.
Andre Noll [Sat, 14 Jun 2025 17:03:59 +0000 (19:03 +0200)]
aft: Avoid unnecessary allocation of current hash buffer.

Currently we allocate the hash pointer of the global status_item_ls_data
structure once at first use. We can avoid the allocation by having it point
to the global current_hash[]. This way it always contains an up-to-date value,
so we no longer need to re-lookup the hash in aft_close().

7 weeks agoSpeed up blob operations.
Andre Noll [Sun, 11 May 2025 20:07:27 +0000 (22:07 +0200)]
Speed up blob operations.

The current status items are unaffected by any blob operations, so this code
is completely unnecessary.

7 weeks agoMerge topic branch t/deprecate_setatt into master
Andre Noll [Sun, 29 Jun 2025 15:45:43 +0000 (17:45 +0200)]
Merge topic branch t/deprecate_setatt into master

A single patch which deprecates the setatt server subcommand. This subcommand
fails, for example, if the name of an audio file happens to end in '+' or
'-'. The replacement for setatt is the touch subcommand, which gained two
options to set or unset attributes.

* refs/heads/t/deprecate_setatt:
  server: Deprecate setatt in favor of touch.

8 weeks agovss: Make vss_chunk_time() static.
Andre Noll [Sun, 15 Jun 2025 20:58:30 +0000 (22:58 +0200)]
vss: Make vss_chunk_time() static.

It's only called from vss.c.

8 weeks agoweb: Kill horizontal line at the bottom of each page.
Andre Noll [Sun, 15 Jun 2025 20:24:05 +0000 (22:24 +0200)]
web: Kill horizontal line at the bottom of each page.

It serves no purpose.

8 weeks agoRemove ->execute() of struct writer.
Andre Noll [Sun, 15 Jun 2025 19:03:12 +0000 (21:03 +0200)]
Remove ->execute() of struct writer.

No writer implements this method.

2 months agosched.h: Remove an unnecessary declaration.
Andre Noll [Mon, 2 Jun 2025 22:58:25 +0000 (00:58 +0200)]
sched.h: Remove an unnecessary declaration.

This incomplete declaration is not needed because the first use of struct
task is the declaration of task_register() further down in the file. This
function returns a pointer to struct task, and this works as an incomplete
declaration as well.

2 months agovss: Make vss_next() and vss_repos() static.
Andre Noll [Sun, 8 Jun 2025 21:18:22 +0000 (23:18 +0200)]
vss: Make vss_next() and vss_repos() static.

Unlike vss_playing(), vss_paused() and vss_stopped(), these are only called
from within vss.c.

2 months agovss: Change vss_playing() and friends to return bool.
Andre Noll [Sun, 8 Jun 2025 21:12:23 +0000 (23:12 +0200)]
vss: Change vss_playing() and friends to return bool.

All users are in boolean contexts.

2 months agosend_common.c does not need afs.h.
Andre Noll [Wed, 11 Jun 2025 17:12:15 +0000 (19:12 +0200)]
send_common.c does not need afs.h.

Sometimes it only takes 17 years to get a bug fixed. Well, it's not really
a bug, but it does trigger a needless recompilation when afs.h changes.

Fixes: 2abba90245f87fab096edfc3faf7df61646b713f
2 months agoMerge topic branch t/completion into master
Andre Noll [Sat, 14 Jun 2025 16:48:21 +0000 (18:48 +0200)]
Merge topic branch t/completion into master

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

2 months agoMove FOR_EACH_RECEIVER from recv.h to recv_common.c.
Andre Noll [Wed, 11 Jun 2025 19:04:48 +0000 (21:04 +0200)]
Move FOR_EACH_RECEIVER from recv.h to recv_common.c.

It called twice from there but from nowhere else.

2 months agowma: Use unsigned byte arrays.
Andre Noll [Mon, 2 Jun 2025 20:08:10 +0000 (22:08 +0200)]
wma: Use unsigned byte arrays.

They get initialized with values which cause an overflow on systems where
char is signed.

2 months agoserver: Delay vss shutdown in command handler context.
Andre Noll [Mon, 9 Jun 2025 19:23:59 +0000 (21:23 +0200)]
server: Delay vss shutdown in command handler context.

The sender status subcommand invoked via ->handle_connect() accesses memory
that has been freed in vss_shutdown(), resulting in garbage output. This
use-after-free bug is correctly reported by valgrind. It can easily be fixed
by moving the vss_shutdown() call down.

Fixes: 018a7b7927b76044b28eece39039cb2f5ea9c192
2 months agoi9e: Constify completer arrays.
Andre Noll [Mon, 2 Jun 2025 21:25:47 +0000 (23:25 +0200)]
i9e: Constify completer arrays.

This way the array of completers goes into the rodata section.

2 months agoPrefer __func__ to __FUNCTION__.
Andre Noll [Mon, 2 Jun 2025 20:48:41 +0000 (22:48 +0200)]
Prefer __func__ to __FUNCTION__.

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

2 months agoimdct: Kill fftsample_t typedef.
Andre Noll [Mon, 2 Jun 2025 19:45:34 +0000 (21:45 +0200)]
imdct: Kill fftsample_t typedef.

There is no advantage in not using plain float here.

2 months agoDoxgen: Do not omit brief descriptions.
Andre Noll [Mon, 2 Jun 2025 22:36:31 +0000 (00:36 +0200)]
Doxgen: Do not omit brief descriptions.

Commit 3107d2411a7a was a bit overzealous because with BRIEF_MEMBER_DESC
and REPEAT_BRIEF both set to NO the short text does not even make it into
the detailed description. This was unintended, so partially revert this change.

Fixes: 3107d2411a7a8f4085d0db65851483f2cb3c4f6e
2 months agofd: Modify xwrite() and write_all() to take void * buffer argument.
Andre Noll [Mon, 2 Jun 2025 21:34:21 +0000 (23:34 +0200)]
fd: Modify xwrite() and write_all() to take void * buffer argument.

That's what the underlying call to writev(2) expects.

2 months agoMerge topic branch t/wmadec into master
Andre Noll [Mon, 2 Jun 2025 19:42:21 +0000 (21:42 +0200)]
Merge topic branch t/wmadec into master

A few patches which remove unused code from the wma decoder and audio
format handler. Notably, noise coding was removed completely since
it was only used for unusual bit rates. Most likely, it never worked
in the first place.

* refs/heads/t/wmadec:
  wmadec: Fix typo in comment.
  wmadec: Remove a stale comment in wma_init().
  wmadec: Kill pointless start/end computations.
  wmadec: Remove noise coding.
  wmadec: Simplify wma_init().
  wmadec: Remove fft().

2 months agonet.c: Convert SS_IS_ADDR_V4MAPPED() to lower case.
Andre Noll [Sat, 31 May 2025 17:30:31 +0000 (19:30 +0200)]
net.c: Convert SS_IS_ADDR_V4MAPPED() to lower case.

It's not a macro, after all. Remove the superfluous braces and fix
a whitespace issue while at it.

2 months agoShrink struct rmatt_event_data.
Andre Noll [Mon, 26 May 2025 18:38:37 +0000 (20:38 +0200)]
Shrink struct rmatt_event_data.

The aft event handler needs to know the bit number of the attribute which is
being removed in order to clear the bit in the afs info structure of each row
of the audio file table. The handler does not need to know the attribute's
name, though, and remove_attribute() already prints it, so remove this field
from the event data structure.

2 months agofilter.c: Constify dummy variable.
Andre Noll [Tue, 27 May 2025 19:19:30 +0000 (21:19 +0200)]
filter.c: Constify dummy variable.

It needs to be non-static, but it may be const because the amp filter
only reads the values of this array.

2 months agofilter.c: Remove unused status_item_list[].
Andre Noll [Tue, 27 May 2025 19:15:51 +0000 (21:15 +0200)]
filter.c: Remove unused status_item_list[].

para_filter does not need this at all, and never has, afaict.

2 months agoaudiod.c: Make slots[] static.
Andre Noll [Tue, 27 May 2025 23:28:02 +0000 (01:28 +0200)]
audiod.c: Make slots[] static.

It's only used in audiod.c.

2 months agoserver.c: Remove unused server_get_tasks().
Andre Noll [Tue, 27 May 2025 21:51:40 +0000 (23:51 +0200)]
server.c: Remove unused server_get_tasks().

The last caller was removed when the tasks server subcommand was disabled
eight years ago.

Fixes: bb91597b9ecf650a63a40753f7f7c771576d252e
2 months agoMerge topic branch t/select- into master
Andre Noll [Mon, 26 May 2025 16:00:34 +0000 (18:00 +0200)]
Merge topic branch t/select- into master

A single patch which implements the new "select -" feature to switch
back to the previous mood or playlist.

* refs/heads/t/select-:
  com_select(): Support '-' to reactivate the previous mood/playlist.

2 months agocss: Remove memItem tweaks.
Andre Noll [Sun, 25 May 2025 20:35:27 +0000 (22:35 +0200)]
css: Remove memItem tweaks.

The pages look better without this since the tables no longer contain
horizontal lines above all entities.

2 months agocss: Fix a typo in comment.
Andre Noll [Sun, 25 May 2025 17:56:47 +0000 (19:56 +0200)]
css: Fix a typo in comment.

2 months agofec.c: Remove an unused #include.
Andre Noll [Sun, 25 May 2025 17:45:58 +0000 (19:45 +0200)]
fec.c: Remove an unused #include.

The fec code does not need the helpers from portable_io.h.

2 months agoMove public key to web/.
Andre Noll [Sun, 25 May 2025 17:33:36 +0000 (19:33 +0200)]
Move public key to web/.

It's only needed for the web pages, so it should not be contained in the
top-level directory.

2 months agoINSTALL: Remove installation instructions of lopsub.
Andre Noll [Sun, 25 May 2025 17:29:57 +0000 (19:29 +0200)]
INSTALL: Remove installation instructions of lopsub.

These days, people should just install the Debian package. If lopsub is not
installed, the configure script prints detailed instructions about how to
obtain lopsub with and without apt.

2 months agohttp sender: Kill pointless macro.
Andre Noll [Sun, 25 May 2025 17:18:42 +0000 (19:18 +0200)]
http sender: Kill pointless macro.

The code is shorter and easier to read without the macro.

2 months agoIntroduce VSS_NEW_AUDIO_FILE to fix playlist updates.
Andre Noll [Wed, 19 Mar 2025 21:05:16 +0000 (22:05 +0100)]
Introduce VSS_NEW_AUDIO_FILE to fix playlist updates.

The playlist event handler handles afsi change events by moving the affected
entry to the end of the playlist. This is the right thing to do if the
event was triggered by virtual streaming system streaming a new file. It is
incorrect, however, if the event was triggered by a subcommand such as touch.

This commit introduces the new afs event type VSS_NEW_AUDIO_FILE to distinguish
between the two different use cases. The audio file table event handler
ignores the VSS_NEW_AUDIO_FILE event while the playlist event handler ignores
the AFSI_CHANGE event. The moods event handler treats both events equally,

Get rid of a pointless static one-liner function in playlist.c while at it.

3 months agoaft: Pass correct afsi argument to AFSI_CHANGE event handlers.
Andre Noll [Wed, 14 May 2025 22:27:47 +0000 (00:27 +0200)]
aft: Pass correct afsi argument to AFSI_CHANGE event handlers.

Each time a new audio file is opened for streaming, we update the numplayed
and lastplayed fields of its afs info entry of the audio file table, then
update the global afsi and ahfi structures, then trigger an AFSI_CHANGE event,
which calls all table event handlers. The event handlers receive as arguments
a pointer to the old afsi and a pointer to the already modified aft row.

The AFSI_CHANGE event handler of the audio file table gets called in the
situation described above, and also via the touch and cpsi subcommands,
because these also change the afsi info structure and therefore trigger
AFSI_CHANGE events as well. The handler checks whether the affected audio
file is the current audio file, and if it is, extracts the modified afsi
from the audio file table into the global afsi structure.

The problem is that in case of the above "next audio file" scenario, the
old afsi pointer points to the global afsi structure, which gets updated
by the aft event handler. Therefore the event handlers which happen to run
after the event handler of the audio file table see the already updated afsi
through the old_afsi pointer.

Since the audio file table happens to be the first table of the 7-element
afs_tables[] array iterated by afs_event(), all six other event handlers see
the incorrect afsi. However, only the moods event handler looks at the old afsi
to update the mean and quadratic variation of the lastplayed and numplayed
values of the afs statistics. Due to the bug described above, the old and
new lastplayed and numplayed values coincide, and therefore the statistics
update is a no-op. In practice, at least for moods with many admissible files,
the values will only be slightly off, so the bug is rather benign.

Fix this by renaming the on-stack new_afsi to old_afsi, adjusting
initializations accordingly, and passing a pointer to this instance instead.

3 months agoImprove documentation of set_max_chunk_size().
Andre Noll [Wed, 21 May 2025 18:36:52 +0000 (20:36 +0200)]
Improve documentation of set_max_chunk_size().

The old text implied that the function could be removed at some point, which
is not the case. Remove this part of the documentation and clarify what the
function actually does.

3 months agoWarn about old (0.5.x or earlier) on-disk afhi.
Andre Noll [Wed, 21 May 2025 18:23:23 +0000 (20:23 +0200)]
Warn about old (0.5.x or earlier) on-disk afhi.

Nine years ago, starting with commit 234647bb5, old on-disk entries are
reported with a notice to re-add the file in order to update the audio file
table. Bump the loglevel for now, and add a comment to turn the check into
a hard error eventually.

3 months agodoxyen: Completely suppress brief descriptions.
Andre Noll [Wed, 21 May 2025 18:03:54 +0000 (20:03 +0200)]
doxyen: Completely suppress brief descriptions.

This shortens the doxygen pages, removing lots of pointless duplications.

3 months agobuffer_tree: Assert that we don't pass NULL to memcpy().
Andre Noll [Tue, 20 May 2025 20:47:46 +0000 (22:47 +0200)]
buffer_tree: Assert that we don't pass NULL to memcpy().

The buffer pointer cannot be NULL here because this only happens when the
buffer tree area is full, which is not the case thanks to the previous n <=
btr_pool_unused(btrp) check.

3 months agomp.c: Remove a dead store.
Andre Noll [Tue, 20 May 2025 20:13:54 +0000 (22:13 +0200)]
mp.c: Remove a dead store.

Found by the clang analyzer.

3 months agowmadec: Fix typo in comment.
Andre Noll [Wed, 21 May 2025 19:38:26 +0000 (21:38 +0200)]
wmadec: Fix typo in comment.

3 months agowmadec: Remove a stale comment in wma_init().
Andre Noll [Wed, 21 May 2025 19:03:02 +0000 (21:03 +0200)]
wmadec: Remove a stale comment in wma_init().

Noise coding has been removed.

Fixes: 9fe8a674535a00c6011f86b4ece3344200d00aa2
3 months agomood.c: Remove a dead store and fix the documentation of mood_load().
Andre Noll [Tue, 20 May 2025 20:10:31 +0000 (22:10 +0200)]
mood.c: Remove a dead store and fix the documentation of mood_load().

The function returns 1 on success, not the number of admissible files.

Found by the clang analyzer.

3 months agoflac_afh: Check for possible integer overflows.
Andre Noll [Tue, 20 May 2025 18:56:36 +0000 (20:56 +0200)]
flac_afh: Check for possible integer overflows.

This is a callback function which should carefully check its inputs.

3 months agogcc-compat.h: Drop inline #define.
Andre Noll [Tue, 20 May 2025 18:00:50 +0000 (20:00 +0200)]
gcc-compat.h: Drop inline #define.

There is no reason to believe that the programmer does a better job than
the compiler here.

3 months agowmadec: Kill pointless start/end computations.
Andre Noll [Tue, 20 May 2025 20:58:13 +0000 (22:58 +0200)]
wmadec: Kill pointless start/end computations.

Neither start nor end are used. The loop simply adds up the entries of one
line of the exponent_bands matrix.

Found by the clang analyzer.

3 months agoplay.c: Kill pointless typedef.
Andre Noll [Sun, 18 May 2025 19:40:31 +0000 (21:40 +0200)]
play.c: Kill pointless typedef.

The signature of the function pointer is too simple to warrant a typedef.

3 months agoafs.h: Omit superfluous semicolons.
Andre Noll [Sun, 18 May 2025 20:42:00 +0000 (22:42 +0200)]
afs.h: Omit superfluous semicolons.

The DECLARE_BLOB_SYMBOLS macro expands to a bunch of declarations, each of
which is terminated by a semicolon. So don't add another one.

3 months agoMakefile: Drop redundant -Wuninitialized.
Andre Noll [Sun, 18 May 2025 20:26:15 +0000 (22:26 +0200)]
Makefile: Drop redundant -Wuninitialized.

It is implied by -Wextra, which is the same as -W, but more descriptive.

3 months agoMerge topic branch t/build into master
Andre Noll [Tue, 20 May 2025 19:33:04 +0000 (21:33 +0200)]
Merge topic branch t/build into master

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}.

3 months agoserver: Deprecate setatt in favor of touch.
Andre Noll [Sun, 16 Mar 2025 23:15:40 +0000 (00:15 +0100)]
server: Deprecate setatt in favor of touch.

This adds --set-attribute and --unset-attribute to the touch subcommand,
re-implementing the features of the setatt command with a saner syntax.

We augment the change_atts_data structure using pre-computed values for
verbose and dry-run mode and pass a pointer to this structure rather than
the general callback arg pointer. The existing setatt subcommand neither
sets nor consults the two new booleans.

The touch completer of para_client is updated to complete the two new options,
executing the lsatt subcommand to get the attribute names. The manual and
the test suite also need minor adjustments.

3 months agoInclude regex.h from para.h.
Andre Noll [Sun, 18 May 2025 20:05:45 +0000 (22:05 +0200)]
Include regex.h from para.h.

Every .c file includes it anyway.

3 months agoRevamp bash_completion.
Andre Noll [Sat, 19 Apr 2025 11:39:26 +0000 (13:39 +0200)]
Revamp bash_completion.

This rewrite of the bash_completion script improves completion for the
para_client and para_audioc commands significantly.

One flaw which is fixed by this patch is related to the fact that by default
readline creates COMP_WORDS by splitting at characters that separate a shell
command, including "=", but for paraslash commands we only want to split at
spaces. So we modify the completer to return the special code 124 to instruct
readline to try split again with space as the only delimiter.

3 months agobash completion: Fix help option parsing.
Andre Noll [Sat, 3 May 2025 18:07:34 +0000 (20:07 +0200)]
bash completion: Fix help option parsing.

If we complete on para_client or para_audioc options rather than on server
or audiod subcommands, we parse the --help output to determine the options to
complete on. The regular expression we currently use for that is too lenient
because it also matches the options in the synopsis section of the help output.

Fix this by prefixing the expression with '^' to extract only the options
of the subsequent help text.

3 months agoaudioc: Fix option completion of version and stat.
Andre Noll [Sun, 4 May 2025 00:35:49 +0000 (02:35 +0200)]
audioc: Fix option completion of version and stat.

If the current word starts with a dash, we should always complete on options,
regardless of the word number.

3 months agoi9e: Introduce i9e_get_nonopt_argnum().
Andre Noll [Mon, 28 Apr 2025 14:37:14 +0000 (16:37 +0200)]
i9e: Introduce i9e_get_nonopt_argnum().

Call the new function from various subcommand completers to attempt completion
only on the first or the first two non-option arguments.

3 months agoi9e: Introduce i9e_cword_is_option_arg().
Andre Noll [Sun, 6 Apr 2025 20:14:43 +0000 (22:14 +0200)]
i9e: Introduce i9e_cword_is_option_arg().

Call the new function to complete --admissible, --sort and --listing-mode of
the ls subcommand and teach the touch completer to prevent filename completion
if a numerical argument is expected. The grab subcommand of para_audiod
also benefits from the new helper: para_audioc learned to complete the three
different grab modes.

Since --admissible expects a mood or playlist argument, factor out the code
from the select completer which returns the list of all moods and playlists
so that it can be called by the ls completer as well.

3 months agoi9e: Constify i9e_complete_option().
Andre Noll [Sun, 6 Apr 2025 17:30:53 +0000 (19:30 +0200)]
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.

3 months agodoxygen: Don't show includes.
Andre Noll [Fri, 16 May 2025 20:36:35 +0000 (22:36 +0200)]
doxygen: Don't show includes.

They use a lot of space and don't help much to understand the API or code.

3 months agoload_afd(): Double check shared memory sizes.
Andre Noll [Mon, 5 May 2025 21:52:42 +0000 (23:52 +0200)]
load_afd(): Double check shared memory sizes.

The shared memory ID is sent by a trusted source, so it is a programming error
(rather than a runtime error that could be handled) if the size of the shared
memory area is smaller than the size of an audio file data structure. Thus,
the right thing to do is to abort immediately in this case.

3 months agoabout: Mention that paraslash works without internet access.
Andre Noll [Sat, 3 May 2025 15:17:58 +0000 (17:17 +0200)]
about: Mention that paraslash works without internet access.

It's a noteworthy feature if software works without relying on third-party
internet services.

3 months agomp3_afh: Kill FOR_EACH_FIELD().
Andre Noll [Tue, 13 May 2025 21:44:41 +0000 (23:44 +0200)]
mp3_afh: Kill FOR_EACH_FIELD().

The macro has only one user. Open-code it to shorten the code and improve
readability.

3 months agomp3_afh: Document id3_field_init() and id3_field_finish().
Andre Noll [Mon, 28 Apr 2025 22:03:26 +0000 (00:03 +0200)]
mp3_afh: Document id3_field_init() and id3_field_finish().

These functions are somewhat obscure because they are not part of the
libid3tag API. They are not part of the internal paraslash API either,
so their documentation should not be shown on the API page. Exclude the
documentation with the doxygen \cond and \endcond markers.

3 months agoaft.c: Remove unused enum touch_flags.
Andre Noll [Sun, 4 May 2025 21:19:26 +0000 (23:19 +0200)]
aft.c: Remove unused enum touch_flags.

This enum became unused ten years ago when the touch command learned to use
the lopsub library.

Fixes: fdf416e9af730a1df9eec8d7acb108d7ca881926
3 months agoserver: Add missing non-opts name to help text.
Andre Noll [Mon, 5 May 2025 23:39:54 +0000 (01:39 +0200)]
server: Add missing non-opts name to help text.

3 months agoblob: Get rid of the two dummy event handlers.
Andre Noll [Sun, 23 Mar 2025 20:53:15 +0000 (21:53 +0100)]
blob: Get rid of the two dummy event handlers.

The four blob operation structures defined in blob.c are created by
a macro which initializes the function pointer for the event handler
to ${name}_event_handler, where $name is the blob type, i.e. one of
images, lyrics, moods, playlists.

Only two of the four, moods and playlists, need an event handler
because the images and lyrics tables ignore events. Currently we
have to define dummy functions {images,lyrics}_event_handler() to
avoid link errors. This extra code can easily be avoided by making
the macros a little smarter.

3 months agoCheck return value of lsu_com_help().
Andre Noll [Tue, 18 Mar 2025 18:31:33 +0000 (19:31 +0100)]
Check return value of lsu_com_help().

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.

3 months agoafs.c: Improve documentation.
Andre Noll [Mon, 24 Mar 2025 00:31:59 +0000 (01:31 +0100)]
afs.c: Improve documentation.

Add an overview of the file and expand the description of
open_next_audio_file() and afs_init().

3 months agowmadec: Remove noise coding.
Andre Noll [Tue, 7 Jan 2025 23:09:21 +0000 (00:09 +0100)]
wmadec: Remove noise coding.

It is not used anyway in most cases, and it complicates the code
considerably.

3 months agowmadec: Simplify wma_init().
Andre Noll [Tue, 7 Jan 2025 22:27:35 +0000 (23:27 +0100)]
wmadec: Simplify wma_init().

This equivalent transformation saves a few lines and one level of
indentation.

3 months agowmadec: Remove fft().
Andre Noll [Fri, 27 Dec 2024 17:38:01 +0000 (18:38 +0100)]
wmadec: Remove fft().

It has only one caller, imdct_half(), so get rid of the trivial
function. Dedox the static imdct_half() while at it.

4 months agoclient: Fix completion for the select subcommand.
Andre Noll [Mon, 7 Apr 2025 11:07:13 +0000 (13:07 +0200)]
client: Fix completion for the select subcommand.

We missed to complete the -v option that was added recently.

Fixes: 1f31fcdd74ab1aab01cbc70942f9d69bb779156a