Commit fb6df6a0 authored by Rohan Garg's avatar Rohan Garg Committed by Youness Alaoui

Fix builds for systems using glib 2.3.81 and above

parent acbd8f09
...@@ -121,7 +121,11 @@ enum ...@@ -121,7 +121,11 @@ enum
static guint signals[N_SIGNALS]; static guint signals[N_SIGNALS];
static GStaticRecMutex agent_mutex = G_STATIC_REC_MUTEX_INIT; /* Mutex used for thread-safe lib */ #if GLIB_CHECK_VERSION(2,31,8)
static GRecMutex agent_mutex; /* Mutex used for thread-safe lib */
#else
static GStaticRecMutex agent_mutex = G_STATIC_REC_MUTEX_INIT;
#endif
static gboolean priv_attach_stream_component (NiceAgent *agent, static gboolean priv_attach_stream_component (NiceAgent *agent,
Stream *stream, Stream *stream,
...@@ -130,18 +134,29 @@ static void priv_detach_stream_component (Stream *stream, Component *component); ...@@ -130,18 +134,29 @@ static void priv_detach_stream_component (Stream *stream, Component *component);
static void priv_free_upnp (NiceAgent *agent); static void priv_free_upnp (NiceAgent *agent);
#if GLIB_CHECK_VERSION(2,31,8)
void agent_lock (void) void agent_lock (void)
{ {
g_static_rec_mutex_lock (&agent_mutex); g_rec_mutex_lock (&agent_mutex);
} }
void agent_unlock (void) void agent_unlock (void)
{ {
g_static_rec_mutex_unlock (&agent_mutex); g_rec_mutex_unlock (&agent_mutex);
}
#else
void agent_lock(void)
{
g_static_rec_mutex_lock (&agent_mutex);
} }
void agent_unlock(void)
{
g_static_rec_mutex_unlock (&agent_mutex);
}
#endif
StunUsageIceCompatibility StunUsageIceCompatibility
agent_to_ice_compatibility (NiceAgent *agent) agent_to_ice_compatibility (NiceAgent *agent)
......
...@@ -51,8 +51,9 @@ main (void) ...@@ -51,8 +51,9 @@ main (void)
nice_address_init (&addr); nice_address_init (&addr);
g_type_init (); g_type_init ();
#if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init (NULL); g_thread_init (NULL);
#endif
if (!nice_address_set_from_string (&addr, "127.0.0.1")) if (!nice_address_set_from_string (&addr, "127.0.0.1"))
g_assert_not_reached (); g_assert_not_reached ();
......
...@@ -208,7 +208,10 @@ int main (void) ...@@ -208,7 +208,10 @@ int main (void)
guint ls_id, rs_id; guint ls_id, rs_id;
g_type_init (); g_type_init ();
#if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init (NULL); g_thread_init (NULL);
#endif
global_mainloop = g_main_loop_new (NULL, FALSE); global_mainloop = g_main_loop_new (NULL, FALSE);
/* step: create the agents L and R */ /* step: create the agents L and R */
......
...@@ -484,7 +484,10 @@ int main (void) ...@@ -484,7 +484,10 @@ int main (void)
const char *stun_server = NULL, *stun_server_port = NULL; const char *stun_server = NULL, *stun_server_port = NULL;
g_type_init (); g_type_init ();
#if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init (NULL); g_thread_init (NULL);
#endif
global_mainloop = g_main_loop_new (NULL, FALSE); global_mainloop = g_main_loop_new (NULL, FALSE);
/* Note: impl limits ... /* Note: impl limits ...
......
...@@ -804,7 +804,10 @@ int main (void) ...@@ -804,7 +804,10 @@ int main (void)
const char *stun_server = NULL, *stun_server_port = NULL; const char *stun_server = NULL, *stun_server_port = NULL;
g_type_init (); g_type_init ();
g_thread_init (NULL); #if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init(NULL);
#endif
global_mainloop = g_main_loop_new (NULL, FALSE); global_mainloop = g_main_loop_new (NULL, FALSE);
/* Note: impl limits ... /* Note: impl limits ...
......
...@@ -73,7 +73,10 @@ main (void) ...@@ -73,7 +73,10 @@ main (void)
nice_address_init (&addr); nice_address_init (&addr);
g_type_init (); g_type_init ();
g_thread_init (NULL); #if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init(NULL);
#endif
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);
agent = nice_agent_new (g_main_loop_get_context (loop), NICE_COMPATIBILITY_RFC5245); agent = nice_agent_new (g_main_loop_get_context (loop), NICE_COMPATIBILITY_RFC5245);
......
...@@ -394,7 +394,10 @@ int main (void) ...@@ -394,7 +394,10 @@ int main (void)
const char *stun_server = NULL, *stun_server_port = NULL; const char *stun_server = NULL, *stun_server_port = NULL;
g_type_init (); g_type_init ();
g_thread_init (NULL); #if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init(NULL)
#endif
global_mainloop = g_main_loop_new (NULL, FALSE); global_mainloop = g_main_loop_new (NULL, FALSE);
/* Note: impl limits ... /* Note: impl limits ...
......
...@@ -189,7 +189,9 @@ int main (void) ...@@ -189,7 +189,9 @@ int main (void)
GThread *ldthread, *rdthread; GThread *ldthread, *rdthread;
g_type_init (); g_type_init ();
g_thread_init (NULL); #if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init(NULL);
#endif
lmainctx = g_main_context_new (); lmainctx = g_main_context_new ();
rmainctx = g_main_context_new (); rmainctx = g_main_context_new ();
...@@ -268,9 +270,15 @@ int main (void) ...@@ -268,9 +270,15 @@ int main (void)
/* step: run test the first time */ /* step: run test the first time */
g_debug ("test-thread: TEST STARTS / running test for the 1st time"); g_debug ("test-thread: TEST STARTS / running test for the 1st time");
#if !GLIB_CHECK_VERSION(2,31,8)
lthread = g_thread_create (mainloop_thread, lmainloop, TRUE, NULL); lthread = g_thread_create (mainloop_thread, lmainloop, TRUE, NULL);
g_assert (lthread);
rthread = g_thread_create (mainloop_thread, rmainloop, TRUE, NULL); rthread = g_thread_create (mainloop_thread, rmainloop, TRUE, NULL);
#else
lthread = g_thread_new ("lthread libnice", mainloop_thread, lmainloop);
rthread = g_thread_new ("rthread libnice", mainloop_thread, rmainloop);
#endif
g_assert (lthread);
g_assert (rthread); g_assert (rthread);
ls_id = nice_agent_add_stream (lagent, 2); ls_id = nice_agent_add_stream (lagent, 2);
...@@ -289,9 +297,14 @@ int main (void) ...@@ -289,9 +297,14 @@ int main (void)
nice_agent_attach_recv (ragent, rs_id, 1, rdmainctx, cb_nice_recv, nice_agent_attach_recv (ragent, rs_id, 1, rdmainctx, cb_nice_recv,
GUINT_TO_POINTER (2)); GUINT_TO_POINTER (2));
#if !GLIB_CHECK_VERSION(2,31,8)
ldthread = g_thread_create (mainloop_thread, ldmainloop, TRUE, NULL); ldthread = g_thread_create (mainloop_thread, ldmainloop, TRUE, NULL);
g_assert (ldthread);
rdthread = g_thread_create (mainloop_thread, rdmainloop, TRUE, NULL); rdthread = g_thread_create (mainloop_thread, rdmainloop, TRUE, NULL);
#else
ldthread = g_thread_new ("ldthread libnice", mainloop_thread, ldmainloop);
rdthread = g_thread_new ("rdthread libnice", mainloop_thread, rdmainloop);
#endif
g_assert (ldthread);
g_assert (rdthread); g_assert (rdthread);
/* Run loop for error timer */ /* Run loop for error timer */
......
...@@ -55,8 +55,10 @@ main (void) ...@@ -55,8 +55,10 @@ main (void)
nice_address_init (&addr_local); nice_address_init (&addr_local);
nice_address_init (&addr_remote); nice_address_init (&addr_remote);
g_type_init (); g_type_init ();
g_thread_init (NULL);
#if !GLIB_CHECK_VERSION(2,31,8)
g_thread_init(NULL);
#endif
g_assert (nice_address_set_from_string (&addr_local, "127.0.0.1")); g_assert (nice_address_set_from_string (&addr_local, "127.0.0.1"));
g_assert (nice_address_set_from_string (&addr_remote, "127.0.0.1")); g_assert (nice_address_set_from_string (&addr_remote, "127.0.0.1"));
......
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