From cecec498a9f90e5771666479872a5c9e5d789ef7 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Tue, 17 Nov 2015 02:06:49 +0100 Subject: [PATCH] Fix a crash bug when avcodec_fill_audio_frame() decided we needed more alignment. --- bmusb | 2 +- h264encode.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bmusb b/bmusb index 6a027cb..ec10aed 160000 --- a/bmusb +++ b/bmusb @@ -1 +1 @@ -Subproject commit 6a027cb2d982c385859150ad1558a1e205817844 +Subproject commit ec10aedf720f2356035255999827beb4158aa4a2 diff --git a/h264encode.cpp b/h264encode.cpp index a359726..0946eb0 100644 --- a/h264encode.cpp +++ b/h264encode.cpp @@ -1709,7 +1709,11 @@ void H264Encoder::save_codeddata(storage_task task) frame->channel_layout = AV_CH_LAYOUT_STEREO; unique_ptr int_samples(new int32_t[audio.size()]); - avcodec_fill_audio_frame(frame, 2, AV_SAMPLE_FMT_S32, (const uint8_t*)int_samples.get(), audio.size() * sizeof(int32_t), 0); + int ret = avcodec_fill_audio_frame(frame, 2, AV_SAMPLE_FMT_S32, (const uint8_t*)int_samples.get(), audio.size() * sizeof(int32_t), 1); + if (ret < 0) { + fprintf(stderr, "avcodec_fill_audio_frame() failed with %d\n", ret); + exit(1); + } for (int i = 0; i < frame->nb_samples * 2; ++i) { if (audio[i] >= 1.0f) { int_samples[i] = 2147483647; -- 2.39.2