diff options
author | Lennart Poettering <lennart@poettering.net> | 2008-09-03 19:57:04 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2008-09-03 20:25:38 +0200 |
commit | e94473de09a5877196196f15a8bc52b2a155a819 (patch) | |
tree | c038afb0a5f5eb976cacfd455536a2fc0a6d597a | |
parent | c563463c89c9ee37014ba3f5b0f22df16d5b8ae0 (diff) |
Make sure we always have a sensible channel mapping
If PA doesn't know a default channel map for the specified number of channels,
synthesize one by extending a known one with a smaller channel number.
-rw-r--r-- | pulse/pcm_pulse.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c index 6d7403c..5a5b954 100644 --- a/pulse/pcm_pulse.c +++ b/pulse/pcm_pulse.c @@ -485,6 +485,7 @@ static int pulse_prepare(snd_pcm_ioplug_t * io) pa_channel_map map; snd_pcm_pulse_t *pcm = io->private_data; int err = 0, r; + unsigned c, d; assert(pcm); assert(pcm->p); @@ -505,22 +506,22 @@ static int pulse_prepare(snd_pcm_ioplug_t * io) assert(pcm->stream == NULL); + for (c = pcm->ss.channels; c > 0; c--) + if (pa_channel_map_init_auto(&map, c, PA_CHANNEL_MAP_ALSA)) + break; + + /* Extend if nessary */ + for (d = c; d < pcm->ss.channels; d++) + map.map[d] = PA_CHANNEL_POSITION_AUX0+(d-c); + + map.channels = pcm->ss.channels; + if (io->stream == SND_PCM_STREAM_PLAYBACK) pcm->stream = - pa_stream_new(pcm->p->context, "ALSA Playback", - &pcm->ss, pa_channel_map_init_auto(&map, - pcm-> - ss. - channels, - PA_CHANNEL_MAP_ALSA)); + pa_stream_new(pcm->p->context, "ALSA Playback", &pcm->ss, &map); else pcm->stream = - pa_stream_new(pcm->p->context, "ALSA Capture", - &pcm->ss, pa_channel_map_init_auto(&map, - pcm-> - ss. - channels, - PA_CHANNEL_MAP_ALSA)); + pa_stream_new(pcm->p->context, "ALSA Capture", &pcm->ss, &map); if (!pcm->stream) { err = -ENOMEM; |