[pulseaudio-discuss] [PATCH] sink-input: Relax initial volume setting restrictions
Arun Raghavan
arun.raghavan at collabora.co.uk
Wed May 9 08:13:39 PDT 2012
[I don't expect major objections to this, but since we're in the midst of a
freeze, playing it safe]
The extended stream creation API introduced subtle breakage at the time
of sink input creation. The sample spec (and thus channel count) is no
longer guaranteed to be available during the PA_SINK_INPUT_NEW hook
(since multiple formats may be specified and a single format might only
be fixed after all hooks are called).
To deal with this, instead of asserting on mismatched channel maps in
whatever volume is set by a hook, we remap the set volume to the desired
number of channels.
---
src/modules/module-stream-restore.c | 7 +------
src/pulsecore/sink-input.c | 9 +++++++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 23889ca..630c78f 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -1473,13 +1473,8 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
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);
-
- v = e->volume;
- pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
- pa_sink_input_new_data_set_volume(new_data, &v);
+ pa_sink_input_new_data_set_volume(new_data, &e->volume);
new_data->volume_is_absolute = FALSE;
new_data->save_volume = TRUE;
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index f6f7324..909f3dc 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -331,10 +331,15 @@ int pa_sink_input_new(
pa_cvolume_reset(&data->volume, data->sample_spec.channels);
data->volume_is_absolute = FALSE;
data->save_volume = FALSE;
+ } else {
+ if (!pa_cvolume_compatible(&data->volume, &data->sample_spec)) {
+ /* Remap volume if channel maps don't match */
+ pa_channel_map from;
+ pa_channel_map_init_auto(&from, data->volume.channels, PA_CHANNEL_MAP_DEFAULT);
+ pa_cvolume_remap(&data->volume, &from, &new_data->channel_map);
+ }
}
- pa_return_val_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec), -PA_ERR_INVALID);
-
if (!data->volume_factor_is_set)
pa_cvolume_reset(&data->volume_factor, data->sample_spec.channels);
--
1.7.8.6
More information about the pulseaudio-discuss
mailing list