sink, source: Call sink input suspend callback also on suspend cause change

Currently, virtual sinks and sources are not suspended when the master sink
or source is suspended. To implement this, the slave must be able to track
the suspend cause of the master.

With this patch, the sink input suspend callback will not only be called
when the sink or source is changing state, but also when the suspend cause
changes. Similar to the set_state_in_*_thread_cb() functions, the suspend
callback receives a state and a suspend cause as additional arguments.
Because the new state and suspend cause of the sink or source have already
been set, the old values are passed to the callback.
This commit is contained in:
Georg Chini 2019-02-12 20:21:01 +01:00 committed by Arun Raghavan
parent f7b3537bbf
commit acb02d9e88
6 changed files with 54 additions and 14 deletions

View file

@ -761,13 +761,20 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
}
/* Called from main thread */
static void source_output_suspend_cb(pa_source_output *o, bool suspended) {
static void source_output_suspend_cb(pa_source_output *o, pa_source_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
struct userdata *u;
bool suspended;
pa_source_output_assert_ref(o);
pa_assert_ctl_context();
pa_assert_se(u = o->userdata);
/* State has not changed, nothing to do */
if (old_state == o->source->state)
return;
suspended = (o->source->state == PA_SOURCE_SUSPENDED);
/* If the source has been suspended, we need to handle this like
* a source change when the source is resumed */
if (suspended) {
@ -1160,13 +1167,20 @@ static bool sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
}
/* Called from main thread */
static void sink_input_suspend_cb(pa_sink_input *i, bool suspended) {
static void sink_input_suspend_cb(pa_sink_input *i, pa_sink_state_t old_state, pa_suspend_cause_t old_suspend_cause) {
struct userdata *u;
bool suspended;
pa_sink_input_assert_ref(i);
pa_assert_ctl_context();
pa_assert_se(u = i->userdata);
/* State has not changed, nothing to do */
if (old_state == i->sink->state)
return;
suspended = (i->sink->state == PA_SINK_SUSPENDED);
/* If the sink has been suspended, we need to handle this like
* a sink change when the sink is resumed. Because the sink
* is suspended, we can set the variables directly. */