From d997a6544ab47f45a33cd9fff226d77b70f183a5 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Wed, 22 Jun 2022 12:05:26 +0900 Subject: [PATCH] timer: enums: rename to ALSATimer.EventType.TICK_TIME and REAL_TIME Signed-off-by: Takashi Sakamoto --- samples/timer | 2 +- src/timer/alsatimer-enum-types.h | 8 ++++---- src/timer/real-time-event.c | 2 +- src/timer/user-instance.c | 16 +++++++++------- tests/alsatimer-enums | 4 ++-- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/samples/timer b/samples/timer index 66acae6..71af177 100755 --- a/samples/timer +++ b/samples/timer @@ -13,7 +13,7 @@ instance = ALSATimer.UserInstance.new() instance.open(0) # Choose tstamp type of data for event and register event handler. -instance.choose_event_type(ALSATimer.EventType.TSTAMP) +instance.choose_event_type(ALSATimer.EventType.REAL_TIME) def handle_real_time_event(instance, event): real_time = event.get_time([0, 0]) print('\nEvent at', real_time) diff --git a/src/timer/alsatimer-enum-types.h b/src/timer/alsatimer-enum-types.h index 2310280..80be895 100644 --- a/src/timer/alsatimer-enum-types.h +++ b/src/timer/alsatimer-enum-types.h @@ -113,14 +113,14 @@ typedef enum /** * ALSATimerEventType - * @ALSATIMER_EVENT_TYPE_TICK: The data for tick event. - * @ALSATIMER_EVENT_TYPE_TSTAMP: The data for timestamp event. + * @ALSATIMER_EVENT_TYPE_TICK_TIME: Event for tick time. + * @ALSATIMER_EVENT_TYPE_REAL_TIME: Event for real time. * * A set of enumerations for the type of event. */ typedef enum { - ALSATIMER_EVENT_TYPE_TICK, - ALSATIMER_EVENT_TYPE_TSTAMP, + ALSATIMER_EVENT_TYPE_TICK_TIME, + ALSATIMER_EVENT_TYPE_REAL_TIME, } ALSATimerEventType; /** diff --git a/src/timer/real-time-event.c b/src/timer/real-time-event.c index 179e772..c66cf58 100644 --- a/src/timer/real-time-event.c +++ b/src/timer/real-time-event.c @@ -43,7 +43,7 @@ void alsatimer_real_time_event_get_event(const ALSATimerRealTimeEvent *self, * @real_time: (array fixed-size=2) (inout): The array with two elements for the seconds and * nanoseconds part of timestamp when the instance queues the timestamp event. * - * Get the seconds and nanoseconds part for the timestamp event. + * Get the seconds and nanoseconds part for the real time event. */ void alsatimer_real_time_event_get_time(const ALSATimerRealTimeEvent *self, gint64 *const real_time[2]) diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index 26d839b..0eef521 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -89,7 +89,7 @@ static void alsatimer_user_instance_class_init(ALSATimerUserInstanceClass *klass * @self: A [class@UserInstance]. * @event: (transfer none): The instance of [struct@TickTimeEvent]. * - * Emitted when tick event occurs. + * Emitted when event occurs to notify tick time. */ timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_TICK_TIME_EVENT] = g_signal_new("handle-tick-time-event", @@ -105,7 +105,7 @@ static void alsatimer_user_instance_class_init(ALSATimerUserInstanceClass *klass * @self: A [class@UserInstance]. * @event: (transfer none): The instance of [struct@RealTimeEvent]. * - * Emitted when timestamp event occurs. + * Emitted when event occurs to notify real time. */ timer_user_instance_sigs[TIMER_USER_INSTANCE_SIG_HANDLE_REAL_TIME_EVENT] = g_signal_new("handle-real-time-event", @@ -250,9 +250,11 @@ gboolean alsatimer_user_instance_get_protocol_version(ALSATimerUserInstance *sel * * Choose the type of event data to receive. * - * The call of function is successful just before the instance is not attached yet. - * [enum@EventType:TICK] is used as a default if the function is not called for - * [enum@EventType:TSTAMP] explicitly. + * The call of function is successful just before call of [method@UserInstance.attach]. + * [enum@EventType].TICK_TIME is used as a default if the function is not called for + * [enum@EventType].REAL_TIME explicitly. When the former is configured, event for tick time is + * available for [signal@UserInstance::handle_tick_time_event]. When the latter is configured, + * event for real time is available for [signal@UserInstance::handle_real_time_event]. * * The call of function executes `ioctl(2)` system call with `SNDRV_TIMER_IOCTL_TREAD` command * for ALSA timer character device. @@ -556,10 +558,10 @@ static gboolean timer_user_instance_dispatch_src(GSource *gsrc, GSourceFunc cb, } switch (priv->event_type) { - case ALSATIMER_EVENT_TYPE_TICK: + case ALSATIMER_EVENT_TYPE_TICK_TIME: dispatch_tick_time_events(self, src->buf, (size_t)len); break; - case ALSATIMER_EVENT_TYPE_TSTAMP: + case ALSATIMER_EVENT_TYPE_REAL_TIME: dispatch_real_time_events(self, src->buf, (size_t)len); break; default: diff --git a/tests/alsatimer-enums b/tests/alsatimer-enums index 142a399..487ad87 100644 --- a/tests/alsatimer-enums +++ b/tests/alsatimer-enums @@ -54,8 +54,8 @@ tstamp_event_types = ( ) event_types = ( - 'TICK', - 'TSTAMP', + 'TICK_TIME', + 'REAL_TIME', ) user_instance_error_types = ( -- 2.47.3