summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosep Torra <n770galaxy@gmail.com>2013-09-24 18:48:24 +0200
committerJosep Torra <n770galaxy@gmail.com>2013-09-24 18:54:23 +0200
commita62815326005cf4c130bec933753d25c68b5a97e (patch)
tree10e1ee8e556b12c88b281def05cfa83e61bc2512
parent92098e66afba94a1f2bb844a88b9c7de8b2c712a (diff)
examples: fix another race condition
Fix a race condition that caused randome deadlocks on EOS.
-rw-r--r--examples/egl/testegl.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/examples/egl/testegl.c b/examples/egl/testegl.c
index b20c91e..7886483 100644
--- a/examples/egl/testegl.c
+++ b/examples/egl/testegl.c
@@ -1102,14 +1102,12 @@ handle_queued_objects (APP_STATE_T * state)
GstMiniObject *object = NULL;
gboolean done = FALSE;
- if (g_async_queue_length (state->queue) == 0) {
- return FALSE;
- }
-
g_mutex_lock (state->queue_lock);
if (state->flushing) {
g_cond_broadcast (state->cond);
done = TRUE;
+ } else if (g_async_queue_length (state->queue) == 0) {
+ done = TRUE;
}
g_mutex_unlock (state->queue_lock);
@@ -1180,6 +1178,8 @@ handle_queued_objects (APP_STATE_T * state)
state->popped_obj = object;
g_cond_broadcast (state->cond);
g_mutex_unlock (state->queue_lock);
+ g_mutex_lock (state->flow_lock);
+ g_mutex_unlock (state->flow_lock);
}
return FALSE;
@@ -1197,16 +1197,16 @@ queue_object (APP_STATE_T * state, GstMiniObject * obj, gboolean synchronous)
goto beach;
}
+ g_mutex_lock (state->queue_lock);
g_async_queue_push (state->queue, obj);
if (synchronous) {
/* Waiting for object to be handled */
- g_mutex_lock (state->queue_lock);
do {
g_cond_wait (state->cond, state->queue_lock);
} while (!state->flushing && state->popped_obj != obj);
- g_mutex_unlock (state->queue_lock);
}
+ g_mutex_unlock (state->queue_lock);
beach:
g_mutex_unlock (state->flow_lock);
@@ -1243,7 +1243,7 @@ events_cb (GstPad * pad, GstPadProbeInfo * probe_info, gpointer user_data)
flush_stop (state);
break;
case GST_EVENT_EOS:
- queue_object (state, GST_MINI_OBJECT_CAST (gst_event_ref (event)), TRUE);
+ queue_object (state, GST_MINI_OBJECT_CAST (gst_event_ref (event)), FALSE);
break;
default:
break;
@@ -1592,7 +1592,6 @@ eos_cb (GstBus * bus, GstMessage * msg, APP_STATE_T * state)
{
if (GST_MESSAGE_SRC (msg) == GST_OBJECT (state->pipeline)) {
g_print ("End-Of-Stream reached.\n");
- flush_start (state);
gst_element_set_state (state->pipeline, GST_STATE_READY);
}
}