From: Takashi Sakamoto Date: Sun, 1 Dec 2019 03:00:24 +0000 (+0900) Subject: rawmidi: stream_pair: add GObject signal to handle disconnection of sound card X-Git-Tag: v0.1.0~167 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=198dd9b37593278df91e8d557a19531bab2e40bf;p=alsa-gobject.git rawmidi: stream_pair: add GObject signal to handle disconnection of sound card Signed-off-by: Takashi Sakamoto --- diff --git a/src/rawmidi/stream-pair.c b/src/rawmidi/stream-pair.c index 73a26aa..7459615 100644 --- a/src/rawmidi/stream-pair.c +++ b/src/rawmidi/stream-pair.c @@ -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) diff --git a/tests/alsarawmidi-stream-pair b/tests/alsarawmidi-stream-pair index 21e79ab..2751836 100644 --- a/tests/alsarawmidi-stream-pair +++ b/tests/alsarawmidi-stream-pair @@ -28,6 +28,7 @@ methods = ( ) signals = ( 'handle-messages', + 'handle-disconnection', ) if not test(target, props, methods, signals):