]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
ctl: card: add GObject signal to handle disconnection of sound card
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 1 Dec 2019 01:25:47 +0000 (10:25 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 12 Dec 2019 05:29:12 +0000 (14:29 +0900)
src/ctl/card.c
tests/alsactl-card

index 4b8b4ac032d88105034d04e56668a1d9696e53e2..03809183241438188fbe2cf2f6f25ace4c3bc225 100644 (file)
@@ -42,6 +42,7 @@ static GParamSpec *ctl_card_props[CTL_CARD_PROP_COUNT] = { NULL, };
 
 enum ctl_card_sig_type {
     CTL_CARD_SIG_HANDLE_ELEM_EVENT = 0,
+    CTL_CARD_SIG_HANDLE_DISCONNECTION,
     CTL_CARD_SIG_COUNT,
 };
 static guint ctl_card_sigs[CTL_CARD_SIG_COUNT] = { 0 };
@@ -120,6 +121,24 @@ static void alsactl_card_class_init(ALSACtlCardClass *klass)
                      alsactl_sigs_marshal_VOID__BOXED_FLAGS,
                      G_TYPE_NONE, 2, ALSACTL_TYPE_ELEM_ID,
                      ALSACTL_TYPE_EVENT_MASK_FLAG);
+
+    /**
+     * ALSACtlCard::handle-disconnection:
+     * @self: A #ALSACtlCard.
+     *
+     * When the sound card is not available anymore due to unbinding driver or
+     * hot unplugging, this signal is emit. The owner of this object should
+     * call g_object_free() as quickly as possible to release ALSA control
+     * character device.
+     */
+    ctl_card_sigs[CTL_CARD_SIG_HANDLE_DISCONNECTION] =
+        g_signal_new("handle-disconnection",
+                     G_OBJECT_CLASS_TYPE(klass),
+                     G_SIGNAL_RUN_LAST,
+                     0,
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__VOID,
+                     G_TYPE_NONE, 0, G_TYPE_NONE, 0);
 }
 
 static void alsactl_card_init(ALSACtlCard *self)
index 3b7d42a0fe5701739dc37cbc8a0b2c082a618815..d4276e1829b88db600a1e0a4738b87246323059d 100644 (file)
@@ -32,6 +32,7 @@ methods = (
 )
 signals = (
     'handle-elem-event',
+    'handle-disconnection',
 )
 
 if not test(target, props, methods, signals):