mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
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:
parent
d8ef9bb691
commit
e51fe6c181
2 changed files with 10 additions and 2 deletions
gst/imagefreeze
|
@ -329,9 +329,16 @@ gst_image_freeze_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
|
|||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
if (do_alloc) {
|
||||
gboolean seeking = FALSE;
|
||||
|
||||
do {
|
||||
GST_PAD_STREAM_LOCK (self->srcpad);
|
||||
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))
|
||||
GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",
|
||||
|
|
|
@ -56,7 +56,8 @@ struct _GstImageFreeze
|
|||
|
||||
guint64 offset;
|
||||
|
||||
/* TRUE if currently doing a flushing seek */
|
||||
/* TRUE if currently doing a flushing seek, protected
|
||||
* by srcpad's stream lock */
|
||||
gint seeking;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue