From: Takashi Sakamoto Date: Wed, 22 Jun 2022 03:05:26 +0000 (+0900) Subject: timer: tick-time-event: rename boxed structure X-Git-Tag: v0.3.0~35 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=16033c8dbe61c0284b8b8852aded3da9167893fc;p=alsa-gobject.git timer: tick-time-event: rename boxed structure Signed-off-by: Takashi Sakamoto --- diff --git a/src/timer/alsatimer.map b/src/timer/alsatimer.map index ea16528..1bff785 100644 --- a/src/timer/alsatimer.map +++ b/src/timer/alsatimer.map @@ -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"; diff --git a/src/timer/tick-time-event.c b/src/timer/tick-time-event.c index 69e019e..c9a5e46 100644 --- a/src/timer/tick-time-event.c +++ b/src/timer/tick-time-event.c @@ -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; } diff --git a/src/timer/tick-time-event.h b/src/timer/tick-time-event.h index c1090ce..b16f3bd 100644 --- a/src/timer/tick-time-event.h +++ b/src/timer/tick-time-event.h @@ -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 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 diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index 4ce08df..a166d49 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -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. * diff --git a/src/timer/user-instance.h b/src/timer/user-instance.h index 6bd3fa7..5b49156 100644 --- a/src/timer/user-instance.h +++ b/src/timer/user-instance.h @@ -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: diff --git a/tests/alsatimer-tick-time-event b/tests/alsatimer-tick-time-event index 4ca7f85..c013554 100644 --- a/tests/alsatimer-tick-time-event +++ b/tests/alsatimer-tick-time-event @@ -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): diff --git a/tests/alsatimer-user-instance b/tests/alsatimer-user-instance index bb1ace1..7d375f0 100644 --- a/tests/alsatimer-user-instance +++ b/tests/alsatimer-user-instance @@ -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', )