sink, source: rename set_state() to set_state_in_main_thread()

There will be a new callback named set_state_in_io_thread(). It seems
like a good idea to have a similar name for the main thread variant.
This commit is contained in:
Tanu Kaskinen 2018-03-13 19:40:36 +02:00
parent f6fe411b32
commit 0fad369ceb
17 changed files with 56 additions and 54 deletions

View file

@ -150,7 +150,7 @@ void pa_sink_new_data_done(pa_sink_new_data *data) {
static void reset_callbacks(pa_sink *s) {
pa_assert(s);
s->set_state = NULL;
s->set_state_in_main_thread = NULL;
s->get_volume = NULL;
s->set_volume = NULL;
s->write_volume = NULL;
@ -427,9 +427,9 @@ 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) {
ret = s->set_state(s, state, suspend_cause);
/* set_state() is allowed to fail only when resuming. */
if (s->set_state_in_main_thread) {
ret = s->set_state_in_main_thread(s, state, suspend_cause);
/* set_state_in_main_thread() is allowed to fail only when resuming. */
pa_assert(ret >= 0 || resuming);
}
@ -438,8 +438,8 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state, pa_suspend_cause_t
/* SET_STATE is allowed to fail only when resuming. */
pa_assert(resuming);
if (s->set_state)
s->set_state(s, PA_SINK_SUSPENDED, 0);
if (s->set_state_in_main_thread)
s->set_state_in_main_thread(s, PA_SINK_SUSPENDED, 0);
}
if (suspend_cause_changed) {

View file

@ -132,10 +132,11 @@ struct pa_sink {
* 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 */
* If set_state_in_main_thread() 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_in_main_thread() is called again. */
int (*set_state_in_main_thread)(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

@ -141,7 +141,7 @@ void pa_source_new_data_done(pa_source_new_data *data) {
static void reset_callbacks(pa_source *s) {
pa_assert(s);
s->set_state = NULL;
s->set_state_in_main_thread = NULL;
s->get_volume = NULL;
s->set_volume = NULL;
s->write_volume = NULL;
@ -381,9 +381,9 @@ 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) {
ret = s->set_state(s, state, suspend_cause);
/* set_state() is allowed to fail only when resuming. */
if (s->set_state_in_main_thread) {
ret = s->set_state_in_main_thread(s, state, suspend_cause);
/* set_state_in_main_thread() is allowed to fail only when resuming. */
pa_assert(ret >= 0 || resuming);
}
@ -392,8 +392,8 @@ static int source_set_state(pa_source *s, pa_source_state_t state, pa_suspend_ca
/* SET_STATE is allowed to fail only when resuming. */
pa_assert(resuming);
if (s->set_state)
s->set_state(s, PA_SOURCE_SUSPENDED, 0);
if (s->set_state_in_main_thread)
s->set_state_in_main_thread(s, PA_SOURCE_SUSPENDED, 0);
}
if (suspend_cause_changed) {

View file

@ -133,10 +133,11 @@ struct pa_source {
* 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 */
* If set_state_in_main_thread() 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_in_main_thread() is called again. */
int (*set_state_in_main_thread)(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