mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
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:
parent
b4a36453da
commit
6665b466d2
26 changed files with 82 additions and 87 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue