imagefreeze: Protect the flushing-seek variable by the srcpad's stream lock

This fixes a subtle race condition, that caused bufferalloc to fail
with wrong-state due to a seek but caused it to be not retried as
it should.
This commit is contained in:
Sebastian Dröge 2010-08-20 10:24:33 +02:00
parent d8ef9bb691
commit e51fe6c181
2 changed files with 10 additions and 2 deletions

View file

@ -329,9 +329,16 @@ gst_image_freeze_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
GST_OBJECT_UNLOCK (self); GST_OBJECT_UNLOCK (self);
if (do_alloc) { if (do_alloc) {
gboolean seeking = FALSE;
do { do {
GST_PAD_STREAM_LOCK (self->srcpad);
ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf); ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf);
} while (ret == GST_FLOW_WRONG_STATE && g_atomic_int_get (&self->seeking));
seeking = ret == GST_FLOW_WRONG_STATE
&& g_atomic_int_get (&self->seeking);
GST_PAD_STREAM_UNLOCK (self->srcpad);
} while (seeking);
if (G_UNLIKELY (ret != GST_FLOW_OK)) if (G_UNLIKELY (ret != GST_FLOW_OK))
GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s", GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",

View file

@ -56,7 +56,8 @@ struct _GstImageFreeze
guint64 offset; guint64 offset;
/* TRUE if currently doing a flushing seek */ /* TRUE if currently doing a flushing seek, protected
* by srcpad's stream lock */
gint seeking; gint seeking;
}; };