summaryrefslogtreecommitdiff
path: root/plugins/media-keys/cut-n-paste/gvc-mixer-card.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-12-07 06:06:41 -0800
committerStefano Karapetsas <[email protected]>2012-12-07 06:06:41 -0800
commit12dcf19aa5f51901053c273cd7f5c17ce85e909d (patch)
tree5b71387df7bf817dd5d0dff60ecc09d8291dba0d /plugins/media-keys/cut-n-paste/gvc-mixer-card.c
parenta279b02b4d563d2300ccb588e5969c7dfac8108e (diff)
parent6e61d207a2088479f5bb12ce4edb1d2886c40b53 (diff)
downloadmate-settings-daemon-12dcf19aa5f51901053c273cd7f5c17ce85e909d.tar.bz2
mate-settings-daemon-12dcf19aa5f51901053c273cd7f5c17ce85e909d.tar.xz
Merge pull request #29 from jasmineaura/develop
Fix #23, and some cleanups
Diffstat (limited to 'plugins/media-keys/cut-n-paste/gvc-mixer-card.c')
-rw-r--r--plugins/media-keys/cut-n-paste/gvc-mixer-card.c27
1 files changed, 16 insertions, 11 deletions
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 <unistd.h>
#include <glib.h>
-#include <glib/gi18n.h>
+#include <glib/gi18n-lib.h>
#include <pulse/pulseaudio.h>
@@ -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);