aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoder/vorbis_encoder.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-04-25 18:27:39 +0200
committerMax Kellermann <max@duempel.org>2009-04-25 18:27:39 +0200
commitecb7f24b01e884aa031c6879268060645cb5d7a6 (patch)
tree93dca8a52cfd44d829b36c7192a6026dc1f405ad /src/encoder/vorbis_encoder.c
parent3888ef2f5504ab5b6b92d9fe1a9a4c0cbabecf0b (diff)
downloadmpd-ecb7f24b01e884aa031c6879268060645cb5d7a6.tar.gz
mpd-ecb7f24b01e884aa031c6879268060645cb5d7a6.tar.xz
mpd-ecb7f24b01e884aa031c6879268060645cb5d7a6.zip
vorbis_encoder: reinitialize vorbis_dsp_state after flush
libvorbis goes into a very long loop if we try to add data after a flush was invoked by vorbis_analysis_wrote(0). This seems to be a problem with the internal end-of-stream marker. Thus, we cannot reuse the vorbis_dsp_state object.
Diffstat (limited to 'src/encoder/vorbis_encoder.c')
-rw-r--r--src/encoder/vorbis_encoder.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/encoder/vorbis_encoder.c b/src/encoder/vorbis_encoder.c
index b2b71f335..2e54b18d3 100644
--- a/src/encoder/vorbis_encoder.c
+++ b/src/encoder/vorbis_encoder.c
@@ -262,6 +262,13 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error)
vorbis_analysis_wrote(&encoder->vd, 0);
vorbis_encoder_blockout(encoder);
+ /* reinitialize vorbis_dsp_state and vorbis_block to reset the
+ end-of-stream marker */
+ vorbis_block_clear(&encoder->vb);
+ vorbis_dsp_clear(&encoder->vd);
+ vorbis_analysis_init(&encoder->vd, &encoder->vi);
+ vorbis_block_init(&encoder->vd, &encoder->vb);
+
encoder->flush = true;
return true;
}