diff --git a/ChangeLog b/ChangeLog index 07b39f96e1..7c19da5d77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-09 Tim-Philipp Müller + + * ext/mad/gstmad.c: (gst_mad_src_query): + For position and duration queries in TIME format, try the peer + first (might be a demuxer). + 2005-12-08 Martin Soto * gst/mpegstream/gstdvddemux.c (gst_dvd_demux_handle_newsegment): diff --git a/common b/common index fe94837afc..4edc214072 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit fe94837afc0b10eaf867156fc29eea0073ba45df +Subproject commit 4edc214072fe07d2aade96bc336493425654d7b4 diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 6103a5efed..9128243581 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -547,10 +547,13 @@ static gboolean gst_mad_src_query (GstPad * pad, GstQuery * query) { gboolean res = TRUE; + GstPad *peer; GstMad *mad; mad = GST_MAD (GST_PAD_PARENT (pad)); + peer = gst_pad_get_peer (mad->sinkpad); + switch (GST_QUERY_TYPE (query)) { case GST_QUERY_POSITION: { @@ -560,6 +563,14 @@ gst_mad_src_query (GstPad * pad, GstQuery * query) /* save requested format */ gst_query_parse_position (query, &format, NULL); + /* try any demuxer before us first */ + if (format == GST_FORMAT_TIME && peer && gst_pad_query (peer, query)) { + gst_query_parse_position (query, NULL, &cur); + GST_LOG_OBJECT (mad, "peer returned position %" GST_TIME_FORMAT, + GST_TIME_ARGS (cur)); + break; + } + /* and convert to the requested format */ if (format != GST_FORMAT_DEFAULT) { if (!gst_mad_convert_src (pad, GST_FORMAT_DEFAULT, mad->total_samples, @@ -583,22 +594,28 @@ gst_mad_src_query (GstPad * pad, GstQuery * query) GstFormat format; GstFormat rformat; gint64 total, total_bytes; - GstPad *peer; /* save requested format */ gst_query_parse_duration (query, &format, NULL); + if (peer == NULL) + goto error; + + /* try any demuxer before us first */ + if (format == GST_FORMAT_TIME && gst_pad_query (peer, query)) { + gst_query_parse_duration (query, NULL, &total); + GST_LOG_OBJECT (mad, "peer returned duration %" GST_TIME_FORMAT, + GST_TIME_ARGS (total)); + break; + } + /* query peer for total length in bytes */ gst_query_set_duration (query, GST_FORMAT_BYTES, -1); - if ((peer = gst_pad_get_peer (mad->sinkpad)) == NULL) - goto error; - if (!gst_pad_query (peer, query)) { GST_LOG_OBJECT (mad, "query on peer pad failed"); goto error; } - gst_object_unref (peer); /* get the returned format */ gst_query_parse_duration (query, &rformat, &total_bytes); @@ -650,11 +667,19 @@ gst_mad_src_query (GstPad * pad, GstQuery * query) res = FALSE; break; } + + if (peer) + gst_object_unref (peer); + return res; error: GST_DEBUG ("error handling query"); + + if (peer) + gst_object_unref (peer); + return FALSE; }