]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: add GObject signal to handle event
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 9 Feb 2020 03:20:53 +0000 (12:20 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Tue, 11 Feb 2020 04:28:18 +0000 (13:28 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/user-instance.c
src/timer/user-instance.h
tests/alsatimer-user-instance

index daf30f5e68e9d487e2a1c3e1a40cd60a821528c4..0bbc947d9d6a14f6bd073d4f6bdc15fff3789195 100644 (file)
@@ -23,6 +23,12 @@ typedef struct {
     unsigned int buf_len;
 } TimerUserInstanceSource;
 
+enum timer_user_instance_sig_type {
+    TIMER_USER_INSTANCE_SIG_HANDLE_EVENT = 0,
+    TIMER_USER_INSTANCE_SIG_COUNT,
+};
+static guint timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_COUNT] = { 0 };
+
 static void timer_user_instance_finalize(GObject *obj)
 {
     ALSATimerUserInstance *self = ALSATIMER_USER_INSTANCE(obj);
@@ -40,6 +46,22 @@ static void alsatimer_user_instance_class_init(ALSATimerUserInstanceClass *klass
     GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
 
     gobject_class->finalize = timer_user_instance_finalize;
+
+    /**
+     * ALSATimerUserInstance::handle-event:
+     * @self: A #ALSATimerUserInstance.
+     * @event_data: (transfer none): An object derived from #ALSATimerEventData.
+     *
+     * When event occurs for any element, this signal is emit.
+     */
+    timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_EVENT] =
+        g_signal_new("handle-event",
+                     G_OBJECT_CLASS_TYPE(klass),
+                     G_SIGNAL_RUN_LAST,
+                     0,
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__OBJECT,
+                     G_TYPE_NONE, 1, ALSATIMER_TYPE_EVENT_DATA);
 }
 
 static void alsatimer_user_instance_init(ALSATimerUserInstance *self)
index 3a21a0eaceaca0fc95ac0a73c049f333deb161bc..a4cc9bfc344d4b64f3f1a75b83bbc6f9c91f40c7 100644 (file)
@@ -9,6 +9,7 @@
 #include <timer/instance-info.h>
 #include <timer/instance-params.h>
 #include <timer/instance-status.h>
+#include <timer/event-data.h>
 
 G_BEGIN_DECLS
 
index 5f189e94ef22aa7aa70ce7c967243c9e9b8f42c2..b369f53eb76cec3abf4be2b4ad7003b6a0169444 100644 (file)
@@ -21,7 +21,9 @@ methods = (
     'get_status',
     'create_source',
 )
-signals = ()
+signals = (
+    'handle-event',
+)
 
 if not test(target, props, methods, signals):
     exit(ENXIO)