[PATCH] null-sink, pipe-sink: some state variable cleanups

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21.02.2018 10:54, Tanu Kaskinen wrote:
> 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.
> ---
>   src/modules/module-null-sink.c | 4 ++--
>   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;

LGTM



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux