loopback: Restart timer after 1/3 second

After switching source or sink, call adjust_rates after a third of a second
instead of waiting one full adjust time. This will ensure that latency regulation
starts as soon as possible.
This commit is contained in:
Georg Chini 2016-06-05 21:05:09 +02:00 committed by Tanu Kaskinen
parent 919cc2f3f9
commit 4a11742652

View file

@ -251,13 +251,16 @@ static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct tim
adjust_rates(u); adjust_rates(u);
} }
/* Called from main context */ /* Called from main context
* When source or sink changes, give it a third of a second to settle down, then call adjust_rates for the first time */
static void enable_adjust_timer(struct userdata *u, bool enable) { static void enable_adjust_timer(struct userdata *u, bool enable) {
if (enable) { if (enable) {
if (u->time_event || u->adjust_time <= 0) if (!u->adjust_time)
return; return;
if (u->time_event)
u->core->mainloop->time_free(u->time_event);
u->time_event = pa_core_rttime_new(u->module->core, pa_rtclock_now() + u->adjust_time, time_callback, u); u->time_event = pa_core_rttime_new(u->module->core, pa_rtclock_now() + 333 * PA_USEC_PER_MSEC, time_callback, u);
} else { } else {
if (!u->time_event) if (!u->time_event)
return; return;