]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: enum: rename EventType from EventDataType
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 5 Jun 2022 03:39:24 +0000 (12:39 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Mon, 6 Jun 2022 02:14:34 +0000 (11:14 +0900)
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 <o-takashi@sakamocchi.jp>
samples/timer
src/timer/alsatimer-enum-types.h
src/timer/alsatimer.map
src/timer/instance-params.c
src/timer/user-instance.c
src/timer/user-instance.h
tests/alsatimer-enums
tests/alsatimer-user-instance

index 72de65af0af3939614e85691bb4bfa6dd54edcd3..808611ae1090ce6ec35d886b4b1f955552414c3c 100755 (executable)
@@ -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)
index 1025e66168cad31602dedf09fd12a1e992e10886..2310280369aa42fc92987e7b94e980091072b070 100644 (file)
@@ -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:
index 3814486c277aa587372e3e87e40bc880bf3508d8..c998622160d66baa71c79afd513d0cdf3bc7437e 100644 (file)
@@ -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;
index 5f6cb4b26c35cc42b70862eb072f4629f917084a..d38ae5a5ce30824c8a7e1ef916cc1c9ead39539c 100644 (file)
@@ -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.
  */
index dd95bc352c8182c11797435811ecda78f1ee69ca..1a859c931c2589a980f1561edf35b85e8cd7dbb6 100644 (file)
@@ -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:
index 8645869a9017e5977a334333a415930c4b904907..cbe5fe65180b513d7f382de76bbef182714e90e1 100644 (file)
@@ -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,
index 153a41a2421f4b8aa5b40784e20c6108c312c976..76906cae477712b8e733b7ef441d9d27c6bc0bc8 100644 (file)
@@ -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,
 }
 
index 3ab54df5ec5e92205b03fbcc9c40ebba1856fed2..b287ed21342ae4f3fe6e3fa092d858b76ce73ed6 100644 (file)
@@ -15,7 +15,7 @@ methods = (
     'new',
     'open',
     'get_protocol_version',
-    'choose_event_data_type',
+    'choose_event_type',
     'attach',
     'attach_as_slave',
     'get_info',