From 99ddca89cdca9b0b92ab9870764f9211e6a82e31 Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Mon, 14 Feb 2011 13:41:06 +0200 Subject: Allow read-only or non-existing sink input volume. There are two known cases where read-only or non-existing sink input volume is relevant: passthrough streams and the planned volume sharing logic. Passthrough streams don't have volume at all, and the volume sharing logic requires read-only sink input volume. This commit is primarily working towards the volume sharing feature, but support for non-existing sink input volume is also added, because it is so closely related to read-only volume. Some unrelated refactoring in iface-stream.c creeped into this commit too (new function: stream_to_string()). --- src/modules/module-stream-restore.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/modules/module-stream-restore.c') diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index f8fecd89..f4e4a55c 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -1168,6 +1168,8 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3 } if (sink_input->save_volume) { + pa_assert(pa_sink_input_is_volume_writable(sink_input)); + entry.channel_map = sink_input->channel_map; pa_sink_input_get_volume(sink_input, &entry.volume, FALSE); entry.volume_valid = TRUE; @@ -1327,8 +1329,11 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu if ((e = read_entry(u, name))) { if (u->restore_volume && e->volume_valid) { - - if (!new_data->volume_is_set) { + if (!pa_sink_input_new_data_is_volume_writable(new_data)) + pa_log_debug("Not restoring volume for sink input %s, because its volume can't be changed.", name); + else if (new_data->volume_is_set) + pa_log_debug("Not restoring volume for sink input %s, because already set.", name); + else { pa_cvolume v; pa_log_info("Restoring volume for sink input %s.", name); @@ -1339,8 +1344,7 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu new_data->volume_is_absolute = FALSE; new_data->save_volume = TRUE; - } else - pa_log_debug("Not restoring volume for sink input %s, because already set.", name); + } } if (u->restore_muted && e->muted_valid) { @@ -1615,7 +1619,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) { } pa_xfree(n); - if (u->restore_volume && e->volume_valid) { + if (u->restore_volume && e->volume_valid && pa_sink_input_is_volume_writable(si)) { pa_cvolume v; v = e->volume; -- cgit