Commit 047c1da0 authored by Youness Alaoui's avatar Youness Alaoui

Adding an idler to quit the mainloop so we avoid a rare race condition

darcs-hash:20080422235156-4f0f6-5f33f7b4f4bcc8a39b5ad2cdf474a99cf1ebae89.gz
parent 2e91628f
...@@ -176,6 +176,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class) ...@@ -176,6 +176,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class)
src->component_id = 0; src->component_id = 0;
src->mainloop = g_main_loop_new (g_main_context_new (), FALSE); src->mainloop = g_main_loop_new (g_main_context_new (), FALSE);
src->unlocked = FALSE; src->unlocked = FALSE;
src->idle_source = NULL;
} }
static void static void
...@@ -199,6 +200,19 @@ gst_nice_src_read_callback (NiceAgent *agent, ...@@ -199,6 +200,19 @@ gst_nice_src_read_callback (NiceAgent *agent,
g_main_loop_quit (nicesrc->mainloop); g_main_loop_quit (nicesrc->mainloop);
} }
static gboolean
gst_nice_src_unlock_idler (gpointer data)
{
GstNiceSrc *nicesrc = GST_NICE_SRC (data);
g_main_loop_quit (nicesrc->mainloop);
g_source_unref (nicesrc->idle_source);
nicesrc->idle_source = NULL;
return FALSE;
}
static gboolean static gboolean
gst_nice_src_unlock (GstBaseSrc *src) gst_nice_src_unlock (GstBaseSrc *src)
{ {
...@@ -207,10 +221,15 @@ gst_nice_src_unlock (GstBaseSrc *src) ...@@ -207,10 +221,15 @@ gst_nice_src_unlock (GstBaseSrc *src)
GST_OBJECT_LOCK (src); GST_OBJECT_LOCK (src);
nicesrc->unlocked = TRUE; nicesrc->unlocked = TRUE;
nicesrc->flow_ret = GST_FLOW_WRONG_STATE; nicesrc->flow_ret = GST_FLOW_WRONG_STATE;
GST_OBJECT_UNLOCK (src);
g_main_loop_quit (nicesrc->mainloop); g_main_loop_quit (nicesrc->mainloop);
nicesrc->idle_source = g_idle_source_new ();
g_source_set_priority (nicesrc->idle_source, G_PRIORITY_HIGH);
g_source_set_callback (nicesrc->idle_source, gst_nice_src_unlock_idler, src, NULL);
g_source_attach (nicesrc->idle_source, g_main_loop_get_context (nicesrc->mainloop));
GST_OBJECT_UNLOCK (src);
return TRUE; return TRUE;
} }
...@@ -222,6 +241,8 @@ gst_nice_src_unlock_stop (GstBaseSrc *src) ...@@ -222,6 +241,8 @@ gst_nice_src_unlock_stop (GstBaseSrc *src)
GST_OBJECT_LOCK (src); GST_OBJECT_LOCK (src);
nicesrc->unlocked = FALSE; nicesrc->unlocked = FALSE;
nicesrc->flow_ret = GST_FLOW_OK; nicesrc->flow_ret = GST_FLOW_OK;
g_source_destroy (nicesrc->idle_source);
nicesrc->idle_source = NULL;
GST_OBJECT_UNLOCK (src); GST_OBJECT_UNLOCK (src);
return TRUE; return TRUE;
......
...@@ -70,6 +70,7 @@ struct _GstNiceSrc ...@@ -70,6 +70,7 @@ struct _GstNiceSrc
GstFlowReturn flow_ret; GstFlowReturn flow_ret;
GstBuffer *outbuf; GstBuffer *outbuf;
gboolean unlocked; gboolean unlocked;
GSource *idle_source;
}; };
typedef struct _GstNiceSrcClass GstNiceSrcClass; typedef struct _GstNiceSrcClass GstNiceSrcClass;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment