]> git.tuebingen.mpg.de Git - paraslash.git/commit
Simplify and improve activate_mood_or_playlist().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 13 Mar 2022 22:28:21 +0000 (23:28 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 17 Oct 2022 18:36:21 +0000 (20:36 +0200)
commit462a71176aa847494a1a26826768b5fa52994f54
treecdc9bab04ffb1da175c9c00e63693e23b953e261
parent513731227550737966bf05f724aef4ff26c0b9a7
Simplify and improve activate_mood_or_playlist().

The logic of this function can be simplified to match the four
possible cases for the argument. Each of the four conditional blocks
now initializes ret, mode and the message pointer.

The message is then printed into the para buffer, which is now
passed to the function instead of a char ** because this simplifies
the select callback a bit. The other callers (for init and SIGHUP
handling) pass NULL and don't need to be adjusted.

To make this work we have to make sure that the message pointer is
properly initialized in all cases, not only in the error case as
before. Thus, playlist_open() and mood_switch() are changed to return
a suitable message also on success.

For playlists, the message only contains the number of files in the
playlist. For moods we also include the afs statistics of the mood
and no longer write this information to the server log. We omit the
correction factors and the normalization divisor, however, as these
are not very interesting.

The only purpose of the num_admissible parameter of
activate_mood_or_playlist() was to let the caller log this
information. This task is now performed by playlist_open() and
mood_switch(), so the parameter can be dropped.
afs.c
afs.h
mood.c
playlist.c