[alsa-devel] [PATCH 1/1] a52: set time_base to avoid crash in avcodec

Alex Hornung alex at alexhornung.com
Sun Mar 18 19:23:49 CET 2012


 * Not setting the avctx->time_base properly results in a crash in
   avcodec_encode_audio() in more recent versions of it.

 * Fix it by setting the time_base according to the sampling rate.

Signed-off-by: Alex Hornung <alex at alexhornung.com>
---
 a52/pcm_a52.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/a52/pcm_a52.c b/a52/pcm_a52.c
index 00c7c59..560071d 100644
--- a/a52/pcm_a52.c
+++ b/a52/pcm_a52.c
@@ -436,6 +436,8 @@ 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;
+	rec->avctx->time_base.num = 1;
+	rec->avctx->time_base.den = io->rate;
 #if LIBAVCODEC_VERSION_MAJOR > 52 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 95)
   rec->avctx->sample_fmt = AV_SAMPLE_FMT_S16;
 #else
-- 
1.7.9.1



More information about the Alsa-devel mailing list