[gnome-media] Fix possible crasher when switching profile
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-media] Fix possible crasher when switching profile
- Date: Thu, 23 Jul 2009 15:31:25 +0000 (UTC)
commit 6f8eff947f03c733c1a66242f1803986a1aa464c
Author: Bastien Nocera <hadess hadess net>
Date: Thu Jul 23 14:52:25 2009 +0100
Fix possible crasher when switching profile
And emit "card-added" when some properties of the card change.
gnome-volume-control/src/gvc-mixer-card.c | 11 ++++++++++-
gnome-volume-control/src/gvc-mixer-card.h | 4 ++--
gnome-volume-control/src/gvc-mixer-control.c | 19 ++++++++-----------
3 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-card.c b/gnome-volume-control/src/gvc-mixer-card.c
index 2382e8f..ed1aae4 100644
--- a/gnome-volume-control/src/gvc-mixer-card.c
+++ b/gnome-volume-control/src/gvc-mixer-card.c
@@ -149,6 +149,7 @@ gvc_mixer_card_get_profile (GvcMixerCard *card)
GvcMixerCardProfile *ret;
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), NULL);
+ g_return_val_if_fail (card->priv->profiles != NULL, FALSE);
ret = NULL;
for (l = card->priv->profiles; l != NULL; l = l->next) {
@@ -438,6 +439,14 @@ gvc_mixer_card_new (pa_context *context,
}
static void
+free_profile (GvcMixerCardProfile *p)
+{
+ g_free (p->profile);
+ g_free (p->human_profile);
+ g_free (p);
+}
+
+static void
gvc_mixer_card_finalize (GObject *object)
{
GvcMixerCard *mixer_card;
@@ -464,7 +473,7 @@ gvc_mixer_card_finalize (GObject *object)
g_free (mixer_card->priv->human_profile);
mixer_card->priv->human_profile = NULL;
- g_list_foreach (mixer_card->priv->profiles, (GFunc) g_free, NULL);
+ g_list_foreach (mixer_card->priv->profiles, (GFunc) free_profile, NULL);
g_list_free (mixer_card->priv->profiles);
mixer_card->priv->profiles = NULL;
diff --git a/gnome-volume-control/src/gvc-mixer-card.h b/gnome-volume-control/src/gvc-mixer-card.h
index cdf4a01..24bbd7b 100644
--- a/gnome-volume-control/src/gvc-mixer-card.h
+++ b/gnome-volume-control/src/gvc-mixer-card.h
@@ -50,8 +50,8 @@ typedef struct
typedef struct
{
- const char *profile;
- const char *human_profile;
+ char *profile;
+ char *human_profile;
guint priority;
} GvcMixerCardProfile;
diff --git a/gnome-volume-control/src/gvc-mixer-control.c b/gnome-volume-control/src/gvc-mixer-control.c
index 9d80f3e..ccc6584 100644
--- a/gnome-volume-control/src/gvc-mixer-control.c
+++ b/gnome-volume-control/src/gvc-mixer-control.c
@@ -937,11 +937,9 @@ update_card (GvcMixerControl *control,
const char *key;
void *state;
- g_debug ("Updating card: index=%u name='%s'",
- info->index,
- info->name);
+ g_debug ("Udpating card %s (index: %u driver: %s):",
+ info->name, info->index, info->driver);
- g_debug ("Adding card %s (driver: %s):", info->name, info->driver);
for (i = 0; i < info->n_profiles; i++) {
struct pa_card_profile_info pi = info->profiles[i];
gboolean is_default;
@@ -969,8 +967,8 @@ update_card (GvcMixerControl *control,
GvcMixerCardProfile *profile;
profile = g_new0 (GvcMixerCardProfile, 1);
- profile->profile = pi.name;
- profile->human_profile = pi.description;
+ profile->profile = g_strdup (pi.name);
+ profile->human_profile = g_strdup (pi.description);
profile->priority = pi.priority;
list = g_list_prepend (list, profile);
}
@@ -988,11 +986,11 @@ update_card (GvcMixerControl *control,
g_hash_table_insert (control->priv->cards,
GUINT_TO_POINTER (info->index),
g_object_ref (card));
- g_signal_emit (G_OBJECT (control),
- signals[CARD_ADDED],
- 0,
- info->index);
}
+ g_signal_emit (G_OBJECT (control),
+ signals[CARD_ADDED],
+ 0,
+ info->index);
}
static void
@@ -1020,7 +1018,6 @@ _pa_context_get_sink_info_cb (pa_context *context,
update_sink (control, i);
}
-
static void
_pa_context_get_source_info_cb (pa_context *context,
const pa_source_info *i,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]