Discussion:
[pulseaudio-discuss] [PATCH 0/3] Various state related cleanups
Tanu Kaskinen
2018-06-26 13:25:55 UTC
Permalink
The first patch is a reaction to a bug report[1] that pointed out a
weird thing in the sink input drained state handling. I came to the
conclusion that we can just remove the entire drained state.

After removing the drained state, pa_sink_input_get_state() didn't have
anything to do any more, except to just return the state variable.
pa_source_output_get_state() didn't do anything either. The second patch
removes those functions.

Then I noticed that pa_sink_get_state() and pa_source_get_state() don't
do anything either, so the third patch removes those as well.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=106982

Tanu Kaskinen (3):
sink-input: remove the DRAINED state
sink-input, source-output: remove the state getters
sink, source: remove the state getters

src/modules/alsa/alsa-sink.c | 2 +-
src/modules/alsa/alsa-source.c | 2 +-
src/modules/dbus/iface-device.c | 12 +++----
src/modules/echo-cancel/module-echo-cancel.c | 34 ++++++++++----------
src/modules/module-combine-sink.c | 16 ++++-----
src/modules/module-device-manager.c | 4 +--
src/modules/module-equalizer-sink.c | 10 +++---
src/modules/module-intended-roles.c | 12 +++----
src/modules/module-ladspa-sink.c | 6 ++--
src/modules/module-loopback.c | 8 ++---
src/modules/module-remap-sink.c | 2 +-
src/modules/module-remap-source.c | 4 +--
src/modules/module-rescue-streams.c | 4 +--
src/modules/module-stream-restore.c | 12 +++----
src/modules/module-suspend-on-idle.c | 22 +++++--------
src/modules/module-tunnel.c | 4 +--
src/modules/module-virtual-sink.c | 10 +++---
src/modules/module-virtual-source.c | 14 ++++----
src/modules/module-virtual-surround-sink.c | 10 +++---
src/modules/stream-interaction.c | 12 +++----
src/pulsecore/cli-command.c | 4 +--
src/pulsecore/cli-text.c | 9 +++---
src/pulsecore/core.c | 4 +--
src/pulsecore/protocol-esound.c | 7 ++--
src/pulsecore/protocol-native.c | 28 ++++++++--------
src/pulsecore/sink-input.c | 34 ++++----------------
src/pulsecore/sink-input.h | 9 +-----
src/pulsecore/sink.c | 8 ++---
src/pulsecore/sink.h | 2 --
src/pulsecore/source-output.c | 10 +++---
src/pulsecore/source-output.h | 2 --
src/pulsecore/source.c | 10 ++----
src/pulsecore/source.h | 2 --
33 files changed, 140 insertions(+), 189 deletions(-)
--
2.17.0
Tanu Kaskinen
2018-06-26 13:25:56 UTC
Permalink
The only thing that the drained state was being used for was "pacmd
list-sink-inputs". In all other cases the drained and running states
were treated as equivalent. IMHO, this usage doesn't justify the
complexity that the additional state brings.

This patch was inspired by a bug report[1] that pointed out an error in
an if condition in pa_sink_input_set_state_within_thread(). The buggy
code is now removed altogether.

[1] https://bugs.freedesktop.org/show_bug.cgi?id=106982
---
src/modules/module-suspend-on-idle.c | 4 ++--
src/pulsecore/cli-text.c | 1 -
src/pulsecore/sink-input.c | 14 --------------
src/pulsecore/sink-input.h | 7 +------
4 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 37ba659e4..9949b5509 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -222,7 +222,7 @@ static pa_hook_result_t sink_input_move_finish_hook_cb(pa_core *c, pa_sink_input
pa_assert(u);

state = pa_sink_input_get_state(s);
- if (state != PA_SINK_INPUT_RUNNING && state != PA_SINK_INPUT_DRAINED)
+ if (state != PA_SINK_INPUT_RUNNING)
return PA_HOOK_OK;

if ((d = pa_hashmap_get(u->device_infos, s->sink)))
@@ -282,7 +282,7 @@ static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_inp
pa_assert(u);

state = pa_sink_input_get_state(s);
- if ((state == PA_SINK_INPUT_RUNNING || state == PA_SINK_INPUT_DRAINED) && s->sink)
+ if (state == PA_SINK_INPUT_RUNNING && s->sink)
if ((d = pa_hashmap_get(u->device_infos, s->sink)))
resume(d);

diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 474f3367b..2e377f0f1 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -525,7 +525,6 @@ char *pa_sink_input_list_to_string(pa_core *c) {
static const char* const state_table[] = {
[PA_SINK_INPUT_INIT] = "INIT",
[PA_SINK_INPUT_RUNNING] = "RUNNING",
- [PA_SINK_INPUT_DRAINED] = "DRAINED",
[PA_SINK_INPUT_CORKED] = "CORKED",
[PA_SINK_INPUT_UNLINKED] = "UNLINKED"
};
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index bc42a9b19..d0b2ad17b 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -541,7 +541,6 @@ int pa_sink_input_new(

i->thread_info.state = i->state;
i->thread_info.attached = false;
- pa_atomic_store(&i->thread_info.drained, 1);
i->thread_info.sample_spec = i->sample_spec;
i->thread_info.resampler = resampler;
i->thread_info.soft_volume = i->soft_volume;
@@ -610,9 +609,6 @@ static void sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state)
pa_assert(i);
pa_assert_ctl_context();

- if (state == PA_SINK_INPUT_DRAINED)
- state = PA_SINK_INPUT_RUNNING;
-
if (i->state == state)
return;

@@ -924,7 +920,6 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa

/* OK, we're corked or the implementor didn't give us any
* data, so let's just hand out silence */
- pa_atomic_store(&i->thread_info.drained, 1);

pa_memblockq_seek(i->thread_info.render_memblockq, (int64_t) slength, PA_SEEK_RELATIVE, true);
i->thread_info.playing_for = 0;
@@ -935,8 +930,6 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink bytes */, pa
break;
}

- pa_atomic_store(&i->thread_info.drained, 0);
-
pa_assert(tchunk.length > 0);
pa_assert(tchunk.memblock);

@@ -2013,10 +2006,6 @@ void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state
if (state == i->thread_info.state)
return;

- if ((state == PA_SINK_INPUT_DRAINED || state == PA_SINK_INPUT_RUNNING) &&
- !(i->thread_info.state == PA_SINK_INPUT_DRAINED || i->thread_info.state != PA_SINK_INPUT_RUNNING))
- pa_atomic_store(&i->thread_info.drained, 1);
-
corking = state == PA_SINK_INPUT_CORKED && i->thread_info.state == PA_SINK_INPUT_RUNNING;
uncorking = i->thread_info.state == PA_SINK_INPUT_CORKED && state == PA_SINK_INPUT_RUNNING;

@@ -2129,9 +2118,6 @@ pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i) {
pa_sink_input_assert_ref(i);
pa_assert_ctl_context();

- if (i->state == PA_SINK_INPUT_RUNNING || i->state == PA_SINK_INPUT_DRAINED)
- return pa_atomic_load(&i->thread_info.drained) ? PA_SINK_INPUT_DRAINED : PA_SINK_INPUT_RUNNING;
-
return i->state;
}

diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index b16f60fe5..aa8c546a7 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -35,7 +35,6 @@

typedef enum pa_sink_input_state {
PA_SINK_INPUT_INIT, /*< The stream is not active yet, because pa_sink_input_put() has not been called yet */
- PA_SINK_INPUT_DRAINED, /*< The stream stopped playing because there was no data to play */
PA_SINK_INPUT_RUNNING, /*< The stream is alive and kicking */
PA_SINK_INPUT_CORKED, /*< The stream was corked on user request */
PA_SINK_INPUT_UNLINKED /*< The stream is dead */
@@ -43,7 +42,7 @@ typedef enum pa_sink_input_state {
} pa_sink_input_state_t;

static inline bool PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) {
- return x == PA_SINK_INPUT_DRAINED || x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
+ return x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
}

typedef enum pa_sink_input_flags {
@@ -67,9 +66,6 @@ struct pa_sink_input {
uint32_t index;
pa_core *core;

- /* Please note that this state should only be read with
- * pa_sink_input_get_state(). That function will transparently
- * merge the thread_info.drained value in. */
pa_sink_input_state_t state;
pa_sink_input_flags_t flags;

@@ -231,7 +227,6 @@ struct pa_sink_input {

struct {
pa_sink_input_state_t state;
- pa_atomic_t drained;

pa_cvolume soft_volume;
bool muted:1;
--
2.17.0
Tanu Kaskinen
2018-06-26 13:25:57 UTC
Permalink
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
Tanu Kaskinen
2018-06-26 13:25:58 UTC
Permalink
pa_sink_get_state() and pa_source_get_state() just return the state
variable. We can as well access the state variable directly.

There are no behaviour changes, except that module-virtual-source
accessed the main thread's sink state variable from its push() callback.
I fixed the module so that it uses the thread_info.state variable
instead. Also, the compiler started to complain about comparing a sink
state variable to a source state enum value in protocol-esound.c. The
underlying bug was that a source pointer was assigned to a variable
whose type was a sink pointer (somehow using the pa_source_get_state()
macro confused the compiler enough so that it didn't complain before).
I fixed the variable type.
---
src/modules/alsa/alsa-sink.c | 2 +-
src/modules/alsa/alsa-source.c | 2 +-
src/modules/dbus/iface-device.c | 12 ++++++------
src/modules/echo-cancel/module-echo-cancel.c | 18 +++++++++---------
src/modules/module-combine-sink.c | 16 ++++++++--------
src/modules/module-equalizer-sink.c | 4 ++--
src/modules/module-intended-roles.c | 8 ++++----
src/modules/module-ladspa-sink.c | 2 +-
src/modules/module-loopback.c | 8 ++++----
src/modules/module-rescue-streams.c | 4 ++--
src/modules/module-stream-restore.c | 8 ++++----
src/modules/module-suspend-on-idle.c | 10 ++++------
src/modules/module-tunnel.c | 4 ++--
src/modules/module-virtual-sink.c | 4 ++--
src/modules/module-virtual-source.c | 6 +++---
src/modules/module-virtual-surround-sink.c | 4 ++--
src/pulsecore/cli-command.c | 4 ++--
src/pulsecore/cli-text.c | 4 ++--
src/pulsecore/core.c | 4 ++--
src/pulsecore/protocol-esound.c | 7 ++++---
src/pulsecore/protocol-native.c | 20 ++++++++++----------
src/pulsecore/sink-input.c | 6 +++---
src/pulsecore/sink.h | 2 --
src/pulsecore/source-output.c | 6 +++---
src/pulsecore/source.c | 2 +-
src/pulsecore/source.h | 2 --
26 files changed, 82 insertions(+), 87 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 871c82922..9a616ea76 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1256,7 +1256,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t new_stat
&& !(new_suspend_cause & PA_SUSPEND_SESSION))
sync_mixer(u, s->active_port);

- old_state = pa_sink_get_state(u->sink);
+ old_state = u->sink->state;

if (PA_SINK_IS_OPENED(old_state) && new_state == PA_SINK_SUSPENDED)
reserve_done(u);
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index c32e7e98b..8c5740373 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1111,7 +1111,7 @@ static int source_set_state_in_main_thread_cb(pa_source *s, pa_source_state_t ne
&& !(new_suspend_cause & PA_SUSPEND_SESSION))
sync_mixer(u, s->active_port);

- old_state = pa_source_get_state(u->source);
+ old_state = u->source->state;

if (PA_SOURCE_IS_OPENED(old_state) && new_state == PA_SOURCE_SUSPENDED)
reserve_done(u);
diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c
index 2c370a822..775cf3ff6 100644
--- a/src/modules/dbus/iface-device.c
+++ b/src/modules/dbus/iface-device.c
@@ -849,7 +849,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
latency = pa_sink_get_latency(d->sink);
is_hardware_device = !!(d->sink->flags & PA_SINK_HARDWARE);
is_network_device = !!(d->sink->flags & PA_SINK_NETWORK);
- state = pa_sink_get_state(d->sink);
+ state = d->sink->state;
} else {
idx = d->source->index;
name = d->source->name;
@@ -870,7 +870,7 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
latency = pa_source_get_latency(d->source);
is_hardware_device = !!(d->source->flags & PA_SOURCE_HARDWARE);
is_network_device = !!(d->source->flags & PA_SOURCE_NETWORK);
- state = pa_source_get_state(d->source);
+ state = d->source->state;
}
if (owner_module)
owner_module_path = pa_dbusiface_core_get_module_path(d->core, owner_module);
@@ -1158,9 +1158,9 @@ static pa_hook_result_t state_changed_cb(void *hook_data, void *call_data, void
return PA_HOOK_OK;

if (d->type == PA_DEVICE_TYPE_SINK)
- new_sink_state = pa_sink_get_state(d->sink);
+ new_sink_state = d->sink->state;
else
- new_source_state = pa_source_get_state(d->source);
+ new_source_state = d->source->state;

if ((d->type == PA_DEVICE_TYPE_SINK && d->sink_state != new_sink_state)
|| (d->type == PA_DEVICE_TYPE_SOURCE && d->source_state != new_source_state)) {
@@ -1258,7 +1258,7 @@ pa_dbusiface_device *pa_dbusiface_device_new_sink(pa_dbusiface_core *core, pa_si
d->path = pa_sprintf_malloc("%s/%s%u", PA_DBUS_CORE_OBJECT_PATH, SINK_OBJECT_NAME, sink->index);
d->volume = *pa_sink_get_volume(sink, false);
d->mute = pa_sink_get_mute(sink, false);
- d->sink_state = pa_sink_get_state(sink);
+ d->sink_state = sink->state;
d->ports = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_device_port_free);
d->next_port_index = 0;
d->active_port = sink->active_port;
@@ -1301,7 +1301,7 @@ pa_dbusiface_device *pa_dbusiface_device_new_source(pa_dbusiface_core *core, pa_
d->path = pa_sprintf_malloc("%s/%s%u", PA_DBUS_CORE_OBJECT_PATH, SOURCE_OBJECT_NAME, source->index);
d->volume = *pa_source_get_volume(source, false);
d->mute = pa_source_get_mute(source, false);
- d->source_state = pa_source_get_state(source);
+ d->source_state = source->state;
d->ports = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_device_port_free);
d->next_port_index = 0;
d->active_port = source->active_port;
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index cbaec2b34..3a4c8c949 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -146,8 +146,8 @@ static const pa_echo_canceller ec_table[] = {
#define MAX_LATENCY_BLOCKS 10

/* Can only be used in main context */
-#define IS_ACTIVE(u) ((pa_source_get_state((u)->source) == PA_SOURCE_RUNNING) && \
- (pa_sink_get_state((u)->sink) == PA_SINK_RUNNING))
+#define IS_ACTIVE(u) (((u)->source->state == PA_SOURCE_RUNNING) && \
+ ((u)->sink->state == PA_SINK_RUNNING))

/* This module creates a new (virtual) source and sink.
*
@@ -476,7 +476,7 @@ static int source_set_state_in_main_thread_cb(pa_source *s, pa_source_state_t st

if (state == PA_SOURCE_RUNNING) {
/* restart timer when both sink and source are active */
- if ((pa_sink_get_state(u->sink) == PA_SINK_RUNNING) && u->adjust_time)
+ if ((u->sink->state == PA_SINK_RUNNING) && u->adjust_time)
pa_core_rttime_restart(u->core, u->time_event, pa_rtclock_now() + u->adjust_time);

pa_atomic_store(&u->request_resync, 1);
@@ -501,7 +501,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *s, pa_sink_state_t state, p

if (state == PA_SINK_RUNNING) {
/* restart timer when both sink and source are active */
- if ((pa_source_get_state(u->source) == PA_SOURCE_RUNNING) && u->adjust_time)
+ if ((u->source->state == PA_SOURCE_RUNNING) && u->adjust_time)
pa_core_rttime_restart(u->core, u->time_event, pa_rtclock_now() + u->adjust_time);

pa_atomic_store(&u->request_resync, 1);
@@ -597,7 +597,7 @@ static void source_set_volume_cb(pa_source *s) {
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
+ if (!PA_SOURCE_IS_LINKED(s->state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
return;

@@ -611,7 +611,7 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

@@ -626,7 +626,7 @@ static void source_get_volume_cb(pa_source *s) {
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
+ if (!PA_SOURCE_IS_LINKED(s->state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
return;

@@ -647,7 +647,7 @@ static void source_set_mute_cb(pa_source *s) {
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
+ if (!PA_SOURCE_IS_LINKED(s->state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
return;

@@ -661,7 +661,7 @@ static void sink_set_mute_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c
index b7dac8049..685e240f5 100644
--- a/src/modules/module-combine-sink.c
+++ b/src/modules/module-combine-sink.c
@@ -194,13 +194,13 @@ static void adjust_rates(struct userdata *u) {
if (pa_idxset_size(u->outputs) <= 0)
return;

- if (!PA_SINK_IS_OPENED(pa_sink_get_state(u->sink)))
+ if (!PA_SINK_IS_OPENED(u->sink->state))
return;

PA_IDXSET_FOREACH(o, u->outputs, idx) {
pa_usec_t sink_latency;

- if (!o->sink_input || !PA_SINK_IS_OPENED(pa_sink_get_state(o->sink)))
+ if (!o->sink_input || !PA_SINK_IS_OPENED(o->sink->state))
continue;

o->total_latency = pa_sink_input_get_latency(o->sink_input, &sink_latency);
@@ -237,7 +237,7 @@ static void adjust_rates(struct userdata *u) {
uint32_t new_rate = base_rate;
uint32_t current_rate;

- if (!o->sink_input || !PA_SINK_IS_OPENED(pa_sink_get_state(o->sink)))
+ if (!o->sink_input || !PA_SINK_IS_OPENED(o->sink->state))
continue;

current_rate = o->sink_input->sample_spec.rate;
@@ -273,7 +273,7 @@ static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct tim

adjust_rates(u);

- if (pa_sink_get_state(u->sink) == PA_SINK_SUSPENDED) {
+ if (u->sink->state == PA_SINK_SUSPENDED) {
u->core->mainloop->time_free(e);
u->time_event = NULL;
} else
@@ -697,7 +697,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *sink, pa_sink_state_t state

switch (state) {
case PA_SINK_SUSPENDED:
- pa_assert(PA_SINK_IS_OPENED(pa_sink_get_state(u->sink)));
+ pa_assert(PA_SINK_IS_OPENED(u->sink->state));

suspend(u);
break;
@@ -705,7 +705,7 @@ static int sink_set_state_in_main_thread_cb(pa_sink *sink, pa_sink_state_t state
case PA_SINK_IDLE:
case PA_SINK_RUNNING:

- if (pa_sink_get_state(u->sink) == PA_SINK_SUSPENDED)
+ if (u->sink->state == PA_SINK_SUSPENDED)
unsuspend(u);

break;
@@ -1126,7 +1126,7 @@ static void output_enable(struct output *o) {

if (output_create_sink_input(o) >= 0) {

- if (pa_sink_get_state(o->sink) != PA_SINK_INIT) {
+ if (o->sink->state != PA_SINK_INIT) {
/* Enable the sink input. That means that the sink
* is now asked for new data. */
pa_sink_input_put(o->sink_input);
@@ -1162,7 +1162,7 @@ static void output_disable(struct output *o) {
static void output_verify(struct output *o) {
pa_assert(o);

- if (PA_SINK_IS_OPENED(pa_sink_get_state(o->userdata->sink)))
+ if (PA_SINK_IS_OPENED(o->userdata->sink->state))
output_enable(o);
else
output_disable(o);
diff --git a/src/modules/module-equalizer-sink.c b/src/modules/module-equalizer-sink.c
index fc561e81f..4cfe3ed48 100644
--- a/src/modules/module-equalizer-sink.c
+++ b/src/modules/module-equalizer-sink.c
@@ -343,7 +343,7 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

@@ -357,7 +357,7 @@ static void sink_set_mute_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

diff --git a/src/modules/module-intended-roles.c b/src/modules/module-intended-roles.c
index cb7c1a768..adee51c20 100644
--- a/src/modules/module-intended-roles.c
+++ b/src/modules/module-intended-roles.c
@@ -99,7 +99,7 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
if (s == c->default_sink)
continue;

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)))
+ if (!PA_SINK_IS_LINKED(s->state))
continue;

if (role_match(s->proplist, role) && pa_sink_input_new_data_set_sink(new_data, s, false, false))
@@ -147,7 +147,7 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
if (s == c->default_source)
continue;

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)))
+ if (!PA_SOURCE_IS_LINKED(s->state))
continue;

/* @todo: favour the highest priority device, not the first one we find? */
@@ -293,7 +293,7 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str
if (d == c->default_sink || d == sink)
continue;

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(d)))
+ if (!PA_SINK_IS_LINKED(d->state))
continue;

if (role_match(d->proplist, role))
@@ -349,7 +349,7 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
if (d == c->default_source || d == source)
continue;

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(d)))
+ if (!PA_SOURCE_IS_LINKED(d->state))
continue;

/* If moving from a monitor, move to another monitor */
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 284fabb82..c654530a3 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -452,7 +452,7 @@ static void sink_set_mute_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

diff --git a/src/modules/module-loopback.c b/src/modules/module-loopback.c
index 31702e32b..e1ab34166 100644
--- a/src/modules/module-loopback.c
+++ b/src/modules/module-loopback.c
@@ -714,7 +714,7 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {

/* Uncork the sink input unless the destination is suspended for other
* reasons than idle. */
- if (pa_source_get_state(dest) == PA_SOURCE_SUSPENDED)
+ if (dest->state == PA_SOURCE_SUSPENDED)
pa_sink_input_cork(u->sink_input, (dest->suspend_cause != PA_SUSPEND_IDLE));
else
pa_sink_input_cork(u->sink_input, false);
@@ -1098,7 +1098,7 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {

/* Uncork the source output unless the destination is suspended for other
* reasons than idle */
- if (pa_sink_get_state(dest) == PA_SINK_SUSPENDED)
+ if (dest->state == PA_SINK_SUSPENDED)
pa_source_output_cork(u->source_output, (dest->suspend_cause != PA_SUSPEND_IDLE));
else
pa_source_output_cork(u->source_output, false);
@@ -1565,10 +1565,10 @@ int pa__init(pa_module *m) {
pa_sink_input_put(u->sink_input);
pa_source_output_put(u->source_output);

- if (pa_source_get_state(u->source_output->source) != PA_SOURCE_SUSPENDED)
+ if (u->source_output->source->state != PA_SOURCE_SUSPENDED)
pa_sink_input_cork(u->sink_input, false);

- if (pa_sink_get_state(u->sink_input->sink) != PA_SINK_SUSPENDED)
+ if (u->sink_input->sink->state != PA_SINK_SUSPENDED)
pa_source_output_cork(u->source_output, false);

update_adjust_timer(u);
diff --git a/src/modules/module-rescue-streams.c b/src/modules/module-rescue-streams.c
index 39549782c..52675ecf7 100644
--- a/src/modules/module-rescue-streams.c
+++ b/src/modules/module-rescue-streams.c
@@ -114,7 +114,7 @@ static pa_sink* find_evacuation_sink(pa_core *c, pa_sink_input *i, pa_sink *skip
if (target == skip)
continue;

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(target)))
+ if (!PA_SINK_IS_LINKED(target->state))
continue;

if (!pa_sink_input_may_move_to(i, target))
@@ -224,7 +224,7 @@ static pa_source* find_evacuation_source(pa_core *c, pa_source_output *o, pa_sou
if (skip && !target->monitor_of != !skip->monitor_of)
continue;

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(target)))
+ if (!PA_SOURCE_IS_LINKED(target->state))
continue;

if (!pa_source_output_may_move_to(o, target))
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 9857a8ee1..228e9e447 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -1453,7 +1453,7 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
/* 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 (s && PA_SINK_IS_LINKED(pa_sink_get_state(s)))
+ if (s && PA_SINK_IS_LINKED(s->state))
if (pa_sink_input_new_data_set_sink(new_data, s, true, false))
pa_log_info("Restoring device for stream %s.", name);

@@ -1556,7 +1556,7 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
/* 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 (s && PA_SOURCE_IS_LINKED(pa_source_get_state(s))) {
+ if (s && PA_SOURCE_IS_LINKED(s->state)) {
pa_log_info("Restoring device for stream %s.", name);
pa_source_output_new_data_set_source(new_data, s, true, false);
}
@@ -1764,7 +1764,7 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str

if ((d = pa_namereg_get(c, e->device, PA_NAMEREG_SINK)) &&
d != sink &&
- PA_SINK_IS_LINKED(pa_sink_get_state(d)))
+ PA_SINK_IS_LINKED(d->state))
pa_sink_input_move_to(si, d, true);
}

@@ -1815,7 +1815,7 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc

if ((d = pa_namereg_get(c, e->device, PA_NAMEREG_SOURCE)) &&
d != source &&
- PA_SOURCE_IS_LINKED(pa_source_get_state(d)))
+ PA_SOURCE_IS_LINKED(d->state))
pa_source_output_move_to(so, d, true);
}

diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 12702d1bd..08a1b1db8 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -390,18 +390,16 @@ static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, s

if (pa_sink_isinstance(o)) {
pa_sink *s = PA_SINK(o);
- pa_sink_state_t state = pa_sink_get_state(s);

if (pa_sink_check_suspend(s, NULL, NULL) <= 0)
- if (PA_SINK_IS_OPENED(state))
+ if (PA_SINK_IS_OPENED(s->state))
restart(d);

} else if (pa_source_isinstance(o)) {
pa_source *s = PA_SOURCE(o);
- pa_source_state_t state = pa_source_get_state(s);

if (pa_source_check_suspend(s, NULL) <= 0)
- if (PA_SOURCE_IS_OPENED(state))
+ if (PA_SOURCE_IS_OPENED(s->state))
restart(d);
}

@@ -481,12 +479,12 @@ void pa__done(pa_module*m) {
u = m->userdata;

PA_HASHMAP_FOREACH(d, u->device_infos, state) {
- if (d->sink && pa_sink_get_state(d->sink) == PA_SINK_SUSPENDED) {
+ if (d->sink && d->sink->state == PA_SINK_SUSPENDED) {
pa_log_debug("Resuming sink %s on module unload.", d->sink->name);
pa_sink_suspend(d->sink, false, PA_SUSPEND_IDLE);
}

- if (d->source && pa_source_get_state(d->source) == PA_SOURCE_SUSPENDED) {
+ if (d->source && d->source->state == PA_SOURCE_SUSPENDED) {
pa_log_debug("Resuming source %s on module unload.", d->source->name);
pa_source_suspend(d->source, false, PA_SUSPEND_IDLE);
}
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index a9f26ad70..054d7d8f0 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -1669,7 +1669,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_tagstruct_putu32(reply, PA_INVALID_INDEX);
pa_tagstruct_puts(reply, u->sink_name);
pa_tagstruct_putu32(reply, u->maxlength);
- pa_tagstruct_put_boolean(reply, !PA_SINK_IS_OPENED(pa_sink_get_state(u->sink)));
+ pa_tagstruct_put_boolean(reply, !PA_SINK_IS_OPENED(u->sink->state));
pa_tagstruct_putu32(reply, u->tlength);
pa_tagstruct_putu32(reply, u->prebuf);
pa_tagstruct_putu32(reply, u->minreq);
@@ -1688,7 +1688,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
pa_tagstruct_putu32(reply, PA_INVALID_INDEX);
pa_tagstruct_puts(reply, u->source_name);
pa_tagstruct_putu32(reply, u->maxlength);
- pa_tagstruct_put_boolean(reply, !PA_SOURCE_IS_OPENED(pa_source_get_state(u->source)));
+ pa_tagstruct_put_boolean(reply, !PA_SOURCE_IS_OPENED(u->source->state));
pa_tagstruct_putu32(reply, u->fragsize);
#endif

diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c
index 2f4445c26..bc109d54c 100644
--- a/src/modules/module-virtual-sink.c
+++ b/src/modules/module-virtual-sink.c
@@ -184,7 +184,7 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

@@ -198,7 +198,7 @@ static void sink_set_mute_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c
index b6de7f499..ba8c52be7 100644
--- a/src/modules/module-virtual-source.c
+++ b/src/modules/module-virtual-source.c
@@ -232,7 +232,7 @@ static void source_set_volume_cb(pa_source *s) {
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
+ if (!PA_SOURCE_IS_LINKED(s->state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
return;

@@ -246,7 +246,7 @@ static void source_set_mute_cb(pa_source *s) {
pa_source_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)) ||
+ if (!PA_SOURCE_IS_LINKED(s->state) ||
!PA_SOURCE_OUTPUT_IS_LINKED(u->source_output->state))
return;

@@ -273,7 +273,7 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)

/* if uplink sink exists, pull data from there; simplify by using
same length as chunk provided by source */
- if (u->sink && (pa_sink_get_state(u->sink) == PA_SINK_RUNNING)) {
+ if (u->sink && (u->sink->thread_info.state == PA_SINK_RUNNING)) {
pa_memchunk tchunk;
size_t nbytes = chunk->length;
pa_mix_info streams[2];
diff --git a/src/modules/module-virtual-surround-sink.c b/src/modules/module-virtual-surround-sink.c
index fe195cde5..d8e0fd94c 100644
--- a/src/modules/module-virtual-surround-sink.c
+++ b/src/modules/module-virtual-surround-sink.c
@@ -212,7 +212,7 @@ static void sink_set_volume_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

@@ -226,7 +226,7 @@ static void sink_set_mute_cb(pa_sink *s) {
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);

- if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)) ||
+ if (!PA_SINK_IS_LINKED(s->state) ||
!PA_SINK_INPUT_IS_LINKED(u->sink_input->state))
return;

diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index defdac1ec..5205349bd 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -1829,7 +1829,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool

pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", sink->name, pa_cvolume_max(pa_sink_get_volume(sink, false)));
pa_strbuf_printf(buf, "set-sink-mute %s %s\n", sink->name, pa_yes_no(pa_sink_get_mute(sink, false)));
- pa_strbuf_printf(buf, "suspend-sink %s %s\n", sink->name, pa_yes_no(pa_sink_get_state(sink) == PA_SINK_SUSPENDED));
+ pa_strbuf_printf(buf, "suspend-sink %s %s\n", sink->name, pa_yes_no(sink->state == PA_SINK_SUSPENDED));
}

nl = false;
@@ -1842,7 +1842,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool

pa_strbuf_printf(buf, "set-source-volume %s 0x%03x\n", source->name, pa_cvolume_max(pa_source_get_volume(source, false)));
pa_strbuf_printf(buf, "set-source-mute %s %s\n", source->name, pa_yes_no(pa_source_get_mute(source, false)));
- pa_strbuf_printf(buf, "suspend-source %s %s\n", source->name, pa_yes_no(pa_source_get_state(source) == PA_SOURCE_SUSPENDED));
+ pa_strbuf_printf(buf, "suspend-source %s %s\n", source->name, pa_yes_no(source->state == PA_SOURCE_SUSPENDED));
}

nl = false;
diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c
index 5be7c3cc9..14800514f 100644
--- a/src/pulsecore/cli-text.c
+++ b/src/pulsecore/cli-text.c
@@ -250,7 +250,7 @@ char *pa_sink_list_to_string(pa_core *c) {
sink->flags & PA_SINK_LATENCY ? "LATENCY " : "",
sink->flags & PA_SINK_FLAT_VOLUME ? "FLAT_VOLUME " : "",
sink->flags & PA_SINK_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
- pa_sink_state_to_string(pa_sink_get_state(sink)),
+ pa_sink_state_to_string(sink->state),
pa_suspend_cause_to_string(sink->suspend_cause, suspend_cause_buf),
sink->priority,
pa_cvolume_snprint_verbose(cv,
@@ -361,7 +361,7 @@ char *pa_source_list_to_string(pa_core *c) {
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "DECIBEL_VOLUME " : "",
source->flags & PA_SOURCE_LATENCY ? "LATENCY " : "",
source->flags & PA_SOURCE_DYNAMIC_LATENCY ? "DYNAMIC_LATENCY" : "",
- pa_source_state_to_string(pa_source_get_state(source)),
+ pa_source_state_to_string(source->state),
pa_suspend_cause_to_string(source->suspend_cause, suspend_cause_buf),
source->priority,
pa_cvolume_snprint_verbose(cv,
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index da42a13e4..cc4a6f38b 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -481,12 +481,12 @@ void pa_core_maybe_vacuum(pa_core *c) {

idx = 0;
PA_IDXSET_FOREACH(si, c->sinks, idx)
- if (pa_sink_get_state(si) != PA_SINK_SUSPENDED)
+ if (si->state != PA_SINK_SUSPENDED)
return;

idx = 0;
PA_IDXSET_FOREACH(so, c->sources, idx)
- if (pa_source_get_state(so) != PA_SOURCE_SUSPENDED)
+ if (so->state != PA_SOURCE_SUSPENDED)
return;

pa_log_info("All sinks and sources are suspended, vacuuming memory");
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 708fa16b0..d54c7f845 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -966,18 +966,19 @@ static int esd_proto_standby_or_resume(connection *c, esd_proto_t request, const

static int esd_proto_standby_mode(connection *c, esd_proto_t request, const void *data, size_t length) {
int32_t mode;
- pa_sink *sink, *source;
+ pa_sink *sink;
+ pa_source *source;

connection_assert_ref(c);

mode = ESM_RUNNING;

if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK)))
- if (pa_sink_get_state(sink) == PA_SINK_SUSPENDED)
+ if (sink->state == PA_SINK_SUSPENDED)
mode = ESM_ON_STANDBY;

if ((source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE)))
- if (pa_source_get_state(source) == PA_SOURCE_SUSPENDED)
+ if (source->state == PA_SOURCE_SUSPENDED)
mode = ESM_ON_STANDBY;

mode = PA_MAYBE_INT32_SWAP(c->swap_byte_order, mode);
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 3def4a6ab..a52b976ee 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1659,7 +1659,7 @@ static void sink_input_moving_cb(pa_sink_input *i, pa_sink *dest) {
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_putu32(t, dest->index);
pa_tagstruct_puts(t, dest->name);
- pa_tagstruct_put_boolean(t, pa_sink_get_state(dest) == PA_SINK_SUSPENDED);
+ pa_tagstruct_put_boolean(t, dest->state == PA_SINK_SUSPENDED);

if (s->connection->version >= 13) {
pa_tagstruct_putu32(t, s->buffer_attr.maxlength);
@@ -1798,7 +1798,7 @@ static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_putu32(t, dest->index);
pa_tagstruct_puts(t, dest->name);
- pa_tagstruct_put_boolean(t, pa_source_get_state(dest) == PA_SOURCE_SUSPENDED);
+ pa_tagstruct_put_boolean(t, dest->state == PA_SOURCE_SUSPENDED);

if (s->connection->version >= 13) {
pa_tagstruct_putu32(t, s->buffer_attr.maxlength);
@@ -2080,7 +2080,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
pa_tagstruct_putu32(reply, s->sink_input->sink->index);
pa_tagstruct_puts(reply, s->sink_input->sink->name);

- pa_tagstruct_put_boolean(reply, pa_sink_get_state(s->sink_input->sink) == PA_SINK_SUSPENDED);
+ pa_tagstruct_put_boolean(reply, s->sink_input->sink->state == PA_SINK_SUSPENDED);
}

if (c->version >= 13)
@@ -2394,7 +2394,7 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
pa_tagstruct_putu32(reply, s->source_output->source->index);
pa_tagstruct_puts(reply, s->source_output->source->name);

- pa_tagstruct_put_boolean(reply, pa_source_get_state(s->source_output->source) == PA_SOURCE_SUSPENDED);
+ pa_tagstruct_put_boolean(reply, s->source_output->source->state == PA_SOURCE_SUSPENDED);
}

if (c->version >= 13)
@@ -2879,7 +2879,7 @@ static void command_get_playback_latency(pa_pdispatch *pd, uint32_t command, uin
pa_tagstruct_put_usec(reply, 0);
pa_tagstruct_put_boolean(reply,
s->playing_for > 0 &&
- pa_sink_get_state(s->sink_input->sink) == PA_SINK_RUNNING &&
+ s->sink_input->sink->state == PA_SINK_RUNNING &&
s->sink_input->state == PA_SINK_INPUT_RUNNING);
pa_tagstruct_put_timeval(reply, &tv);
pa_tagstruct_put_timeval(reply, pa_gettimeofday(&now));
@@ -2924,7 +2924,7 @@ static void command_get_record_latency(pa_pdispatch *pd, uint32_t command, uint3
s->current_source_latency +
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 &&
+ s->source_output->source->state == PA_SOURCE_RUNNING &&
s->source_output->state == PA_SOURCE_OUTPUT_RUNNING);
pa_tagstruct_put_timeval(reply, &tv);
pa_tagstruct_put_timeval(reply, pa_gettimeofday(&now));
@@ -3167,9 +3167,9 @@ static void sink_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sin

if (c->version >= 15) {
pa_tagstruct_put_volume(t, sink->base_volume);
- if (PA_UNLIKELY(pa_sink_get_state(sink) == PA_SINK_INVALID_STATE))
+ if (PA_UNLIKELY(sink->state == PA_SINK_INVALID_STATE))
pa_log_error("Internal sink state is invalid.");
- pa_tagstruct_putu32(t, pa_sink_get_state(sink));
+ pa_tagstruct_putu32(t, sink->state);
pa_tagstruct_putu32(t, sink->n_volume_steps);
pa_tagstruct_putu32(t, sink->card ? sink->card->index : PA_INVALID_INDEX);
}
@@ -3237,9 +3237,9 @@ static void source_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_s

if (c->version >= 15) {
pa_tagstruct_put_volume(t, source->base_volume);
- if (PA_UNLIKELY(pa_source_get_state(source) == PA_SOURCE_INVALID_STATE))
+ if (PA_UNLIKELY(source->state == PA_SOURCE_INVALID_STATE))
pa_log_error("Internal source state is invalid.");
- pa_tagstruct_putu32(t, pa_source_get_state(source));
+ pa_tagstruct_putu32(t, source->state);
pa_tagstruct_putu32(t, source->n_volume_steps);
pa_tagstruct_putu32(t, source->card ? source->card->index : PA_INVALID_INDEX);
}
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 2a8c6831d..312ec4a97 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -357,7 +357,7 @@ int pa_sink_input_new(
return -PA_ERR_NOTSUPPORTED;
}

- pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);
+ pa_return_val_if_fail(PA_SINK_IS_LINKED(data->sink->state), -PA_ERR_BADSTATE);
pa_return_val_if_fail(!data->sync_base || (data->sync_base->sink == data->sink
&& data->sync_base->state == PA_SINK_INPUT_CORKED),
-PA_ERR_INVALID);
@@ -442,7 +442,7 @@ int pa_sink_input_new(
return r;

if ((data->flags & PA_SINK_INPUT_NO_CREATE_ON_SUSPEND) &&
- pa_sink_get_state(data->sink) == PA_SINK_SUSPENDED) {
+ data->sink->state == PA_SINK_SUSPENDED) {
pa_log_warn("Failed to create sink input: sink is suspended.");
return -PA_ERR_BADSTATE;
}
@@ -720,7 +720,7 @@ void pa_sink_input_unlink(pa_sink_input *i) {
reset_callbacks(i);

if (i->sink) {
- if (PA_SINK_IS_LINKED(pa_sink_get_state(i->sink)))
+ if (PA_SINK_IS_LINKED(i->sink->state))
pa_sink_update_status(i->sink);

i->sink = NULL;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 638d50693..8f254408f 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -494,8 +494,6 @@ unsigned pa_sink_used_by(pa_sink *s); /* Number of connected streams which are n
* why "ignore_output" may be relevant). */
unsigned pa_sink_check_suspend(pa_sink *s, pa_sink_input *ignore_input, pa_source_output *ignore_output);

-#define pa_sink_get_state(s) ((s)->state)
-
const char *pa_sink_state_to_string(pa_sink_state_t state);

/* Moves all inputs away, and stores them in pa_queue */
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 7ee77cf93..955a2ac57 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -301,7 +301,7 @@ int pa_source_output_new(
return -PA_ERR_NOTSUPPORTED;
}

- pa_return_val_if_fail(PA_SOURCE_IS_LINKED(pa_source_get_state(data->source)), -PA_ERR_BADSTATE);
+ pa_return_val_if_fail(PA_SOURCE_IS_LINKED(data->source->state), -PA_ERR_BADSTATE);
pa_return_val_if_fail(!data->direct_on_input || data->direct_on_input->sink == data->source->monitor_of, -PA_ERR_INVALID);

/* Routing is done. We have a source and a format. */
@@ -390,7 +390,7 @@ int pa_source_output_new(
return r;

if ((data->flags & PA_SOURCE_OUTPUT_NO_CREATE_ON_SUSPEND) &&
- pa_source_get_state(data->source) == PA_SOURCE_SUSPENDED) {
+ data->source->state == PA_SOURCE_SUSPENDED) {
pa_log("Failed to create source output: source is suspended.");
return -PA_ERR_BADSTATE;
}
@@ -612,7 +612,7 @@ void pa_source_output_unlink(pa_source_output*o) {
reset_callbacks(o);

if (o->source) {
- if (PA_SOURCE_IS_LINKED(pa_source_get_state(o->source)))
+ if (PA_SOURCE_IS_LINKED(o->source->state))
pa_source_update_status(o->source);

o->source = NULL;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 6d4319632..b5017336f 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -842,7 +842,7 @@ int pa_source_sync_suspend(pa_source *s) {
pa_assert(PA_SOURCE_IS_LINKED(s->state));
pa_assert(s->monitor_of);

- state = pa_sink_get_state(s->monitor_of);
+ state = s->monitor_of->state;
suspend_cause = s->monitor_of->suspend_cause;

/* The monitor source usually has the same state and suspend cause as the
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index f89a0c875..f4b69fe93 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -425,8 +425,6 @@ unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that ar
* "ignore" is non-NULL, that stream is not included in the count. */
unsigned pa_source_check_suspend(pa_source *s, pa_source_output *ignore);

-#define pa_source_get_state(s) ((pa_source_state_t) (s)->state)
-
const char *pa_source_state_to_string(pa_source_state_t state);

/* Moves all inputs away, and stores them in pa_queue */
--
2.17.0
Georg Chini
2018-06-30 10:11:14 UTC
Permalink
Post by Tanu Kaskinen
The first patch is a reaction to a bug report[1] that pointed out a
weird thing in the sink input drained state handling. I came to the
conclusion that we can just remove the entire drained state.
After removing the drained state, pa_sink_input_get_state() didn't have
anything to do any more, except to just return the state variable.
pa_source_output_get_state() didn't do anything either. The second patch
removes those functions.
Then I noticed that pa_sink_get_state() and pa_source_get_state() don't
do anything either, so the third patch removes those as well.
[1] https://bugs.freedesktop.org/show_bug.cgi?id=106982
All three look good.

Loading...