From 40b563b3e6355bc74388abdb0ad2960ddf5476d6 Mon Sep 17 00:00:00 2001
From: Manuel Amador (Rudd-O) <rudd-o@rudd-o.com>
Date: Mon, 13 Jul 2009 08:52:33 -0500
Subject: [PATCH] Virtualized surround support with alsa vdownmix plugin.
PLEASE CHECK THIS PATCH, file src/pulse/channelmap.c, I am not sure if that change is needed at all, or if I missed something obvious.
Given the following additional ALSA configuration and the vdownmix plugin if installed, if any of the new profiles is selected, that should cause multichannel audio to be written to the underlying audio device, which will trigger the vdownmix plugin into remixing audio in a virtualized fashion:
------------------------------------------------
pcm.!vdownmix51 {
@args [ CARD DEV ]
@args.CARD {
type string
default {
@func getenv
vars [
ALSA_VDOWNMIX51_CARD
ALSA_PCM_CARD
ALSA_CARD
]
default {
@func refer
name defaults.pcm.vdownmix51.card
}
}
}
@args.DEV {
type integer
default {
@func igetenv
vars [
ALSA_VDOWNMIX51_DEVICE
]
default {
@func refer
name defaults.pcm.vdownmix51.device
}
}
}
type vdownmix
slave.pcm {
@func refer
name {
@func concat
strings [
"cards."
{
@func card_driver
card $CARD
}
".pcm.vdownmix51." $DEV ":CARD=" $CARD
]
}
}
hint {
description "Downmix to stereo 5.1 Surround output to Front, Center, Rear and Subwoofer speakers"
device $DEV
}
}
pcm.!vdownmix40 {
@args [ CARD DEV ]
@args.CARD {
type string
default {
@func getenv
vars [
ALSA_VDOWNMIX51_CARD
ALSA_PCM_CARD
ALSA_CARD
]
default {
@func refer
name defaults.pcm.vdownmix40.card
}
}
}
@args.DEV {
type integer
default {
@func igetenv
vars [
ALSA_VDOWNMIX51_DEVICE
]
default {
@func refer
name defaults.pcm.vdownmix40.device
}
}
}
type vdownmix
slave.pcm {
@func refer
name {
@func concat
strings [
"cards."
{
@func card_driver
card $CARD
}
".pcm.vdownmix51." $DEV ":CARD=" $CARD
]
}
}
hint {
description "Downmix to stereo 4.0 Surround output to Front, Center, Rear and Subwoofer speakers"
device $DEV
}
}
------------------------------------------------------
---
src/modules/alsa/alsa-mixer.c | 2 ++
src/modules/alsa/mixer/profile-sets/default.conf | 14 ++++++++++++++
src/pulse/channelmap.c | 4 ++--
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index a5515e1..6fc16bb 100644
|
a
|
b
|
|
| 2803 | 2803 | { "analog-surround-61", N_("Analog Surround 6.1") }, |
| 2804 | 2804 | { "analog-surround-70", N_("Analog Surround 7.0") }, |
| 2805 | 2805 | { "analog-surround-71", N_("Analog Surround 7.1") }, |
| | 2806 | { "analog-vdownmix-40", N_("Virtualized Analog Surround 4.0 (for stereo headphones)") }, |
| | 2807 | { "analog-vdownmix-51", N_("Virtualized Analog Surround 5.1 (for stereo headphones)") }, |
| 2806 | 2808 | { "iec958-stereo", N_("Digital Stereo (IEC958)") }, |
| 2807 | 2809 | { "iec958-surround-40", N_("Digital Surround 4.0 (IEC958)") }, |
| 2808 | 2810 | { "iec958-ac3-surround-40", N_("Digital Surround 4.0 (IEC958/AC3)") }, |
diff --git a/src/modules/alsa/mixer/profile-sets/default.conf b/src/modules/alsa/mixer/profile-sets/default.conf
index ac41a8d..de80eae 100644
|
a
|
b
|
|
| 137 | 137 | priority = 4 |
| 138 | 138 | direction = output |
| 139 | 139 | |
| | 140 | [Mapping analog-vdownmix-40] |
| | 141 | device-strings = vdownmix40:%f |
| | 142 | channel-map = front-left,front-right,rear-left,rear-right |
| | 143 | paths-output = analog-output analog-output-lfe-on-mono |
| | 144 | priority = 11 |
| | 145 | direction = output |
| | 146 | |
| | 147 | [Mapping analog-vdownmix-51] |
| | 148 | device-strings = vdownmix51:%f |
| | 149 | channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe |
| | 150 | paths-output = analog-output analog-output-lfe-on-mono |
| | 151 | priority = 11 |
| | 152 | direction = output |
| | 153 | |
| 140 | 154 | ; An example for defining multiple-sink profiles |
| 141 | 155 | #[Profile output:analog-stereo+output:iec958-stereo+input:analog-stereo] |
| 142 | 156 | #description = Foobar |
diff --git a/src/pulse/channelmap.c b/src/pulse/channelmap.c
index 8882301..8f405e8 100644
|
a
|
b
|
|
| 533 | 533 | map.map[0] = PA_CHANNEL_POSITION_LEFT; |
| 534 | 534 | map.map[1] = PA_CHANNEL_POSITION_RIGHT; |
| 535 | 535 | goto finish; |
| 536 | | } else if (pa_streq(s, "surround-40")) { |
| | 536 | } else if (pa_streq(s, "surround-40") || pa_streq(s, "vdownmix-40")) { /* i am not so sure whether this change is needed, Lennart, ideas? */ |
| 537 | 537 | map.channels = 4; |
| 538 | 538 | map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; |
| 539 | 539 | map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; |
| … |
… |
|
| 556 | 556 | map.map[3] = PA_CHANNEL_POSITION_REAR_RIGHT; |
| 557 | 557 | map.map[4] = PA_CHANNEL_POSITION_FRONT_CENTER; |
| 558 | 558 | goto finish; |
| 559 | | } else if (pa_streq(s, "surround-51")) { |
| | 559 | } else if (pa_streq(s, "surround-51") || pa_streq(s, "vdownmix-51")) { /* i am not so sure whether this change is needed, Lennart, ideas? */ |
| 560 | 560 | map.channels = 6; |
| 561 | 561 | map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; |
| 562 | 562 | map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; |