From 75e8a3f7a9322bba1cff478e35b6e15203d78aa8 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 5 Dec 2012 00:47:54 +0200 Subject: [media-keys] Update volume code (should be copy-paste from mate-media) Updates volume code from gnome-media http://git.gnome.org/browse/gnome-settings-daemon/commit/?id=5f4b71733713741ec6c48480e3ddc73bf72eb290 referenced bug also says fixes a memory leak https://bugzilla.gnome.org/show_bug.cgi?id=612024 --- plugins/media-keys/cut-n-paste/gvc-mixer-card.c | 27 +++++++++++++++---------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'plugins/media-keys/cut-n-paste/gvc-mixer-card.c') diff --git a/plugins/media-keys/cut-n-paste/gvc-mixer-card.c b/plugins/media-keys/cut-n-paste/gvc-mixer-card.c index 25c77c0..91bdf19 100644 --- a/plugins/media-keys/cut-n-paste/gvc-mixer-card.c +++ b/plugins/media-keys/cut-n-paste/gvc-mixer-card.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include @@ -47,6 +47,7 @@ struct GvcMixerCardPrivate char *target_profile; char *human_profile; GList *profiles; + pa_operation *profile_op; }; enum @@ -209,6 +210,9 @@ _pa_context_set_card_profile_by_index_cb (pa_context *cont } g_free (card->priv->target_profile); card->priv->target_profile = NULL; + + pa_operation_unref (card->priv->profile_op); + card->priv->profile_op = NULL; } gboolean @@ -223,25 +227,26 @@ gvc_mixer_card_change_profile (GvcMixerCard *card, return TRUE; if (g_strcmp0 (profile, card->priv->target_profile) == 0) return TRUE; + if (card->priv->profile_op != NULL) { + pa_operation_cancel (card->priv->profile_op); + pa_operation_unref (card->priv->profile_op); + card->priv->profile_op = NULL; + } if (card->priv->profile != NULL) { - pa_operation *o; - g_free (card->priv->target_profile); card->priv->target_profile = g_strdup (profile); - o = pa_context_set_card_profile_by_index (card->priv->pa_context, - card->priv->index, - card->priv->target_profile, - _pa_context_set_card_profile_by_index_cb, - card); + card->priv->profile_op = pa_context_set_card_profile_by_index (card->priv->pa_context, + card->priv->index, + card->priv->target_profile, + _pa_context_set_card_profile_by_index_cb, + card); - if (o == NULL) { + if (card->priv->profile_op == NULL) { g_warning ("pa_context_set_card_profile_by_index() failed"); return FALSE; } - - pa_operation_unref (o); } else { g_assert (card->priv->human_profile == NULL); card->priv->profile = g_strdup (profile); -- cgit v1.2.1