summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2011-09-14 13:10:52 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2011-09-14 14:15:01 +0530
commit2ef7bc6a8092731e2370cd28d34cb932c191e967 (patch)
tree36d8eae2c3b032195e6d2a17e433753ef235fca8
parenta9c85074cbf6903e5eb9789f470f6c2c3ee40734 (diff)
volume: Handle varying channel count for shared volumes
This handles the case where a virtual sink/source and it's master have different channel counts. The solution is not ideal because if the former has fewer channels and the master has channel volumes that are not all at the same level, it will lose this information and have all channels at the same level. This is not just a theoretical problem, since module-echo-cancel prefers a mono virtual source/sink and will usually be sitting on top of a stereo ALSA source/sink. That said, I don't really see a good solution to this problem, so the idea is to make volume sharing optional (on by default) in module-echo-cancel, so that the few people who care can then disable it if they so desire.
-rw-r--r--src/pulsecore/sink.c3
-rw-r--r--src/pulsecore/source.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 0350284a..a29d61db 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1863,6 +1863,9 @@ void pa_sink_set_volume(
/* Let's 'push' the reference volume if necessary */
pa_cvolume_merge(&new_reference_volume, &s->reference_volume, &root_sink->real_volume);
+ /* If the sink and it's root don't have the same number of channels, we need to remap */
+ if (s != root_sink && !pa_channel_map_equal(&s->channel_map, &root_sink->channel_map))
+ pa_cvolume_remap(&new_reference_volume, &s->channel_map, &root_sink->channel_map);
update_reference_volume(root_sink, &new_reference_volume, &root_sink->channel_map, save);
/* Now that the reference volume is updated, we can update the streams'
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 84c8edca..5f57265c 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1439,6 +1439,9 @@ void pa_source_set_volume(
/* Let's 'push' the reference volume if necessary */
pa_cvolume_merge(&new_reference_volume, &s->reference_volume, &root_source->real_volume);
+ /* If the source and it's root don't have the same number of channels, we need to remap */
+ if (s != root_source && !pa_channel_map_equal(&s->channel_map, &root_source->channel_map))
+ pa_cvolume_remap(&new_reference_volume, &s->channel_map, &root_source->channel_map);
update_reference_volume(root_source, &new_reference_volume, &root_source->channel_map, save);
/* Now that the reference volume is updated, we can update the streams'