From 76bb9e3148c00bccbb2029bc177cf1a702227b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 7 Mar 2024 12:25:19 +0100 Subject: [PATCH] mixer-card: Allow setting profiles on card more than once With the next commit, we'll start updating card profiles after the initial creation of the GvcMixerCard, so get gvc_mixer_card_set_profiles() ready and support replacing the list of profiles instead of only setting it a single time. --- gvc-mixer-card.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gvc-mixer-card.c b/gvc-mixer-card.c index fbc29f6..90ede98 100644 --- a/gvc-mixer-card.c +++ b/gvc-mixer-card.c @@ -315,6 +315,15 @@ gvc_mixer_card_profile_compare (GvcMixerCardProfile *a, return -1; } +static void +free_profile (GvcMixerCardProfile *p) +{ + g_free (p->profile); + g_free (p->human_profile); + g_free (p->status); + g_free (p); +} + /** * gvc_mixer_card_set_profiles: * @profiles: (transfer full) (element-type GvcMixerCardProfile): @@ -324,8 +333,8 @@ gvc_mixer_card_set_profiles (GvcMixerCard *card, GList *profiles) { g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE); - g_return_val_if_fail (card->priv->profiles == NULL, FALSE); + g_list_free_full (card->priv->profiles, (GDestroyNotify) free_profile); card->priv->profiles = g_list_sort (profiles, (GCompareFunc) gvc_mixer_card_profile_compare); return TRUE; @@ -530,15 +539,6 @@ gvc_mixer_card_new (pa_context *context, return GVC_MIXER_CARD (object); } -static void -free_profile (GvcMixerCardProfile *p) -{ - g_free (p->profile); - g_free (p->human_profile); - g_free (p->status); - g_free (p); -} - static void gvc_mixer_card_finalize (GObject *object) {