From f8bfade4f139bffb062a5adae6111076e4b1af0f Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 1 Dec 2019 10:27:16 +0900 Subject: [PATCH] ctl: card: add virtual method to handle disconnection of sound card --- src/ctl/card.c | 2 +- src/ctl/card.h | 11 +++++++++++ tests/alsactl-card | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ctl/card.c b/src/ctl/card.c index 0380918..1adf01a 100644 --- a/src/ctl/card.c +++ b/src/ctl/card.c @@ -135,7 +135,7 @@ static void alsactl_card_class_init(ALSACtlCardClass *klass) g_signal_new("handle-disconnection", G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_LAST, - 0, + G_STRUCT_OFFSET(ALSACtlCardClass, handle_disconnection), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, G_TYPE_NONE, 0); diff --git a/src/ctl/card.h b/src/ctl/card.h index eb48633..72446de 100644 --- a/src/ctl/card.h +++ b/src/ctl/card.h @@ -58,6 +58,17 @@ struct _ALSACtlCardClass { */ void (*handle_elem_event)(ALSACtlCard *self, const ALSACtlElemId *elem_id, ALSACtlEventMaskFlag events); + + /** + * ALSACtlCardClass::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. + */ + void (*handle_disconnection)(ALSACtlCard *self); }; GType alsactl_card_get_type() G_GNUC_CONST; diff --git a/tests/alsactl-card b/tests/alsactl-card index d4276e1..b949108 100644 --- a/tests/alsactl-card +++ b/tests/alsactl-card @@ -29,6 +29,7 @@ methods = ( 'remove_elems', 'create_source', 'do_handle_elem_event', + 'do_handle_disconnection', ) signals = ( 'handle-elem-event', -- 2.47.3