From 1197dce0d0e2eac8c089381390b8264f8faac828 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 5 Jun 2022 12:39:24 +0900 Subject: [PATCH] timer: enums: rename TstampEventType from EventType ALSATimer.EventType is for the type of tstamp event, thus it's not for tick event. This commit renames the enumerations with explicit name. Signed-off-by: Takashi Sakamoto --- samples/timer | 16 ++++---- src/timer/alsatimer-enum-types.h | 66 ++++++++++++++++---------------- src/timer/alsatimer.map | 3 +- src/timer/event-data-tstamp.c | 6 +-- src/timer/event-data-tstamp.h | 2 +- src/timer/instance-params.c | 22 ++++++----- src/timer/instance-params.h | 4 +- tests/alsatimer-enums | 4 +- 8 files changed, 63 insertions(+), 60 deletions(-) diff --git a/samples/timer b/samples/timer index 8c50f8a..72de65a 100755 --- a/samples/timer +++ b/samples/timer @@ -62,14 +62,14 @@ params.set_property('flags', flags) ticks = 500 * 1000 * 1000 // resolution # 500msec params.set_property('interval', ticks) params.set_property('queue-size', 64) -events = (ALSATimer.EventType.RESOLUTION, - ALSATimer.EventType.TICK, - ALSATimer.EventType.START, - ALSATimer.EventType.STOP, - ALSATimer.EventType.CONTINUE, - ALSATimer.EventType.PAUSE, - ALSATimer.EventType.SUSPEND, - ALSATimer.EventType.RESUME) +events = (ALSATimer.TstampEventType.RESOLUTION, + ALSATimer.TstampEventType.TICK, + ALSATimer.TstampEventType.START, + ALSATimer.TstampEventType.STOP, + ALSATimer.TstampEventType.CONTINUE, + ALSATimer.TstampEventType.PAUSE, + ALSATimer.TstampEventType.SUSPEND, + ALSATimer.TstampEventType.RESUME) params.set_event_filter(events) _, params = instance.set_params(params) diff --git a/src/timer/alsatimer-enum-types.h b/src/timer/alsatimer-enum-types.h index 8c3a2ec..1025e66 100644 --- a/src/timer/alsatimer-enum-types.h +++ b/src/timer/alsatimer-enum-types.h @@ -73,43 +73,43 @@ typedef enum /*< flags >*/ } ALSATimerInstanceParamFlag; /** - * ALSATimerEventType: - * @ALSATIMER_EVENT_TYPE_RESOLUTION: The event for timer resolution. - * @ALSATIMER_EVENT_TYPE_TICK: The event for timer tick. - * @ALSATIMER_EVENT_TYPE_START: The event for timer start. - * @ALSATIMER_EVENT_TYPE_STOP: The event for timer stop. - * @ALSATIMER_EVENT_TYPE_CONTINUE: The event for timer continue. - * @ALSATIMER_EVENT_TYPE_PAUSE: The event for timer pause. - * @ALSATIMER_EVENT_TYPE_EARLY: The event before timer start. - * @ALSATIMER_EVENT_TYPE_SUSPEND: The event for timer suspend. - * @ALSATIMER_EVENT_TYPE_RESUME: The event for timer resume. - * @ALSATIMER_EVENT_TYPE_MSTART: The event for master timer start. - * @ALSATIMER_EVENT_TYPE_MSTOP: The event for master timer stop. - * @ALSATIMER_EVENT_TYPE_MCONTINUE: The event for master timer continue. - * @ALSATIMER_EVENT_TYPE_MPAUSE: The event for master timer pause. - * @ALSATIMER_EVENT_TYPE_MSUSPEND: The event for master timer suspend. - * @ALSATIMER_EVENT_TYPE_MRESUME: The event for master timer resume. + * ALSATimerTstampEventType: + * @ALSATIMER_TSTAMP_EVENT_TYPE_RESOLUTION: The event for timer resolution. + * @ALSATIMER_TSTAMP_EVENT_TYPE_TICK: The event for timer tick. + * @ALSATIMER_TSTAMP_EVENT_TYPE_START: The event for timer start. + * @ALSATIMER_TSTAMP_EVENT_TYPE_STOP: The event for timer stop. + * @ALSATIMER_TSTAMP_EVENT_TYPE_CONTINUE: The event for timer continue. + * @ALSATIMER_TSTAMP_EVENT_TYPE_PAUSE: The event for timer pause. + * @ALSATIMER_TSTAMP_EVENT_TYPE_EARLY: The event before timer start. + * @ALSATIMER_TSTAMP_EVENT_TYPE_SUSPEND: The event for timer suspend. + * @ALSATIMER_TSTAMP_EVENT_TYPE_RESUME: The event for timer resume. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MSTART: The event for master timer start. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MSTOP: The event for master timer stop. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MCONTINUE: The event for master timer continue. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MPAUSE: The event for master timer pause. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MSUSPEND: The event for master timer suspend. + * @ALSATIMER_TSTAMP_EVENT_TYPE_MRESUME: The event for master timer resume. * - * A set of enumerations for timer event. + * A set of enumerations for the type of timestamp event. */ typedef enum { - ALSATIMER_EVENT_TYPE_RESOLUTION = SNDRV_TIMER_EVENT_RESOLUTION, - ALSATIMER_EVENT_TYPE_TICK = SNDRV_TIMER_EVENT_TICK, - ALSATIMER_EVENT_TYPE_START = SNDRV_TIMER_EVENT_START, - ALSATIMER_EVENT_TYPE_STOP = SNDRV_TIMER_EVENT_STOP, - ALSATIMER_EVENT_TYPE_CONTINUE = SNDRV_TIMER_EVENT_CONTINUE, - ALSATIMER_EVENT_TYPE_PAUSE = SNDRV_TIMER_EVENT_PAUSE, - ALSATIMER_EVENT_TYPE_EARLY = SNDRV_TIMER_EVENT_EARLY, - ALSATIMER_EVENT_TYPE_SUSPEND = SNDRV_TIMER_EVENT_SUSPEND, - ALSATIMER_EVENT_TYPE_RESUME = SNDRV_TIMER_EVENT_RESUME, - ALSATIMER_EVENT_TYPE_MSTART = SNDRV_TIMER_EVENT_MSTART, - ALSATIMER_EVENT_TYPE_MSTOP = SNDRV_TIMER_EVENT_MSTOP, - ALSATIMER_EVENT_TYPE_MCONTINUE = SNDRV_TIMER_EVENT_MCONTINUE, - ALSATIMER_EVENT_TYPE_MPAUSE = SNDRV_TIMER_EVENT_MPAUSE, - ALSATIMER_EVENT_TYPE_MSUSPEND = SNDRV_TIMER_EVENT_MSUSPEND, - ALSATIMER_EVENT_TYPE_MRESUME = SNDRV_TIMER_EVENT_MRESUME, -} ALSATimerEventType; + ALSATIMER_TSTAMP_EVENT_TYPE_RESOLUTION = SNDRV_TIMER_EVENT_RESOLUTION, + ALSATIMER_TSTAMP_EVENT_TYPE_TICK = SNDRV_TIMER_EVENT_TICK, + ALSATIMER_TSTAMP_EVENT_TYPE_START = SNDRV_TIMER_EVENT_START, + ALSATIMER_TSTAMP_EVENT_TYPE_STOP = SNDRV_TIMER_EVENT_STOP, + ALSATIMER_TSTAMP_EVENT_TYPE_CONTINUE = SNDRV_TIMER_EVENT_CONTINUE, + ALSATIMER_TSTAMP_EVENT_TYPE_PAUSE = SNDRV_TIMER_EVENT_PAUSE, + ALSATIMER_TSTAMP_EVENT_TYPE_EARLY = SNDRV_TIMER_EVENT_EARLY, + ALSATIMER_TSTAMP_EVENT_TYPE_SUSPEND = SNDRV_TIMER_EVENT_SUSPEND, + ALSATIMER_TSTAMP_EVENT_TYPE_RESUME = SNDRV_TIMER_EVENT_RESUME, + ALSATIMER_TSTAMP_EVENT_TYPE_MSTART = SNDRV_TIMER_EVENT_MSTART, + ALSATIMER_TSTAMP_EVENT_TYPE_MSTOP = SNDRV_TIMER_EVENT_MSTOP, + ALSATIMER_TSTAMP_EVENT_TYPE_MCONTINUE = SNDRV_TIMER_EVENT_MCONTINUE, + ALSATIMER_TSTAMP_EVENT_TYPE_MPAUSE = SNDRV_TIMER_EVENT_MPAUSE, + ALSATIMER_TSTAMP_EVENT_TYPE_MSUSPEND = SNDRV_TIMER_EVENT_MSUSPEND, + ALSATIMER_TSTAMP_EVENT_TYPE_MRESUME = SNDRV_TIMER_EVENT_MRESUME, +} ALSATimerTstampEventType; /** * ALSATimerEventDataType diff --git a/src/timer/alsatimer.map b/src/timer/alsatimer.map index 1681feb..3814486 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_type_get_type"; "alsatimer_event_data_type_get_type"; "alsatimer_device_id_get_type"; @@ -76,4 +75,6 @@ ALSA_GOBJECT_0_3_0 { "alsatimer_user_instance_stop"; "alsatimer_user_instance_pause"; "alsatimer_user_instance_continue"; + + "alsatimer_tstamp_event_type_get_type"; } ALSA_GOBJECT_0_2_0; diff --git a/src/timer/event-data-tstamp.c b/src/timer/event-data-tstamp.c index 493e3d2..80ceeaf 100644 --- a/src/timer/event-data-tstamp.c +++ b/src/timer/event-data-tstamp.c @@ -27,14 +27,14 @@ G_DEFINE_BOXED_TYPE(ALSATimerEventDataTstamp, alsatimer_event_data_tstamp, timer /** * alsatimer_event_data_tstamp_get_event: * @self: A [struct@EventDataTstamp]. - * @event: (out): The type of tstamp event, one of [enum@EventType]. + * @event: (out): The type of tstamp event, one of [enum@TstampEventType]. * * Get the kind of event for the timestamp event. */ void alsatimer_event_data_tstamp_get_event(const ALSATimerEventDataTstamp *self, - ALSATimerEventType *event) + ALSATimerTstampEventType *event) { - *event = (ALSATimerEventType)self->event; + *event = (ALSATimerTstampEventType)self->event; } /** diff --git a/src/timer/event-data-tstamp.h b/src/timer/event-data-tstamp.h index fbd1ef9..d004a66 100644 --- a/src/timer/event-data-tstamp.h +++ b/src/timer/event-data-tstamp.h @@ -13,7 +13,7 @@ typedef struct snd_timer_tread ALSATimerEventDataTstamp; GType alsatimer_event_data_tstamp_get_type() G_GNUC_CONST; void alsatimer_event_data_tstamp_get_event(const ALSATimerEventDataTstamp *self, - ALSATimerEventType *event); + ALSATimerTstampEventType *event); void alsatimer_event_data_tstamp_get_tstamp(const ALSATimerEventDataTstamp *self, gint64 *const tstamp[2]); diff --git a/src/timer/instance-params.c b/src/timer/instance-params.c index e76ffd1..5f6cb4b 100644 --- a/src/timer/instance-params.c +++ b/src/timer/instance-params.c @@ -126,17 +126,18 @@ ALSATimerInstanceParams *alsatimer_instance_params_new() /** * alsatimer_instance_params_set_event_filter: * @self: A [class@InstanceParams]. - * @entries: (array length=entry_count): The array with elements for entries of [enum@EventType]. + * @entries: (array length=entry_count): The array with elements for entries of + * [enum@TstampEventType]. * @entry_count: The number of elements in the above array. * @error: A [struct@GLib.Error] at failure. * - * Set the list of [enum@EventType] to filter events. This parameter is effective only for target - * instance with [enum@EventDataType:TIMESTAMP]. + * Set the list of [enum@TstampEventType] to filter events. This parameter is effective only for + * target instance with [enum@EventDataType:TIMESTAMP]. * * Returns: %TRUE when the overall operation finishes successfully, else %FALSE. */ gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self, - const ALSATimerEventType *entries, + const ALSATimerTstampEventType *entries, gsize entry_count, GError **error) { ALSATimerInstanceParamsPrivate *priv; @@ -174,21 +175,22 @@ gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *sel /** * alsatimer_instance_params_get_event_filter: * @self: A [class@InstanceParams]. - * @entries: (array length=entry_count)(out): The array with elements for entries of [enum@EventType]. + * @entries: (array length=entry_count)(out): The array with elements for entries of + * [enum@TstampEventType]. * @entry_count: The number of elements in the above array. * @error: A [struct@GLib.Error] at failure. * - * Get the list of ALSATimerEventType to filter events. This parameter is effective only for target - * instance with [enum@EventDataType:TIMESTAMP]. + * Get the list of [enum@TstampEventType] to filter events. This parameter is effective only for + * target instance with [enum@EventDataType:TIMESTAMP]. * * Returns: %TRUE when the overall operation finishes successfully, else %FALSE. */ gboolean alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self, - ALSATimerEventType **entries, + ALSATimerTstampEventType **entries, gsize *entry_count, GError **error) { ALSATimerInstanceParamsPrivate *priv; - ALSATimerEventType *list; + ALSATimerTstampEventType *list; unsigned int filter; unsigned int count; unsigned int index; @@ -216,7 +218,7 @@ gboolean alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *sel index = 0; for (i = 0; i < sizeof(filter) * 8; ++i) { if ((1u << i) & filter) { - list[index] = (ALSATimerEventType)i; + list[index] = (ALSATimerTstampEventType)i; if (++index >= count) break; } diff --git a/src/timer/instance-params.h b/src/timer/instance-params.h index 5ba060a..7ed5814 100644 --- a/src/timer/instance-params.h +++ b/src/timer/instance-params.h @@ -18,11 +18,11 @@ struct _ALSATimerInstanceParamsClass { ALSATimerInstanceParams *alsatimer_instance_params_new(); gboolean alsatimer_instance_params_set_event_filter(ALSATimerInstanceParams *self, - const ALSATimerEventType *entries, + const ALSATimerTstampEventType *entries, gsize entry_count, GError **error); gboolean alsatimer_instance_params_get_event_filter(ALSATimerInstanceParams *self, - ALSATimerEventType **entries, + ALSATimerTstampEventType **entries, gsize *entry_count, GError **error); G_END_DECLS diff --git a/tests/alsatimer-enums b/tests/alsatimer-enums index 008a1f8..153a41a 100644 --- a/tests/alsatimer-enums +++ b/tests/alsatimer-enums @@ -33,7 +33,7 @@ instance_param_flags = ( 'EARLY_EVENT', ) -event_types = ( +tstamp_event_types = ( 'RESOLUTION', 'TICK', 'START', @@ -69,7 +69,7 @@ types = { ALSATimer.SpecificGlobalDevice: specific_global_devices, ALSATimer.DeviceInfoFlag: device_info_flags, ALSATimer.InstanceParamFlag: instance_param_flags, - ALSATimer.EventType: event_types, + ALSATimer.TstampEventType: tstamp_event_types, ALSATimer.EventDataType: event_data_types, ALSATimer.UserInstanceError: user_instance_error_types, } -- 2.47.3