]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
a52 - set channel layout with recent libavcodec
authorAnssi Hannula <anssi.hannula@iki.fi>
Fri, 27 Nov 2009 15:15:46 +0000 (17:15 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 27 Nov 2009 15:39:37 +0000 (16:39 +0100)
As of SVN r18631 (2009-04-20) A52 encoder of libavcodec outputs a
warning at run-time if channel layout is not specified.

Fix that by setting the channel layout in a52_prepare() when building
against libavcodec revision that supports this.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
a52/pcm_a52.c

index b95d7d4c4a3b4fb2c231084c5b54c69d2e05f624..ed491b31c32a87a65258524b497d05d6e876fc0b 100644 (file)
@@ -436,6 +436,21 @@ static int a52_prepare(snd_pcm_ioplug_t *io)
        rec->avctx->bit_rate = rec->bitrate * 1000;
        rec->avctx->sample_rate = io->rate;
        rec->avctx->channels = io->channels;
+#if LIBAVCODEC_VERSION_MAJOR > 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 3)
+       switch (io->channels) {
+       case 2:
+               rec->avctx->channel_layout = CH_LAYOUT_STEREO;
+               break;
+       case 4:
+               rec->avctx->channel_layout = CH_LAYOUT_QUAD;
+               break;
+       case 6:
+               rec->avctx->channel_layout = CH_LAYOUT_5POINT1;
+               break;
+       default:
+               break;
+       }
+#endif
 
        if (avcodec_open(rec->avctx, rec->codec) < 0)
                return -EINVAL;