diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-05-16 17:52:11 +0200 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2011-05-16 17:52:11 +0200 |
commit | cf1248e566ca460f4c24daef39d2ff488974c246 (patch) | |
tree | ccbacaa5ec43572e5981e68b0b1d4d5d01167621 /ext/flac | |
parent | a0e301ab1a80f6e6f1919baa318ba792fa24d878 (diff) | |
parent | 8b910885ecec02c1974a2689ee06e3bd3f0b8cca (diff) | |
download | gstreamer-plugins-good-cf1248e566ca460f4c24daef39d2ff488974c246.tar.gz |
Merge branch 'master' into 0.11
Conflicts:
configure.ac
Diffstat (limited to 'ext/flac')
-rw-r--r-- | ext/flac/gstflacdec.c | 50 | ||||
-rw-r--r-- | ext/flac/gstflacdec.h | 2 |
2 files changed, 47 insertions, 5 deletions
diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index ac0553346..6eaee8978 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -1084,6 +1084,33 @@ gst_flac_dec_loop (GstPad * sinkpad) GST_LOG_OBJECT (flacdec, "entering loop"); + if (flacdec->eos) { + GST_DEBUG_OBJECT (flacdec, "Seeked after end of file"); + + if (flacdec->close_segment) { + GST_DEBUG_OBJECT (flacdec, "pushing close segment"); + gst_pad_push_event (flacdec->srcpad, flacdec->close_segment); + flacdec->close_segment = NULL; + } + if (flacdec->start_segment) { + GST_DEBUG_OBJECT (flacdec, "pushing start segment"); + gst_pad_push_event (flacdec->srcpad, flacdec->start_segment); + flacdec->start_segment = NULL; + } + + if (flacdec->tags) { + gst_element_found_tags_for_pad (GST_ELEMENT (flacdec), flacdec->srcpad, + flacdec->tags); + flacdec->tags = NULL; + } + + if ((flacdec->segment.flags & GST_SEEK_FLAG_SEGMENT) == 0) { + goto eos_and_pause; + } else { + goto segment_done_and_pause; + } + } + if (flacdec->init) { GST_DEBUG_OBJECT (flacdec, "initializing new decoder"); is = FLAC__stream_decoder_init_stream (flacdec->decoder, @@ -1848,6 +1875,14 @@ gst_flac_dec_handle_seek_event (GstFlacDec * flacdec, GstEvent * event) } } + /* Check if we seeked after the end of file */ + if (start_type != GST_SEEK_TYPE_NONE && flacdec->segment.duration > 0 && + start >= flacdec->segment.duration) { + flacdec->eos = TRUE; + } else { + flacdec->eos = FALSE; + } + flush = ((seek_flags & GST_SEEK_FLAG_FLUSH) == GST_SEEK_FLAG_FLUSH); if (flush) { @@ -1911,17 +1946,21 @@ gst_flac_dec_handle_seek_event (GstFlacDec * flacdec, GstEvent * event) * callbacks that need to behave differently when seeking */ flacdec->seeking = TRUE; - GST_LOG_OBJECT (flacdec, "calling seek_absolute"); - seek_ok = FLAC__stream_decoder_seek_absolute (flacdec->decoder, - flacdec->segment.last_stop); - GST_LOG_OBJECT (flacdec, "done with seek_absolute, seek_ok=%d", seek_ok); + if (!flacdec->eos) { + GST_LOG_OBJECT (flacdec, "calling seek_absolute"); + seek_ok = FLAC__stream_decoder_seek_absolute (flacdec->decoder, + flacdec->segment.last_stop); + GST_LOG_OBJECT (flacdec, "done with seek_absolute, seek_ok=%d", seek_ok); + } else { + GST_LOG_OBJECT (flacdec, "not seeking, seeked after end of file"); + seek_ok = TRUE; + } flacdec->seeking = FALSE; GST_DEBUG_OBJECT (flacdec, "performed seek to sample %" G_GINT64_FORMAT, flacdec->segment.last_stop); - if (!seek_ok) { GST_WARNING_OBJECT (flacdec, "seek failed"); /* seek failed, restore the segment and start streaming again with @@ -2094,6 +2133,7 @@ gst_flac_dec_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: + flacdec->eos = FALSE; flacdec->seeking = FALSE; flacdec->channels = 0; flacdec->depth = 0; diff --git a/ext/flac/gstflacdec.h b/ext/flac/gstflacdec.h index aa56b4b80..835bdbd8c 100644 --- a/ext/flac/gstflacdec.h +++ b/ext/flac/gstflacdec.h @@ -61,6 +61,8 @@ struct _GstFlacDec { * don't push any buffers in the write callback * until we are actually at the new position */ + gboolean eos; /* set to TRUE if seeked after the end of file */ + GstSegment segment; /* the currently configured segment, in * samples/audio frames (DEFAULT format) */ gboolean running; |