ext/vorbis/vorbisenc.c: Don't flush encoder state unless we have an initialised encoder.

Original commit message from CVS:
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_clear),
(gst_vorbisenc_sink_event), (gst_vorbisenc_change_state):
Don't flush encoder state unless we have an initialised encoder.
Clear out encoder state on PAUSED_TO_READY.
This commit is contained in:
Michael Smith 2005-09-22 14:35:57 +00:00
parent 9798126a0b
commit 17d40cbbd1
2 changed files with 27 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2005-09-22 Michael Smith <msmith@fluendo.com>
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_clear),
(gst_vorbisenc_sink_event), (gst_vorbisenc_change_state):
Don't flush encoder state unless we have an initialised encoder.
Clear out encoder state on PAUSED_TO_READY.
2005-09-22 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/rtp/gstbasertppayload.c:

View file

@ -777,6 +777,24 @@ gst_vorbisenc_setup (GstVorbisEnc * vorbisenc)
return TRUE;
}
static void
gst_vorbisenc_clear (GstVorbisEnc * vorbisenc)
{
if (vorbisenc->setup) {
vorbis_analysis_wrote (&vorbisenc->vd, 0);
gst_vorbisenc_output_buffers (vorbisenc);
vorbisenc->setup = FALSE;
}
/* 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);
vorbisenc->header_sent = FALSE;
}
/* prepare a buffer for transmission by passing data through libvorbis */
static GstBuffer *
gst_vorbisenc_buffer_from_packet (GstVorbisEnc * vorbisenc, ogg_packet * packet)
@ -866,13 +884,7 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event)
/* 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);
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);
gst_vorbisenc_clear (vorbisenc);
res = gst_pad_event_default (pad, event);
break;
@ -1140,8 +1152,7 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
vorbisenc->setup = FALSE;
vorbisenc->header_sent = FALSE;
gst_vorbisenc_clear (vorbisenc);
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_tag_list_free (vorbisenc->tags);