From e72e75570c97ee9dd1cbce6480d7de8637d470fe Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Sun, 27 Mar 2011 23:00:26 +0300 Subject: sink-input: Add volume_writable to pa_sink_input. This is pretty cosmetic change; there's no actual functionality added. Previously the volume_writable information was available through the pa_sink_input_is_volume_writable() function, but I find it cleaner to have a real variable. The sink input introspection variable name was also changed from read_only_volume to volume_writable for consistency. --- src/pulsecore/cli-command.c | 2 +- src/pulsecore/protocol-native.c | 4 ++-- src/pulsecore/sink-input.c | 36 +++++++----------------------------- src/pulsecore/sink-input.h | 6 ++++-- 4 files changed, 14 insertions(+), 34 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index de4995eb..17b0e150 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -585,7 +585,7 @@ static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strb return -1; } - if (!pa_sink_input_is_volume_writable(si)) { + if (!si->volume_writable) { pa_strbuf_puts(buf, "This sink input's volume can't be changed.\n"); return -1; } diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index bb4be726..4952ee41 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3089,7 +3089,7 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_tagstruct_put_boolean(t, (pa_sink_input_get_state(s) == PA_SINK_INPUT_CORKED)); if (c->version >= 20) { pa_tagstruct_put_boolean(t, has_volume); - pa_tagstruct_put_boolean(t, has_volume ? !pa_sink_input_is_volume_writable(s) : FALSE); + pa_tagstruct_put_boolean(t, s->volume_writable); } } @@ -3472,7 +3472,7 @@ static void command_set_volume( pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, TRUE); } else if (si) { - CHECK_VALIDITY(c->pstream, pa_sink_input_is_volume_writable(si), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, si->volume_writable, tag, PA_ERR_BADSTATE); CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of sink input %s.", diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index e0e81be4..46f26f92 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -88,6 +88,7 @@ pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data pa_zero(*data); data->resample_method = PA_RESAMPLER_INVALID; data->proplist = pa_proplist_new(); + data->volume_writable = TRUE; return data; } @@ -106,21 +107,9 @@ void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const data->channel_map = *map; } -pa_bool_t pa_sink_input_new_data_is_volume_writable(pa_sink_input_new_data *data) { - pa_assert(data); - - if (data->flags & PA_SINK_INPUT_PASSTHROUGH) - return FALSE; - - if (data->origin_sink && (data->origin_sink->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER)) - return FALSE; - - return TRUE; -} - void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume) { pa_assert(data); - pa_assert(pa_sink_input_new_data_is_volume_writable(data)); + pa_assert(data->volume_writable); if ((data->volume_is_set = !!volume)) data->volume = *volume; @@ -209,10 +198,12 @@ int pa_sink_input_new( if (data->client) pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist); + if (data->origin_sink && (data->origin_sink->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER)) + data->volume_writable = FALSE; + if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data)) < 0) return r; - pa_assert(!data->volume_is_set || pa_sink_input_new_data_is_volume_writable(data)); pa_return_val_if_fail(!data->driver || pa_utf8_valid(data->driver), -PA_ERR_INVALID); if (!data->sink) { @@ -353,6 +344,7 @@ int pa_sink_input_new( i->real_ratio = i->reference_ratio = data->volume; pa_cvolume_reset(&i->soft_volume, i->sample_spec.channels); pa_cvolume_reset(&i->real_ratio, i->sample_spec.channels); + i->volume_writable = data->volume_writable; i->save_volume = data->save_volume; i->save_sink = data->save_sink; i->save_muted = data->save_muted; @@ -1026,7 +1018,7 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_boo pa_assert(volume); pa_assert(pa_cvolume_valid(volume)); pa_assert(volume->channels == 1 || pa_cvolume_compatible(volume, &i->sample_spec)); - pa_assert(pa_sink_input_is_volume_writable(i)); + pa_assert(i->volume_writable); if ((i->sink->flags & PA_SINK_FLAT_VOLUME) && !absolute) { v = i->sink->reference_volume; @@ -1103,20 +1095,6 @@ pa_bool_t pa_sink_input_is_volume_readable(pa_sink_input *i) { return !(i->flags & PA_SINK_INPUT_PASSTHROUGH); } -/* Called from main context */ -pa_bool_t pa_sink_input_is_volume_writable(pa_sink_input *i) { - pa_sink_input_assert_ref(i); - pa_assert_ctl_context(); - - if (i->flags & PA_SINK_INPUT_PASSTHROUGH) - return FALSE; - - if (i->origin_sink && (i->origin_sink->flags & PA_SINK_SHARE_VOLUME_WITH_MASTER)) - return FALSE; - - return TRUE; -} - /* Called from main context */ pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i, pa_cvolume *volume, pa_bool_t absolute) { pa_sink_input_assert_ref(i); diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h index 588005fd..11f6608f 100644 --- a/src/pulsecore/sink-input.h +++ b/src/pulsecore/sink-input.h @@ -104,6 +104,8 @@ struct pa_sink_input { pa_cvolume volume_factor_sink; /* A second volume factor in format of the sink this stream is connected to */ + pa_bool_t volume_writable:1; + pa_bool_t muted:1; /* if TRUE then the source we are connected to and/or the volume @@ -289,13 +291,14 @@ typedef struct pa_sink_input_new_data { pa_bool_t volume_is_absolute:1; + pa_bool_t volume_writable:1; + pa_bool_t save_sink:1, save_volume:1, save_muted:1; } pa_sink_input_new_data; pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data); void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec); void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map); -pa_bool_t pa_sink_input_new_data_is_volume_writable(pa_sink_input_new_data *data); void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume); void pa_sink_input_new_data_apply_volume_factor(pa_sink_input_new_data *data, const pa_cvolume *volume_factor); void pa_sink_input_new_data_apply_volume_factor_sink(pa_sink_input_new_data *data, const pa_cvolume *volume_factor); @@ -341,7 +344,6 @@ void pa_sink_input_kill(pa_sink_input*i); pa_usec_t pa_sink_input_get_latency(pa_sink_input *i, pa_usec_t *sink_latency); pa_bool_t pa_sink_input_is_volume_readable(pa_sink_input *i); -pa_bool_t pa_sink_input_is_volume_writable(pa_sink_input *i); void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_bool_t save, pa_bool_t absolute); pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i, pa_cvolume *volume, pa_bool_t absolute); -- cgit