From 62dd7c4efd1722702249418a7c83e31c3235ad5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 11 Aug 2010 11:36:31 +0200 Subject: [PATCH] imagefreeze: Retry bufferalloc if it was aborted with WRONG_STATE because of a flushing seek --- gst/imagefreeze/gstimagefreeze.c | 9 ++++++++- gst/imagefreeze/gstimagefreeze.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gst/imagefreeze/gstimagefreeze.c b/gst/imagefreeze/gstimagefreeze.c index 0db2e86c3a..b93d0a711e 100644 --- a/gst/imagefreeze/gstimagefreeze.c +++ b/gst/imagefreeze/gstimagefreeze.c @@ -163,6 +163,8 @@ gst_image_freeze_reset (GstImageFreeze * self) self->fps_n = self->fps_d = 0; self->offset = 0; GST_OBJECT_UNLOCK (self); + + g_atomic_int_set (&self->seeking, 0); } static gboolean @@ -327,7 +329,10 @@ gst_image_freeze_sink_bufferalloc (GstPad * pad, guint64 offset, guint size, GST_OBJECT_UNLOCK (self); if (do_alloc) { - ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf); + do { + ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf); + } while (ret == GST_FLOW_WRONG_STATE && g_atomic_int_get (&self->seeking)); + if (G_UNLIKELY (ret != GST_FLOW_OK)) GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s", gst_flow_get_name (ret)); @@ -609,6 +614,7 @@ gst_image_freeze_src_event (GstPad * pad, GstEvent * event) if (flush) { GstEvent *e; + g_atomic_int_set (&self->seeking, 1); e = gst_event_new_flush_start (); gst_pad_push_event (self->srcpad, e); } else { @@ -651,6 +657,7 @@ gst_image_freeze_src_event (GstPad * pad, GstEvent * event) e = gst_event_new_flush_stop (); gst_pad_push_event (self->srcpad, e); + g_atomic_int_set (&self->seeking, 0); } if (flags & GST_SEEK_FLAG_SEGMENT) { diff --git a/gst/imagefreeze/gstimagefreeze.h b/gst/imagefreeze/gstimagefreeze.h index c65a3cd648..b9bc53f39c 100644 --- a/gst/imagefreeze/gstimagefreeze.h +++ b/gst/imagefreeze/gstimagefreeze.h @@ -55,6 +55,9 @@ struct _GstImageFreeze GstEvent *close_segment; guint64 offset; + + /* TRUE if currently doing a flushing seek */ + gint seeking; }; struct _GstImageFreezeClass