]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Implement select -verbose.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 22 Oct 2022 19:54:29 +0000 (21:54 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 15 May 2023 18:21:29 +0000 (20:21 +0200)
Just set ->pbout to NULL if the new option is not given. This supresses
normal output while error messages still make it to the client because
those are sent with afs_error().

afs.c
m4/lls/server_cmd.suite.m4
mood.c

diff --git a/afs.c b/afs.c
index 78e42eaec54b9a1cbb87a3c349a0fa12ae98601f..cb3ead27e55d43df0d7230f2ca404499439348ec 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -980,29 +980,32 @@ static int com_select_callback(struct afs_callback_arg *aca)
        const struct lls_command *cmd = SERVER_CMD_CMD_PTR(SELECT);
        const char *arg;
        int ret;
+       struct para_buffer *pbout;
 
        ret = lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr);
        assert(ret >= 0);
        arg = lls_input(0, aca->lpr);
+       pbout = SERVER_CMD_OPT_GIVEN(SELECT, VERBOSE, aca->lpr)?
+               &aca->pbout : NULL;
        score_clear();
        if (current_play_mode == PLAY_MODE_MOOD)
                mood_unload();
        else
                playlist_unload();
-       ret = activate_mood_or_playlist(arg, &aca->pbout);
+       ret = activate_mood_or_playlist(arg, pbout);
        if (ret >= 0)
                goto free_lpr;
        /* ignore subsequent errors (but log them) */
        if (current_mop && strcmp(current_mop, arg) != 0) {
                int ret2;
                afs_error(aca, "switching back to %s\n", current_mop);
-               ret2 = activate_mood_or_playlist(current_mop, &aca->pbout);
+               ret2 = activate_mood_or_playlist(current_mop, pbout);
                if (ret2 >= 0)
                        goto free_lpr;
                afs_error(aca, "could not reactivate %s: %s\n", current_mop,
                        para_strerror(-ret2));
        }
-       activate_mood_or_playlist(NULL, &aca->pbout);
+       activate_mood_or_playlist(NULL, pbout);
 free_lpr:
        lls_free_parse_result(aca->lpr, cmd);
        return ret;
index 8200c6249449f81b5743775f04796462fc912b83..8784fe7816f60e25503e7b19f4107714dca56587 100644 (file)
@@ -407,6 +407,9 @@ m4_include(`com_ll.m4')
 
                activates the mood named 'foo'.
        [/description]
+       [option verbose]
+               short_opt = v
+               summary = print information about the loaded mood or playlist
 
 [subcommand sender]
        purpose = control paraslash senders
diff --git a/mood.c b/mood.c
index e85cf36a35b9e533370bddd95c5c5db74a214e85..7c0d2b4fba9feb13a9287d55281e1451df65e276 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -535,12 +535,15 @@ static char *get_statistics(struct mood_instance *m, int64_t sse)
                "loaded mood %s (%u files)\n"
                "last_played mean/sigma: %d/%d days\n"
                "num_played mean/sigma: %" PRId64 "/%" PRIu64 "\n"
+               "correction factor ratio: %.2lf\n"
        ,
                m->name? m->name : "(dummy)",
                n,
                mean_days, sigma_days,
                m->stats.num_played_sum / n,
-                       int_sqrt(m->stats.num_played_qd / n)
+               int_sqrt(m->stats.num_played_qd / n),
+               86400.0 * m->stats.last_played_correction /
+                       m->stats.num_played_correction
        );
 }