diff options
author | Tanu Kaskinen <tanuk@iki.fi> | 2018-02-21 11:54:41 +0200 |
---|---|---|
committer | Tanu Kaskinen <tanuk@iki.fi> | 2018-02-23 13:36:35 +0200 |
commit | 7f09164ed7979210adcdb7674b9d6217fd44ed66 (patch) | |
tree | 86b9d7f0f09d14537f6385276592ddbd7f871cd5 | |
parent | 2dff0d6a6a4df2aab6f36212b705489d5af42835 (diff) | |
download | pulseaudio-7f09164ed7979210adcdb7674b9d6217fd44ed66.tar.gz |
null-sink, pipe-sink: some state variable cleanups
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.
-rw-r--r-- | src/modules/module-null-sink.c | 4 | ||||
-rw-r--r-- | src/modules/module-pipe-sink.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 25b0f3091..3ace082df 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -91,8 +91,8 @@ static int sink_process_msg( 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(); } diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c index a2074c1f2..995785e1e 100644 --- a/src/modules/module-pipe-sink.c +++ b/src/modules/module-pipe-sink.c @@ -111,10 +111,10 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse 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; |