From e6d10b67d0bce636cbeedc063dfed9ce7eb5a3ce Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 16 Jun 2021 09:29:56 +0200 Subject: [PATCH] a52: allow to specify the avcodec Signed-off-by: Jaroslav Kysela --- a52/pcm_a52.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/a52/pcm_a52.c b/a52/pcm_a52.c index 16ac722..9b5d135 100644 --- a/a52/pcm_a52.c +++ b/a52/pcm_a52.c @@ -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) { -- 2.47.1