From: Lennart Poettering Date: Wed, 3 Sep 2008 17:57:04 +0000 (+0200) Subject: Make sure we always have a sensible channel mapping X-Git-Tag: v1.0.18rc3~7 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=e94473de09a5877196196f15a8bc52b2a155a819;p=alsa-plugins.git 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. --- 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;