diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-25 21:23:30 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2012-04-05 21:35:20 +0800 |
commit | 2c3892eb9f27b2c8dc8832402ceb06053f36b987 (patch) | |
tree | ec2bc40f1cf347642e28515622f3200d917221f7 /src | |
parent | ee2e583ba62e7bc1b6765a8115a78a4a74818d61 (diff) | |
download | gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar.gz gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar.bz2 gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar.lz gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar.xz gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.tar.zst gsoc2013-empathy-2c3892eb9f27b2c8dc8832402ceb06053f36b987.zip |
Allocate GMutex on the stack
g_mutex_new() has been deprecated in GLib 2.31.
https://bugzilla.gnome.org/show_bug.cgi?id=662662
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-audio-sink.c | 26 | ||||
-rw-r--r-- | src/empathy-audio-src.c | 55 | ||||
-rw-r--r-- | src/empathy-call-window.c | 18 | ||||
-rw-r--r-- | src/empathy-streamed-media-window.c | 18 | ||||
-rw-r--r-- | src/empathy-video-widget.c | 14 |
5 files changed, 66 insertions, 65 deletions
diff --git a/src/empathy-audio-sink.c b/src/empathy-audio-sink.c index 2968fb53c..d48e6af20 100644 --- a/src/empathy-audio-sink.c +++ b/src/empathy-audio-sink.c @@ -65,7 +65,7 @@ struct _EmpathyGstAudioSinkPrivate gboolean echo_cancel; gdouble volume; gint volume_idle_id; - GStaticMutex volume_mutex; + GMutex volume_mutex; }; #define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \ @@ -77,7 +77,7 @@ empathy_audio_sink_init (EmpathyGstAudioSink *self) { self->priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self); self->priv->echo_cancel = TRUE; - g_static_mutex_init (&self->priv->volume_mutex); + g_mutex_init (&self->priv->volume_mutex); } static GstPad * empathy_audio_sink_request_new_pad (GstElement *self, @@ -95,9 +95,9 @@ empathy_audio_sink_set_property (GObject *object, switch (property_id) { case PROP_VOLUME: - g_static_mutex_lock (&self->priv->volume_mutex); + g_mutex_lock (&self->priv->volume_mutex); self->priv->volume = g_value_get_double (value); - g_static_mutex_unlock (&self->priv->volume_mutex); + g_mutex_unlock (&self->priv->volume_mutex); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -129,7 +129,7 @@ empathy_audio_sink_dispose (GObject *object) g_source_remove (priv->volume_idle_id); priv->volume_idle_id = 0; - g_static_mutex_free (&self->priv->volume_mutex); + g_mutex_clear (&self->priv->volume_mutex); /* release any references held by the object here */ if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose) @@ -236,9 +236,9 @@ empathy_audio_sink_volume_idle_updated (gpointer user_data) { EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data); - g_static_mutex_lock (&self->priv->volume_mutex); + g_mutex_lock (&self->priv->volume_mutex); self->priv->volume_idle_id = 0; - g_static_mutex_unlock (&self->priv->volume_mutex); + g_mutex_unlock (&self->priv->volume_mutex); g_object_notify (G_OBJECT (self), "volume"); @@ -253,7 +253,7 @@ empathy_audio_sink_volume_updated (GObject *object, EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data); gdouble volume; - g_static_mutex_lock (&self->priv->volume_mutex); + g_mutex_lock (&self->priv->volume_mutex); g_object_get (object, "volume", &volume, NULL); if (self->priv->volume == volume) @@ -265,7 +265,7 @@ empathy_audio_sink_volume_updated (GObject *object, empathy_audio_sink_volume_idle_updated, self); out: - g_static_mutex_unlock (&self->priv->volume_mutex); + g_mutex_unlock (&self->priv->volume_mutex); } static gboolean @@ -274,9 +274,9 @@ empathy_audio_sink_volume_idle_setup (gpointer user_data) EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (user_data); gdouble volume; - g_static_mutex_lock (&self->priv->volume_mutex); + g_mutex_lock (&self->priv->volume_mutex); self->priv->volume_idle_id = 0; - g_static_mutex_unlock (&self->priv->volume_mutex); + g_mutex_unlock (&self->priv->volume_mutex); /* We can't do a bidirection bind as the ::notify comes from another * thread, for other bits of empathy it's most simpler if it comes from @@ -329,11 +329,11 @@ empathy_audio_sink_request_new_pad (GstElement *element, if (GST_IS_STREAM_VOLUME (self->priv->sink)) { - g_static_mutex_lock (&self->priv->volume_mutex); + g_mutex_lock (&self->priv->volume_mutex); if (self->priv->volume_idle_id == 0) self->priv->volume_idle_id = g_idle_add ( empathy_audio_sink_volume_idle_setup, self); - g_static_mutex_unlock (&self->priv->volume_mutex); + g_mutex_unlock (&self->priv->volume_mutex); } else { diff --git a/src/empathy-audio-src.c b/src/empathy-audio-src.c index 9a882c146..590c65b66 100644 --- a/src/empathy-audio-src.c +++ b/src/empathy-audio-src.c @@ -77,7 +77,7 @@ struct _EmpathyGstAudioSrcPrivate /* the mixer track on src we follow and adjust */ GstMixerTrack *track; - GMutex *lock; + GMutex lock; guint level_idle_id; guint volume_idle_id; }; @@ -93,7 +93,7 @@ struct _EmpathyGstAudioSrcPrivate static void empathy_audio_set_hw_mute (EmpathyGstAudioSrc *self, gboolean mute) { - g_mutex_lock (self->priv->lock); + g_mutex_lock (&self->priv->lock); /* If there is no mixer available ignore the setting */ if (self->priv->track == NULL) goto out; @@ -101,7 +101,7 @@ empathy_audio_set_hw_mute (EmpathyGstAudioSrc *self, gboolean mute) gst_mixer_set_mute (GST_MIXER (self->priv->src), self->priv->track, mute); out: - g_mutex_unlock (self->priv->lock); + g_mutex_unlock (&self->priv->lock); self->priv->mute = mute; } @@ -110,13 +110,13 @@ empathy_audio_src_get_hw_mute (EmpathyGstAudioSrc *self) { gboolean result = self->priv->mute; - g_mutex_lock (self->priv->lock); + g_mutex_lock (&self->priv->lock); if (self->priv->track == NULL) goto out; result = GST_MIXER_TRACK_HAS_FLAG (self->priv->track, GST_MIXER_TRACK_MUTE); out: - g_mutex_unlock (self->priv->lock); + g_mutex_unlock (&self->priv->lock); return result; } @@ -128,7 +128,7 @@ empathy_audio_src_set_hw_volume (EmpathyGstAudioSrc *self, gint volumes[MAX_MIC_CHANNELS]; int i; - g_mutex_lock (self->priv->lock); + g_mutex_lock (&self->priv->lock); /* If there is no mixer available ignore the setting */ if (self->priv->track == NULL) goto out; @@ -140,7 +140,7 @@ empathy_audio_src_set_hw_volume (EmpathyGstAudioSrc *self, self->priv->track, volumes); out: - g_mutex_unlock (self->priv->lock); + g_mutex_unlock (&self->priv->lock); self->priv->volume = volume; } @@ -151,7 +151,7 @@ empathy_audio_src_get_hw_volume (EmpathyGstAudioSrc *self) gint volumes[MAX_MIC_CHANNELS]; gdouble result = self->priv->volume; - g_mutex_lock (self->priv->lock); + g_mutex_lock (&self->priv->lock); if (self->priv->track == NULL) goto out; @@ -160,7 +160,7 @@ empathy_audio_src_get_hw_volume (EmpathyGstAudioSrc *self) result = volumes[0]/(gdouble)self->priv->track->max_volume; out: - g_mutex_unlock (self->priv->lock); + g_mutex_unlock (&self->priv->lock); return result; } @@ -347,7 +347,8 @@ empathy_audio_src_init (EmpathyGstAudioSrc *obj) obj->priv = priv; priv->peak_level = -G_MAXDOUBLE; - priv->lock = g_mutex_new (); + g_mutex_init (&priv->lock); + priv->volume = 1.0; priv->src = create_src (); @@ -439,14 +440,14 @@ empathy_audio_src_get_property (GObject *object, g_value_set_boolean (value, priv->mute); break; case PROP_PEAK_LEVEL: - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_value_set_double (value, priv->peak_level); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); break; case PROP_RMS_LEVEL: - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_value_set_double (value, priv->rms_level); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); break; case PROP_MICROPHONE: g_value_set_uint (value, priv->source_idx); @@ -552,7 +553,7 @@ empathy_audio_src_finalize (GObject *object) EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); /* free any data held directly by the object here */ - g_mutex_free (priv->lock); + g_mutex_clear (&priv->lock); G_OBJECT_CLASS (empathy_audio_src_parent_class)->finalize (object); } @@ -563,13 +564,13 @@ empathy_audio_src_levels_updated (gpointer user_data) EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (user_data); EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self); - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_signal_emit (self, signals[PEAK_LEVEL_CHANGED], 0, priv->peak_level); g_signal_emit (self, signals[RMS_LEVEL_CHANGED], 0, priv->rms_level); priv->level_idle_id = 0; - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); return FALSE; } @@ -582,9 +583,9 @@ empathy_audio_src_volume_changed (gpointer user_data) gdouble volume; gboolean mute; - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->volume_idle_id = 0; - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); volume = empathy_audio_src_get_hw_volume (self); @@ -652,7 +653,7 @@ empathy_audio_src_handle_message (GstBin *bin, GstMessage *message) rms = MAX (db, rms); } - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->peak_level = peak; priv->rms_level = rms; @@ -660,7 +661,7 @@ empathy_audio_src_handle_message (GstBin *bin, GstMessage *message) priv->level_idle_id = g_idle_add ( empathy_audio_src_levels_updated, self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } else if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT && GST_MESSAGE_SRC (message) == GST_OBJECT (priv->src)) @@ -677,13 +678,13 @@ empathy_audio_src_handle_message (GstBin *bin, GstMessage *message) GST_MIXER_MESSAGE_MUTE_TOGGLED) gst_mixer_message_parse_mute_toggled (message, &track, NULL); - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); if (track != NULL && track == priv->track && priv->volume_idle_id == 0) priv->volume_idle_id = g_idle_add ( empathy_audio_src_volume_changed, self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } else if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED && GST_MESSAGE_SRC (message) == GST_OBJECT (priv->src)) @@ -699,18 +700,18 @@ empathy_audio_src_handle_message (GstBin *bin, GstMessage *message) * Empathy. We want to pick up the level pulseaudio saved */ if (old == GST_STATE_NULL && new == GST_STATE_READY) { - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->track = empathy_audio_src_get_track (priv->src); if (priv->track != NULL) priv->volume_idle_id = g_idle_add ( empathy_audio_src_volume_changed, self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } else if (old == GST_STATE_READY && new == GST_STATE_NULL) { - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->track = NULL; - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } } diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index 3b05d4d7a..7ecac2806 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -242,7 +242,7 @@ struct _EmpathyCallWindowPriv GTimer *timer; guint timer_id; - GMutex *lock; + GMutex lock; gboolean call_started; gboolean sending_video; CameraState camera_state; @@ -1638,7 +1638,7 @@ empathy_call_window_init (EmpathyCallWindow *self) g_signal_connect (priv->camera_monitor, "removed", G_CALLBACK (empathy_call_window_camera_removed_cb), self); - priv->lock = g_mutex_new (); + g_mutex_init (&priv->lock); gtk_container_add (GTK_CONTAINER (self), top_vbox); @@ -2371,7 +2371,7 @@ empathy_call_window_finalize (GObject *object) disconnect_video_output_motion_handler (self); /* free any data held directly by the object here */ - g_mutex_free (priv->lock); + g_mutex_clear (&priv->lock); g_timer_destroy (priv->timer); @@ -2544,7 +2544,7 @@ empathy_call_window_disconnected (EmpathyCallWindow *self, if (could_reset_pipeline) { - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_timer_stop (priv->timer); @@ -2552,7 +2552,7 @@ empathy_call_window_disconnected (EmpathyCallWindow *self, g_source_remove (priv->timer_id); priv->timer_id = 0; - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); if (!restart) /* We are about to destroy the window, no need to update it or create @@ -3202,12 +3202,12 @@ empathy_call_window_state_changed_cb (EmpathyCallHandler *handler, g_object_unref (call); - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->timer_id = g_timeout_add_seconds (1, empathy_call_window_update_timer, self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); empathy_call_window_update_timer (self); @@ -3281,7 +3281,7 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler, GstPad *pad; - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_object_get (content, "media-type", &media_type, NULL); @@ -3348,7 +3348,7 @@ empathy_call_window_src_added_cb (EmpathyCallHandler *handler, } - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); return TRUE; } diff --git a/src/empathy-streamed-media-window.c b/src/empathy-streamed-media-window.c index deaae10d6..3bcb0e4f2 100644 --- a/src/empathy-streamed-media-window.c +++ b/src/empathy-streamed-media-window.c @@ -201,7 +201,7 @@ struct _EmpathyStreamedMediaWindowPriv GtkWidget *video_brightness; GtkWidget *video_gamma; - GMutex *lock; + GMutex lock; gboolean call_started; gboolean sending_video; CameraState camera_state; @@ -1035,7 +1035,7 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self) gtk_action_set_sensitive (priv->menu_fullscreen, FALSE); - priv->lock = g_mutex_new (); + g_mutex_init (&priv->lock); gtk_container_add (GTK_CONTAINER (self), top_vbox); @@ -1727,7 +1727,7 @@ empathy_streamed_media_window_finalize (GObject *object) disconnect_video_output_motion_handler (self); /* free any data held directly by the object here */ - g_mutex_free (priv->lock); + g_mutex_clear (&priv->lock); g_timer_destroy (priv->timer); @@ -1870,7 +1870,7 @@ empathy_streamed_media_window_disconnected (EmpathyStreamedMediaWindow *self, if (could_reset_pipeline) { - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); g_timer_stop (priv->timer); @@ -1878,7 +1878,7 @@ empathy_streamed_media_window_disconnected (EmpathyStreamedMediaWindow *self, g_source_remove (priv->timer_id); priv->timer_id = 0; - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); if (!restart) /* We are about to destroy the window, no need to update it or create @@ -2375,12 +2375,12 @@ empathy_streamed_media_window_connected (gpointer user_data) g_object_unref (call); - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); priv->timer_id = g_timeout_add_seconds (1, empathy_streamed_media_window_update_timer, self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); empathy_streamed_media_window_update_timer (self); @@ -2401,7 +2401,7 @@ empathy_streamed_media_window_src_added_cb (EmpathyStreamedMediaHandler *handler GstPad *pad; - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); if (priv->call_state != CONNECTED) { @@ -2467,7 +2467,7 @@ empathy_streamed_media_window_src_added_cb (EmpathyStreamedMediaHandler *handler } - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); return TRUE; } diff --git a/src/empathy-video-widget.c b/src/empathy-video-widget.c index adca53ef6..9cf31d9c1 100644 --- a/src/empathy-video-widget.c +++ b/src/empathy-video-widget.c @@ -78,7 +78,7 @@ struct _EmpathyVideoWidgetPriv gboolean flip_video; guintptr xid; - GMutex *lock; + GMutex lock; }; #define GET_PRIV(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ @@ -90,7 +90,7 @@ empathy_video_widget_init (EmpathyVideoWidget *obj) EmpathyVideoWidgetPriv *priv = GET_PRIV (obj); GdkRGBA black; - priv->lock = g_mutex_new (); + g_mutex_init (&priv->lock); priv->notifier = fs_element_added_notifier_new (); g_signal_connect (priv->notifier, "element-added", @@ -367,7 +367,7 @@ empathy_video_widget_finalize (GObject *object) EmpathyVideoWidgetPriv *priv = GET_PRIV (self); /* free any data held directly by the object here */ - g_mutex_free (priv->lock); + g_mutex_clear (&priv->lock); G_OBJECT_CLASS (empathy_video_widget_parent_class)->finalize (object); } @@ -400,9 +400,9 @@ empathy_video_widget_element_set_sink_properties (EmpathyVideoWidget *self) { EmpathyVideoWidgetPriv *priv = GET_PRIV (self); - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); empathy_video_widget_element_set_sink_properties_unlocked (self); - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } static void @@ -412,7 +412,7 @@ empathy_video_widget_element_added_cb (FsElementAddedNotifier *notifier, EmpathyVideoWidgetPriv *priv = GET_PRIV (self); /* We assume the overlay is the sink */ - g_mutex_lock (priv->lock); + g_mutex_lock (&priv->lock); if (priv->overlay == NULL && GST_IS_X_OVERLAY (element)) { priv->overlay = element; @@ -421,7 +421,7 @@ empathy_video_widget_element_added_cb (FsElementAddedNotifier *notifier, empathy_video_widget_element_set_sink_properties_unlocked (self); gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay)); } - g_mutex_unlock (priv->lock); + g_mutex_unlock (&priv->lock); } static void |