mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
sink-input, source-output: remove the state getters
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.
This commit is contained in:
parent
64ba239f65
commit
b4a36453da
21 changed files with 57 additions and 81 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue