pass pa_suspend_cause_t to set_state() callbacks

The suspend cause isn't yet used by any of the callbacks. The alsa sink
and source will use it to sync the mixer when the SESSION suspend cause
is removed. Currently the syncing is done in pa_sink/source_suspend(),
and I want to change that, because pa_sink/source_suspend() shouldn't
have any alsa specific code.
This commit is contained in:
Tanu Kaskinen 2018-02-19 16:48:23 +02:00
parent 3da0de5418
commit 6ed37aeef2
17 changed files with 58 additions and 27 deletions

View file

@ -427,8 +427,8 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
* cause, or it might just add unnecessary complexity, given that the
* current approach of not setting any suspend cause works well enough. */
if (s->set_state && state_changed) {
ret = s->set_state(s, state);
if (s->set_state) {
ret = s->set_state(s, state, suspend_cause);
/* set_state() is allowed to fail only when resuming. */
pa_assert(ret >= 0 || resuming);
}
@ -439,7 +439,7 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
pa_assert(resuming);
if (s->set_state)
s->set_state(s, PA_SINK_SUSPENDED);
s->set_state(s, PA_SINK_SUSPENDED, 0);
}
if (suspend_cause_changed) {

View file

@ -126,8 +126,16 @@ struct pa_sink {
/* Called when the main loop requests a state change. Called from
* main loop context. If returns -1 the state change will be
* inhibited */
int (*set_state)(pa_sink *s, pa_sink_state_t state); /* may be NULL */
* inhibited. This will also be called even if only the suspend cause
* changes.
*
* s->state and s->suspend_cause haven't been updated yet when this is
* called, so the callback can get the old state through those variables.
*
* If set_state() is successful, the IO thread will be notified with the
* SET_STATE message. The message handler is allowed to fail, in which
* case the old state is restored, and set_state() is called again. */
int (*set_state)(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */
/* Sink drivers that support hardware volume may set this
* callback. This is called when the current volume needs to be

View file

@ -381,8 +381,8 @@ static int source_set_state(pa_source *s, pa_source_state_t state, pa_suspend_ca
* cause, or it might just add unnecessary complexity, given that the
* current approach of not setting any suspend cause works well enough. */
if (s->set_state && state_changed) {
ret = s->set_state(s, state);
if (s->set_state) {
ret = s->set_state(s, state, suspend_cause);
/* set_state() is allowed to fail only when resuming. */
pa_assert(ret >= 0 || resuming);
}
@ -393,7 +393,7 @@ static int source_set_state(pa_source *s, pa_source_state_t state, pa_suspend_ca
pa_assert(resuming);
if (s->set_state)
s->set_state(s, PA_SOURCE_SUSPENDED);
s->set_state(s, PA_SOURCE_SUSPENDED, 0);
}
if (suspend_cause_changed) {

View file

@ -127,8 +127,16 @@ struct pa_source {
/* Called when the main loop requests a state change. Called from
* main loop context. If returns -1 the state change will be
* inhibited */
int (*set_state)(pa_source*source, pa_source_state_t state); /* may be NULL */
* inhibited. This will also be called even if only the suspend cause
* changes.
*
* s->state and s->suspend_cause haven't been updated yet when this is
* called, so the callback can get the old state through those variables.
*
* If set_state() is successful, the IO thread will be notified with the
* SET_STATE message. The message handler is allowed to fail, in which
* case the old state is restored, and set_state() is called again. */
int (*set_state)(pa_source *source, pa_source_state_t state, pa_suspend_cause_t suspend_cause); /* may be NULL */
/* Called when the volume is queried. Called from main loop
* context. If this is NULL a PA_SOURCE_MESSAGE_GET_VOLUME message