]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: tick-time-event: rename boxed structure
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Jun 2022 03:05:26 +0000 (12:05 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 22 Jun 2022 03:05:26 +0000 (12:05 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/alsatimer.map
src/timer/tick-time-event.c
src/timer/tick-time-event.h
src/timer/user-instance.c
src/timer/user-instance.h
tests/alsatimer-tick-time-event
tests/alsatimer-user-instance

index ea16528093e1cf72e0bf1a11feb878407626efe3..1bff785edb65e431f967fe2c2fa2e272c1cf0e36 100644 (file)
@@ -69,9 +69,9 @@ ALSA_GOBJECT_0_3_0 {
     "alsatimer_tstamp_event_type_get_type";
     "alsatimer_event_type_get_type";
 
-    "alsatimer_tick_event_get_type";
-    "alsatimer_tick_event_get_resolution";
-    "alsatimer_tick_event_get_ticks";
+    "alsatimer_tick_time_event_get_type";
+    "alsatimer_tick_time_event_get_resolution";
+    "alsatimer_tick_time_event_get_count";
 
     "alsatimer_tstamp_event_get_type";
     "alsatimer_tstamp_event_get_event";
index 69e019e2a57e182255e6f943c446b31b6b4c16eb..c9a5e4658602c3a21f3c54aa5c142f9527f48934 100644 (file)
@@ -2,14 +2,14 @@
 #include "privates.h"
 
 /**
- * ALSATimerTickEvent:
- * A boxed object to represent event of timer with tick count.
+ * ALSATimerTickTimeEvent:
+ * A boxed object to express event of timer with tick count.
  *
- * A [struct@TickEvent] is a boxed object to represent event of timer with tick count.
+ * A [struct@TickTimeEvent] includes tick count at which the event is queued.
  *
  * The object wraps `struct snd_timer_read` in UAPI of Linux sound subsystem.
  */
-ALSATimerTickEvent *timer_tick_event_copy(const ALSATimerTickEvent *self)
+ALSATimerTickTimeEvent *timer_tick_time_event_copy(const ALSATimerTickTimeEvent *self)
 {
 #ifdef g_memdup2
     return g_memdup2(self, sizeof(*self));
@@ -22,30 +22,29 @@ ALSATimerTickEvent *timer_tick_event_copy(const ALSATimerTickEvent *self)
 #endif
 }
 
-G_DEFINE_BOXED_TYPE(ALSATimerTickEvent, alsatimer_tick_event, timer_tick_event_copy, g_free)
+G_DEFINE_BOXED_TYPE(ALSATimerTickTimeEvent, alsatimer_tick_time_event, timer_tick_time_event_copy, g_free)
 
 /**
- * alsatimer_tick_event_get_resolution:
- * @self: A [struct@TickEvent].
+ * alsatimer_tick_time_event_get_resolution:
+ * @self: A [struct@TickTimeEvent].
  * @resolution: (out): The resolution of tick event.
  *
  * Get the resolution of tick event.
  */
-void alsatimer_tick_event_get_resolution(const ALSATimerTickEvent *self,
+void alsatimer_tick_time_event_get_resolution(const ALSATimerTickTimeEvent *self,
                                               guint *resolution)
 {
     *resolution = self->resolution;
 }
 
 /**
- * alsatimer_tick_event_get_ticks:
- * @self: A [struct@TickEvent].
- * @ticks: (out): The tick count since the last event.
+ * alsatimer_tick_time_event_get_count:
+ * @self: A [struct@TickTimeEvent].
+ * @count: (out): The tick count since the last event.
  *
  * Get the tick count since the last event.
  */
-void alsatimer_tick_event_get_ticks(const ALSATimerTickEvent *self,
-                                         guint *ticks)
+void alsatimer_tick_time_event_get_ticks(const ALSATimerTickTimeEvent *self, guint *count)
 {
-    *ticks = self->ticks;
+    *count = self->ticks;
 }
index c1090ce08d6ee1c852e7e3dd8d8975567751ca4e..b16f3bd55848b3b64e85d7841f86f97be095dc1c 100644 (file)
@@ -1,22 +1,21 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
-#ifndef __ALSA_GOBJECT_ALSATIMER_TICK_EVENT_H__
-#define __ALSA_GOBJECT_ALSATIMER_TICK_EVENT_H__
+#ifndef __ALSA_GOBJECT_ALSATIMER_TICK_TIME_EVENT_H__
+#define __ALSA_GOBJECT_ALSATIMER_TICK_TIME_EVENT_H__
 
 #include <alsatimer.h>
 
 G_BEGIN_DECLS
 
-#define ALSATIMER_TYPE_TICK_EVENT   (alsatimer_tick_event_get_type())
+#define ALSATIMER_TYPE_TICK_TIME_EVENT   (alsatimer_tick_time_event_get_type())
 
-typedef struct snd_timer_read ALSATimerTickEvent;
+typedef struct snd_timer_read ALSATimerTickTimeEvent;
 
-GType alsatimer_tick_event_get_type() G_GNUC_CONST;
+GType alsatimer_tick_time_event_get_type() G_GNUC_CONST;
 
-void alsatimer_tick_event_get_resolution(const ALSATimerTickEvent *self,
+void alsatimer_tick_time_event_get_resolution(const ALSATimerTickTimeEvent *self,
                                               guint *resolution);
 
-void alsatimer_tick_event_get_ticks(const ALSATimerTickEvent *self,
-                                         guint *ticks);
+void alsatimer_tick_time_event_get_count(const ALSATimerTickTimeEvent *self, guint *count);
 
 G_END_DECLS
 
index 4ce08df80992c2420636e124e3ad49c560b3b8c6..a166d499ce8657e05055e05c2e889280c372215f 100644 (file)
@@ -59,7 +59,7 @@ typedef struct {
 } TimerUserInstanceSource;
 
 enum timer_user_instance_sig_type {
-    TIMER_USER_INSTANCE_SIG_HANDLE_TICK_EVENT = 0,
+    TIMER_USER_INSTANCE_SIG_HANDLE_TICK_TIME_EVENT = 0,
     TIMER_USER_INSTANCE_SIG_HANDLE_TSTAMP_EVENT,
     TIMER_USER_INSTANCE_SIG_HANDLE_DISCONNECTION,
     TIMER_USER_INSTANCE_SIG_COUNT,
@@ -85,20 +85,20 @@ static void alsatimer_user_instance_class_init(ALSATimerUserInstanceClass *klass
     gobject_class->finalize = timer_user_instance_finalize;
 
     /**
-     * ALSATimerUserInstance::handle-tick-event:
+     * ALSATimerUserInstance::handle-tick-time-event:
      * @self: A [class@UserInstance].
-     * @event: (transfer none): The instance of [struct@TickEvent].
+     * @event: (transfer none): The instance of [struct@TickTimeEvent].
      *
      * Emitted when tick event occurs.
      */
-    timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_TICK_EVENT] =
-        g_signal_new("handle-tick-event",
+    timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_TICK_TIME_EVENT] =
+        g_signal_new("handle-tick-time-event",
                      G_OBJECT_CLASS_TYPE(klass),
                      G_SIGNAL_RUN_LAST,
-                     G_STRUCT_OFFSET(ALSATimerUserInstanceClass, handle_tick_event),
+                     G_STRUCT_OFFSET(ALSATimerUserInstanceClass, handle_tick_time_event),
                      NULL, NULL,
                      g_cclosure_marshal_VOID__BOXED,
-                     G_TYPE_NONE, 1, ALSATIMER_TYPE_TICK_EVENT);
+                     G_TYPE_NONE, 1, ALSATIMER_TYPE_TICK_TIME_EVENT);
 
     /**
      * ALSATimerUserInstance::handle-tstamp-event:
@@ -494,14 +494,15 @@ static gboolean timer_user_instance_check_src(GSource *gsrc)
     return !!(condition & (G_IO_IN | G_IO_ERR));
 }
 
-static void dispatch_tick_events(ALSATimerUserInstance *self, const guint8 *buf, gsize length)
+static void dispatch_tick_time_events(ALSATimerUserInstance *self, const guint8 *buf, gsize length)
 {
     const struct snd_timer_read *ev;
 
     while (length >= sizeof(*ev)) {
         ev = (const struct snd_timer_read *)buf;
 
-        g_signal_emit(self, timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_TICK_EVENT],
+        g_signal_emit(self,
+                      timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_TICK_TIME_EVENT],
                       0, ev);
 
         length -= sizeof(*ev);
@@ -555,7 +556,7 @@ static gboolean timer_user_instance_dispatch_src(GSource *gsrc, GSourceFunc cb,
 
     switch (priv->event_type) {
     case ALSATIMER_EVENT_TYPE_TICK:
-        dispatch_tick_events(self, src->buf, (size_t)len);
+        dispatch_tick_time_events(self, src->buf, (size_t)len);
         break;
     case ALSATIMER_EVENT_TYPE_TSTAMP:
         dispatch_tstamp_events(self, src->buf, (size_t)len);
@@ -584,7 +585,7 @@ static void timer_user_instance_finalize_src(GSource *gsrc)
  *
  * Allocate [struct@GLib.Source] structure to handle events from ALSA timer character device. In
  * each iteration of [struct@GLib.MainContext], the `read(2)` system call is executed to dispatch
- * timer event for either [signal@UserInstance::handle-tick-event] or
+ * timer event for either [signal@UserInstance::handle-tick-time-event] or
  * [signal@UserInstance::handle-tstamp-event] signals, according to the result of `poll(2)` system
  * call.
  *
index 6bd3fa78decb15cd907893b584c4e0c7a3940ae2..5b49156b3f1ff7921ea340542bcd05c3caa318cc 100644 (file)
@@ -19,13 +19,14 @@ struct _ALSATimerUserInstanceClass {
     GObjectClass parent_class;
 
     /**
-     * ALSATimerUserInstanceClass::handle_tick_event:
+     * ALSATimerUserInstanceClass::handle_tick_time_event:
      * @self: A [class@UserInstance].
-     * @event: (transfer none): An object derived from [struct@TickEvent].
+     * @event: (transfer none): An object derived from [struct@TickTimeEvent].
      *
-     * Class closure for the [signal@UserInstance::handle-tick-event] signal.
+     * Class closure for the [signal@UserInstance::handle-tick-time-event] signal.
      */
-    void (*handle_tick_event)(ALSATimerUserInstance *self, const ALSATimerTickEvent *event);
+    void (*handle_tick_time_event)(ALSATimerUserInstance *self,
+                                   const ALSATimerTickTimeEvent *event);
 
     /**
      * ALSATimerUserInstanceClass::handle_tstamp_event:
index 4ca7f85fdbaf06ab7be304f959c9eca193c2b9c5..c01355449b34806e4b817c758311b023a5a46c26 100644 (file)
@@ -9,10 +9,10 @@ import gi
 gi.require_version('ALSATimer', '0.0')
 from gi.repository import ALSATimer
 
-target_type = ALSATimer.TickEvent
+target_type = ALSATimer.TickTimeEvent
 methods = (
     'get_resolution',
-    'get_ticks',
+    'get_count',
 )
 
 if not test_struct(target_type, methods):
index bb1ace1ca67db97dcf0ccd55c3b8464eed7d6580..7d375f0de15aa71994cd53e70e7938e0d4bbf2fd 100644 (file)
@@ -28,12 +28,12 @@ methods = (
     'continue_',
 )
 vmethods = (
-    'do_handle_tick_event',
+    'do_handle_tick_time_event',
     'do_handle_tstamp_event',
     'do_handle_disconnection',
 )
 signals = (
-    'handle-tick-event',
+    'handle-tick-time-event',
     'handle-tstamp-event',
     'handle-disconnection',
 )