From 75f2e971421d0ec58b39ff42b050e5ba7182f2f2 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 5 Jun 2022 12:39:24 +0900 Subject: [PATCH] timer: enum: rename EventType from EventDataType ALSATimer.EventDataType is used to distinguish the type of event from either tick or timestamp. This commit renames the enumerations with explicit name. Signed-off-by: Takashi Sakamoto --- samples/timer | 2 +- src/timer/alsatimer-enum-types.h | 14 +++++++------- src/timer/alsatimer.map | 4 ++-- src/timer/instance-params.c | 4 ++-- src/timer/user-instance.c | 24 ++++++++++++------------ src/timer/user-instance.h | 4 ++-- tests/alsatimer-enums | 4 ++-- tests/alsatimer-user-instance | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/samples/timer b/samples/timer index 72de65a..808611a 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_data_type(ALSATimer.EventDataType.TSTAMP) +instance.choose_event_type(ALSATimer.EventType.TSTAMP) def handle_tstamp_event(instance, event): tstamp = event.get_tstamp([0, 0]) print('\nEvent at', tstamp) diff --git a/src/timer/alsatimer-enum-types.h b/src/timer/alsatimer-enum-types.h index 1025e66..2310280 100644 --- a/src/timer/alsatimer-enum-types.h +++ b/src/timer/alsatimer-enum-types.h @@ -112,16 +112,16 @@ typedef enum } ALSATimerTstampEventType; /** - * ALSATimerEventDataType - * @ALSATIMER_EVENT_DATA_TYPE_TICK: The data for tick event. - * @ALSATIMER_EVENT_DATA_TYPE_TSTAMP: The data for timestamp event. + * ALSATimerEventType + * @ALSATIMER_EVENT_TYPE_TICK: The data for tick event. + * @ALSATIMER_EVENT_TYPE_TSTAMP: The data for timestamp event. * - * A set of enumerations for the type of event data. + * A set of enumerations for the type of event. */ typedef enum { - ALSATIMER_EVENT_DATA_TYPE_TICK, - ALSATIMER_EVENT_DATA_TYPE_TSTAMP, -} ALSATimerEventDataType; + ALSATIMER_EVENT_TYPE_TICK, + ALSATIMER_EVENT_TYPE_TSTAMP, +} ALSATimerEventType; /** * ALSATimerUserInstanceError: diff --git a/src/timer/alsatimer.map b/src/timer/alsatimer.map index 3814486..c998622 100644 --- a/src/timer/alsatimer.map +++ b/src/timer/alsatimer.map @@ -5,7 +5,6 @@ ALSA_GOBJECT_0_0_0 { "alsatimer_specific_global_device_get_type"; "alsatimer_device_info_flag_get_type"; "alsatimer_instance_param_flag_get_type"; - "alsatimer_event_data_type_get_type"; "alsatimer_device_id_get_type"; "alsatimer_device_id_new"; @@ -64,7 +63,6 @@ ALSA_GOBJECT_0_3_0 { "alsatimer_user_instance_open"; "alsatimer_user_instance_get_protocol_version"; - "alsatimer_user_instance_choose_event_data_type"; "alsatimer_user_instance_attach"; "alsatimer_user_instance_attach_as_slave"; "alsatimer_user_instance_get_info"; @@ -75,6 +73,8 @@ ALSA_GOBJECT_0_3_0 { "alsatimer_user_instance_stop"; "alsatimer_user_instance_pause"; "alsatimer_user_instance_continue"; + "alsatimer_user_instance_choose_event_type"; "alsatimer_tstamp_event_type_get_type"; + "alsatimer_event_type_get_type"; } ALSA_GOBJECT_0_2_0; diff --git a/src/timer/instance-params.c b/src/timer/instance-params.c index 5f6cb4b..d38ae5a 100644 --- a/src/timer/instance-params.c +++ b/src/timer/instance-params.c @@ -132,7 +132,7 @@ ALSATimerInstanceParams *alsatimer_instance_params_new() * @error: A [struct@GLib.Error] at failure. * * Set the list of [enum@TstampEventType] to filter events. This parameter is effective only for - * target instance with [enum@EventDataType:TIMESTAMP]. + * target instance with [enum@EventType:TIMESTAMP]. * * Returns: %TRUE when the overall operation finishes successfully, else %FALSE. */ @@ -181,7 +181,7 @@ gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *sel * @error: A [struct@GLib.Error] at failure. * * Get the list of [enum@TstampEventType] to filter events. This parameter is effective only for - * target instance with [enum@EventDataType:TIMESTAMP]. + * target instance with [enum@EventType:TIMESTAMP]. * * Returns: %TRUE when the overall operation finishes successfully, else %FALSE. */ diff --git a/src/timer/user-instance.c b/src/timer/user-instance.c index dd95bc3..1a859c9 100644 --- a/src/timer/user-instance.c +++ b/src/timer/user-instance.c @@ -22,7 +22,7 @@ */ typedef struct { int fd; - ALSATimerEventDataType event_data_type; + ALSATimerEventType event_type; guint16 proto_ver_triplet[3]; } ALSATimerUserInstancePrivate; G_DEFINE_TYPE_WITH_PRIVATE(ALSATimerUserInstance, alsatimer_user_instance, G_TYPE_OBJECT) @@ -243,24 +243,24 @@ gboolean alsatimer_user_instance_get_protocol_version(ALSATimerUserInstance *sel } /** - * alsatimer_user_instance_choose_event_data_type: + * alsatimer_user_instance_choose_event_type: * @self: A [class@UserInstance]. - * @event_data_type: The type of event data, one of [enum@EventDataType]. + * @event_type: The type of event data, one of [enum@EventType]. * @error: A [struct@GLib.Error]. Error is generated with domain of `ALSATimer.UserInstanceError`. * * Choose the type of event data to receive. * * The call of function is successful just before the instance is not attached yet. - * [enum@EventDataType:TICK] is used as a default if the function is not called for - * [enum@EventDataType:TSTAMP] explicitly. + * [enum@EventType:TICK] is used as a default if the function is not called for + * [enum@EventType:TSTAMP] explicitly. * * The call of function executes `ioctl(2)` system call with `SNDRV_TIMER_IOCTL_TREAD` command * for ALSA timer character device. * * Returns: %TRUE when the overall operation finishes successfully, else %FALSE. */ -gboolean alsatimer_user_instance_choose_event_data_type(ALSATimerUserInstance *self, - ALSATimerEventDataType event_data_type, +gboolean alsatimer_user_instance_choose_event_type(ALSATimerUserInstance *self, + ALSATimerEventType event_type, GError **error) { ALSATimerUserInstancePrivate *priv; @@ -271,7 +271,7 @@ gboolean alsatimer_user_instance_choose_event_data_type(ALSATimerUserInstance *s g_return_val_if_fail(error == NULL || *error == NULL, FALSE); - tread = (int)event_data_type; + tread = (int)event_type; if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_TREAD, &tread) < 0) { if (errno == EBUSY) generate_local_error(error, ALSATIMER_USER_INSTANCE_ERROR_ATTACHED); @@ -280,7 +280,7 @@ gboolean alsatimer_user_instance_choose_event_data_type(ALSATimerUserInstance *s return FALSE; } - priv->event_data_type = event_data_type; + priv->event_type = event_type; return TRUE; } @@ -553,11 +553,11 @@ static gboolean timer_user_instance_dispatch_src(GSource *gsrc, GSourceFunc cb, return G_SOURCE_REMOVE; } - switch (priv->event_data_type) { - case ALSATIMER_EVENT_DATA_TYPE_TICK: + switch (priv->event_type) { + case ALSATIMER_EVENT_TYPE_TICK: dispatch_tick_events(self, src->buf, (size_t)len); break; - case ALSATIMER_EVENT_DATA_TYPE_TSTAMP: + case ALSATIMER_EVENT_TYPE_TSTAMP: dispatch_tstamp_events(self, src->buf, (size_t)len); break; default: diff --git a/src/timer/user-instance.h b/src/timer/user-instance.h index 8645869..cbe5fe6 100644 --- a/src/timer/user-instance.h +++ b/src/timer/user-instance.h @@ -53,8 +53,8 @@ gboolean alsatimer_user_instance_get_protocol_version(ALSATimerUserInstance *sel const guint16 *proto_ver_triplet[3], GError **error); -gboolean alsatimer_user_instance_choose_event_data_type(ALSATimerUserInstance *self, - ALSATimerEventDataType event_data_type, +gboolean alsatimer_user_instance_choose_event_type(ALSATimerUserInstance *self, + ALSATimerEventType event_type, GError **error); gboolean alsatimer_user_instance_attach(ALSATimerUserInstance *self, ALSATimerDeviceId *device_id, diff --git a/tests/alsatimer-enums b/tests/alsatimer-enums index 153a41a..76906ca 100644 --- a/tests/alsatimer-enums +++ b/tests/alsatimer-enums @@ -51,7 +51,7 @@ tstamp_event_types = ( 'MRESUME', ) -event_data_types = ( +event_types = ( 'TICK', 'TSTAMP', ) @@ -70,7 +70,7 @@ types = { ALSATimer.DeviceInfoFlag: device_info_flags, ALSATimer.InstanceParamFlag: instance_param_flags, ALSATimer.TstampEventType: tstamp_event_types, - ALSATimer.EventDataType: event_data_types, + ALSATimer.EventType: event_types, ALSATimer.UserInstanceError: user_instance_error_types, } diff --git a/tests/alsatimer-user-instance b/tests/alsatimer-user-instance index 3ab54df..b287ed2 100644 --- a/tests/alsatimer-user-instance +++ b/tests/alsatimer-user-instance @@ -15,7 +15,7 @@ methods = ( 'new', 'open', 'get_protocol_version', - 'choose_event_data_type', + 'choose_event_type', 'attach', 'attach_as_slave', 'get_info', -- 2.47.3