diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2008-04-22 23:51:00 +0000 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2008-04-22 23:51:00 +0000 |
commit | 047c1da05f9fb73e64b4ed35331b454de267220b (patch) | |
tree | 59b77f809b0d98fb54e55d579eef574a0a897f26 /gst | |
parent | 2e91628f17999695a32b2346c68372a6ad7ceb9d (diff) | |
download | libnice-047c1da05f9fb73e64b4ed35331b454de267220b.tar.gz |
Adding an idler to quit the mainloop so we avoid a rare race condition
darcs-hash:20080422235156-4f0f6-5f33f7b4f4bcc8a39b5ad2cdf474a99cf1ebae89.gz
Diffstat (limited to 'gst')
-rw-r--r-- | gst/gstnicesrc.c | 23 | ||||
-rw-r--r-- | gst/gstnicesrc.h | 1 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gst/gstnicesrc.c b/gst/gstnicesrc.c index 09d6c10..b7f9216 100644 --- a/gst/gstnicesrc.c +++ b/gst/gstnicesrc.c @@ -176,6 +176,7 @@ gst_nice_src_init (GstNiceSrc *src, GstNiceSrcClass *g_class) src->component_id = 0; src->mainloop = g_main_loop_new (g_main_context_new (), FALSE); src->unlocked = FALSE; + src->idle_source = NULL; } static void @@ -200,6 +201,19 @@ gst_nice_src_read_callback (NiceAgent *agent, } 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 gst_nice_src_unlock (GstBaseSrc *src) { GstNiceSrc *nicesrc = GST_NICE_SRC (src); @@ -207,10 +221,15 @@ gst_nice_src_unlock (GstBaseSrc *src) GST_OBJECT_LOCK (src); nicesrc->unlocked = TRUE; nicesrc->flow_ret = GST_FLOW_WRONG_STATE; - GST_OBJECT_UNLOCK (src); 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; } @@ -222,6 +241,8 @@ gst_nice_src_unlock_stop (GstBaseSrc *src) GST_OBJECT_LOCK (src); nicesrc->unlocked = FALSE; nicesrc->flow_ret = GST_FLOW_OK; + g_source_destroy (nicesrc->idle_source); + nicesrc->idle_source = NULL; GST_OBJECT_UNLOCK (src); return TRUE; diff --git a/gst/gstnicesrc.h b/gst/gstnicesrc.h index e19fa0e..96e8f2a 100644 --- a/gst/gstnicesrc.h +++ b/gst/gstnicesrc.h @@ -70,6 +70,7 @@ struct _GstNiceSrc GstFlowReturn flow_ret; GstBuffer *outbuf; gboolean unlocked; + GSource *idle_source; }; typedef struct _GstNiceSrcClass GstNiceSrcClass; |