From 27ee60a27b771aa0bd34d06267e95e41927a61d6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 19 Jan 2012 11:34:26 +0100 Subject: [PATCH] port to new gthread API --- ext/assrender/gstassrender.c | 82 +++++++++---------- ext/assrender/gstassrender.h | 6 +- ext/mplex/gstmplex.cc | 8 +- ext/mplex/gstmplex.hh | 12 +-- .../gst/basecamerabinsrc/gstbasecamerasrc.c | 16 ++-- .../gst/basecamerabinsrc/gstbasecamerasrc.h | 2 +- .../basecamerabinsrc/gstcamerabinpreview.c | 38 ++++----- .../basecamerabinsrc/gstcamerabinpreview.h | 4 +- gst-libs/gst/video/gstbasevideocodec.c | 4 +- gst-libs/gst/video/gstbasevideocodec.h | 6 +- gst/audiovisualizers/gstbaseaudiovisualizer.c | 20 ++--- gst/audiovisualizers/gstbaseaudiovisualizer.h | 2 +- gst/camerabin2/gstcamerabin2.c | 81 +++++++++--------- gst/camerabin2/gstcamerabin2.h | 8 +- gst/camerabin2/gstwrappercamerabinsrc.c | 20 ++--- gst/dvbsuboverlay/gstdvbsuboverlay.c | 17 ++-- gst/dvbsuboverlay/gstdvbsuboverlay.h | 2 +- gst/dvdspu/gstdvdspu.c | 4 +- gst/dvdspu/gstdvdspu.h | 6 +- gst/multifdsink/gstmultifdsink.c | 6 +- gst/multifdsink/gstmultifdsink.h | 10 +-- gst/sdp/gstsdpdemux.c | 6 +- gst/sdp/gstsdpdemux.h | 8 +- sys/dvb/gstdvbsrc.c | 12 +-- sys/dvb/gstdvbsrc.h | 2 +- tests/examples/camerabin/gst-camera-perf.c | 3 - tests/examples/camerabin/gst-camerabin-test.c | 3 - .../examples/camerabin2/gst-camerabin2-test.c | 3 - tests/examples/mxf/mxfdemux-structure.c | 3 - tests/examples/scaletempo/demo-gui.c | 2 +- tests/examples/scaletempo/demo-main.c | 3 - 31 files changed, 188 insertions(+), 211 deletions(-) diff --git a/ext/assrender/gstassrender.c b/ext/assrender/gstassrender.c index 19016f5f62..fb39789496 100644 --- a/ext/assrender/gstassrender.c +++ b/ext/assrender/gstassrender.c @@ -207,8 +207,8 @@ gst_ass_render_init (GstAssRender * render) gst_video_info_init (&render->info); - render->subtitle_mutex = g_mutex_new (); - render->subtitle_cond = g_cond_new (); + g_mutex_init (&render->subtitle_mutex); + g_cond_init (&render->subtitle_cond); render->renderer_init_ok = FALSE; render->track_init_ok = FALSE; @@ -218,7 +218,7 @@ gst_ass_render_init (GstAssRender * render) gst_segment_init (&render->video_segment, GST_FORMAT_TIME); gst_segment_init (&render->subtitle_segment, GST_FORMAT_TIME); - render->ass_mutex = g_mutex_new (); + g_mutex_init (&render->ass_mutex); render->ass_library = ass_library_init (); #if defined(LIBASS_VERSION) && LIBASS_VERSION >= 0x00907000 ass_set_message_cb (render->ass_library, _libass_message_cb, render); @@ -241,11 +241,8 @@ gst_ass_render_finalize (GObject * object) { GstAssRender *render = GST_ASS_RENDER (object); - if (render->subtitle_mutex) - g_mutex_free (render->subtitle_mutex); - - if (render->subtitle_cond) - g_cond_free (render->subtitle_cond); + g_mutex_clear (&render->subtitle_mutex); + g_cond_clear (&render->subtitle_cond); if (render->ass_track) { ass_free_track (render->ass_track); @@ -259,8 +256,7 @@ gst_ass_render_finalize (GObject * object) ass_library_done (render->ass_library); } - if (render->ass_mutex) - g_mutex_free (render->ass_mutex); + g_mutex_clear (&render->ass_mutex); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -277,9 +273,9 @@ gst_ass_render_set_property (GObject * object, guint prop_id, break; case PROP_EMBEDDEDFONTS: render->embeddedfonts = g_value_get_boolean (value); - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); ass_set_extract_fonts (render->ass_library, render->embeddedfonts); - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -324,13 +320,13 @@ gst_ass_render_change_state (GstElement * element, GstStateChange transition) break; case GST_STATE_CHANGE_PAUSED_TO_READY: - g_mutex_lock (render->subtitle_mutex); + g_mutex_lock (&render->subtitle_mutex); render->subtitle_flushing = TRUE; if (render->subtitle_pending) gst_buffer_unref (render->subtitle_pending); render->subtitle_pending = NULL; - g_cond_signal (render->subtitle_cond); - g_mutex_unlock (render->subtitle_mutex); + g_cond_signal (&render->subtitle_cond); + g_mutex_unlock (&render->subtitle_mutex); break; } @@ -338,11 +334,11 @@ gst_ass_render_change_state (GstElement * element, GstStateChange transition) switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); if (render->ass_track) ass_free_track (render->ass_track); render->ass_track = NULL; - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); render->track_init_ok = FALSE; render->renderer_init_ok = FALSE; break; @@ -400,13 +396,13 @@ gst_ass_render_event_src (GstPad * pad, GstObject * parent, GstEvent * event) gst_pad_push_event (render->srcpad, gst_event_new_flush_start ()); /* Mark subtitle as flushing, unblocks chains */ - g_mutex_lock (render->subtitle_mutex); + g_mutex_lock (&render->subtitle_mutex); if (render->subtitle_pending) gst_buffer_unref (render->subtitle_pending); render->subtitle_pending = NULL; render->subtitle_flushing = TRUE; - g_cond_signal (render->subtitle_cond); - g_mutex_unlock (render->subtitle_mutex); + g_cond_signal (&render->subtitle_cond); + g_mutex_unlock (&render->subtitle_mutex); /* Seek on each sink pad */ gst_event_ref (event); @@ -780,7 +776,7 @@ gst_ass_render_setcaps_video (GstPad * pad, GstCaps * caps) goto out; } - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); ass_set_frame_size (render->ass_renderer, info.width, info.height); dar = (((gdouble) par_n) * ((gdouble) info.width)) @@ -803,7 +799,7 @@ gst_ass_render_setcaps_video (GstPad * pad, GstCaps * caps) #endif ass_set_margins (render->ass_renderer, 0, 0, 0, 0); ass_set_use_margins (render->ass_renderer, 0); - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); render->renderer_init_ok = TRUE; @@ -841,7 +837,7 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps) value = gst_structure_get_value (structure, "codec_data"); - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); if (value != NULL) { priv = gst_value_get_buffer (value); g_return_val_if_fail (priv != NULL, FALSE); @@ -869,7 +865,7 @@ gst_ass_render_setcaps_text (GstPad * pad, GstCaps * caps) ret = TRUE; } - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); gst_object_unref (render); @@ -897,9 +893,9 @@ gst_ass_render_process_text (GstAssRender * render, GstBuffer * buffer, data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); ass_process_chunk (render->ass_track, data, size, pts_start, pts_end); - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); gst_buffer_unmap (buffer, data, size); gst_buffer_unref (buffer); @@ -953,7 +949,7 @@ gst_ass_render_chain_video (GstPad * pad, GstObject * parent, render->video_segment.position = clip_start; - g_mutex_lock (render->subtitle_mutex); + g_mutex_lock (&render->subtitle_mutex); if (render->subtitle_pending) { GstClockTime sub_running_time, vid_running_time; GstClockTime sub_running_time_end, vid_running_time_end; @@ -979,15 +975,15 @@ gst_ass_render_chain_video (GstPad * pad, GstObject * parent, GST_TIME_FORMAT, GST_TIME_ARGS (sub_running_time_end), GST_TIME_ARGS (vid_running_time)); render->subtitle_pending = NULL; - g_cond_signal (render->subtitle_cond); + g_cond_signal (&render->subtitle_cond); } else if (sub_running_time <= vid_running_time_end + GST_SECOND / 2) { gst_ass_render_process_text (render, render->subtitle_pending, sub_running_time, sub_running_time_end - sub_running_time); render->subtitle_pending = NULL; - g_cond_signal (render->subtitle_cond); + g_cond_signal (&render->subtitle_cond); } } - g_mutex_unlock (render->subtitle_mutex); + g_mutex_unlock (&render->subtitle_mutex); /* now start rendering subtitles, if all conditions are met */ if (render->renderer_init_ok && render->track_init_ok && render->enable) { @@ -1006,7 +1002,7 @@ gst_ass_render_chain_video (GstPad * pad, GstObject * parent, /* libass needs timestamps in ms */ timestamp = running_time / GST_MSECOND; - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); #ifndef GST_DISABLE_GST_DEBUG /* only for testing right now. could possibly be used for optimizations? */ step = ass_step_sub (render->ass_track, timestamp, 1); @@ -1018,7 +1014,7 @@ gst_ass_render_chain_video (GstPad * pad, GstObject * parent, /* not sure what the last parameter to this call is for (detect_change) */ ass_image = ass_render_frame (render->ass_renderer, render->ass_track, timestamp, NULL); - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); if (ass_image != NULL) { GstVideoFrame frame; @@ -1108,11 +1104,11 @@ gst_ass_render_chain_text (GstPad * pad, GstObject * parent, GstBuffer * buffer) if (sub_running_time > vid_running_time + GST_SECOND / 2) { g_assert (render->subtitle_pending == NULL); - g_mutex_lock (render->subtitle_mutex); + g_mutex_lock (&render->subtitle_mutex); if (G_UNLIKELY (render->subtitle_flushing)) { GST_DEBUG_OBJECT (render, "Text pad flushing"); gst_buffer_unref (buffer); - g_mutex_unlock (render->subtitle_mutex); + g_mutex_unlock (&render->subtitle_mutex); return GST_FLOW_WRONG_STATE; } GST_DEBUG_OBJECT (render, @@ -1120,8 +1116,8 @@ gst_ass_render_chain_text (GstPad * pad, GstObject * parent, GstBuffer * buffer) GST_TIME_FORMAT, GST_TIME_ARGS (sub_running_time), GST_TIME_ARGS (vid_running_time)); render->subtitle_pending = buffer; - g_cond_wait (render->subtitle_cond, render->subtitle_mutex); - g_mutex_unlock (render->subtitle_mutex); + g_cond_wait (&render->subtitle_cond, &render->subtitle_mutex); + g_mutex_unlock (&render->subtitle_mutex); } else if (sub_running_time_end < vid_running_time) { GST_DEBUG_OBJECT (render, "Too late text buffer, dropping (%" GST_TIME_FORMAT " < %" @@ -1212,11 +1208,11 @@ gst_ass_render_handle_tags (GstAssRender * render, GstTagList * taglist) } if (valid_mimetype || valid_extension) { - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); ass_add_font (render->ass_library, (gchar *) filename, (gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); GST_DEBUG_OBJECT (render, "registered new font %s", filename); - g_mutex_unlock (render->ass_mutex); + g_mutex_unlock (&render->ass_mutex); } #endif } @@ -1368,7 +1364,7 @@ gst_ass_render_event_text (GstPad * pad, GstObject * parent, GstEvent * event) break; case GST_EVENT_FLUSH_START: GST_DEBUG_OBJECT (render, "begin flushing"); - g_mutex_lock (render->ass_mutex); + g_mutex_lock (&render->ass_mutex); if (render->ass_track) { /* delete any events on the ass_track */ for (i = 0; i < render->ass_track->n_events; i++) { @@ -1378,14 +1374,14 @@ gst_ass_render_event_text (GstPad * pad, GstObject * parent, GstEvent * event) render->ass_track->n_events = 0; GST_DEBUG_OBJECT (render, "done flushing"); } - g_mutex_unlock (render->ass_mutex); - g_mutex_lock (render->subtitle_mutex); + g_mutex_unlock (&render->ass_mutex); + g_mutex_lock (&render->subtitle_mutex); if (render->subtitle_pending) gst_buffer_unref (render->subtitle_pending); render->subtitle_pending = NULL; render->subtitle_flushing = TRUE; - g_cond_signal (render->subtitle_cond); - g_mutex_unlock (render->subtitle_mutex); + g_cond_signal (&render->subtitle_cond); + g_mutex_unlock (&render->subtitle_mutex); gst_event_unref (event); ret = TRUE; break; diff --git a/ext/assrender/gstassrender.h b/ext/assrender/gstassrender.h index 23dd4df247..3fe412de56 100644 --- a/ext/assrender/gstassrender.h +++ b/ext/assrender/gstassrender.h @@ -60,13 +60,13 @@ struct _GstAssRender GstVideoInfo info; GstAssRenderBlitFunction blit; - GMutex *subtitle_mutex; - GCond *subtitle_cond; + GMutex subtitle_mutex; + GCond subtitle_cond; GstBuffer *subtitle_pending; gboolean subtitle_flushing; GstSegment subtitle_segment; - GMutex *ass_mutex; + GMutex ass_mutex; ASS_Library *ass_library; ASS_Renderer *ass_renderer; ASS_Track *ass_track; diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index b69f1384e6..ebf1a15a16 100644 --- a/ext/mplex/gstmplex.cc +++ b/ext/mplex/gstmplex.cc @@ -179,7 +179,7 @@ gst_mplex_finalize (GObject * object) /* ... and of the rest */ delete mplex->job; - g_mutex_free (mplex->tlock); + g_mutex_clear (&mplex->tlock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -200,7 +200,7 @@ gst_mplex_init (GstMplex * mplex) mplex->num_apads = 0; mplex->num_vpads = 0; - mplex->tlock = g_mutex_new (); + g_mutex_init (&mplex->tlock); gst_mplex_reset (mplex); } @@ -231,7 +231,7 @@ gst_mplex_reset (GstMplex * mplex) } if (!mpad->pad) { - g_cond_free (mpad->cond); + g_cond_clear (&mpad->cond); g_object_unref (mpad->adapter); g_free (mpad); } else @@ -630,7 +630,7 @@ gst_mplex_request_new_pad (GstElement * element, mpad = g_new0 (GstMplexPad, 1); mpad->adapter = gst_adapter_new (); - mpad->cond = g_cond_new (); + g_cond_init (&mpad->cond); gst_object_ref (newpad); mpad->pad = newpad; diff --git a/ext/mplex/gstmplex.hh b/ext/mplex/gstmplex.hh index c519f1dc31..5e64ef1d17 100644 --- a/ext/mplex/gstmplex.hh +++ b/ext/mplex/gstmplex.hh @@ -46,23 +46,23 @@ GST_DEBUG_CATEGORY_EXTERN (mplex_debug); #define GST_MPLEX_MUTEX_LOCK(m) G_STMT_START { \ GST_LOG_OBJECT (m, "locking tlock from thread %p", g_thread_self ()); \ - g_mutex_lock ((m)->tlock); \ + g_mutex_lock (&(m)->tlock); \ GST_LOG_OBJECT (m, "locked tlock from thread %p", g_thread_self ()); \ } G_STMT_END #define GST_MPLEX_MUTEX_UNLOCK(m) G_STMT_START { \ GST_LOG_OBJECT (m, "unlocking tlock from thread %p", g_thread_self ()); \ - g_mutex_unlock ((m)->tlock); \ + g_mutex_unlock (&(m)->tlock); \ } G_STMT_END #define GST_MPLEX_WAIT(m, p) G_STMT_START { \ GST_LOG_OBJECT (m, "thread %p waiting", g_thread_self ()); \ - g_cond_wait ((p)->cond, (m)->tlock); \ + g_cond_wait (&(p)->cond, &(m)->tlock); \ } G_STMT_END #define GST_MPLEX_SIGNAL(m, p) G_STMT_START { \ GST_LOG_OBJECT (m, "signalling from thread %p", g_thread_self ()); \ - g_cond_signal ((p)->cond); \ + g_cond_signal (&(p)->cond); \ } G_STMT_END #define GST_MPLEX_SIGNAL_ALL(m) G_STMT_START { \ @@ -84,7 +84,7 @@ typedef struct _GstMplexPad /* no more to expect on this pad */ gboolean eos; /* signals counterpart thread to have a look */ - GCond *cond; + GCond cond; /* amount needed by mplex on this stream */ guint needed; /* bitstream for this pad */ @@ -103,7 +103,7 @@ typedef struct _GstMplex { GstMplexJob *job; /* lock for syncing */ - GMutex *tlock; + GMutex tlock; /* with TLOCK */ /* muxer writer generated eos */ gboolean eos; diff --git a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c index 98213c9bae..d6ad8d517b 100644 --- a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c +++ b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.c @@ -181,10 +181,10 @@ gst_base_camera_src_start_capture (GstBaseCameraSrc * src) GST_DEBUG_OBJECT (src, "Starting capture"); - g_mutex_lock (src->capturing_mutex); + g_mutex_lock (&src->capturing_mutex); if (src->capturing) { GST_WARNING_OBJECT (src, "Capturing already ongoing"); - g_mutex_unlock (src->capturing_mutex); + g_mutex_unlock (&src->capturing_mutex); /* post a warning to notify camerabin2 that the capture failed */ GST_ELEMENT_WARNING (src, RESOURCE, BUSY, (NULL), (NULL)); @@ -200,7 +200,7 @@ gst_base_camera_src_start_capture (GstBaseCameraSrc * src) g_object_notify (G_OBJECT (src), "ready-for-capture"); GST_WARNING_OBJECT (src, "Failed to start capture"); } - g_mutex_unlock (src->capturing_mutex); + g_mutex_unlock (&src->capturing_mutex); } static void @@ -210,14 +210,14 @@ gst_base_camera_src_stop_capture (GstBaseCameraSrc * src) g_return_if_fail (klass->stop_capture != NULL); - g_mutex_lock (src->capturing_mutex); + g_mutex_lock (&src->capturing_mutex); if (!src->capturing) { GST_DEBUG_OBJECT (src, "No ongoing capture"); - g_mutex_unlock (src->capturing_mutex); + g_mutex_unlock (&src->capturing_mutex); return; } klass->stop_capture (src); - g_mutex_unlock (src->capturing_mutex); + g_mutex_unlock (&src->capturing_mutex); } void @@ -234,7 +234,7 @@ gst_base_camera_src_dispose (GObject * object) { GstBaseCameraSrc *src = GST_BASE_CAMERA_SRC_CAST (object); - g_mutex_free (src->capturing_mutex); + g_mutex_clear (&src->capturing_mutex); if (src->preview_pipeline) { gst_camerabin_destroy_preview_pipeline (src->preview_pipeline); @@ -542,7 +542,7 @@ gst_base_camera_src_init (GstBaseCameraSrc * self) self->mode = MODE_IMAGE; self->capturing = FALSE; - self->capturing_mutex = g_mutex_new (); + g_mutex_init (&self->capturing_mutex); self->post_preview = DEFAULT_POST_PREVIEW; diff --git a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h index 9d63e2d3c1..31e077f983 100644 --- a/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h +++ b/gst-libs/gst/basecamerabinsrc/gstbasecamerasrc.h @@ -69,7 +69,7 @@ struct _GstBaseCameraSrc GstCameraBinMode mode; gboolean capturing; - GMutex *capturing_mutex; + GMutex capturing_mutex; /* Preview convert pipeline */ GstCaps *preview_caps; diff --git a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c index 41d11e1588..426df21cbc 100644 --- a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c +++ b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.c @@ -68,7 +68,7 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer user_data) data->pipeline = NULL; } - g_cond_signal (data->processing_cond); + g_cond_signal (&data->processing_cond); break; } @@ -101,13 +101,13 @@ gst_camerabin_preview_pipeline_new_sample (GstAppSink * appsink, "This element has no bus, therefore no message sent!"); } - g_mutex_lock (data->processing_lock); + g_mutex_lock (&data->processing_lock); data->processing--; if (data->processing == 0) - g_cond_signal (data->processing_cond); + g_cond_signal (&data->processing_cond); - g_mutex_unlock (data->processing_lock); + g_mutex_unlock (&data->processing_lock); return GST_FLOW_OK; } @@ -195,8 +195,8 @@ gst_camerabin_create_preview_pipeline (GstElement * element, data->filter = filter; data->vscale = vscale; - data->processing_lock = g_mutex_new (); - data->processing_cond = g_cond_new (); + g_mutex_init (&data->processing_lock); + g_cond_init (&data->processing_cond); data->pending_preview_caps = NULL; data->processing = 0; @@ -230,13 +230,13 @@ gst_camerabin_destroy_preview_pipeline (GstCameraBinPreviewPipelineData * { g_return_if_fail (preview != NULL); - if (preview->processing_lock) { - g_mutex_free (preview->processing_lock); - preview->processing_lock = NULL; + if (preview->processing_lock.p) { + g_mutex_clear (&preview->processing_lock); + preview->processing_lock.p = NULL; } - if (preview->processing_cond) { - g_cond_free (preview->processing_cond); - preview->processing_cond = NULL; + if (preview->processing_cond.p) { + g_cond_clear (&preview->processing_cond); + preview->processing_cond.p = NULL; } if (preview->pipeline) { gst_element_set_state (preview->pipeline, GST_STATE_NULL); @@ -263,12 +263,12 @@ gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview, g_return_val_if_fail (preview->pipeline != NULL, FALSE); g_return_val_if_fail (buffer, FALSE); - g_mutex_lock (preview->processing_lock); + g_mutex_lock (&preview->processing_lock); g_return_val_if_fail (preview->pipeline != NULL, FALSE); if (preview->pending_preview_caps) { if (preview->processing > 0) { - g_cond_wait (preview->processing_cond, preview->processing_lock); + g_cond_wait (&preview->processing_cond, &preview->processing_lock); } _gst_camerabin_preview_set_caps (preview, preview->pending_preview_caps); gst_caps_replace (&preview->pending_preview_caps, NULL); @@ -279,7 +279,7 @@ gst_camerabin_preview_pipeline_post (GstCameraBinPreviewPipelineData * preview, gst_app_src_push_buffer ((GstAppSrc *) preview->appsrc, gst_buffer_ref (buffer)); - g_mutex_unlock (preview->processing_lock); + g_mutex_unlock (&preview->processing_lock); return TRUE; } @@ -321,7 +321,7 @@ gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview, { g_return_if_fail (preview != NULL); - g_mutex_lock (preview->processing_lock); + g_mutex_lock (&preview->processing_lock); if (preview->processing == 0) { _gst_camerabin_preview_set_caps (preview, caps); @@ -329,7 +329,7 @@ gst_camerabin_preview_set_caps (GstCameraBinPreviewPipelineData * preview, GST_DEBUG ("Preview pipeline busy, storing new caps as pending"); gst_caps_replace (&preview->pending_preview_caps, caps); } - g_mutex_unlock (preview->processing_lock); + g_mutex_unlock (&preview->processing_lock); } /** @@ -352,7 +352,7 @@ gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview, GST_DEBUG ("Preview pipeline setting new filter %p", filter); - g_mutex_lock (preview->processing_lock); + g_mutex_lock (&preview->processing_lock); gst_element_get_state (preview->pipeline, ¤t, NULL, 0); @@ -398,7 +398,7 @@ gst_camerabin_preview_set_filter (GstCameraBinPreviewPipelineData * preview, GST_WARNING ("Cannot change filter when pipeline is running"); ret = FALSE; } - g_mutex_unlock (preview->processing_lock); + g_mutex_unlock (&preview->processing_lock); return ret; } diff --git a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.h b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.h index eb4a45f335..fba274cbca 100644 --- a/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.h +++ b/gst-libs/gst/basecamerabinsrc/gstcamerabinpreview.h @@ -42,8 +42,8 @@ typedef struct GstCaps *pending_preview_caps; guint processing; - GMutex *processing_lock; - GCond *processing_cond; + GMutex processing_lock; + GCond processing_cond; } GstCameraBinPreviewPipelineData; diff --git a/gst-libs/gst/video/gstbasevideocodec.c b/gst-libs/gst/video/gstbasevideocodec.c index c545b07867..70d8d12e48 100644 --- a/gst-libs/gst/video/gstbasevideocodec.c +++ b/gst-libs/gst/video/gstbasevideocodec.c @@ -130,7 +130,7 @@ gst_base_video_codec_init (GstBaseVideoCodec * base_video_codec, gst_segment_init (&base_video_codec->segment, GST_FORMAT_TIME); - g_static_rec_mutex_init (&base_video_codec->stream_lock); + g_rec_mutex_init (&base_video_codec->stream_lock); } static void @@ -162,7 +162,7 @@ gst_base_video_codec_finalize (GObject * object) { GstBaseVideoCodec *base_video_codec = GST_BASE_VIDEO_CODEC (object); - g_static_rec_mutex_free (&base_video_codec->stream_lock); + g_rec_mutex_clear (&base_video_codec->stream_lock); G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst-libs/gst/video/gstbasevideocodec.h b/gst-libs/gst/video/gstbasevideocodec.h index dafd995da9..5073806707 100644 --- a/gst-libs/gst/video/gstbasevideocodec.h +++ b/gst-libs/gst/video/gstbasevideocodec.h @@ -81,8 +81,8 @@ G_BEGIN_DECLS */ #define GST_BASE_VIDEO_CODEC_FLOW_NEED_DATA GST_FLOW_CUSTOM_SUCCESS -#define GST_BASE_VIDEO_CODEC_STREAM_LOCK(codec) g_static_rec_mutex_lock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock) -#define GST_BASE_VIDEO_CODEC_STREAM_UNLOCK(codec) g_static_rec_mutex_unlock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock) +#define GST_BASE_VIDEO_CODEC_STREAM_LOCK(codec) g_rec_mutex_lock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock) +#define GST_BASE_VIDEO_CODEC_STREAM_UNLOCK(codec) g_rec_mutex_unlock (&GST_BASE_VIDEO_CODEC (codec)->stream_lock) typedef struct _GstVideoState GstVideoState; typedef struct _GstVideoFrameState GstVideoFrameState; @@ -160,7 +160,7 @@ struct _GstBaseVideoCodec /* protects all data processing, i.e. is locked * in the chain function, finish_frame and when * processing serialized events */ - GStaticRecMutex stream_lock; + GRecMutex stream_lock; guint64 system_frame_number; diff --git a/gst/audiovisualizers/gstbaseaudiovisualizer.c b/gst/audiovisualizers/gstbaseaudiovisualizer.c index 0c8ba7df0c..6cb8a58372 100644 --- a/gst/audiovisualizers/gstbaseaudiovisualizer.c +++ b/gst/audiovisualizers/gstbaseaudiovisualizer.c @@ -501,7 +501,7 @@ gst_base_audio_visualizer_init (GstBaseAudioVisualizer * scope, scope->rate = GST_AUDIO_DEF_RATE; scope->channels = 2; - scope->config_lock = g_mutex_new (); + g_mutex_init (&scope->config_lock); } static void @@ -560,9 +560,9 @@ gst_base_audio_visualizer_dispose (GObject * object) g_free (scope->pixelbuf); scope->pixelbuf = NULL; } - if (scope->config_lock) { - g_mutex_free (scope->config_lock); - scope->config_lock = NULL; + if (scope->config_lock.p) { + g_mutex_clear (&scope->config_lock); + scope->config_lock.p = NULL; } G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -821,7 +821,7 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, gst_adapter_push (scope->adapter, buffer); - g_mutex_lock (scope->config_lock); + g_mutex_lock (&scope->config_lock); /* this is what we want */ sbpf = scope->req_spf * scope->channels * sizeof (gint16); @@ -865,9 +865,9 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, } } - g_mutex_unlock (scope->config_lock); + g_mutex_unlock (&scope->config_lock); ret = gst_buffer_pool_acquire_buffer (scope->pool, &outbuf, NULL); - g_mutex_lock (scope->config_lock); + g_mutex_lock (&scope->config_lock); /* recheck as the value could have changed */ sbpf = scope->req_spf * scope->channels * sizeof (gint16); @@ -910,10 +910,10 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, gst_buffer_unmap (outbuf, vdata, scope->bpf); - g_mutex_unlock (scope->config_lock); + g_mutex_unlock (&scope->config_lock); ret = gst_pad_push (scope->srcpad, outbuf); outbuf = NULL; - g_mutex_lock (scope->config_lock); + g_mutex_lock (&scope->config_lock); skip: /* recheck as the value could have changed */ @@ -935,7 +935,7 @@ gst_base_audio_visualizer_chain (GstPad * pad, GstObject * parent, break; } - g_mutex_unlock (scope->config_lock); + g_mutex_unlock (&scope->config_lock); beach: return ret; diff --git a/gst/audiovisualizers/gstbaseaudiovisualizer.h b/gst/audiovisualizers/gstbaseaudiovisualizer.h index 0bd7687b8f..26da1f33d6 100644 --- a/gst/audiovisualizers/gstbaseaudiovisualizer.h +++ b/gst/audiovisualizers/gstbaseaudiovisualizer.h @@ -101,7 +101,7 @@ struct _GstBaseAudioVisualizer gint rate; /* configuration mutex */ - GMutex *config_lock; + GMutex config_lock; /* QoS stuff *//* with LOCK */ gdouble proportion; diff --git a/gst/camerabin2/gstcamerabin2.c b/gst/camerabin2/gstcamerabin2.c index cd21647fbf..8bf1e2799a 100644 --- a/gst/camerabin2/gstcamerabin2.c +++ b/gst/camerabin2/gstcamerabin2.c @@ -377,14 +377,15 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin) return; } - g_mutex_lock (camerabin->video_capture_mutex); + g_mutex_lock (&camerabin->video_capture_mutex); while (camerabin->video_state == GST_CAMERA_BIN_VIDEO_FINISHING) { - g_cond_wait (camerabin->video_state_cond, camerabin->video_capture_mutex); + g_cond_wait (&camerabin->video_state_cond, + &camerabin->video_capture_mutex); } if (camerabin->video_state != GST_CAMERA_BIN_VIDEO_IDLE) { GST_WARNING_OBJECT (camerabin, "Another video recording is ongoing" " (state %d), cannot start a new one", camerabin->video_state); - g_mutex_unlock (camerabin->video_capture_mutex); + g_mutex_unlock (&camerabin->video_capture_mutex); return; } camerabin->video_state = GST_CAMERA_BIN_VIDEO_STARTING; @@ -410,20 +411,20 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin) } } else { /* store the next capture buffer filename */ - g_mutex_lock (camerabin->image_capture_mutex); + g_mutex_lock (&camerabin->image_capture_mutex); camerabin->image_location_list = g_slist_append (camerabin->image_location_list, g_strdup (location)); - g_mutex_unlock (camerabin->image_capture_mutex); + g_mutex_unlock (&camerabin->image_capture_mutex); } if (camerabin->post_previews) { /* Count processing of preview images too */ GST_CAMERA_BIN2_PROCESSING_INC (camerabin); /* store the next preview filename */ - g_mutex_lock (camerabin->preview_list_mutex); + g_mutex_lock (&camerabin->preview_list_mutex); camerabin->preview_location_list = g_slist_append (camerabin->preview_location_list, location); - g_mutex_unlock (camerabin->preview_list_mutex); + g_mutex_unlock (&camerabin->preview_list_mutex); } else { g_free (location); } @@ -435,7 +436,7 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin) gst_element_set_state (camerabin->audio_src, GST_STATE_PLAYING); camerabin->video_state = GST_CAMERA_BIN_VIDEO_RECORDING; - g_mutex_unlock (camerabin->video_capture_mutex); + g_mutex_unlock (&camerabin->video_capture_mutex); } /* @@ -450,11 +451,11 @@ gst_camera_bin_start_capture (GstCameraBin2 * camerabin) if (camerabin->mode == MODE_IMAGE) { /* Store image tags in a list and push them later, this prevents start_capture() from blocking in pad_push_event call */ - g_mutex_lock (camerabin->image_capture_mutex); + g_mutex_lock (&camerabin->image_capture_mutex); camerabin->image_tags_list = g_slist_append (camerabin->image_tags_list, taglist ? gst_tag_list_copy (taglist) : NULL); - g_mutex_unlock (camerabin->image_capture_mutex); + g_mutex_unlock (&camerabin->image_capture_mutex); } else if (taglist) { GstPad *active_pad; @@ -474,7 +475,7 @@ gst_camera_bin_stop_capture (GstCameraBin2 * camerabin) { GST_DEBUG_OBJECT (camerabin, "Received stop-capture"); if (camerabin->mode == MODE_VIDEO) { - g_mutex_lock (camerabin->video_capture_mutex); + g_mutex_lock (&camerabin->video_capture_mutex); if (camerabin->video_state == GST_CAMERA_BIN_VIDEO_RECORDING) { if (camerabin->src) g_signal_emit_by_name (camerabin->src, "stop-capture", NULL); @@ -485,7 +486,7 @@ gst_camera_bin_stop_capture (GstCameraBin2 * camerabin) gst_element_send_event (camerabin->audio_src, gst_event_new_eos ()); } } - g_mutex_unlock (camerabin->video_capture_mutex); + g_mutex_unlock (&camerabin->video_capture_mutex); } } @@ -540,10 +541,10 @@ gst_camera_bin_dispose (GObject * object) GstCameraBin2 *camerabin = GST_CAMERA_BIN2_CAST (object); g_free (camerabin->location); - g_mutex_free (camerabin->preview_list_mutex); - g_mutex_free (camerabin->image_capture_mutex); - g_mutex_free (camerabin->video_capture_mutex); - g_cond_free (camerabin->video_state_cond); + g_mutex_clear (&camerabin->preview_list_mutex); + g_mutex_clear (&camerabin->image_capture_mutex); + g_mutex_clear (&camerabin->video_capture_mutex); + g_cond_clear (&camerabin->video_state_cond); if (camerabin->src_capture_notify_id) g_signal_handler_disconnect (camerabin->src, @@ -899,10 +900,10 @@ gst_camera_bin_init (GstCameraBin2 * camera) camera->zoom = DEFAULT_ZOOM; camera->max_zoom = MAX_ZOOM; camera->flags = DEFAULT_FLAGS; - camera->preview_list_mutex = g_mutex_new (); - camera->image_capture_mutex = g_mutex_new (); - camera->video_capture_mutex = g_mutex_new (); - camera->video_state_cond = g_cond_new (); + g_mutex_init (&camera->preview_list_mutex); + g_mutex_init (&camera->image_capture_mutex); + g_mutex_init (&camera->video_capture_mutex); + g_cond_init (&camera->video_state_cond); /* capsfilters are created here as we proxy their caps properties and * this way we avoid having to store the caps while on NULL state to @@ -959,7 +960,7 @@ gst_camera_bin_skip_next_preview (GstCameraBin2 * camerabin) { gchar *location; - g_mutex_lock (camerabin->preview_list_mutex); + g_mutex_lock (&camerabin->preview_list_mutex); if (camerabin->preview_location_list) { location = camerabin->preview_location_list->data; GST_DEBUG_OBJECT (camerabin, "Skipping preview for %s", location); @@ -971,7 +972,7 @@ gst_camera_bin_skip_next_preview (GstCameraBin2 * camerabin) } else { GST_WARNING_OBJECT (camerabin, "No previews to skip"); } - g_mutex_unlock (camerabin->preview_list_mutex); + g_mutex_unlock (&camerabin->preview_list_mutex); } static gpointer @@ -980,7 +981,7 @@ gst_camera_bin_video_reset_elements (gpointer u_data) GstCameraBin2 *camerabin = GST_CAMERA_BIN2_CAST (u_data); GST_DEBUG_OBJECT (camerabin, "Resetting video elements state"); - g_mutex_lock (camerabin->video_capture_mutex); + g_mutex_lock (&camerabin->video_capture_mutex); /* reset element states to clear eos/flushing pads */ gst_element_set_state (camerabin->video_encodebin, GST_STATE_READY); @@ -1016,8 +1017,8 @@ gst_camera_bin_video_reset_elements (gpointer u_data) GST_DEBUG_OBJECT (camerabin, "Setting video state to idle"); camerabin->video_state = GST_CAMERA_BIN_VIDEO_IDLE; - g_cond_signal (camerabin->video_state_cond); - g_mutex_unlock (camerabin->video_capture_mutex); + g_cond_signal (&camerabin->video_state_cond); + g_mutex_unlock (&camerabin->video_capture_mutex); gst_object_unref (camerabin); return NULL; @@ -1046,7 +1047,7 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message) } else if (gst_structure_has_name (structure, "preview-image")) { gchar *location = NULL; - g_mutex_lock (camerabin->preview_list_mutex); + g_mutex_lock (&camerabin->preview_list_mutex); if (camerabin->preview_location_list) { location = camerabin->preview_location_list->data; camerabin->preview_location_list = @@ -1060,7 +1061,7 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message) "happen if the source is posting previews while camerabin2 is " "shutting down"); } - g_mutex_unlock (camerabin->preview_list_mutex); + g_mutex_unlock (&camerabin->preview_list_mutex); if (location) { GValue value = { 0 }; @@ -1097,23 +1098,25 @@ gst_camera_bin_handle_message (GstBin * bin, GstMessage * message) GstElement *src = GST_ELEMENT (GST_MESSAGE_SRC (message)); if (src == GST_CAMERA_BIN2_CAST (bin)->videosink) { - g_mutex_lock (camerabin->video_capture_mutex); + g_mutex_lock (&camerabin->video_capture_mutex); GST_DEBUG_OBJECT (bin, "EOS from video branch"); g_assert (camerabin->video_state == GST_CAMERA_BIN_VIDEO_FINISHING); gst_video_capture_bin_post_video_done (GST_CAMERA_BIN2_CAST (bin)); dec_counter = TRUE; - if (!g_thread_create (gst_camera_bin_video_reset_elements, - gst_object_ref (camerabin), FALSE, NULL)) { - GST_WARNING_OBJECT (camerabin, "Failed to create thread to " + if (!g_thread_try_new ("reset-element-thread", + gst_camera_bin_video_reset_elements, gst_object_ref (camerabin), + NULL)) { + GST_WARNING_OBJECT (camerabin, + "Failed to create thread to " "reset video elements' state, video recordings may not work " "anymore"); gst_object_unref (camerabin); camerabin->video_state = GST_CAMERA_BIN_VIDEO_IDLE; } - g_mutex_unlock (camerabin->video_capture_mutex); + g_mutex_unlock (&camerabin->video_capture_mutex); } } break; @@ -1356,7 +1359,7 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstPadProbeInfo * info, GstPad *peer; GstTagList *tags; - g_mutex_lock (camerabin->image_capture_mutex); + g_mutex_lock (&camerabin->image_capture_mutex); /* Push pending image tags */ if (camerabin->image_tags_list) { @@ -1385,10 +1388,10 @@ gst_camera_bin_image_src_buffer_probe (GstPad * pad, GstPadProbeInfo * info, location); } else { GST_DEBUG_OBJECT (camerabin, "No filename location change to send"); - g_mutex_unlock (camerabin->image_capture_mutex); + g_mutex_unlock (&camerabin->image_capture_mutex); return ret; } - g_mutex_unlock (camerabin->image_capture_mutex); + g_mutex_unlock (&camerabin->image_capture_mutex); if (location) { evt = gst_camera_bin_new_event_file_location (location); @@ -1930,7 +1933,7 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans) GST_CAMERA_BIN2_RESET_PROCESSING_COUNTER (camera); camera->video_state = GST_CAMERA_BIN_VIDEO_IDLE; - g_mutex_lock (camera->image_capture_mutex); + g_mutex_lock (&camera->image_capture_mutex); g_slist_foreach (camera->image_location_list, (GFunc) g_free, NULL); g_slist_free (camera->image_location_list); camera->image_location_list = NULL; @@ -1939,13 +1942,13 @@ gst_camera_bin_change_state (GstElement * element, GstStateChange trans) (GFunc) _gst_tag_list_free_maybe, NULL); g_slist_free (camera->image_tags_list); camera->image_tags_list = NULL; - g_mutex_unlock (camera->image_capture_mutex); + g_mutex_unlock (&camera->image_capture_mutex); - g_mutex_lock (camera->preview_list_mutex); + g_mutex_lock (&camera->preview_list_mutex); g_slist_foreach (camera->preview_location_list, (GFunc) g_free, NULL); g_slist_free (camera->preview_location_list); camera->preview_location_list = NULL; - g_mutex_unlock (camera->preview_list_mutex); + g_mutex_unlock (&camera->preview_list_mutex); /* explicitly set to READY as they might be outside of the bin */ gst_element_set_state (camera->audio_volume, GST_STATE_READY); diff --git a/gst/camerabin2/gstcamerabin2.h b/gst/camerabin2/gstcamerabin2.h index 29e1c9a586..4c243d53b8 100644 --- a/gst/camerabin2/gstcamerabin2.h +++ b/gst/camerabin2/gstcamerabin2.h @@ -97,7 +97,7 @@ struct _GstCameraBin2 /* Index of the auto incrementing file index for captures */ gint capture_index; - GMutex *image_capture_mutex; + GMutex image_capture_mutex; /* stores list of image locations to be pushed to the image sink * as file location change notifications, they are pushed before * each buffer capture */ @@ -120,7 +120,7 @@ struct _GstCameraBin2 * list and the message handling function looking at preview names) */ GSList *preview_location_list; - GMutex *preview_list_mutex; + GMutex preview_list_mutex; gboolean video_profile_switch; gboolean image_profile_switch; @@ -128,8 +128,8 @@ struct _GstCameraBin2 gboolean audio_drop_eos; gboolean audio_send_newseg; - GMutex *video_capture_mutex; - GCond *video_state_cond; + GMutex video_capture_mutex; + GCond video_state_cond; GstCameraBinVideoState video_state; /* properties */ diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c index 8c2634a652..9c9d1ba8c5 100644 --- a/gst/camerabin2/gstwrappercamerabinsrc.c +++ b/gst/camerabin2/gstwrappercamerabinsrc.c @@ -213,7 +213,7 @@ gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstPadProbeInfo * info, GST_LOG_OBJECT (self, "Image probe, mode %d, capture count %d", camerasrc->mode, self->image_capture_count); - g_mutex_lock (camerasrc->capturing_mutex); + g_mutex_lock (&camerasrc->capturing_mutex); if (self->image_capture_count > 0) { ret = GST_PAD_PROBE_OK; self->image_capture_count--; @@ -228,7 +228,7 @@ gst_wrapper_camera_bin_src_imgsrc_probe (GstPad * pad, GstPadProbeInfo * info, gst_base_camera_src_finish_capture (camerasrc); } } - g_mutex_unlock (camerasrc->capturing_mutex); + g_mutex_unlock (&camerasrc->capturing_mutex); return ret; } @@ -255,7 +255,7 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstPadProbeInfo * info, * probe. */ /* TODO shouldn't access this directly */ - g_mutex_lock (camerasrc->capturing_mutex); + g_mutex_lock (&camerasrc->capturing_mutex); if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_DONE) { /* NOP */ } else if (self->video_rec_status == GST_VIDEO_RECORDING_STATUS_STARTING) { @@ -286,7 +286,7 @@ gst_wrapper_camera_bin_src_vidsrc_probe (GstPad * pad, GstPadProbeInfo * info, } else { ret = GST_PAD_PROBE_OK; } - g_mutex_unlock (camerasrc->capturing_mutex); + g_mutex_unlock (&camerasrc->capturing_mutex); return ret; } @@ -747,10 +747,10 @@ start_image_capture (GstWrapperCameraBinSrc * self) (GstPhotoCapturePrepared) img_capture_prepared, self->image_capture_caps, self); } else { - g_mutex_unlock (bcamsrc->capturing_mutex); + g_mutex_unlock (&bcamsrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (self, self->image_capture_caps); - g_mutex_lock (bcamsrc->capturing_mutex); + g_mutex_lock (&bcamsrc->capturing_mutex); ret = TRUE; } @@ -995,9 +995,9 @@ gst_wrapper_camera_bin_src_start_capture (GstBaseCameraSrc * camerasrc) GstCaps *caps = NULL; if (src->video_renegotiate) { - g_mutex_unlock (camerasrc->capturing_mutex); + g_mutex_unlock (&camerasrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (src, NULL); - g_mutex_lock (camerasrc->capturing_mutex); + g_mutex_lock (&camerasrc->capturing_mutex); /* clean capsfilter caps so they don't interfere here */ g_object_set (src->src_filter, "caps", NULL, NULL); @@ -1009,9 +1009,9 @@ gst_wrapper_camera_bin_src_start_capture (GstBaseCameraSrc * camerasrc) GST_DEBUG_OBJECT (src, "Video src caps %" GST_PTR_FORMAT, caps); src->video_renegotiate = FALSE; - g_mutex_unlock (camerasrc->capturing_mutex); + g_mutex_unlock (&camerasrc->capturing_mutex); gst_wrapper_camera_bin_reset_video_src_caps (src, caps); - g_mutex_lock (camerasrc->capturing_mutex); + g_mutex_lock (&camerasrc->capturing_mutex); gst_caps_unref (caps); } if (src->video_rec_status == GST_VIDEO_RECORDING_STATUS_DONE) { diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.c b/gst/dvbsuboverlay/gstdvbsuboverlay.c index 4e1fb378e9..53f4f90923 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.c +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c @@ -158,7 +158,7 @@ gst_dvbsub_overlay_flush_subtitles (GstDVBSubOverlay * render) { DVBSubtitles *subs; - g_mutex_lock (render->dvbsub_mutex); + g_mutex_lock (&render->dvbsub_mutex); while ((subs = g_queue_pop_head (render->pending_subtitles))) { dvb_subtitles_free (subs); } @@ -177,7 +177,7 @@ gst_dvbsub_overlay_flush_subtitles (GstDVBSubOverlay * render) dvb_sub_set_callbacks (render->dvb_sub, &dvbsub_callbacks, render); } - g_mutex_unlock (render->dvbsub_mutex); + g_mutex_unlock (&render->dvbsub_mutex); } static void @@ -220,7 +220,7 @@ gst_dvbsub_overlay_init (GstDVBSubOverlay * render) render->enable = DEFAULT_ENABLE; render->max_page_timeout = DEFAULT_MAX_PAGE_TIMEOUT; - render->dvbsub_mutex = g_mutex_new (); + g_mutex_init (&render->dvbsub_mutex); gst_dvbsub_overlay_flush_subtitles (render); gst_segment_init (&render->video_segment, GST_FORMAT_TIME); @@ -247,8 +247,7 @@ gst_dvbsub_overlay_finalize (GObject * object) if (overlay->dvb_sub) dvb_sub_free (overlay->dvb_sub); - if (overlay->dvbsub_mutex) - g_mutex_free (overlay->dvbsub_mutex); + g_mutex_clear (&overlay->dvbsub_mutex); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -715,9 +714,9 @@ gst_dvbsub_overlay_process_text (GstDVBSubOverlay * overlay, GstBuffer * buffer, data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ); - g_mutex_lock (overlay->dvbsub_mutex); + g_mutex_lock (&overlay->dvbsub_mutex); dvb_sub_feed_with_pts (overlay->dvb_sub, pts, data, size); - g_mutex_unlock (overlay->dvbsub_mutex); + g_mutex_unlock (&overlay->dvbsub_mutex); gst_buffer_unmap (buffer, data, size); gst_buffer_unref (buffer); @@ -850,7 +849,7 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstObject * parent, overlay->video_segment.position = GST_BUFFER_TIMESTAMP (buffer); - g_mutex_lock (overlay->dvbsub_mutex); + g_mutex_lock (&overlay->dvbsub_mutex); if (!g_queue_is_empty (overlay->pending_subtitles)) { DVBSubtitles *tmp, *candidate = NULL; @@ -919,7 +918,7 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstObject * parent, blit_i420 (overlay, overlay->current_subtitle, &frame); gst_video_frame_unmap (&frame); } - g_mutex_unlock (overlay->dvbsub_mutex); + g_mutex_unlock (&overlay->dvbsub_mutex); ret = gst_pad_push (overlay->srcpad, buffer); diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.h b/gst/dvbsuboverlay/gstdvbsuboverlay.h index e7e227d53d..b2b79005ca 100644 --- a/gst/dvbsuboverlay/gstdvbsuboverlay.h +++ b/gst/dvbsuboverlay/gstdvbsuboverlay.h @@ -56,7 +56,7 @@ struct _GstDVBSubOverlay GQueue *pending_subtitles; /* A queue of raw subtitle region sets with * metadata that are waiting their running time */ - GMutex *dvbsub_mutex; /* protects the queue and the DvbSub instance */ + GMutex dvbsub_mutex; /* protects the queue and the DvbSub instance */ DvbSub *dvb_sub; }; diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index 937e27840f..8e60c29e95 100644 --- a/gst/dvdspu/gstdvdspu.c +++ b/gst/dvdspu/gstdvdspu.c @@ -172,7 +172,7 @@ gst_dvd_spu_init (GstDVDSpu * dvdspu) gst_element_add_pad (GST_ELEMENT (dvdspu), dvdspu->subpic_sinkpad); gst_element_add_pad (GST_ELEMENT (dvdspu), dvdspu->srcpad); - dvdspu->spu_lock = g_mutex_new (); + g_mutex_init (&dvdspu->spu_lock); dvdspu->pending_spus = g_queue_new (); gst_dvd_spu_clear (dvdspu); @@ -221,7 +221,7 @@ gst_dvd_spu_finalize (GObject * object) } } g_queue_free (dvdspu->pending_spus); - g_mutex_free (dvdspu->spu_lock); + g_mutex_clear (&dvdspu->spu_lock); G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/gst/dvdspu/gstdvdspu.h b/gst/dvdspu/gstdvdspu.h index 747b00259e..f46ff6748a 100644 --- a/gst/dvdspu/gstdvdspu.h +++ b/gst/dvdspu/gstdvdspu.h @@ -38,8 +38,8 @@ G_BEGIN_DECLS #define GST_IS_DVD_SPU_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVD_SPU)) -#define DVD_SPU_LOCK(s) g_mutex_lock ((s)->spu_lock); -#define DVD_SPU_UNLOCK(s) g_mutex_unlock ((s)->spu_lock); +#define DVD_SPU_LOCK(s) g_mutex_lock (&(s)->spu_lock); +#define DVD_SPU_UNLOCK(s) g_mutex_unlock (&(s)->spu_lock); typedef struct _GstDVDSpuClass GstDVDSpuClass; @@ -96,7 +96,7 @@ struct _GstDVDSpu { GstPad *srcpad; /* Mutex to protect state we access from different chain funcs */ - GMutex *spu_lock; + GMutex spu_lock; GstSegment video_seg; GstSegment subp_seg; diff --git a/gst/multifdsink/gstmultifdsink.c b/gst/multifdsink/gstmultifdsink.c index e807e0e116..061fd68984 100644 --- a/gst/multifdsink/gstmultifdsink.c +++ b/gst/multifdsink/gstmultifdsink.c @@ -102,10 +102,6 @@ #include "config.h" #endif -/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex - * with newer GLib versions (>= 2.31.0) */ -#define GLIB_DISABLE_DEPRECATION_WARNINGS - #include #include @@ -718,7 +714,7 @@ gst_multi_fd_sink_finalize (GObject * object) this = GST_MULTI_FD_SINK (object); - CLIENTS_LOCK_FREE (this); + CLIENTS_LOCK_CLEAR (this); g_hash_table_destroy (this->fd_hash); g_array_free (this->bufqueue, TRUE); diff --git a/gst/multifdsink/gstmultifdsink.h b/gst/multifdsink/gstmultifdsink.h index aa049806c6..5ac0df79fe 100644 --- a/gst/multifdsink/gstmultifdsink.h +++ b/gst/multifdsink/gstmultifdsink.h @@ -176,10 +176,10 @@ typedef struct { guint64 last_buffer_ts; } GstTCPClient; -#define CLIENTS_LOCK_INIT(fdsink) (g_static_rec_mutex_init(&fdsink->clientslock)) -#define CLIENTS_LOCK_FREE(fdsink) (g_static_rec_mutex_free(&fdsink->clientslock)) -#define CLIENTS_LOCK(fdsink) (g_static_rec_mutex_lock(&fdsink->clientslock)) -#define CLIENTS_UNLOCK(fdsink) (g_static_rec_mutex_unlock(&fdsink->clientslock)) +#define CLIENTS_LOCK_INIT(fdsink) (g_rec_mutex_init(&fdsink->clientslock)) +#define CLIENTS_LOCK_CLEAR(fdsink) (g_rec_mutex_clear(&fdsink->clientslock)) +#define CLIENTS_LOCK(fdsink) (g_rec_mutex_lock(&fdsink->clientslock)) +#define CLIENTS_UNLOCK(fdsink) (g_rec_mutex_unlock(&fdsink->clientslock)) /** * GstMultiFdSink: @@ -193,7 +193,7 @@ struct _GstMultiFdSink { guint64 bytes_to_serve; /* how much bytes we must serve */ guint64 bytes_served; /* how much bytes have we served */ - GStaticRecMutex clientslock; /* lock to protect the clients list */ + GRecMutex clientslock; /* lock to protect the clients list */ GList *clients; /* list of clients we are serving */ GHashTable *fd_hash; /* index on fd to client */ guint clients_cookie; /* Cookie to detect changes to the clients list */ diff --git a/gst/sdp/gstsdpdemux.c b/gst/sdp/gstsdpdemux.c index 62f10c2af8..0eb46a0450 100644 --- a/gst/sdp/gstsdpdemux.c +++ b/gst/sdp/gstsdpdemux.c @@ -185,8 +185,7 @@ gst_sdp_demux_init (GstSDPDemux * demux) /* protects the streaming thread in interleaved mode or the polling * thread in UDP mode. */ - demux->stream_rec_lock = g_new (GStaticRecMutex, 1); - g_static_rec_mutex_init (demux->stream_rec_lock); + g_rec_mutex_init (&demux->stream_rec_lock); demux->adapter = gst_adapter_new (); } @@ -199,8 +198,7 @@ gst_sdp_demux_finalize (GObject * object) demux = GST_SDP_DEMUX (object); /* free locks */ - g_static_rec_mutex_free (demux->stream_rec_lock); - g_free (demux->stream_rec_lock); + g_rec_mutex_clear (&demux->stream_rec_lock); g_object_unref (demux->adapter); diff --git a/gst/sdp/gstsdpdemux.h b/gst/sdp/gstsdpdemux.h index 566b10e22f..c04cd293ad 100644 --- a/gst/sdp/gstsdpdemux.h +++ b/gst/sdp/gstsdpdemux.h @@ -42,9 +42,9 @@ G_BEGIN_DECLS typedef struct _GstSDPDemux GstSDPDemux; typedef struct _GstSDPDemuxClass GstSDPDemuxClass; -#define GST_SDP_STREAM_GET_LOCK(sdp) (GST_SDP_DEMUX_CAST(sdp)->stream_rec_lock) -#define GST_SDP_STREAM_LOCK(sdp) (g_static_rec_mutex_lock (GST_SDP_STREAM_GET_LOCK(sdp))) -#define GST_SDP_STREAM_UNLOCK(sdp) (g_static_rec_mutex_unlock (GST_SDP_STREAM_GET_LOCK(sdp))) +#define GST_SDP_STREAM_GET_LOCK(sdp) (&GST_SDP_DEMUX_CAST(sdp)->stream_rec_lock) +#define GST_SDP_STREAM_LOCK(sdp) (g_rec_mutex_lock (GST_SDP_STREAM_GET_LOCK(sdp))) +#define GST_SDP_STREAM_UNLOCK(sdp) (g_rec_mutex_unlock (GST_SDP_STREAM_GET_LOCK(sdp))) typedef struct _GstSDPStream GstSDPStream; @@ -91,7 +91,7 @@ struct _GstSDPDemux { gboolean ignore_timeout; gint numstreams; - GStaticRecMutex *stream_rec_lock; + GRecMutex stream_rec_lock; GList *streams; /* properties */ diff --git a/sys/dvb/gstdvbsrc.c b/sys/dvb/gstdvbsrc.c index 1562908798..01fac89262 100644 --- a/sys/dvb/gstdvbsrc.c +++ b/sys/dvb/gstdvbsrc.c @@ -488,7 +488,7 @@ gst_dvbsrc_init (GstDvbSrc * object) object->inversion = DEFAULT_INVERSION; object->stats_interval = DEFAULT_STATS_REPORTING_INTERVAL; - object->tune_mutex = g_mutex_new (); + g_mutex_init (&object->tune_mutex); object->timeout = DEFAULT_TIMEOUT; } @@ -617,9 +617,9 @@ gst_dvbsrc_set_property (GObject * _object, guint prop_id, /* if we are in paused/playing state tune now, otherwise in ready to paused state change */ if (GST_STATE (object) > GST_STATE_READY) { - g_mutex_lock (object->tune_mutex); + g_mutex_lock (&object->tune_mutex); gst_dvbsrc_tune (object); - g_mutex_unlock (object->tune_mutex); + g_mutex_unlock (&object->tune_mutex); } break; } @@ -856,7 +856,7 @@ gst_dvbsrc_finalize (GObject * _object) object = GST_DVBSRC (_object); /* freeing the mutex segfaults somehow */ - g_mutex_free (object->tune_mutex); + g_mutex_clear (&object->tune_mutex); if (G_OBJECT_CLASS (parent_class)->finalize) G_OBJECT_CLASS (parent_class)->finalize (_object); @@ -969,7 +969,7 @@ gst_dvbsrc_create (GstPushSrc * element, GstBuffer ** buf) buffer_size = DEFAULT_BUFFER_SIZE; /* device can not be tuned during read */ - g_mutex_lock (object->tune_mutex); + g_mutex_lock (&object->tune_mutex); if (object->fd_dvr > -1) { @@ -987,7 +987,7 @@ gst_dvbsrc_create (GstPushSrc * element, GstBuffer ** buf) } } - g_mutex_unlock (object->tune_mutex); + g_mutex_unlock (&object->tune_mutex); return retval; } diff --git a/sys/dvb/gstdvbsrc.h b/sys/dvb/gstdvbsrc.h index 8feac593f2..e290f4d6b9 100644 --- a/sys/dvb/gstdvbsrc.h +++ b/sys/dvb/gstdvbsrc.h @@ -41,7 +41,7 @@ G_BEGIN_DECLS GstPushSrc element; GstPad *srcpad; - GMutex *tune_mutex; + GMutex tune_mutex; gboolean need_tune; int adapter_type; diff --git a/tests/examples/camerabin/gst-camera-perf.c b/tests/examples/camerabin/gst-camera-perf.c index 1b1c9d8684..e865fdf895 100644 --- a/tests/examples/camerabin/gst-camera-perf.c +++ b/tests/examples/camerabin/gst-camera-perf.c @@ -974,9 +974,6 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; - if (!g_thread_supported ()) - g_thread_init (NULL); - ctx = g_option_context_new (NULL); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); diff --git a/tests/examples/camerabin/gst-camerabin-test.c b/tests/examples/camerabin/gst-camerabin-test.c index e877de1e90..9c8c9f8926 100644 --- a/tests/examples/camerabin/gst-camerabin-test.c +++ b/tests/examples/camerabin/gst-camerabin-test.c @@ -781,9 +781,6 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; - if (!g_thread_supported ()) - g_thread_init (NULL); - ctx = g_option_context_new ("\n\ncamerabin command line test application."); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); diff --git a/tests/examples/camerabin2/gst-camerabin2-test.c b/tests/examples/camerabin2/gst-camerabin2-test.c index 952dadfb25..b32abc1ed2 100644 --- a/tests/examples/camerabin2/gst-camerabin2-test.c +++ b/tests/examples/camerabin2/gst-camerabin2-test.c @@ -1250,9 +1250,6 @@ main (int argc, char *argv[]) GOptionContext *ctx; GError *err = NULL; - if (!g_thread_supported ()) - g_thread_init (NULL); - ctx = g_option_context_new ("\n\ncamerabin command line test application."); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); diff --git a/tests/examples/mxf/mxfdemux-structure.c b/tests/examples/mxf/mxfdemux-structure.c index 03ab7b9203..a8be22dc9a 100644 --- a/tests/examples/mxf/mxfdemux-structure.c +++ b/tests/examples/mxf/mxfdemux-structure.c @@ -190,9 +190,6 @@ main (gint argc, gchar ** argv) return -1; } - if (!g_thread_supported ()) - g_thread_init (NULL); - gst_init (NULL, NULL); gtk_init (NULL, NULL); diff --git a/tests/examples/scaletempo/demo-gui.c b/tests/examples/scaletempo/demo-gui.c index c31c2bf199..b4e5683310 100644 --- a/tests/examples/scaletempo/demo-gui.c +++ b/tests/examples/scaletempo/demo-gui.c @@ -1141,7 +1141,7 @@ demo_gui_show_func (DemoGui * gui) status_bar_printf (GTK_STATUSBAR (status_bar), 5, "Welcome to the Scaletempo demo."); - if (!g_thread_create ((GThreadFunc) gtk_main, NULL, FALSE, &error)) { + if (!g_thread_try_new ("name", (GThreadFunc) gtk_main, NULL, &error)) { g_signal_emit (gui, demo_gui_signals[SIGNAL_ERROR], 0, error->message); } } diff --git a/tests/examples/scaletempo/demo-main.c b/tests/examples/scaletempo/demo-main.c index 6ddcde71dc..5648bc54e2 100644 --- a/tests/examples/scaletempo/demo-main.c +++ b/tests/examples/scaletempo/demo-main.c @@ -60,9 +60,6 @@ main (int argc, char *argv[]) {NULL,} }; - if (!g_thread_supported ()) - g_thread_init (NULL); - ctx = g_option_context_new ("uri ..."); g_option_context_add_group (ctx, gst_init_get_option_group ()); g_option_context_add_group (ctx, gtk_get_option_group (FALSE));