PA_SUSPEND_IDLE = 4, /* Used by module-suspend-on-idle */
PA_SUSPEND_SESSION = 8, /* Used by module-hal for mark inactive sessions */
PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */
+ PA_SUSPEND_INTERNAL = 32, /* This is used for short period server-internal suspends, such as for sample rate updates */
PA_SUSPEND_ALL = 0xFFFF /* Magic cause that can be used to resume forcibly */
} pa_suspend_cause_t;
/* Called from main thread */
pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
{
+ pa_bool_t ret = FALSE;
+
if (s->update_rate) {
uint32_t desired_rate = rate;
uint32_t default_rate = s->default_sample_rate;
return FALSE;
pa_log_debug("Suspending sink %s due to changing the sample rate.", s->name);
- pa_sink_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
+ pa_sink_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
if (s->update_rate(s, desired_rate) == TRUE) {
/* update monitor source as well */
pa_sink_input_update_rate(i);
}
- return TRUE;
+ ret = TRUE;
}
+
+ pa_sink_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
}
- return FALSE;
+
+ return ret ;
}
/* Called from main thread */
/* Called from main thread */
pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrough)
{
+ pa_bool_t ret = FALSE;
+
if (s->update_rate) {
uint32_t desired_rate = rate;
uint32_t default_rate = s->default_sample_rate;
return FALSE;
pa_log_debug("Suspending source %s due to changing the sample rate.", s->name);
- pa_source_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
+ pa_source_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
if (s->update_rate(s, desired_rate) == TRUE) {
pa_log_info("Changed sampling rate successfully ");
if (o->state == PA_SOURCE_OUTPUT_CORKED)
pa_source_output_update_rate(o);
}
- return TRUE;
+ ret = TRUE;
}
+
+ pa_source_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
}
- return FALSE;
+
+ return ret;
}
/* Called from main thread */