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.
This commit is contained in:
Jonas Dreßler 2024-03-07 12:25:19 +01:00
parent f75ad37943
commit 76bb9e3148

View File

@ -315,6 +315,15 @@ gvc_mixer_card_profile_compare (GvcMixerCardProfile *a,
return -1; 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: * gvc_mixer_card_set_profiles:
* @profiles: (transfer full) (element-type GvcMixerCardProfile): * @profiles: (transfer full) (element-type GvcMixerCardProfile):
@ -324,8 +333,8 @@ gvc_mixer_card_set_profiles (GvcMixerCard *card,
GList *profiles) GList *profiles)
{ {
g_return_val_if_fail (GVC_IS_MIXER_CARD (card), FALSE); 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); card->priv->profiles = g_list_sort (profiles, (GCompareFunc) gvc_mixer_card_profile_compare);
return TRUE; return TRUE;
@ -530,15 +539,6 @@ gvc_mixer_card_new (pa_context *context,
return GVC_MIXER_CARD (object); 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 static void
gvc_mixer_card_finalize (GObject *object) gvc_mixer_card_finalize (GObject *object)
{ {