6161 PROP_ICON_NAME ,
6262 PROP_PROFILE ,
6363 PROP_HUMAN_PROFILE ,
64+ N_PROPS
6465};
66+ static GParamSpec * obj_props [N_PROPS ] = { NULL , };
6567
6668static void gvc_mixer_card_finalize (GObject * object );
6769
@@ -117,7 +119,7 @@ gvc_mixer_card_set_name (GvcMixerCard *card,
117119
118120 g_free (card -> priv -> name );
119121 card -> priv -> name = g_strdup (name );
120- g_object_notify (G_OBJECT (card ), "name" );
122+ g_object_notify_by_pspec (G_OBJECT (card ), obj_props [ PROP_NAME ] );
121123
122124 return TRUE;
123125}
@@ -137,7 +139,7 @@ gvc_mixer_card_set_icon_name (GvcMixerCard *card,
137139
138140 g_free (card -> priv -> icon_name );
139141 card -> priv -> icon_name = g_strdup (icon_name );
140- g_object_notify (G_OBJECT (card ), "icon-name" );
142+ g_object_notify_by_pspec (G_OBJECT (card ), obj_props [ PROP_ICON_NAME ] );
141143
142144 return TRUE;
143145}
@@ -177,6 +179,9 @@ gvc_mixer_card_set_profile (GvcMixerCard *card,
177179 g_return_val_if_fail (GVC_IS_MIXER_CARD (card ), FALSE);
178180 g_return_val_if_fail (card -> priv -> profiles != NULL , FALSE);
179181
182+ if (g_strcmp0 (card -> priv -> profile , profile ) == 0 )
183+ return TRUE;
184+
180185 g_free (card -> priv -> profile );
181186 card -> priv -> profile = g_strdup (profile );
182187
@@ -191,7 +196,7 @@ gvc_mixer_card_set_profile (GvcMixerCard *card,
191196 }
192197 }
193198
194- g_object_notify (G_OBJECT (card ), "profile" );
199+ g_object_notify_by_pspec (G_OBJECT (card ), obj_props [ PROP_PROFILE ] );
195200
196201 return TRUE;
197202}
@@ -310,6 +315,15 @@ gvc_mixer_card_profile_compare (GvcMixerCardProfile *a,
310315 return -1 ;
311316}
312317
318+ static void
319+ free_profile (GvcMixerCardProfile * p )
320+ {
321+ g_free (p -> profile );
322+ g_free (p -> human_profile );
323+ g_free (p -> status );
324+ g_free (p );
325+ }
326+
313327/**
314328 * gvc_mixer_card_set_profiles:
315329 * @profiles: (transfer full) (element-type GvcMixerCardProfile):
@@ -319,8 +333,8 @@ gvc_mixer_card_set_profiles (GvcMixerCard *card,
319333 GList * profiles )
320334{
321335 g_return_val_if_fail (GVC_IS_MIXER_CARD (card ), FALSE);
322- g_return_val_if_fail (card -> priv -> profiles == NULL , FALSE);
323336
337+ g_list_free_full (card -> priv -> profiles , (GDestroyNotify ) free_profile );
324338 card -> priv -> profiles = g_list_sort (profiles , (GCompareFunc ) gvc_mixer_card_profile_compare );
325339
326340 return TRUE;
@@ -371,6 +385,21 @@ gvc_mixer_card_set_ports (GvcMixerCard *card,
371385 return TRUE;
372386}
373387
388+ void
389+ gvc_mixer_card_add_port (GvcMixerCard * card ,
390+ GvcMixerCardPort * port )
391+ {
392+ card -> priv -> ports = g_list_prepend (card -> priv -> ports , port );
393+ }
394+
395+ void
396+ gvc_mixer_card_remove_port (GvcMixerCard * card ,
397+ GvcMixerCardPort * port )
398+ {
399+ card -> priv -> ports = g_list_remove (card -> priv -> ports , port );
400+ free_port (port );
401+ }
402+
374403static void
375404gvc_mixer_card_set_property (GObject * object ,
376405 guint prop_id ,
@@ -468,54 +497,42 @@ gvc_mixer_card_class_init (GvcMixerCardClass *klass)
468497 gobject_class -> set_property = gvc_mixer_card_set_property ;
469498 gobject_class -> get_property = gvc_mixer_card_get_property ;
470499
471- g_object_class_install_property (gobject_class ,
472- PROP_INDEX ,
473- g_param_spec_ulong ("index" ,
474- "Index" ,
475- "The index for this card" ,
476- 0 , G_MAXULONG , 0 ,
477- G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY ));
478- g_object_class_install_property (gobject_class ,
479- PROP_ID ,
480- g_param_spec_ulong ("id" ,
481- "id" ,
482- "The id for this card" ,
483- 0 , G_MAXULONG , 0 ,
484- G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY ));
485- g_object_class_install_property (gobject_class ,
486- PROP_PA_CONTEXT ,
487- g_param_spec_pointer ("pa-context" ,
488- "PulseAudio context" ,
489- "The PulseAudio context for this card" ,
490- G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY ));
491- g_object_class_install_property (gobject_class ,
492- PROP_NAME ,
493- g_param_spec_string ("name" ,
494- "Name" ,
495- "Name to display for this card" ,
496- NULL ,
497- G_PARAM_READWRITE |G_PARAM_CONSTRUCT ));
498- g_object_class_install_property (gobject_class ,
499- PROP_ICON_NAME ,
500- g_param_spec_string ("icon-name" ,
501- "Icon Name" ,
502- "Name of icon to display for this card" ,
503- NULL ,
504- G_PARAM_READWRITE |G_PARAM_CONSTRUCT ));
505- g_object_class_install_property (gobject_class ,
506- PROP_PROFILE ,
507- g_param_spec_string ("profile" ,
508- "Profile" ,
509- "Name of current profile for this card" ,
510- NULL ,
511- G_PARAM_READWRITE ));
512- g_object_class_install_property (gobject_class ,
513- PROP_HUMAN_PROFILE ,
514- g_param_spec_string ("human-profile" ,
515- "Profile (Human readable)" ,
516- "Name of current profile for this card in human readable form" ,
517- NULL ,
518- G_PARAM_READABLE ));
500+ obj_props [PROP_INDEX ] = g_param_spec_ulong ("index" ,
501+ "Index" ,
502+ "The index for this card" ,
503+ 0 , G_MAXULONG , 0 ,
504+ G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY |G_PARAM_STATIC_STRINGS );
505+ obj_props [PROP_ID ] = g_param_spec_ulong ("id" ,
506+ "id" ,
507+ "The id for this card" ,
508+ 0 , G_MAXULONG , 0 ,
509+ G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY |G_PARAM_STATIC_STRINGS );
510+ obj_props [PROP_PA_CONTEXT ] = g_param_spec_pointer ("pa-context" ,
511+ "PulseAudio context" ,
512+ "The PulseAudio context for this card" ,
513+ G_PARAM_READWRITE |G_PARAM_CONSTRUCT_ONLY |G_PARAM_STATIC_STRINGS );
514+ obj_props [PROP_NAME ] = g_param_spec_string ("name" ,
515+ "Name" ,
516+ "Name to display for this card" ,
517+ NULL ,
518+ G_PARAM_READWRITE |G_PARAM_CONSTRUCT |G_PARAM_STATIC_STRINGS );
519+ obj_props [PROP_ICON_NAME ] = g_param_spec_string ("icon-name" ,
520+ "Icon Name" ,
521+ "Name of icon to display for this card" ,
522+ NULL ,
523+ G_PARAM_READWRITE |G_PARAM_CONSTRUCT |G_PARAM_STATIC_STRINGS );
524+ obj_props [PROP_PROFILE ] = g_param_spec_string ("profile" ,
525+ "Profile" ,
526+ "Name of current profile for this card" ,
527+ NULL ,
528+ G_PARAM_READWRITE |G_PARAM_STATIC_STRINGS );
529+ obj_props [PROP_HUMAN_PROFILE ] = g_param_spec_string ("human-profile" ,
530+ "Profile (Human readable)" ,
531+ "Name of current profile for this card in human readable form" ,
532+ NULL ,
533+ G_PARAM_READABLE |G_PARAM_STATIC_STRINGS );
534+
535+ g_object_class_install_properties (gobject_class , N_PROPS , obj_props );
519536}
520537
521538static void
@@ -537,15 +554,6 @@ gvc_mixer_card_new (pa_context *context,
537554 return GVC_MIXER_CARD (object );
538555}
539556
540- static void
541- free_profile (GvcMixerCardProfile * p )
542- {
543- g_free (p -> profile );
544- g_free (p -> human_profile );
545- g_free (p -> status );
546- g_free (p );
547- }
548-
549557static void
550558gvc_mixer_card_finalize (GObject * object )
551559{
0 commit comments