]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
rawmidi: stream_pair: add GObject signal to handle disconnection of sound card
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 1 Dec 2019 03:00:24 +0000 (12:00 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Sun, 12 Apr 2020 05:30:33 +0000 (14:30 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/rawmidi/stream-pair.c
tests/alsarawmidi-stream-pair

index 73a26aa419ba0eb21ee4ce570057adcc5f5d2dd1..74596158a848726a0cfe9eefcbec823e69cab8e5 100644 (file)
@@ -31,6 +31,7 @@ static GParamSpec *rawmidi_stream_pair_props[RAWMIDI_STREAM_PAIR_PROP_COUNT] = {
 
 enum rawmidi_stream_pair_sig_type {
     RAWMIDI_STREAM_PAIR_SIG_HANDLE_MESSAGES = 0,
+    RAWMIDI_STREAM_PAIR_SIG_DISCONNECTION,
     RAWMIDI_STREAM_PAIR_SIG_COUNT,
 };
 static guint rawmidi_stream_pair_sigs[RAWMIDI_STREAM_PAIR_SIG_COUNT] = { 0 };
@@ -96,6 +97,24 @@ static void alsarawmidi_stream_pair_class_init(ALSARawmidiStreamPairClass *klass
                      NULL, NULL,
                      g_cclosure_marshal_VOID__VOID,
                      G_TYPE_NONE, 0, NULL);
+
+    /**
+     * ALSARawmidiStreamPair::handle-disconnection:
+     * @self: A #ALSARawmidiStreamPair.
+     *
+     * 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 rawmidi
+     * character device.
+     */
+    rawmidi_stream_pair_sigs[RAWMIDI_STREAM_PAIR_SIG_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 alsarawmidi_stream_pair_init(ALSARawmidiStreamPair *self)
index 21e79ab5e978443c4bd68e55b8b7bb19e97b9d65..2751836550a53361e82c780f743f14ecc488c3d3 100644 (file)
@@ -28,6 +28,7 @@ methods = (
 )
 signals = (
     'handle-messages',
+    'handle-disconnection',
 )
 
 if not test(target, props, methods, signals):