From af701d80d58617a18d2295344a40a64d9ffa80d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 20 Apr 2006 18:02:07 +0000 Subject: ext/musepack/gstmusepackdec.c: Add support for segment seeks. Original commit message from CVS: * ext/musepack/gstmusepackdec.c: (gst_musepackdec_handle_seek_event), (gst_musepackdec_loop): Add support for segment seeks. --- ext/musepack/gstmusepackdec.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'ext') diff --git a/ext/musepack/gstmusepackdec.c b/ext/musepack/gstmusepackdec.c index 8172aa8f..bb302cac 100644 --- a/ext/musepack/gstmusepackdec.c +++ b/ext/musepack/gstmusepackdec.c @@ -224,7 +224,13 @@ gst_musepackdec_handle_seek_event (GstMusepackDec * dec, GstEvent * event) if (!mpc_decoder_seek_sample (dec->d, segment.start)) goto failed; - /* FIXME: support segment seeks */ + if ((flags & GST_SEEK_FLAG_SEGMENT) == GST_SEEK_FLAG_SEGMENT) { + GST_DEBUG_OBJECT (dec, "posting SEGMENT_START message"); + + gst_element_post_message (GST_ELEMENT (dec), + gst_message_new_segment_start (GST_OBJECT (dec), GST_FORMAT_TIME, + gst_util_uint64_scale_int (segment.start, GST_SECOND, dec->rate))); + } if (flush) { gst_pad_push_event (dec->srcpad, gst_event_new_flush_stop ()); @@ -493,9 +499,7 @@ gst_musepackdec_loop (GstPad * sinkpad) GST_ELEMENT_ERROR (musepackdec, STREAM, DECODE, (NULL), (NULL)); goto pause_task; } else if (num_samples == 0) { - GST_DEBUG_OBJECT (musepackdec, "EOS"); - gst_pad_push_event (musepackdec->srcpad, gst_event_new_eos ()); - goto pause_task; + goto eos_and_pause; } GST_BUFFER_SIZE (out) = num_samples * bitspersample; @@ -518,8 +522,37 @@ gst_musepackdec_loop (GstPad * sinkpad) goto pause_task; } + /* check if we're at the end of a configured segment */ + if (musepackdec->segment.stop != -1 && + musepackdec->segment.last_stop >= musepackdec->segment.stop) { + gint64 stop_time; + + GST_DEBUG_OBJECT (musepackdec, "Reached end of configured segment"); + + if ((musepackdec->segment.flags & GST_SEEK_FLAG_SEGMENT) == 0) + goto eos_and_pause; + + GST_DEBUG_OBJECT (musepackdec, "Posting SEGMENT_DONE message"); + + stop_time = gst_util_uint64_scale_int (musepackdec->segment.stop, + GST_SECOND, samplerate); + + gst_element_post_message (GST_ELEMENT (musepackdec), + gst_message_new_segment_done (GST_OBJECT (musepackdec), + GST_FORMAT_TIME, stop_time)); + + goto pause_task; + } + return; +eos_and_pause: + { + GST_DEBUG_OBJECT (musepackdec, "sending EOS event"); + gst_pad_push_event (musepackdec->srcpad, gst_event_new_eos ()); + /* fall through to pause */ + } + pause_task: { GST_DEBUG_OBJECT (musepackdec, "Pausing task"); -- cgit v1.2.1