summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-04-28 17:13:47 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-04-28 17:13:47 +0000
commitfc5d296de240a404d3f713a0a36f810d855405a8 (patch)
tree9aea01d89bcbf44a071bf3ba81eebb46c52591e8 /ext
parent82d1e686516fe9cddeb030ccbd082d6b8fa3097e (diff)
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.
Diffstat (limited to 'ext')
-rw-r--r--ext/ogg/gstoggdemux.c12
-rw-r--r--ext/vorbis/vorbisdec.c22
2 files changed, 17 insertions, 17 deletions
diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c
index a35627b55..0b375e3bd 100644
--- a/ext/ogg/gstoggdemux.c
+++ b/ext/ogg/gstoggdemux.c
@@ -174,6 +174,12 @@ struct _GstOggDemuxClass
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 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" */
pad->elem_pad = gst_element_get_pad (element, "sink");
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_ogg_pad_internal_chain);
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;
if (bisect <= begin)
- bisect = begin + 1;
+ bisect = begin;
}
gst_ogg_demux_seek (ogg, bisect);
diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c
index 3c1bddbbb..82a8cafd2 100644
--- a/ext/vorbis/vorbisdec.c
+++ b/ext/vorbis/vorbisdec.c
@@ -180,7 +180,7 @@ vorbis_dec_convert (GstPad * pad,
GstVorbisDec *dec;
guint64 scale = 1;
- dec = GST_VORBIS_DEC (gst_pad_get_parent (pad));
+ dec = GST_VORBIS_DEC (GST_PAD_PARENT (pad));
if (dec->packetno < 1)
return FALSE;
@@ -238,7 +238,7 @@ vorbis_dec_src_query (GstPad * pad, GstQueryType query, GstFormat * format,
gint64 * value)
{
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) {
granulepos = dec->granulepos;
@@ -261,7 +261,7 @@ static gboolean
vorbis_dec_src_event (GstPad * pad, GstEvent * event)
{
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)) {
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,
(gint64 *) & start_value, &end_value)) {
dec->granulepos = start_value * dec->vi.rate / GST_SECOND;
+ GST_DEBUG_OBJECT (dec,
+ "setting granuleposition to %" G_GUINT64_FORMAT " after discont",
+ dec->granulepos);
} else {
GST_WARNING_OBJECT (dec,
"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;
- if (packet->packet[0] / 2 != packet->packetno)
- goto unexpected_packet;
-
GST_DEBUG ("parsing header packet");
/* Packetno = 0 if the first byte is exactly 0x01 */
@@ -521,14 +521,6 @@ vorbis_handle_header_packet (GstVorbisDec * vd, ogg_packet * packet)
return res;
/* 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:
{
GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE,
@@ -653,7 +645,7 @@ vorbis_dec_chain (GstPad * pad, GstBuffer * buffer)
/* switch depending on packet type */
if (packet.packet[0] & 1) {
- if (packet.packetno > 3) {
+ if (vd->initialized) {
GST_WARNING_OBJECT (vd, "Ignoring header");
goto done;
}