[pulseaudio-discuss] [PATCH 2/3] sink-input, source-output: remove the state getters

Tanu Kaskinen tanuk at iki.fi
Tue Jun 26 13:25:57 UTC 2018


pa_sink_input_get_state() and pa_source_output_get_state() just return
the state variable. We can as well access the state variable directly.

There are no behaviour changes, except that some filter sources accessed
the main thread's state variable from their push() callbacks. I fixed
them so that they use the thread_info.state variable instead.
---
 src/modules/echo-cancel/module-echo-cancel.c | 16 ++++++++--------
 src/modules/module-device-manager.c          |  4 ++--
 src/modules/module-equalizer-sink.c          |  6 +++---
 src/modules/module-intended-roles.c          |  4 ++--
 src/modules/module-ladspa-sink.c             |  4 ++--
 src/modules/module-remap-sink.c              |  2 +-
 src/modules/module-remap-source.c            |  4 ++--
 src/modules/module-stream-restore.c          |  4 ++--
 src/modules/module-suspend-on-idle.c         | 12 ++++--------
 src/modules/module-virtual-sink.c            |  6 +++---
 src/modules/module-virtual-source.c          |  8 ++++----
 src/modules/module-virtual-surround-sink.c   |  6 +++---
 src/modules/stream-interaction.c             | 12 ++++++------
 src/pulsecore/cli-text.c                     |  4 ++--
 src/pulsecore/protocol-native.c              |  8 ++++----
 src/pulsecore/sink-input.c                   | 14 +++-----------
 src/pulsecore/sink-input.h                   |  2 --
 src/pulsecore/sink.c                         |  8 ++------
 src/pulsecore/source-output.c                |  4 ++--
 src/pulsecore/source-output.h                |  2 --
 src/pulsecore/source.c                       |  8 ++------
 21 files changed, 57 insertions(+), 81 deletions(-)

diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index 0f4af4410..cbaec2b34 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -471,7 +471,7 @@ static int source_set_state_in_main_thread_cb(pa_source *s, pa_source_state_t st
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(state) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return 0;
 
     if (state == PA_SOURCE_RUNNING) {
@@ -496,7 +496,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     if (state == PA_SINK_RUNNING) {
@@ -598,7 +598,7 @@ static void source_set_volume_cb(pa_source *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return;
 
     pa_source_output_set_volume(u->source_output, &s->real_volume, s->save_volume, true);
@@ -612,7 +612,7 @@ static void sink_set_volume_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_volume(u->sink_input, &s->real_volume, s->save_volume, true);
@@ -627,7 +627,7 @@ static void source_get_volume_cb(pa_source *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return;
 
     pa_source_output_get_volume(u->source_output, &v, true);
@@ -648,7 +648,7 @@ static void source_set_mute_cb(pa_source *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return;
 
     pa_source_output_set_mute(u->source_output, s->muted, s->save_muted);
@@ -662,7 +662,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
@@ -902,7 +902,7 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
     if (!PA_SOURCE_IS_LINKED(u->source->thread_info.state))
         return;
 
-    if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output))) {
+    if (!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state)) {
         pa_log("Push when no link?");
         return;
     }
diff --git a/src/modules/module-device-manager.c b/src/modules/module-device-manager.c
index abc7f94e8..15fdaaaa2 100644
--- a/src/modules/module-device-manager.c
+++ b/src/modules/module-device-manager.c
@@ -671,7 +671,7 @@ static void route_sink_input(struct userdata *u, pa_sink_input *si) {
     /* It might happen that a stream and a sink are set up at the
     same time, in which case we want to make sure we don't
     interfere with that */
-    if (!PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(si)))
+    if (!PA_SINK_INPUT_IS_LINKED(si->state))
         return;
 
     if (!(role = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROLE)))
@@ -746,7 +746,7 @@ static void route_source_output(struct userdata *u, pa_source_output *so) {
     /* It might happen that a stream and a source are set up at the
     same time, in which case we want to make sure we don't
     interfere with that */
-    if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(so)))
+    if (!PA_SOURCE_OUTPUT_IS_LINKED(so->state))
         return;
 
     if (!(role = pa_proplist_gets(so->proplist, PA_PROP_MEDIA_ROLE)))
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index 681f44d29..fc561e81f 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -280,7 +280,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     pa_sink_input_cork(u->sink_input, state == PA_SINK_SUSPENDED);
@@ -344,7 +344,7 @@ static void sink_set_volume_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_volume(u->sink_input, &s->real_volume, s->save_volume, true);
@@ -358,7 +358,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
diff --git a/src/modules/module-intended-roles.c b/src/modules/module-intended-roles.c
index da7366a6a..cb7c1a768 100644
--- a/src/modules/module-intended-roles.c
+++ b/src/modules/module-intended-roles.c
@@ -186,7 +186,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
         /* It might happen that a stream and a sink are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
-        if (!PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(si)))
+        if (!PA_SINK_INPUT_IS_LINKED(si->state))
             continue;
 
         if (!(role = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROLE)))
@@ -236,7 +236,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
         /* It might happen that a stream and a source are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
-        if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(so)))
+        if (!PA_SOURCE_OUTPUT_IS_LINKED(so->state))
             continue;
 
         if (!(role = pa_proplist_gets(so->proplist, PA_PROP_MEDIA_ROLE)))
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index a09d8b24e..284fabb82 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -387,7 +387,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-            !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+            !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     pa_sink_input_cork(u->sink_input, state == PA_SINK_SUSPENDED);
@@ -453,7 +453,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-            !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+            !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 503fcf5c7..1f7997c17 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -107,7 +107,7 @@ static int sink_set_state_in_main_thread(pa_sink *s, pa_sink_state_t state, pa_s
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     pa_sink_input_cork(u->sink_input, state == PA_SINK_SUSPENDED);
diff --git a/src/modules/module-remap-source.c b/src/modules/module-remap-source.c
index 8901eb905..cad04afac 100644
--- a/src/modules/module-remap-source.c
+++ b/src/modules/module-remap-source.c
@@ -115,7 +115,7 @@ static int source_set_state_in_main_thread_cb(pa_source *s, pa_source_state_t st
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(state) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return 0;
 
     pa_source_output_cork(u->source_output, state == PA_SOURCE_SUSPENDED);
@@ -152,7 +152,7 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
     if (!PA_SOURCE_IS_LINKED(u->source->thread_info.state))
         return;
 
-    if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output))) {
+    if (!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state)) {
         pa_log("push when no link?");
         return;
     }
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index e562e4edd..9857a8ee1 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -1657,7 +1657,7 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
         /* It might happen that a stream and a sink are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
-        if (!PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(si)))
+        if (!PA_SINK_INPUT_IS_LINKED(si->state))
             continue;
 
         if (!(name = pa_proplist_get_stream_group(si->proplist, "sink-input", IDENTIFICATION_PROPERTY)))
@@ -1710,7 +1710,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
         /* It might happen that a stream and a source are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
-        if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(so)))
+        if (!PA_SOURCE_OUTPUT_IS_LINKED(so->state))
             continue;
 
         if (!(name = pa_proplist_get_stream_group(so->proplist, "source-output", IDENTIFICATION_PROPERTY)))
diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 9949b5509..12702d1bd 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -215,14 +215,12 @@ static pa_hook_result_t sink_input_move_start_hook_cb(pa_core *c, pa_sink_input
 
 static pa_hook_result_t sink_input_move_finish_hook_cb(pa_core *c, pa_sink_input *s, struct userdata *u) {
     struct device_info *d;
-    pa_sink_input_state_t state;
 
     pa_assert(c);
     pa_sink_input_assert_ref(s);
     pa_assert(u);
 
-    state = pa_sink_input_get_state(s);
-    if (state != PA_SINK_INPUT_RUNNING)
+    if (s->state != PA_SINK_INPUT_RUNNING)
         return PA_HOOK_OK;
 
     if ((d = pa_hashmap_get(u->device_infos, s->sink)))
@@ -259,7 +257,7 @@ static pa_hook_result_t source_output_move_finish_hook_cb(pa_core *c, pa_source_
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
-    if (pa_source_output_get_state(s) != PA_SOURCE_OUTPUT_RUNNING)
+    if (s->state != PA_SOURCE_OUTPUT_RUNNING)
         return PA_HOOK_OK;
 
     if (s->source->monitor_of)
@@ -275,14 +273,12 @@ static pa_hook_result_t source_output_move_finish_hook_cb(pa_core *c, pa_source_
 
 static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_input *s, struct userdata *u) {
     struct device_info *d;
-    pa_sink_input_state_t state;
 
     pa_assert(c);
     pa_sink_input_assert_ref(s);
     pa_assert(u);
 
-    state = pa_sink_input_get_state(s);
-    if (state == PA_SINK_INPUT_RUNNING && s->sink)
+    if (s->state == PA_SINK_INPUT_RUNNING && s->sink)
         if ((d = pa_hashmap_get(u->device_infos, s->sink)))
             resume(d);
 
@@ -294,7 +290,7 @@ static pa_hook_result_t source_output_state_changed_hook_cb(pa_core *c, pa_sourc
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
-    if (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_RUNNING && s->source) {
+    if (s->state == PA_SOURCE_OUTPUT_RUNNING && s->source) {
         struct device_info *d;
 
         if (s->source->monitor_of)
diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c
index 3a818225d..2f4445c26 100644
--- a/src/modules/module-virtual-sink.c
+++ b/src/modules/module-virtual-sink.c
@@ -119,7 +119,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     pa_sink_input_cork(u->sink_input, state == PA_SINK_SUSPENDED);
@@ -185,7 +185,7 @@ static void sink_set_volume_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_volume(u->sink_input, &s->real_volume, s->save_volume, true);
@@ -199,7 +199,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c
index c40ffb616..b6de7f499 100644
--- a/src/modules/module-virtual-source.c
+++ b/src/modules/module-virtual-source.c
@@ -201,7 +201,7 @@ static int source_set_state_in_main_thread_cb(pa_source *s, pa_source_state_t st
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(state) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return 0;
 
     pa_source_output_cork(u->source_output, state == PA_SOURCE_SUSPENDED);
@@ -233,7 +233,7 @@ static void source_set_volume_cb(pa_source *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return;
 
     pa_source_output_set_volume(u->source_output, &s->real_volume, s->save_volume, true);
@@ -247,7 +247,7 @@ static void source_set_mute_cb(pa_source *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
-        !PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
+        !PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
         return;
 
     pa_source_output_set_mute(u->source_output, s->muted, s->save_muted);
@@ -264,7 +264,7 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
     if (!PA_SOURCE_IS_LINKED(u->source->thread_info.state))
         return;
 
-    if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output))) {
+    if (!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->thread_info.state)) {
         pa_log("push when no link?");
         return;
     }
diff --git a/src/modules/module-virtual-surround-sink.c b/src/modules/module-virtual-surround-sink.c
index f14f137fb..fe195cde5 100644
--- a/src/modules/module-virtual-surround-sink.c
+++ b/src/modules/module-virtual-surround-sink.c
@@ -147,7 +147,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(state) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return 0;
 
     pa_sink_input_cork(u->sink_input, state == PA_SINK_SUSPENDED);
@@ -213,7 +213,7 @@ static void sink_set_volume_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_volume(u->sink_input, &s->real_volume, s->save_volume, true);
@@ -227,7 +227,7 @@ static void sink_set_mute_cb(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
-        !PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(u->sink_input)))
+        !PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
         return;
 
     pa_sink_input_set_mute(u->sink_input, s->muted, s->save_muted);
diff --git a/src/modules/stream-interaction.c b/src/modules/stream-interaction.c
index 41847860c..bf7134ac9 100644
--- a/src/modules/stream-interaction.c
+++ b/src/modules/stream-interaction.c
@@ -98,7 +98,7 @@ static const char *find_trigger_stream(struct userdata *u, pa_sink *s, pa_sink_i
             continue;
 
         trigger_role = get_trigger_role(u, j, g);
-        if (trigger_role && !j->muted && pa_sink_input_get_state(j) != PA_SINK_INPUT_CORKED)
+        if (trigger_role && !j->muted && j->state != PA_SINK_INPUT_CORKED)
             return trigger_role;
     }
 
@@ -185,7 +185,7 @@ static inline void apply_interaction_to_sink(struct userdata *u, pa_sink *s, con
         /* the application only after sink_input_put() was called. If a new stream turns */
         /* up, act as if it was not corked. In the case of module-role-cork this will */
         /* only mute the stream because corking is reverted later by the application */
-        corked = (pa_sink_input_get_state(j) == PA_SINK_INPUT_CORKED);
+        corked = (j->state == PA_SINK_INPUT_CORKED);
         if (new_stream && corked)
             corked = false;
         interaction_applied = !!pa_hashmap_get(g->interaction_state, j);
@@ -227,7 +227,7 @@ static void remove_interactions(struct userdata *u, struct group *g) {
         for (j = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx_input)); j; j = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx_input))) {
 
             if(!!pa_hashmap_get(g->interaction_state, j)) {
-                corked = (pa_sink_input_get_state(j) == PA_SINK_INPUT_CORKED);
+                corked = (j->state == PA_SINK_INPUT_CORKED);
                 if (!(role = pa_proplist_gets(j->proplist, PA_PROP_MEDIA_ROLE)))
                    role = "no_role";
                 uncork_or_unduck(u, j, role, corked, g);
@@ -289,7 +289,7 @@ static pa_hook_result_t sink_input_state_changed_cb(pa_core *core, pa_sink_input
     pa_core_assert_ref(core);
     pa_sink_input_assert_ref(i);
 
-    if (PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(i)) && get_trigger_role(u, i, NULL))
+    if (PA_SINK_INPUT_IS_LINKED(i->state) && get_trigger_role(u, i, NULL))
         return process(u, i, true, false);
 
     return PA_HOOK_OK;
@@ -299,7 +299,7 @@ static pa_hook_result_t sink_input_mute_changed_cb(pa_core *core, pa_sink_input
     pa_core_assert_ref(core);
     pa_sink_input_assert_ref(i);
 
-    if (PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(i)) && get_trigger_role(u, i, NULL))
+    if (PA_SINK_INPUT_IS_LINKED(i->state) && get_trigger_role(u, i, NULL))
         return process(u, i, true, false);
 
     return PA_HOOK_OK;
@@ -309,7 +309,7 @@ static pa_hook_result_t sink_input_proplist_changed_cb(pa_core *core, pa_sink_in
     pa_core_assert_ref(core);
     pa_sink_input_assert_ref(i);
 
-    if (PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(i)))
+    if (PA_SINK_INPUT_IS_LINKED(i->state))
         return process(u, i, true, false);
 
     return PA_HOOK_OK;
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 2e377f0f1..5be7c3cc9 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -489,7 +489,7 @@ char *pa_source_output_list_to_string(pa_core *c) {
             o->flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_ON_SUSPEND " : "",
             o->flags & PA_SOURCE_OUTPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
             o->flags & PA_SOURCE_OUTPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
-            state_table[pa_source_output_get_state(o)],
+            state_table[o->state],
             o->source->index, o->source->name,
             volume_str,
             pa_yes_no(o->muted),
@@ -586,7 +586,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
             i->flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND ? "NO_CREATE_SUSPEND " : "",
             i->flags & PA_SINK_INPUT_KILL_ON_SUSPEND ? "KILL_ON_SUSPEND " : "",
             i->flags & PA_SINK_INPUT_PASSTHROUGH ? "PASSTHROUGH " : "",
-            state_table[pa_sink_input_get_state(i)],
+            state_table[i->state],
             i->sink->index, i->sink->name,
             volume_str,
             pa_yes_no(i->muted),
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 2d45a4cb6..3def4a6ab 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2880,7 +2880,7 @@ static void command_get_playback_latency(pa_pdispatch *pd, uint32_t command, uin
     pa_tagstruct_put_boolean(reply,
                              s->playing_for > 0 &&
                              pa_sink_get_state(s->sink_input->sink) == PA_SINK_RUNNING &&
-                             pa_sink_input_get_state(s->sink_input) == PA_SINK_INPUT_RUNNING);
+                             s->sink_input->state == PA_SINK_INPUT_RUNNING);
     pa_tagstruct_put_timeval(reply, &tv);
     pa_tagstruct_put_timeval(reply, pa_gettimeofday(&now));
     pa_tagstruct_puts64(reply, s->write_index);
@@ -2925,7 +2925,7 @@ static void command_get_record_latency(pa_pdispatch *pd, uint32_t command, uint3
                           pa_bytes_to_usec(s->on_the_fly_snapshot, &s->source_output->sample_spec));
     pa_tagstruct_put_boolean(reply,
                              pa_source_get_state(s->source_output->source) == PA_SOURCE_RUNNING &&
-                             pa_source_output_get_state(s->source_output) == PA_SOURCE_OUTPUT_RUNNING);
+                             s->source_output->state == PA_SOURCE_OUTPUT_RUNNING);
     pa_tagstruct_put_timeval(reply, &tv);
     pa_tagstruct_put_timeval(reply, pa_gettimeofday(&now));
     pa_tagstruct_puts64(reply, pa_memblockq_get_write_index(s->memblockq));
@@ -3392,7 +3392,7 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t,
     if (c->version >= 13)
         pa_tagstruct_put_proplist(t, s->proplist);
     if (c->version >= 19)
-        pa_tagstruct_put_boolean(t, (pa_sink_input_get_state(s) == PA_SINK_INPUT_CORKED));
+        pa_tagstruct_put_boolean(t, s->state == PA_SINK_INPUT_CORKED);
     if (c->version >= 20) {
         pa_tagstruct_put_boolean(t, has_volume);
         pa_tagstruct_put_boolean(t, s->volume_writable);
@@ -3432,7 +3432,7 @@ static void source_output_fill_tagstruct(pa_native_connection *c, pa_tagstruct *
     if (c->version >= 13)
         pa_tagstruct_put_proplist(t, s->proplist);
     if (c->version >= 19)
-        pa_tagstruct_put_boolean(t, (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_CORKED));
+        pa_tagstruct_put_boolean(t, s->state == PA_SOURCE_OUTPUT_CORKED);
     if (c->version >= 22) {
         pa_tagstruct_put_cvolume(t, &v);
         pa_tagstruct_put_boolean(t, s->muted);
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d0b2ad17b..2a8c6831d 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -359,7 +359,7 @@ int pa_sink_input_new(
 
     pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);
     pa_return_val_if_fail(!data->sync_base || (data->sync_base->sink == data->sink
-                                               && pa_sink_input_get_state(data->sync_base) == PA_SINK_INPUT_CORKED),
+                                               && data->sync_base->state == PA_SINK_INPUT_CORKED),
                           -PA_ERR_INVALID);
 
     /* Routing is done. We have a sink and a format. */
@@ -1720,7 +1720,7 @@ int pa_sink_input_start_move(pa_sink_input *i) {
 
     pa_idxset_remove_by_data(i->sink->inputs, i, NULL);
 
-    if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED)
+    if (i->state == PA_SINK_INPUT_CORKED)
         pa_assert_se(i->sink->n_corked-- >= 1);
 
     if (pa_sink_input_is_passthrough(i))
@@ -1922,7 +1922,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, bool save) {
 
     pa_cvolume_remap(&i->volume_factor_sink, &i->channel_map, &i->sink->channel_map);
 
-    if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED)
+    if (i->state == PA_SINK_INPUT_CORKED)
         i->sink->n_corked++;
 
     pa_sink_input_update_rate(i);
@@ -2113,14 +2113,6 @@ int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t
     return -PA_ERR_NOTIMPLEMENTED;
 }
 
-/* Called from main thread */
-pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i) {
-    pa_sink_input_assert_ref(i);
-    pa_assert_ctl_context();
-
-    return i->state;
-}
-
 /* Called from IO context */
 bool pa_sink_input_safe_to_remove(pa_sink_input *i) {
     pa_sink_input_assert_ref(i);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index aa8c546a7..9e90291ca 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -394,8 +394,6 @@ int pa_sink_input_start_move(pa_sink_input *i);
 int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, bool save);
 void pa_sink_input_fail_move(pa_sink_input *i);
 
-pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i);
-
 pa_usec_t pa_sink_input_get_requested_latency(pa_sink_input *i);
 
 /* To be used exclusively by the sink driver IO thread */
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d617d27f6..566367f9e 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2456,22 +2456,18 @@ unsigned pa_sink_check_suspend(pa_sink *s, pa_sink_input *ignore_input, pa_sourc
     ret = 0;
 
     PA_IDXSET_FOREACH(i, s->inputs, idx) {
-        pa_sink_input_state_t st;
-
         if (i == ignore_input)
             continue;
 
-        st = pa_sink_input_get_state(i);
-
         /* We do not assert here. It is perfectly valid for a sink input to
          * be in the INIT state (i.e. created, marked done but not yet put)
          * and we should not care if it's unlinked as it won't contribute
          * towards our busy status.
          */
-        if (!PA_SINK_INPUT_IS_LINKED(st))
+        if (!PA_SINK_INPUT_IS_LINKED(i->state))
             continue;
 
-        if (st == PA_SINK_INPUT_CORKED)
+        if (i->state == PA_SINK_INPUT_CORKED)
             continue;
 
         if (i->flags & PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND)
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index e4ed43804..7ee77cf93 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -1356,7 +1356,7 @@ int pa_source_output_start_move(pa_source_output *o) {
 
     pa_idxset_remove_by_data(o->source->outputs, o, NULL);
 
-    if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED)
+    if (o->state == PA_SOURCE_OUTPUT_CORKED)
         pa_assert_se(origin->n_corked-- >= 1);
 
     if (pa_source_output_is_passthrough(o))
@@ -1551,7 +1551,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, bool save
 
     pa_cvolume_remap(&o->volume_factor_source, &o->channel_map, &o->source->channel_map);
 
-    if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED)
+    if (o->state == PA_SOURCE_OUTPUT_CORKED)
         o->source->n_corked++;
 
     pa_source_output_update_rate(o);
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index 2f06f7d16..661b64b95 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -344,8 +344,6 @@ int pa_source_output_start_move(pa_source_output *o);
 int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, bool save);
 void pa_source_output_fail_move(pa_source_output *o);
 
-#define pa_source_output_get_state(o) ((o)->state)
-
 pa_usec_t pa_source_output_get_requested_latency(pa_source_output *o);
 
 /* To be used exclusively by the source driver thread */
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index dac085ce4..6d4319632 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -2024,22 +2024,18 @@ unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore) {
     ret = 0;
 
     PA_IDXSET_FOREACH(o, s->outputs, idx) {
-        pa_source_output_state_t st;
-
         if (o == ignore)
             continue;
 
-        st = pa_source_output_get_state(o);
-
         /* We do not assert here. It is perfectly valid for a source output to
          * be in the INIT state (i.e. created, marked done but not yet put)
          * and we should not care if it's unlinked as it won't contribute
          * towards our busy status.
          */
-        if (!PA_SOURCE_OUTPUT_IS_LINKED(st))
+        if (!PA_SOURCE_OUTPUT_IS_LINKED(o->state))
             continue;
 
-        if (st == PA_SOURCE_OUTPUT_CORKED)
+        if (o->state == PA_SOURCE_OUTPUT_CORKED)
             continue;
 
         if (o->flags & PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND)
-- 
2.17.0



More information about the pulseaudio-discuss mailing list