You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.3 KiB

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