From 891fb4943a633bdd6bc745b4f352a63c799155d9 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Thu, 15 Sep 2005 19:59:50 +0000 Subject: [PATCH] ext/vorbis/vorbisenc.*: Fix EOS handling. Still needs a fix in the ogg muxer to mark the last page as eos somehow. Original commit message from CVS: 2005-09-15 Thomas Vander Stichele * ext/vorbis/vorbisenc.c: (gst_vorbisenc_init), (gst_vorbisenc_sink_event), (gst_vorbisenc_chain), (gst_vorbisenc_output_buffers), (gst_vorbisenc_change_state): * ext/vorbis/vorbisenc.h: Fix EOS handling. Still needs a fix in the ogg muxer to mark the last page as eos somehow. --- ChangeLog | 9 +++++++++ ext/vorbis/vorbisenc.c | 42 +++++++++++++++++++++--------------------- ext/vorbis/vorbisenc.h | 2 -- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3b371e6d0..51749210b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-09-15 Thomas Vander Stichele + + * ext/vorbis/vorbisenc.c: (gst_vorbisenc_init), + (gst_vorbisenc_sink_event), (gst_vorbisenc_chain), + (gst_vorbisenc_output_buffers), (gst_vorbisenc_change_state): + * ext/vorbis/vorbisenc.h: + Fix EOS handling. Still needs a fix in the ogg muxer to + mark the last page as eos somehow. + 2005-09-15 Thomas Vander Stichele * common/gtk-doc-plugins.mak: diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c index a4eb94dfc..75f7709c7 100644 --- a/ext/vorbis/vorbisenc.c +++ b/ext/vorbis/vorbisenc.c @@ -96,6 +96,8 @@ enum ARG_LAST_MESSAGE }; +static void gst_vorbisenc_output_buffers (GstVorbisEnc * vorbisenc); + /* FIXME: * vorbis_granule_time was added between 1.0 and 1.0.1; it's too silly * to require a new version for such a simple function, but once we move @@ -548,7 +550,6 @@ gst_vorbisenc_init (GstVorbisEnc * vorbisenc) vorbisenc->last_message = NULL; vorbisenc->setup = FALSE; - vorbisenc->eos = FALSE; vorbisenc->header_sent = FALSE; } @@ -862,14 +863,18 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - /* end of file. this can be done implicitly in the mainline, - but it's easier to see here in non-clever fashion. - Tell the library we're at end of stream so that it can handle - the last frame and mark end of stream in the output properly */ - GST_DEBUG_OBJECT (vorbisenc, "received EOS, will process later"); + /* Tell the library we're at end of stream so that it can handle + * the last frame and mark end of stream in the output properly */ + GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on"); vorbis_analysis_wrote (&vorbisenc->vd, 0); - vorbisenc->eos = TRUE; - gst_event_unref (event); + gst_vorbisenc_output_buffers (vorbisenc); + + /* clean up and exit. vorbis_info_clear() must be called last */ + vorbis_block_clear (&vorbisenc->vb); + vorbis_dsp_clear (&vorbisenc->vd); + vorbis_info_clear (&vorbisenc->vi); + + res = gst_pad_event_default (pad, event); break; case GST_EVENT_TAG: if (vorbisenc->tags) { @@ -978,6 +983,14 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buffer) gst_buffer_unref (buf); } + gst_vorbisenc_output_buffers (vorbisenc); + + return GST_FLOW_OK; +} + +static void +gst_vorbisenc_output_buffers (GstVorbisEnc * vorbisenc) +{ /* vorbis does some data preanalysis, then divides up blocks for more involved (potentially parallel) processing. Get a single block for encoding now */ @@ -995,17 +1008,6 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buffer) gst_vorbisenc_push_packet (vorbisenc, &op); } } - - if (vorbisenc->eos) { - GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on"); - /* clean up and exit. vorbis_info_clear() must be called last */ - vorbis_block_clear (&vorbisenc->vb); - vorbis_dsp_clear (&vorbisenc->vd); - vorbis_info_clear (&vorbisenc->vi); - gst_pad_push_event (vorbisenc->srcpad, gst_event_new_eos ()); - //gst_element_set_eos (GST_ELEMENT (vorbisenc)); - } - return GST_FLOW_OK; } static void @@ -1127,8 +1129,6 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition) vorbisenc->tags = gst_tag_list_new (); break; case GST_STATE_CHANGE_READY_TO_PAUSED: - vorbisenc->eos = FALSE; - break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: default: break; diff --git a/ext/vorbis/vorbisenc.h b/ext/vorbis/vorbisenc.h index 94c151d81..a93cf9300 100644 --- a/ext/vorbis/vorbisenc.h +++ b/ext/vorbis/vorbisenc.h @@ -57,8 +57,6 @@ struct _GstVorbisEnc { vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ vorbis_block vb; /* local working space for packet->PCM decode */ - gboolean eos; - gboolean managed; gint bitrate; gint min_bitrate; -- 2.34.1