pa_sink_get_state() is supposed to be used from the main thread. In this
case it doesn't really matter, because the SET_STATE handler is executed
while the main thread is waiting, but since the state is available also
in thread_info, let's use that. All other modules use thread_info.state
too, so at least this change improves consistency.
Also, we can use the PA_SINK_IS_OPENED macro to simplify the code a bit.
switch (code) {
case PA_SINK_MESSAGE_SET_STATE:
- if (pa_sink_get_state(u->sink) == PA_SINK_SUSPENDED || pa_sink_get_state(u->sink) == PA_SINK_INIT) {
- if (PA_PTR_TO_UINT(data) == PA_SINK_RUNNING || PA_PTR_TO_UINT(data) == PA_SINK_IDLE)
+ if (u->sink->thread_info.state == PA_SINK_SUSPENDED || u->sink->thread_info.state == PA_SINK_INIT) {
+ if (PA_SINK_IS_OPENED(PA_PTR_TO_UINT(data)))
u->timestamp = pa_rtclock_now();
}
switch (code) {
case PA_SINK_MESSAGE_SET_STATE:
- if (pa_sink_get_state(u->sink) == PA_SINK_SUSPENDED || pa_sink_get_state(u->sink) == PA_SINK_INIT) {
- if (PA_PTR_TO_UINT(data) == PA_SINK_RUNNING || PA_PTR_TO_UINT(data) == PA_SINK_IDLE)
+ if (u->sink->thread_info.state == PA_SINK_SUSPENDED || u->sink->thread_info.state == PA_SINK_INIT) {
+ if (PA_SINK_IS_OPENED(PA_PTR_TO_UINT(data)))
u->timestamp = pa_rtclock_now();
- } else if (pa_sink_get_state(u->sink) == PA_SINK_RUNNING || pa_sink_get_state(u->sink) == PA_SINK_IDLE) {
+ } else if (u->sink->thread_info.state == PA_SINK_RUNNING || u->sink->thread_info.state == PA_SINK_IDLE) {
if (PA_PTR_TO_UINT(data) == PA_SINK_SUSPENDED) {
/* Clear potential FIFO error flag */
u->fifo_error = false;