Fix stream grabbing.
[paraslash.git] / audiod.c
index 3cc0921..79dd615 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -541,6 +541,29 @@ static int receiver_running(int format)
        return ret;
 }
 
+struct btr_node *audiod_get_btr_root(void)
+{
+       int i, newest_slot = -1;
+       struct timeval newest_rstime = {0, 0};
+
+       FOR_EACH_SLOT(i) {
+               struct slot_info *s = &slot[i];
+               struct timeval rstime;
+               if (!s->receiver_node)
+                       continue;
+               if (s->receiver_node->task.error < 0)
+                       continue;
+               btr_get_node_start(s->receiver_node->btrn, &rstime);
+               if (newest_slot >= 0 && tv_diff(&rstime, &newest_rstime, NULL) < 0)
+                       continue;
+               newest_rstime = rstime;
+               newest_slot = i;
+       }
+       if (newest_slot == -1)
+               return NULL;
+       return slot[newest_slot].receiver_node->btrn;
+}
+
 /* returns slot num on success. */
 static int open_current_receiver(struct sched *s)
 {
@@ -1052,6 +1075,7 @@ static void start_stop_decoders(struct sched *s)
        if (a->num_filters)
                open_filters(sl);
        open_writers(sl);
+       activate_grab_clients();
        btr_log_tree(sl->receiver_node->btrn, LL_NOTICE);
        s->timeout.tv_sec = 0;
        s->timeout.tv_usec = 1;