Andre Noll [Wed, 11 Aug 2021 19:37:16 +0000 (21:37 +0200)]
mp4: Hide ->read_error.
This does not belong into the callback structure whose fields are
supposed to get initialized by the audio format handler. Move it to
the internal struct mp4 instead, next to the existing error counter.
Andre Noll [Wed, 11 Aug 2021 17:26:00 +0000 (19:26 +0200)]
mp4: Don't parse the esds atom any more.
With the decoder specific config no longer in use, we can simplify
mp4.c further by getting rid of some cryptic and underdocumented code
which no longer does anything useful for us.
Andre Noll [Wed, 11 Aug 2021 17:12:07 +0000 (19:12 +0200)]
mp4: Introduce mp4_is_audio_track().
Currently the aac audio format handler iterates over the tracks
in an mp4 file. For each track it tries to get the audio-specific
configuration by calling mp4_get_decoder_config() and calls into faad
to check whether it is a valid configuration for the aac decoder.
We can simplify all this because the mp4 code already knows the type
of each track, albeit it does not expose this information yet. So
provide the new mp4_is_audio_track() helper and let the aac audio
format handler pick the first track for which this helper returns true.
As an additional benefit, we can remove the now unused
mp4_get_decoder_config().
The old name is misleading because the returned file handle is by no
means opened read-only. In fact we call mp4ff_meta_update() on it,
which alters the file to store the modified metadata.
Andre Noll [Wed, 11 Aug 2021 13:41:37 +0000 (15:41 +0200)]
mp4: Introduce mp4ff_get_duration().
This allows us to get rid of an ugly hack in aac_afh.c where we peeked
at the audio-specific config structure to get the scaling factor which
was needed to compute the duration.
Andre Noll [Tue, 10 Aug 2021 16:57:42 +0000 (18:57 +0200)]
mp4: Remove const qualifier from non-pointer function arguments.
In contrast to the pointer case, it's generally not very interesting
to know whether a function will modify the automatic variable which
corresponds to a non-pointer argument.
Andre Noll [Mon, 9 Aug 2021 22:14:53 +0000 (00:14 +0200)]
mp4: Reduce indentation of create_ilst().
This function contained an indented block for no good reason. No real
change except that a few variables are exposed to the code below the
former block, but this is not a problem.
Andre Noll [Mon, 9 Aug 2021 21:13:35 +0000 (23:13 +0200)]
mp4: Use read/write functions from portable_io.h.
This removes quite a bit of ugly code. In particular, atom_get_size()
is completely unnecessary and can be removed. Since there is no
function in portable_io.h to read a 24 bit integer, we have to add
read_u24_be().
Andre Noll [Mon, 9 Aug 2021 18:27:28 +0000 (20:27 +0200)]
mp4: Further reduce the indentation of mp4ff_parse_tag().
Handle the easy cases first. Again, this patch looks unreviewable,
but it in essence it is only one large block that is shifted to the
left with no other changes.
Andre Noll [Mon, 9 Aug 2021 18:05:10 +0000 (20:05 +0200)]
mp4: Use para_strdup().
Like malloc(), strdup() may fail. The current code does not always
check that. Using the paraslash wrapper avoids the issue and has the
additional benefit that para_strdup(NULL) does not segfault.
Andre Noll [Mon, 9 Aug 2021 17:43:36 +0000 (19:43 +0200)]
mp4: Use para_{c,m}alloc() to allocate memory.
With mp4ff being internal we can afford to just abort if allocations
fail (which is what the para_ wrappers do). This allows us to simplify
the code quite a bit.
The code used to cast the pointer returned from malloc(). This is
unnecessary, so drop these casts.
Andre Noll [Mon, 9 Aug 2021 17:10:46 +0000 (19:10 +0200)]
mp4: Simplify and rename mp4ff_read_sample_getsize().
The new code is much shorter. It is equivalent because the single
caller only checks whether the return value is less or equal then zero,
and does not use the return value in this case.
Andre Noll [Mon, 9 Aug 2021 16:43:44 +0000 (18:43 +0200)]
aac: Move declaration of mp4ff_set_sample_position() to mp4.h.
We used to provide the declaration of mp4ff_set_sample_position()
in aac_afh.c. With the internal mp4.c this is no longer necessary as
we may as well declare the function in mp4.h.
Remove the documentation since it has become stale.
Andre Noll [Sun, 8 Aug 2021 20:09:28 +0000 (22:09 +0200)]
mp4: Make non-public functions static.
It's generally a good thing to reduce the scope to the compilation
unit where possible. Static functions also reduce the number of
symbols and help the compiler to optimize the generated code.
Andre Noll [Thu, 21 Oct 2021 17:09:59 +0000 (19:09 +0200)]
mp4: Wire it in and make it compile cleanly.
This switches to our local copy of libmp4ff. The configure script
now turns on support for the aac audio format even if libmp4ff is
not installed.
Some changes to mp4.c were necessary to silence warnings, most of
which are trivial. The single notably non-trivial change is the missing
initialization of chunk_sample and chunk in mp4ff_chunk_of_sample().
Andre Noll [Sun, 8 Aug 2021 19:13:41 +0000 (21:13 +0200)]
Provide our own copy of libmp4ff.
This library was removed from the faad repository in 2017. This
commit put everything we need from the libmp4ff code base into the
new mp4.c and mp4.h files. All content was taken unmodified from
commit 1cf5a505daf0 of the faad2 repo, the last commit that contains
the library.
The code needs a lot of cleanup and does not compile without warnings.
We commit it as-is to track what exactly has been copied from
libmp4ff. The new mp4.c has not been included into the build system,
however, so this commit has no effect yet.
It is broken because the recipe for the .d files does not honor
CPPFLAGS since we only modify the CPPFLAGS variable for the .o
targets. Adding the corresponding .d targets would be too ugly,
so revert the commit for now until a better solution has been found.
Andre Noll [Mon, 14 Mar 2022 21:28:27 +0000 (22:28 +0100)]
Makefile: Fix compilation after header removal.
When switching from an older git version which still contains some
header file to a newer version where it got removed, a .d file remains
in build/deps which lists the no longer existing header file as a
prerequisite. This causes the build to fail because the prerequisite
cannot be created. The problem can be worked around by removing the
stale .d file, for example by running make clean, but this is no real
fix, and is inefficient.
The root of the matter is that .d files depend on their .c counterpart,
but this dependency is not stated anywhere in the Makefile. Thus, we
need a rule for the .d target with the same prerequisites and the same
recipe as the object file target. GNU make supports multiple targets,
but the feature does not seem to work as advertised, regardless of
whether rules with independent targets or rules with grouped targets
(using the &: separator) are employed. Thus we bite the bullet and
use two separate rules.
We have to add at least one mood to trigger the bug. Since addmood is
a stdin command we must redirect stdin for the para_client command. It
does not hurt to do this for all commands, not just the new one.
Andre Noll [Wed, 16 Mar 2022 18:21:24 +0000 (19:21 +0100)]
Minor log severity adjustments.
Two small changes which improve the error output of para_audiod. The
first makes sure we get a message when hitting ctrl+c when audiod
is running in forground mode. The second decreases the severity of
the log message which is shown when a client connection terminates,
since this is not necessarily an error.
Andre Noll [Wed, 20 Oct 2021 19:13:58 +0000 (21:13 +0200)]
server: Early vss shutdown for command handlers.
Command must communicate with the vss through the shared memory area
(mmd). Deallocating all resources early in the command handler makes
the code more robust and saves some memory.
Andre Noll [Fri, 27 Aug 2021 13:12:34 +0000 (15:12 +0200)]
afh: Limit chunk numbers to 32 bit.
The number of chunks and the chunk offsets are stored in the audio
file table as 32 bit unsigned integers. Thus, chunk numbers and
sizes cannot exceed 2^32 - 1. Make this fact obvious by changing
the corresponding parameters of aac_afh_get_chunk() from size_t or
unsigned long to uint32_t.
Andre Noll [Wed, 9 Mar 2022 22:56:56 +0000 (23:56 +0100)]
audiod: Stop stream immediately when being switched off.
When para_audiod enters off/standby mode, we stop the receiver
but continue to filter and write data already received until the
input queue has drained. This can take several seconds, which may
be annoying.
To stop the stream immediately, stop the writer(s) rather than the
receiver. We still only stop the receiver when the server has paused
or stopped the stream because we don't want to discard any data in
this case.
Andre Noll [Sat, 19 Mar 2022 22:48:18 +0000 (23:48 +0100)]
vss: Reset afhi.chunks_total on eof.
Without this, the server can be crashed by running
para_client nomore # set the nomore flag
# wait for eof
para_client jmp 50 # set the repos flag, clear the next flag
para_client play # boom
The problem is that the command handler of the jmp command checks
afhi.chunks_total to determine if some audio file is currently
open. Since vss_eof() did not reset chunks_total, the command handler
wrongly believes that there is an open audio file, sets the repos
flag and clears the next flag. When streaming is resumed later, the
virtual streaming system attempts to access the chunk table which
was freed earlier in vss_eof().
Andre Noll [Thu, 17 Mar 2022 21:44:11 +0000 (22:44 +0100)]
afs.c: Improve documentation of callback_query.
It had some language issues and focussed too much on details rather than
explaining the big picture. The new text is shorter and should be much easier
to understand.
Andre Noll [Wed, 9 Mar 2022 21:43:26 +0000 (22:43 +0100)]
afs.c: Improve documentation of score table.
The text focussed on implementation details rather than describing the
purpose of the table. It was also slightly incorrect because playlists
also use the score tables, albeit in a much simpler way and without
"Gaussian normal distributions".
Andre Noll [Tue, 15 Mar 2022 20:33:03 +0000 (21:33 +0100)]
attribute.c: De-doxify static functions.
Because static functions don't need doxygen comments. The existing
comments for attribute_close() and attribute_open() did not contain
useful information, so remove these,
Andre Noll [Mon, 14 Mar 2022 18:52:46 +0000 (19:52 +0100)]
afs: Update dummy mood assumptions to reflect the reality.
The code in afs.c assumes that loading the dummy mood always succeeds,
and this is even documented in change_current_mood(). However, this
has never been true because we call into osl library functions which
may fail for various reasons. In particular, if the server is started
without a database the attempt to load the dummy mood fails because
the audio file table does not exist.
The current code was not prepared to handle this case, and does stupid
things like storing the negative error code in *num_admissible and
returning success.
Fix this confusion by adjusting the documentation and letting
activate_mood_or_playlist() fail early. One of its callers,
init_admissible_files(), needs also be adjusted because it asserted
in its error path that the mood which failed to load was not the
dummy mood.
This is a benign bug because the most common way to hit this is
at startup on a fresh install when the database does not exist. In
this case the caller, init_admissible_files(), ignores the negative
num_admissible value.
Andre Noll [Sun, 13 Feb 2022 20:29:03 +0000 (21:29 +0100)]
com_ls(): Drop "audio file table syntax error" messsage.
This error message is printed if ls is called with an invalid argument
for the listing mode or sort order. That's not a syntax error, so
use the standard EINVAL error code instead.
Andre Noll [Wed, 18 Aug 2021 14:44:15 +0000 (16:44 +0200)]
aac_afh: Be more lenient about zero sized reads.
These actually happen for example when the file contains a meta
tag with an empty string value. POSIX says that the read() function
shall return zero and have no other results, so don't return -1 if
the number of bytes read is zero.
Similarly, return zero if the file offset is beyond EOF.
Andre Noll [Sat, 12 Mar 2022 16:22:15 +0000 (17:22 +0100)]
Merge branch 'refs/heads/t/logo'
The fancy new svg logo and a couple of changes which streamline
the look of the web pages.
Cooking for a month.
* refs/heads/t/logo:
web: Add horizontal space between table columns.
web: Clean up style sheet.
web: Avoid bold face on main page.
web: Add padding to all pages.
web: Move navigation into top level table.
web: Link to "./index.html" rather than to ".".
web: Remove selected APIs page.
web: Avoid "integrated" in feature list of main page.
web: Shorten slogan.
web: The new logo for paraslash-0.7.
manual: Avoid vertical space between coding style items.
Andre Noll [Tue, 8 Mar 2022 22:37:08 +0000 (23:37 +0100)]
mood.c: Fix memory leak in change_current_mood().
In two error cases we return without freeing the bison mood parser
and the temporary array. Worse, in these cases we also expose the
partially loaded mood via the global current_mood.
The good news is that these errors should be "impossible" to trigger
in practice.
Andre Noll [Thu, 21 Oct 2021 19:48:24 +0000 (21:48 +0200)]
server: Loglevel adjustments for shutdown path.
The log output of the server is rather verbose with respect to
shutdown messages. These not only occur when the server exits but
also in command handler context each time a command is executed.
This patch quietens these messages in two ways. For some messages we
simply reduce the log level. For others we print the message only in
server context, i.e. when process_is_command_handler() returns false.
Andre Noll [Mon, 21 Feb 2022 14:52:42 +0000 (15:52 +0100)]
Merge branch 'refs/heads/t/sha256'
A couple of changes which start to eliminate the use of sha1 in favor
of sha256. This series is only the first step, though, as we need to
keep sha1 for the time being to provide backward compatibility.
Cooking for four months.
* refs/heads/t/sha256:
manual: Avoid sha1.
upgrade_db: Add copyright and purpose to upgrade_db.c.
web: Add link to the para_upgrade_db(1) man page.
afs: Switch to sha256 and change default database path.
Add para_upgrade_db.
Use sha256 for the challenge response.
Introduce hash2 (sha256).
Assume sideband and aes_ctr128 are always supported/requested.
Andre Noll [Thu, 25 Nov 2021 19:25:43 +0000 (20:25 +0100)]
audiod: Avoid delay in status transition from standby to on.
In close_receiver() we invalidate the current audio format value
to prevent the receiver from re-starting too quickly. See commit 2d61a8005c74 (audiod: Invalidate current audio format on close)
from seven years ago for details.
This invalidation happens in particular when the receiver is closed
because audiod was told to enter standby mode. If audiod is switched
back on shortly thereafter, no receiver can't be started because we
forgot the current audio format and must wait up to one minute until
the next status item dump arrives from the server which re-initializes
the current audio format value.
Fix this flaw by only invalidating the current audio format when
audiod operates in "on" mode.
Andre Noll [Sun, 14 Nov 2021 19:16:01 +0000 (20:16 +0100)]
web: Add horizontal space between table columns.
This tweaks the style sheet to make the rows of the tables easier to
read. It affects the topic list on the development page and the list
of files on the doxygen API page.
Andre Noll [Sat, 6 Nov 2021 20:31:59 +0000 (21:31 +0100)]
web: Link to "./index.html" rather than to ".".
When browsing the generated html locally, clicking the logo or the
about link may cause the browser to open the directory view, which
is annoying. This commit makes these links open the main page instead.
Andre Noll [Sun, 31 Oct 2021 22:07:06 +0000 (23:07 +0100)]
web: The new logo for paraslash-0.7.
This new svg logo was not made with a graphical editor but with a
plain text exitor. Unfortunately, ImageMagick is unable to create
a working .ico file from the svg source. Therefore we continue to
carry a manually created .ico file in the repo.
The new logo is less wide than the previous one, and it does not look
nice when it floats to the right side of its tabular cell. Fortunately
this can be fixed by removing some code from the style sheet.