{
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;
- stat_task->current_audio_format_num = -1;
+ tv_add(now, &restart_delay, &afi[s->format].restart_barrier);
}
static void writer_cleanup(struct writer_node *wn)
* belongs to the file just completed.
*/
if (stat_task->server_stream_start.tv_sec != 0)
- return -1;
+ sched_request_timeout_ms(100, s);
}
if (tv_diff(now, &afi[cafn].restart_barrier, &diff) < 0) {
- /* avoid busy loop */
- s->timeout = diff;
+ if (tv_diff(&s->timeout, &diff, NULL) > 0)
+ s->timeout = diff;
+ else
+ sched_min_delay(s);
return -1;
}
/* start a new receiver */
tv_add(now, &delay, &stat_task->restart_barrier);
}
-static void try_to_close_slot(int slot_num)
+static bool try_to_close_slot(int slot_num)
{
struct slot_info *s = &slot[slot_num];
struct audio_format_info *a = afi + s->format;
int i;
if (s->format < 0)
- return;
+ return false;
if (s->receiver_node && s->receiver_node->task.error != -E_TASK_UNREGISTERED)
- return;
+ return false;
for (i = 0; i < a->num_filters; i++)
if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED)
- return;
+ return false;
for (i = 0; i < a->num_writers; i++)
if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED)
- return;
+ return false;
PARA_INFO_LOG("closing slot %d\n", slot_num);
close_writers(s);
_close_filters(s);
close_receiver(slot_num);
clear_slot(slot_num);
+ return true;
}
/*
struct audio_format_info *a;
FOR_EACH_SLOT(i)
- try_to_close_slot(i);
+ if (try_to_close_slot(i))
+ sched_min_delay(s);
// if (audiod_status != AUDIOD_ON ||
// !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING))
// return kill_all_decoders(-E_NOT_PLAYING);
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;
+ sched_min_delay(s);
}
/* restart the client task if necessary */
if (tv_diff(now, &st->restart_barrier, NULL) < 0)
goto out;
if (st->clock_diff_count) { /* get status only one time */
- char *argv[] = {"audiod", "--", "stat", "-p", "1", NULL};
+ char *argv[] = {"audiod", "--", "stat", "-p", "-n=1", NULL};
int argc = 5;
PARA_INFO_LOG("clock diff count: %d\n", st->clock_diff_count);
st->clock_diff_count--;
client_open(argc, argv, &st->ct, NULL);
set_stat_task_restart_barrier(2);
+ sched_min_delay(s);
} else {
char *argv[] = {"audiod", "--", "stat", "-p", NULL};
int argc = 4;
client_open(argc, argv, &st->ct, NULL);
set_stat_task_restart_barrier(5);
+ sched_min_delay(s);
}
free(stat_item_values[SI_BASENAME]);
stat_item_values[SI_BASENAME] = para_strdup(