ext/: Don't crap out when seeking back to position 0.

Original commit message from CVS:
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_typefind),
(gst_ogg_demux_perform_seek), (gst_ogg_demux_sink_activate):
* ext/vorbis/vorbisdec.c: (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event),
(vorbis_dec_sink_event), (vorbis_handle_comment_packet),
(vorbis_handle_type_packet), (vorbis_handle_header_packet),
(copy_samples), (vorbis_handle_data_packet), (vorbis_dec_chain):
Don't crap out when seeking back to position 0.
This commit is contained in:
Wim Taymans 2005-04-28 17:13:47 +00:00
parent 82d1e68651
commit fc5d296de2
3 changed files with 28 additions and 17 deletions

View file

@ -1,3 +1,14 @@
2005-04-28 Wim Taymans <wim@fluendo.com>
* ext/ogg/gstoggdemux.c: (gst_ogg_pad_typefind),
(gst_ogg_demux_perform_seek), (gst_ogg_demux_sink_activate):
* ext/vorbis/vorbisdec.c: (vorbis_dec_convert),
(vorbis_dec_src_query), (vorbis_dec_src_event),
(vorbis_dec_sink_event), (vorbis_handle_comment_packet),
(vorbis_handle_type_packet), (vorbis_handle_header_packet),
(copy_samples), (vorbis_handle_data_packet), (vorbis_dec_chain):
Don't crap out when seeking back to position 0.
2005-04-28 Wim Taymans <wim@fluendo.com> 2005-04-28 Wim Taymans <wim@fluendo.com>
* examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline), * examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline),

View file

@ -174,6 +174,12 @@ struct _GstOggDemuxClass
GstElementClass parent_class; GstElementClass parent_class;
}; };
static GstStaticPadTemplate internaltemplate =
GST_STATIC_PAD_TEMPLATE ("internal",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static gboolean gst_ogg_demux_perform_seek (GstOggDemux * ogg, gint64 pos); static gboolean gst_ogg_demux_perform_seek (GstOggDemux * ogg, gint64 pos);
static void gst_ogg_pad_class_init (GstOggPadClass * klass); static void gst_ogg_pad_class_init (GstOggPadClass * klass);
@ -578,7 +584,9 @@ gst_ogg_pad_typefind (GstOggPad * pad, ogg_packet * packet)
/* FIXME, it might not be named "sink" */ /* FIXME, it might not be named "sink" */
pad->elem_pad = gst_element_get_pad (element, "sink"); pad->elem_pad = gst_element_get_pad (element, "sink");
gst_element_set_state (element, GST_STATE_PAUSED); gst_element_set_state (element, GST_STATE_PAUSED);
pad->elem_out = gst_pad_new ("internal", GST_PAD_SINK); pad->elem_out =
gst_pad_new_from_template (gst_static_pad_template_get
(&internaltemplate), "internal");
gst_pad_set_chain_function (pad->elem_out, gst_pad_set_chain_function (pad->elem_out,
gst_ogg_pad_internal_chain); gst_ogg_pad_internal_chain);
gst_pad_set_element_private (pad->elem_out, pad); gst_pad_set_element_private (pad->elem_out, pad);
@ -1284,7 +1292,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gint64 pos)
bisect = (target - begintime) / GST_MSECOND * rate + begin - CHUNKSIZE; bisect = (target - begintime) / GST_MSECOND * rate + begin - CHUNKSIZE;
if (bisect <= begin) if (bisect <= begin)
bisect = begin + 1; bisect = begin;
} }
gst_ogg_demux_seek (ogg, bisect); gst_ogg_demux_seek (ogg, bisect);

View file

@ -180,7 +180,7 @@ vorbis_dec_convert (GstPad * pad,
GstVorbisDec *dec; GstVorbisDec *dec;
guint64 scale = 1; guint64 scale = 1;
dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
if (dec->packetno < 1) if (dec->packetno < 1)
return FALSE; return FALSE;
@ -238,7 +238,7 @@ vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
gint64 * value) gint64 * value)
{ {
gint64 granulepos = 0; gint64 granulepos = 0;
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); GstVorbisDec *dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
if (query == GST_QUERY_POSITION) { if (query == GST_QUERY_POSITION) {
granulepos = dec->granulepos; granulepos = dec->granulepos;
@ -261,7 +261,7 @@ static gboolean
vorbis_dec_src_event (GstPad * pad, GstEvent * event) vorbis_dec_src_event (GstPad * pad, GstEvent * event)
{ {
gboolean res = TRUE; gboolean res = TRUE;
GstVorbisDec *dec = GST_VORBIS_DEC (gst_pad_get_parent (pad)); GstVorbisDec *dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:{ case GST_EVENT_SEEK:{
@ -311,6 +311,9 @@ vorbis_dec_sink_event (GstPad * pad, GstEvent * event)
if (gst_event_discont_get_value (event, GST_FORMAT_TIME, if (gst_event_discont_get_value (event, GST_FORMAT_TIME,
(gint64 *) & start_value, &end_value)) { (gint64 *) & start_value, &end_value)) {
dec->granulepos = start_value * dec->vi.rate / GST_SECOND; dec->granulepos = start_value * dec->vi.rate / GST_SECOND;
GST_DEBUG_OBJECT (dec,
"setting granuleposition to %" G_GUINT64_FORMAT " after discont",
dec->granulepos);
} else { } else {
GST_WARNING_OBJECT (dec, GST_WARNING_OBJECT (dec,
"discont event didn't include offset, we might set it wrong now"); "discont event didn't include offset, we might set it wrong now");
@ -495,9 +498,6 @@ vorbis_handle_header_packet (GstVorbisDec * vd, ogg_packet * packet)
{ {
GstFlowReturn res; GstFlowReturn res;
if (packet->packet[0] / 2 != packet->packetno)
goto unexpected_packet;
GST_DEBUG ("parsing header packet"); GST_DEBUG ("parsing header packet");
/* Packetno = 0 if the first byte is exactly 0x01 */ /* Packetno = 0 if the first byte is exactly 0x01 */
@ -521,14 +521,6 @@ vorbis_handle_header_packet (GstVorbisDec * vd, ogg_packet * packet)
return res; return res;
/* ERRORS */ /* ERRORS */
unexpected_packet:
{
/* FIXME: just skip? */
GST_WARNING_OBJECT (GST_ELEMENT (vd),
"unexpected packet type %d, expected %d",
(gint) packet->packet[0], (gint) packet->packetno);
return GST_FLOW_UNEXPECTED;
}
header_read_error: header_read_error:
{ {
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE, GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
@ -653,7 +645,7 @@ vorbis_dec_chain (GstPad * pad, GstBuffer * buffer)
/* switch depending on packet type */ /* switch depending on packet type */
if (packet.packet[0] & 1) { if (packet.packet[0] & 1) {
if (packet.packetno > 3) { if (vd->initialized) {
GST_WARNING_OBJECT (vd, "Ignoring header"); GST_WARNING_OBJECT (vd, "Ignoring header");
goto done; goto done;
} }