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> 2005-09-22 Wim Taymans <wim@fluendo.com>
* gst-libs/gst/rtp/gstbasertppayload.c: * gst-libs/gst/rtp/gstbasertppayload.c:

View file

@ -777,6 +777,24 @@ gst_vorbisenc_setup (GstVorbisEnc * vorbisenc)
return TRUE; 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 */ /* prepare a buffer for transmission by passing data through libvorbis */
static GstBuffer * static GstBuffer *
gst_vorbisenc_buffer_from_packet (GstVorbisEnc * vorbisenc, ogg_packet * packet) 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 /* 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 */ * the last frame and mark end of stream in the output properly */
GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on"); GST_DEBUG_OBJECT (vorbisenc, "EOS, clearing state and sending event on");
vorbis_analysis_wrote (&vorbisenc->vd, 0); gst_vorbisenc_clear (vorbisenc);
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); res = gst_pad_event_default (pad, event);
break; break;
@ -1140,8 +1152,7 @@ gst_vorbisenc_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PLAYING_TO_PAUSED: case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
vorbisenc->setup = FALSE; gst_vorbisenc_clear (vorbisenc);
vorbisenc->header_sent = FALSE;
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
gst_tag_list_free (vorbisenc->tags); gst_tag_list_free (vorbisenc->tags);