Use g_thread_try_new() instead of g_thread_crate() with newer glib versions

This commit is contained in:
Tim-Philipp Müller 2011-12-12 02:38:37 +00:00
parent f60eb9ae2c
commit 330d984288
4 changed files with 23 additions and 1 deletions

View file

@ -504,8 +504,14 @@ gst_soup_http_client_sink_start (GstBaseSink * sink)
g_mutex_lock (souphttpsink->mutex);
/* FIXME: error handling */
#if !GLIB_CHECK_VERSION (2, 31, 0)
souphttpsink->thread = g_thread_create (thread_func, souphttpsink,
TRUE, &error);
#else
souphttpsink->thread = g_thread_try_new ("souphttpclientsink-thread",
thread_func, souphttpsink, &error);
#endif
GST_LOG_OBJECT (souphttpsink, "waiting for main loop thread to start up");
g_cond_wait (souphttpsink->cond, souphttpsink->mutex);

View file

@ -910,8 +910,13 @@ start_rtcp_thread (GstRtpSession * rtpsession)
g_thread_join (rtpsession->priv->thread);
/* only create a new thread if the old one was stopped. Otherwise we can
* just reuse the currently running one. */
#if !GLIB_CHECK_VERSION (2, 31, 0)
rtpsession->priv->thread =
g_thread_create ((GThreadFunc) rtcp_thread, rtpsession, TRUE, &error);
#else
rtpsession->priv->thread = g_thread_try_new ("rtpsession-rtcp-thread",
(GThreadFunc) rtcp_thread, rtpsession, &error);
#endif
rtpsession->priv->thread_stopped = FALSE;
}
GST_RTP_SESSION_UNLOCK (rtpsession);

View file

@ -542,8 +542,13 @@ gst_oss4_mixer_start_watch_task (GstOss4Mixer * mixer)
mixer->watch_cond = g_cond_new ();
mixer->watch_shutdown = FALSE;
#if !GLIB_CHECK_VERSION (2, 31, 0)
mixer->watch_thread = g_thread_create (gst_oss4_mixer_watch_thread,
gst_object_ref (mixer), TRUE, &err);
#else
mixer->watch_thread = g_thread_try_new ("oss4-mixer-thread",
gst_oss4_mixer_watch_thread, gst_object_ref (mixer), &err);
#endif
if (mixer->watch_thread == NULL) {
GST_ERROR_OBJECT (mixer, "Could not create watch thread: %s", err->message);

View file

@ -491,7 +491,13 @@ main (int argc, char *argv[])
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
loop = g_main_loop_new (NULL, FALSE);
if (!(input_thread = g_thread_create (read_user, source, TRUE, NULL))) {
#if !GLIB_CHECK_VERSION (2, 31, 0)
input_thread = g_thread_create (read_user, source, TRUE, NULL);
#else
input_thread = g_thread_try_new ("v4l2src-test", read_user, source, NULL);
#endif
if (input_thread == NULL) {
fprintf (stderr, "error: g_thread_create return NULL");
return -1;
}