]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
a52: allow to specify the avcodec
authorJaroslav Kysela <perex@perex.cz>
Wed, 16 Jun 2021 07:29:56 +0000 (09:29 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 16 Jun 2021 07:43:53 +0000 (09:43 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
a52/pcm_a52.c

index 16ac72207b1dd558b7426449578799c6abc94947..9b5d13584ca28b62847ad027c8da537c4a0bae87 100644 (file)
@@ -952,6 +952,7 @@ SND_PCM_PLUGIN_DEFINE_FUNC(a52)
        int err;
        const char *card = NULL;
        const char *pcm_string = NULL;
+       const char *avcodec = NULL;
        unsigned int rate = 48000;
        unsigned int bitrate = 448;
        unsigned int channels = 6;
@@ -1049,6 +1050,16 @@ SND_PCM_PLUGIN_DEFINE_FUNC(a52)
                        }
                        continue;
                }
+               if (strcmp(id, "avcodec") == 0) {
+                       const char *str;
+                       err = snd_config_get_string(n, &str);
+                       if (err < 0) {
+                               SNDERR("invalid type for %s", id);
+                               return -EINVAL;
+                       }
+                       avcodec = str;
+                       continue;
+               }
                SNDERR("Unknown field %s", id);
                return -EINVAL;
        }
@@ -1072,9 +1083,13 @@ SND_PCM_PLUGIN_DEFINE_FUNC(a52)
        avcodec_register_all();
 #endif
 
-       rec->codec = avcodec_find_encoder_by_name("ac3_fixed");
-       if (rec->codec == NULL)
-               rec->codec = avcodec_find_encoder_by_name("ac3");
+       if (avcodec) {
+               rec->codec = avcodec_find_encoder_by_name(avcodec);
+       } else {
+               rec->codec = avcodec_find_encoder_by_name("ac3_fixed");
+               if (rec->codec == NULL)
+                       rec->codec = avcodec_find_encoder_by_name("ac3");
+       }
        if (rec->codec == NULL) 
                rec->codec = avcodec_find_encoder(AV_CODEC_ID_AC3);
        if (rec->codec == NULL) {