[PATCH 6/8] pass pa_suspend_cause_t to SINK/SOURCE_SET_STATE handlers

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

 



On 02/19/2018 05:48 PM, Tanu Kaskinen wrote:
> The suspend cause isn't yet used by any of the handlers. The alsa sink
> and source will use it to sync the mixer when the SESSION suspend cause
> is removed. Currently the syncing is done in pa_sink/source_suspend(),
> and I want to change that, because pa_sink/source_suspend() shouldn't
> have any alsa specific code.
> ---
> @@ -2845,12 +2848,12 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
>              return 0;
>  
>          case PA_SINK_MESSAGE_SET_STATE: {
> -
> +            pa_sink_state_t new_state = ((pa_sink_message_set_state *) userdata)->state;

I think we can save suspend_cause to thread_info too:

+            pa_suspend_cause_t suspend_cause = ((pa_sink_message_set_state *) userdata)->suspend_cause;

>              bool suspend_change =
> -                (s->thread_info.state == PA_SINK_SUSPENDED && PA_SINK_IS_OPENED(PA_PTR_TO_UINT(userdata))) ||
> -                (PA_SINK_IS_OPENED(s->thread_info.state) && PA_PTR_TO_UINT(userdata) == PA_SINK_SUSPENDED);
> +                (s->thread_info.state == PA_SINK_SUSPENDED && PA_SINK_IS_OPENED(new_state)) ||
> +                (PA_SINK_IS_OPENED(s->thread_info.state) && new_state == PA_SINK_SUSPENDED);
>  
> -            s->thread_info.state = PA_PTR_TO_UINT(userdata);
> +            s->thread_info.state = new_state;

+            s->thread_info.suspend_cause = suspend_cause;

>  
>              if (s->thread_info.state == PA_SINK_SUSPENDED) {
>                  s->thread_info.rewind_nbytes = 0;

...

> @@ -2219,12 +2222,12 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
>              return 0;
>  
>          case PA_SOURCE_MESSAGE_SET_STATE: {
> -
> +            pa_source_state_t new_state = ((pa_source_message_set_state *) userdata)->state;

+            pa_source_state_t suspend_cause = ((pa_source_message_set_state *) userdata)->suspend_cause;

>              bool suspend_change =
> -                (s->thread_info.state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(PA_PTR_TO_UINT(userdata))) ||
> -                (PA_SOURCE_IS_OPENED(s->thread_info.state) && PA_PTR_TO_UINT(userdata) == PA_SOURCE_SUSPENDED);
> +                (s->thread_info.state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(new_state)) ||
> +                (PA_SOURCE_IS_OPENED(s->thread_info.state) && new_state == PA_SOURCE_SUSPENDED);
>  
> -            s->thread_info.state = PA_PTR_TO_UINT(userdata);
> +            s->thread_info.state = new_state;

+            s->thread_info.suspend_cause = suspend_cause;

>  
>              if (suspend_change) {
>                  pa_source_output *o;

And add suspend_cause to sink's and source's thread_info and init:

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 7f5c37f..3904158 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -330,6 +330,7 @@ pa_sink* pa_sink_new(
     s->thread_info.soft_volume =  s->soft_volume;
     s->thread_info.soft_muted = s->muted;
     s->thread_info.state = s->state;
+    s->thread_info.suspend_cause = s->suspend_cause;
     s->thread_info.rewind_nbytes = 0;
     s->thread_info.rewind_requested = false;
     s->thread_info.max_rewind = 0;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 3fb2301..e897d69 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -252,6 +252,7 @@ struct pa_sink {
      * thread can work without access locking */
     struct {
         pa_sink_state_t state;
+        pa_suspend_cause_t suspend_cause;
         pa_hashmap *inputs;
 
         pa_rtpoll *rtpoll;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 2a6b1f1..4eaa1a9 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -318,6 +318,7 @@ pa_source* pa_source_new(
     s->thread_info.soft_volume = s->soft_volume;
     s->thread_info.soft_muted = s->muted;
     s->thread_info.state = s->state;
+    s->thread_info.suspend_cause = s->suspend_cause;
     s->thread_info.max_rewind = 0;
     s->thread_info.requested_latency_valid = false;
     s->thread_info.requested_latency = 0;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 75ce241..cfe4306 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -210,6 +210,7 @@ struct pa_source {
      * thread can work without access locking */
     struct {
         pa_source_state_t state;
+        pa_suspend_cause_t suspend_cause;
         pa_hashmap *outputs;
 
         pa_rtpoll *rtpoll;

--
Raman


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

  Powered by Linux