mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
shapewipe: Fix race condition during shutdown that can lead to a deadlock
This commit is contained in:
parent
2d1f06103a
commit
8d213d51f6
2 changed files with 17 additions and 5 deletions
|
@ -917,13 +917,18 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GST_TIME_ARGS (timestamp), self->mask_position);
|
||||
|
||||
g_mutex_lock (self->mask_mutex);
|
||||
if (self->shutdown) {
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
}
|
||||
|
||||
if (!self->mask)
|
||||
g_cond_wait (self->mask_cond, self->mask_mutex);
|
||||
|
||||
if (self->mask == NULL) {
|
||||
g_mutex_unlock (self->mask_mutex);
|
||||
gst_buffer_unref (buffer);
|
||||
return GST_FLOW_UNEXPECTED;
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
} else {
|
||||
mask = gst_buffer_ref (self->mask);
|
||||
}
|
||||
|
@ -1007,14 +1012,19 @@ gst_shape_wipe_change_state (GstElement * element, GstStateChange transition)
|
|||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
self->shutdown = FALSE;
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
/* Unblock video sink chain function */
|
||||
g_mutex_lock (self->mask_mutex);
|
||||
self->shutdown = TRUE;
|
||||
g_cond_signal (self->mask_cond);
|
||||
g_mutex_unlock (self->mask_mutex);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* Unblock video sink chain function */
|
||||
if (transition == GST_STATE_CHANGE_PAUSED_TO_READY)
|
||||
g_cond_signal (self->mask_cond);
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ struct _GstShapeWipe
|
|||
GstVideoFormat fmt;
|
||||
gint width, height;
|
||||
|
||||
gboolean shutdown;
|
||||
|
||||
gdouble proportion;
|
||||
GstClockTime earliest_time;
|
||||
GstClockTime frame_duration;
|
||||
|
|
Loading…
Reference in a new issue