From 31e1be75709e7ca69184b9277cfe13e71594b029 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Oct 2012 08:13:48 +0200 Subject: encoder/opus: call ogg_stream_flush() only in the last iteration If there are multiple pages, the last partial page must be flushed. --- src/encoder/OpusEncoderPlugin.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/encoder') diff --git a/src/encoder/OpusEncoderPlugin.cxx b/src/encoder/OpusEncoderPlugin.cxx index c967a24a7..4a51dabb3 100644 --- a/src/encoder/OpusEncoderPlugin.cxx +++ b/src/encoder/OpusEncoderPlugin.cxx @@ -371,12 +371,12 @@ opus_encoder_read(struct encoder *_encoder, void *_dest, size_t length) opus_encoder_generate_tags(encoder); ogg_page page; - int result; - if (encoder->flush) { + int result = ogg_stream_pageout(&encoder->os, &page); + if (result == 0 && encoder->flush) { encoder->flush = false; result = ogg_stream_flush(&encoder->os, &page); - } else - result = ogg_stream_pageout(&encoder->os, &page); + + } if (result == 0) return 0; -- cgit v1.2.3