0
0
mirror of https://github.com/openwrt/packages.git synced 2025-01-31 04:51:44 +00:00
packages/libs/libopusenc/patches/0001-Fix-ope_encoder_drain-assertion-failure.patch
Andre Heider 7200d1386c libopusenc: cherry-pick post-release crash fixes
Fixes crashes like:
daemon.err asterisk[5087]: Assertion failed: enc->streams == NULL (src/opusenc.c: ope_encoder_drain: 839)

Signed-off-by: Andre Heider <a.heider@gmail.com>
2021-07-31 13:38:28 +02:00

28 lines
1.3 KiB
Diff

From 205552370e058d99452fd34983942e10f2db6dff Mon Sep 17 00:00:00 2001
From: Mark Harris <mark.hsj@gmail.com>
Date: Mon, 28 Dec 2020 12:58:17 -0800
Subject: [PATCH] Fix ope_encoder_drain() assertion failure
If the stream is drained without writing any audio and the frame size is
smaller than the encoder latency, the assertion (enc->streams == NULL)
would fail because pad_samples was computed using an incorrect value of
enc->global_granule_offset before it was set in init_stream(), causing
the padding to be insufficient to drain the stream.
---
src/opusenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -808,9 +808,9 @@ int ope_encoder_drain(OggOpusEnc *enc) {
if (enc->unrecoverable) return enc->unrecoverable;
/* Check if it's already been drained. */
if (enc->streams == NULL) return OPE_TOO_LATE;
+ if (!enc->streams->stream_is_init) init_stream(enc);
if (enc->re) resampler_drain = speex_resampler_get_output_latency(enc->re);
pad_samples = MAX(LPC_PADDING, enc->global_granule_offset + enc->frame_size + resampler_drain + 1);
- if (!enc->streams->stream_is_init) init_stream(enc);
shift_buffer(enc);
assert(enc->buffer_end + pad_samples <= BUFFER_SAMPLES);
memset(&enc->buffer[enc->channels*enc->buffer_end], 0, pad_samples*enc->channels*sizeof(enc->buffer[0]));