shapewipe: Fix race condition during shutdown that can lead to a deadlock

This commit is contained in:
Sebastian Dröge 2010-02-08 08:12:11 +01:00
parent 2d1f06103a
commit 8d213d51f6
2 changed files with 17 additions and 5 deletions

View file

@ -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);

View file

@ -62,6 +62,8 @@ struct _GstShapeWipe
GstVideoFormat fmt;
gint width, height;
gboolean shutdown;
gdouble proportion;
GstClockTime earliest_time;
GstClockTime frame_duration;