encoder/opus: call ogg_stream_flush() only in the last iteration

If there are multiple pages, the last partial page must be flushed.
This commit is contained in:
Max Kellermann 2012-10-02 08:13:48 +02:00
parent d793b7c03f
commit 31e1be7570

View File

@ -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;