s->receiver_node = NULL;
set_restart_barrier(s->format, NULL);
}
-static void close_writer(int slot_num)
-{
- struct slot_info *s = &slot[slot_num];
- if (s->wng) {
- PARA_INFO_LOG("slot %d: closing writer node group\n",
- slot_num);
- wng_close(s->wng);
- s->wng = NULL;
- }
- if (s->fc)
- *s->fc->output_eof = 1; /* FIXME */
-}
-
static void kill_all_decoders(void)
{
int i;
- FOR_EACH_SLOT(i)
- close_writer(i);
+ FOR_EACH_SLOT(i) {
+ struct slot_info *s = &slot[i];
+ if (s->receiver_node)
+ s->receiver_node->eof = 1;
+ }
}
static void check_sigchld(void)
s->fc = NULL;
if (!nf)
return;
+ PARA_INFO_LOG("opening %s filters\n", audio_formats[s->format]);
s->fc = para_calloc(sizeof(struct filter_chain));
INIT_LIST_HEAD(&s->fc->filters);
s->fc->inbuf = s->receiver_node->buf;
}
}
-static void start_stream_writer(int slot_num, struct timeval *now)
+static void open_writer(int slot_num, struct timeval *now)
{
int ret, i;
struct slot_info *s = &slot[slot_num];
struct audio_format_info *a = &afi[s->format];
- PARA_INFO_LOG("opening %s filters\n", audio_formats[s->format]);
- open_filters(slot_num);
PARA_INFO_LOG("opening %s writers\n", audio_formats[s->format]);
if (!a->num_writers)
s->wng = setup_default_wng();
register_task(&rn->task);
}
-static int is_frozen(int format)
+static int is_frozen(int format, struct timeval *now)
{
- struct timeval now;
struct audio_format_info *a = &afi[format];
- gettimeofday(&now, NULL);
- return (tv_diff(&now, &a->restart_barrier, NULL) > 0)? 0 : 1;
+ return (tv_diff(now, &a->restart_barrier, NULL) > 0)? 0 : 1;
}
-static void start_current_receiver(void)
+static void start_current_receiver(struct timeval *now)
{
int i;
i = get_audio_format_num(af_status);
if (i < 0)
return;
- if ((decoder_running(i) & 1) || is_frozen(i))
+ if ((decoder_running(i) & 1) || is_frozen(i, now))
return;
open_receiver(i);
}
clear_slot(slot_num);
}
-static void audiod_pre_select(__a_unused struct sched *s, __a_unused struct task *t)
+static void audiod_pre_select(struct sched *s, __a_unused struct task *t)
{
int i;
if (audiod_status != AUDIOD_ON)
kill_all_decoders();
else if (playing)
- start_current_receiver();
+ start_current_receiver(&s->now);
check_timeouts();
FOR_EACH_SLOT(i) {
struct receiver_node *rn;
continue;
rn = slot[i].receiver_node;
if (rn && rn->loaded && !slot[i].wng) {
- PARA_INFO_LOG("no writer in slot %d\n", i);
- start_stream_writer(i, &s->now);
+ open_filters(i);
+ open_writer(i, &s->now);
}
}
}