mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
optimize set_state_in_io_thread() callbacks
Source and sink are passed in arguments to set_state_in_io_thread() callbacks. There is optimal to access them directly.
This commit is contained in:
parent
de705a0eea
commit
556cdfa190
16 changed files with 41 additions and 41 deletions
|
|
@ -1291,7 +1291,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
switch (new_state) {
|
||||
|
||||
case PA_SINK_SUSPENDED: {
|
||||
pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
|
||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
||||
|
||||
suspend(u);
|
||||
|
||||
|
|
@ -1302,7 +1302,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
case PA_SINK_RUNNING: {
|
||||
int r;
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (s->thread_info.state == PA_SINK_INIT) {
|
||||
if (build_pollfd(u) < 0)
|
||||
/* FIXME: This will cause an assertion failure, because
|
||||
* with the current design pa_sink_put() is not allowed
|
||||
|
|
@ -1312,7 +1312,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
return -PA_ERR_IO;
|
||||
}
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
if ((r = unsuspend(u)) < 0)
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1146,7 +1146,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
switch (new_state) {
|
||||
|
||||
case PA_SOURCE_SUSPENDED: {
|
||||
pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
|
||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
||||
|
||||
suspend(u);
|
||||
|
||||
|
|
@ -1157,7 +1157,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
case PA_SOURCE_RUNNING: {
|
||||
int r;
|
||||
|
||||
if (u->source->thread_info.state == PA_SOURCE_INIT) {
|
||||
if (s->thread_info.state == PA_SOURCE_INIT) {
|
||||
if (build_pollfd(u) < 0)
|
||||
/* FIXME: This will cause an assertion failure, because
|
||||
* with the current design pa_source_put() is not allowed
|
||||
|
|
@ -1167,7 +1167,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
return -PA_ERR_IO;
|
||||
}
|
||||
|
||||
if (u->source->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
if ((r = unsuspend(u)) < 0)
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
case PA_SINK_SUSPENDED:
|
||||
/* Ignore if transition is PA_SINK_INIT->PA_SINK_SUSPENDED */
|
||||
if (!PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!PA_SINK_IS_OPENED(s->thread_info.state))
|
||||
break;
|
||||
|
||||
/* Stop the device if the source is suspended as well */
|
||||
|
|
@ -437,7 +437,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
case PA_SINK_IDLE:
|
||||
case PA_SINK_RUNNING:
|
||||
if (u->sink->thread_info.state != PA_SINK_SUSPENDED)
|
||||
if (s->thread_info.state != PA_SINK_SUSPENDED)
|
||||
break;
|
||||
|
||||
/* Resume the device if the source was suspended as well */
|
||||
|
|
@ -497,7 +497,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
|
||||
case PA_SOURCE_SUSPENDED:
|
||||
/* Ignore if transition is PA_SOURCE_INIT->PA_SOURCE_SUSPENDED */
|
||||
if (!PA_SOURCE_IS_OPENED(u->source->thread_info.state))
|
||||
if (!PA_SOURCE_IS_OPENED(s->thread_info.state))
|
||||
break;
|
||||
|
||||
/* Stop the device if the sink is suspended as well */
|
||||
|
|
@ -510,7 +510,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
|
||||
case PA_SOURCE_IDLE:
|
||||
case PA_SOURCE_RUNNING:
|
||||
if (u->source->thread_info.state != PA_SOURCE_SUSPENDED)
|
||||
if (s->thread_info.state != PA_SOURCE_SUSPENDED)
|
||||
break;
|
||||
|
||||
/* Resume the device if the sink was suspended as well */
|
||||
|
|
|
|||
|
|
@ -980,7 +980,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
|
||||
case PA_SOURCE_SUSPENDED:
|
||||
/* Ignore if transition is PA_SOURCE_INIT->PA_SOURCE_SUSPENDED */
|
||||
if (!PA_SOURCE_IS_OPENED(u->source->thread_info.state))
|
||||
if (!PA_SOURCE_IS_OPENED(s->thread_info.state))
|
||||
break;
|
||||
|
||||
/* Stop the device if the sink is suspended as well */
|
||||
|
|
@ -994,7 +994,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
|
||||
case PA_SOURCE_IDLE:
|
||||
case PA_SOURCE_RUNNING:
|
||||
if (u->source->thread_info.state != PA_SOURCE_SUSPENDED)
|
||||
if (s->thread_info.state != PA_SOURCE_SUSPENDED)
|
||||
break;
|
||||
|
||||
/* Resume the device if the sink was suspended as well */
|
||||
|
|
@ -1157,7 +1157,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
case PA_SINK_SUSPENDED:
|
||||
/* Ignore if transition is PA_SINK_INIT->PA_SINK_SUSPENDED */
|
||||
if (!PA_SINK_IS_OPENED(u->sink->thread_info.state))
|
||||
if (!PA_SINK_IS_OPENED(s->thread_info.state))
|
||||
break;
|
||||
|
||||
/* Stop the device if the source is suspended as well */
|
||||
|
|
@ -1171,7 +1171,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
case PA_SINK_IDLE:
|
||||
case PA_SINK_RUNNING:
|
||||
if (u->sink->thread_info.state != PA_SINK_SUSPENDED)
|
||||
if (s->thread_info.state != PA_SINK_SUSPENDED)
|
||||
break;
|
||||
|
||||
/* Resume the device if the source was suspended as well */
|
||||
|
|
|
|||
|
|
@ -522,7 +522,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
switch (new_state) {
|
||||
|
||||
case PA_SINK_SUSPENDED:
|
||||
pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
|
||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
||||
|
||||
pa_smoother_pause(u->smoother, pa_rtclock_now());
|
||||
break;
|
||||
|
|
@ -191,7 +191,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
case PA_SINK_IDLE:
|
||||
case PA_SINK_RUNNING:
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED)
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED)
|
||||
pa_smoother_resume(u->smoother, pa_rtclock_now(), true);
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
pa_assert(s);
|
||||
pa_assert_se(u = s->userdata);
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED || u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED || s->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state))
|
||||
u->timestamp = pa_rtclock_now();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,10 +142,10 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
pa_assert(s);
|
||||
pa_assert_se(u = s->userdata);
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED || u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED || s->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state))
|
||||
u->timestamp = pa_rtclock_now();
|
||||
} else if (u->sink->thread_info.state == PA_SINK_RUNNING || u->sink->thread_info.state == PA_SINK_IDLE) {
|
||||
} else if (PA_SINK_IS_OPENED(s->thread_info.state)) {
|
||||
if (new_state == PA_SINK_SUSPENDED) {
|
||||
/* Clear potential FIFO error flag */
|
||||
u->fifo_error = false;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
case PA_SINK_SUSPENDED:
|
||||
|
||||
pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
|
||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
||||
|
||||
pa_smoother_pause(u->smoother, pa_rtclock_now());
|
||||
|
||||
|
|
@ -424,16 +424,16 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
case PA_SINK_IDLE:
|
||||
case PA_SINK_RUNNING:
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
pa_smoother_resume(u->smoother, pa_rtclock_now(), true);
|
||||
|
||||
if (!u->source || u->source_suspended) {
|
||||
bool mute;
|
||||
if (unsuspend(u) < 0)
|
||||
return -1;
|
||||
u->sink->get_volume(u->sink);
|
||||
if (u->sink->get_mute(u->sink, &mute) >= 0)
|
||||
pa_sink_set_mute(u->sink, mute, false);
|
||||
s->get_volume(s);
|
||||
if (s->get_mute(s, &mute) >= 0)
|
||||
pa_sink_set_mute(s, mute, false);
|
||||
}
|
||||
u->sink_suspended = false;
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
|
||||
case PA_SOURCE_SUSPENDED:
|
||||
|
||||
pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
|
||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
||||
|
||||
if (!u->sink || u->sink_suspended)
|
||||
suspend(u);
|
||||
|
|
@ -488,11 +488,11 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
case PA_SOURCE_IDLE:
|
||||
case PA_SOURCE_RUNNING:
|
||||
|
||||
if (u->source->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
if (!u->sink || u->sink_suspended) {
|
||||
if (unsuspend(u) < 0)
|
||||
return -1;
|
||||
u->source->get_volume(u->source);
|
||||
s->get_volume(s);
|
||||
}
|
||||
u->source_suspended = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
|
||||
/* When set to running or idle for the first time, request a rewind
|
||||
* of the master sink to make sure we are heard immediately */
|
||||
if ((new_state == PA_SINK_IDLE || new_state == PA_SINK_RUNNING) && u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (PA_SINK_IS_OPENED(new_state) && s->thread_info.state == PA_SINK_INIT) {
|
||||
pa_log_debug("Requesting rewind due to state change.");
|
||||
pa_sink_input_request_rewind(u->sink_input, 0, false, true, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
switch (new_state) {
|
||||
|
||||
case PA_SINK_SUSPENDED:
|
||||
pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
|
||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
||||
|
||||
if (!u->source || u->source_suspended)
|
||||
suspend(u);
|
||||
|
|
@ -695,12 +695,12 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
case PA_SINK_IDLE:
|
||||
case PA_SINK_RUNNING:
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_INIT) {
|
||||
if (s->thread_info.state == PA_SINK_INIT) {
|
||||
do_trigger = true;
|
||||
quick = u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state);
|
||||
}
|
||||
|
||||
if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SINK_SUSPENDED) {
|
||||
|
||||
if (!u->source || u->source_suspended) {
|
||||
if (unsuspend(u) < 0)
|
||||
|
|
@ -770,7 +770,7 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
switch (new_state) {
|
||||
|
||||
case PA_SOURCE_SUSPENDED:
|
||||
pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
|
||||
pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
|
||||
|
||||
if (!u->sink || u->sink_suspended)
|
||||
suspend(u);
|
||||
|
|
@ -783,12 +783,12 @@ static int source_set_state_in_io_thread_cb(pa_source *s, pa_source_state_t new_
|
|||
case PA_SOURCE_IDLE:
|
||||
case PA_SOURCE_RUNNING:
|
||||
|
||||
if (u->source->thread_info.state == PA_SOURCE_INIT) {
|
||||
if (s->thread_info.state == PA_SOURCE_INIT) {
|
||||
do_trigger = true;
|
||||
quick = u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state);
|
||||
}
|
||||
|
||||
if (u->source->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
if (s->thread_info.state == PA_SOURCE_SUSPENDED) {
|
||||
|
||||
if (!u->sink || u->sink_suspended) {
|
||||
if (unsuspend(u) < 0)
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
case PA_SINK_SUSPENDED:
|
||||
pa_log_debug("RAOP: SUSPENDED");
|
||||
|
||||
pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
|
||||
pa_assert(PA_SINK_IS_OPENED(s->thread_info.state));
|
||||
|
||||
/* Issue a TEARDOWN if we are still connected */
|
||||
if (pa_raop_client_is_alive(u->raop)) {
|
||||
|
|
@ -249,7 +249,7 @@ static int sink_set_state_in_io_thread_cb(pa_sink *s, pa_sink_state_t new_state,
|
|||
pa_log_debug("RAOP: IDLE");
|
||||
|
||||
/* Issue a FLUSH if we're comming from running state */
|
||||
if (u->sink->thread_info.state == PA_SINK_RUNNING) {
|
||||
if (s->thread_info.state == PA_SINK_RUNNING) {
|
||||
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
||||
pa_raop_client_flush(u->raop);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue