]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
audiod: Stop stream immediately when being switched off.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 9 Mar 2022 22:56:56 +0000 (23:56 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 28 Mar 2022 20:28:20 +0000 (22:28 +0200)
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.

audiod.c

index 7293285ef9687ee1c35fd46bfb735a73f6870ec0..838f375fe6df2c2d96c4bfa2aa41d28e64c29f72 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -480,6 +480,23 @@ static void close_writers(struct slot_info *s)
        s->wns = NULL;
 }
 
+static void notify_writers(int error)
+{
+       int i;
+
+       FOR_EACH_SLOT(i) {
+               struct slot_info *s = slot + i;
+               struct audio_format_info *a;
+               int j;
+
+               if (s->format < 0)
+                       continue;
+               a = afi + s->format;
+               for (j = 0; j < a->num_writers; j++)
+                       task_notify(s->wns[j].task, error);
+       }
+}
+
 static void close_filters(struct slot_info *s)
 {
        int i;
@@ -1218,8 +1235,9 @@ static void start_stop_decoders(void)
        struct slot_info *sl;
 
        close_unused_slots();
-       if (audiod_status != AUDIOD_ON ||
-                       !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING))
+       if (audiod_status != AUDIOD_ON)
+               return notify_writers(E_NOT_PLAYING);
+       if (!(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING))
                return notify_receivers(E_NOT_PLAYING);
        if (!must_start_decoder())
                return;