{
struct slot_info *s = &slot[slot_num];
struct audio_format_info *a;
- struct timeval restart_delay = {0, 200 * 1000};
if (s->format < 0 || !s->receiver_node)
return;
btr_free_node(s->receiver_node->btrn);
free(s->receiver_node);
s->receiver_node = NULL;
- tv_add(now, &restart_delay, &afi[s->format].restart_barrier);
}
static void writer_cleanup(struct writer_node *wn)
return slot_num;
}
-/* return: 0: Not running, 1: Running, -1: Running but eof (or error) */
-static int receiver_running(int format)
+static bool receiver_running(void)
{
- int i, ret = 0;
+ int i;
+ long unsigned ss1 = stat_task->server_stream_start.tv_sec;
FOR_EACH_SLOT(i) {
struct slot_info *s = &slot[i];
- if (s->format != format)
- continue;
+ long unsigned ss2 = s->server_stream_start.tv_sec;
+
if (!s->receiver_node)
continue;
if (s->receiver_node->task.error >= 0)
- return 1;
- ret = -1;
+ return true;
+ if (ss1 == ss2)
+ return true;
}
- return ret;
+ return false;
}
/**
/* whether a new instance of a decoder should be started. */
static bool must_start_decoder(void)
{
- int ret, cafn = stat_task->current_audio_format_num;
+ int cafn = stat_task->current_audio_format_num;
+ unsigned vs = stat_task->vss_status;
- if (cafn < 0 || !stat_task->ct)
+ if (cafn < 0)
+ return false;
+ if (!stat_task->ct)
+ return false;
+ if (vs & VSS_STATUS_FLAG_NEXT)
return false;
- /* Do nothing if the 'N' flag is set or the 'P' flag is unset */
- if (stat_task->vss_status != VSS_STATUS_FLAG_PLAYING)
+ if (!(vs & VSS_STATUS_FLAG_PLAYING))
return false;
- ret = receiver_running(cafn);
- if (ret != 0) /* already running */
+ if (receiver_running())
return false;
if (tv_diff(now, &afi[cafn].restart_barrier, NULL) < 0)
return false;