sink, source: remove the state getters

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.
This commit is contained in:
Tanu Kaskinen 2018-06-26 16:25:58 +03:00
parent b4a36453da
commit 6665b466d2
26 changed files with 82 additions and 87 deletions

View file

@ -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);