]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: event_data_tick: become boxed object
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 10 Jun 2020 01:31:47 +0000 (10:31 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Fri, 12 Jun 2020 00:00:43 +0000 (09:00 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/event-data-tick.c
src/timer/event-data-tick.h
src/timer/event.h
src/timer/privates.h
tests/alsatimer-event-data-tick [deleted file]
tests/meson.build

index 401011936f2f35ddb1333fe3e34b86438cfba33b..875aece916bc178814d0905e3f594e5e33046721 100644 (file)
@@ -5,80 +5,17 @@
 /**
  * SECTION: event-data-tick
  * @Title: ALSATimerEventDataTick
- * @Short_description: A GObject-derived object to represent event of timer with
- *                     tick count
+ * @Short_description: A boxed object to represent event of timer with tick
+ *                     count
  *
- * A #ALSATimerEventDataTick is a GObject-derived object to represent event of
- * timer with tick count. The instance of object is passed to handler for
- * 'handle-event' GObject signal in ALSATimerUserInstance when it's available.
- * The object inherits properties of #ALSATimerEventData.
+ * A #ALSATimerEventDataTick is a boxed object to represent event of timer with
+ * tick count.
  *
  * The object wraps 'struct snd_timer_read' in UAPI of Linux sound subsystem.
  */
-struct _ALSATimerEventDataTickPrivate {
-    struct snd_timer_read event;
-};
-G_DEFINE_TYPE_WITH_PRIVATE(ALSATimerEventDataTick, alsatimer_event_data_tick, ALSATIMER_TYPE_EVENT_DATA)
-
-enum timer_event_data_tick_prop_type{
-    TIMER_EVENT_DATA_TICK_PROP_RESOLUTION = 1,
-    TIMER_EVENT_DATA_TICK_PROP_TICKS,
-    TIMER_EVENT_DATA_TICK_PROP_COUNT,
-};
-static GParamSpec *timer_event_data_tick_props[TIMER_EVENT_DATA_TICK_PROP_COUNT] = { NULL, };
-
-static void timer_event_data_tick_get_property(GObject *obj, guint id, GValue *val, GParamSpec *spec)
-{
-    ALSATimerEventDataTick *self = ALSATIMER_EVENT_DATA_TICK(obj);
-    ALSATimerEventDataTickPrivate *priv = alsatimer_event_data_tick_get_instance_private(self);
-
-    switch (id) {
-    case TIMER_EVENT_DATA_TICK_PROP_RESOLUTION:
-        g_value_set_uint(val, priv->event.resolution);
-        break;
-    case TIMER_EVENT_DATA_TICK_PROP_TICKS:
-        g_value_set_uint(val, priv->event.ticks);
-        break;
-    default:
-        G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, id, spec);
-        break;
-    }
-}
-
-static void alsatimer_event_data_tick_class_init(ALSATimerEventDataTickClass *klass)
-{
-    GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
-
-    gobject_class->get_property = timer_event_data_tick_get_property;
-
-    timer_event_data_tick_props[TIMER_EVENT_DATA_TICK_PROP_RESOLUTION] =
-        g_param_spec_uint("resolution", "resolution",
-                          "The resolution of tick.",
-                          0, G_MAXUINT,
-                          0,
-                          G_PARAM_READABLE);
-
-    timer_event_data_tick_props[TIMER_EVENT_DATA_TICK_PROP_TICKS] =
-        g_param_spec_uint("ticks", "ticks",
-                          "The ticks since the latest event.",
-                          0, G_MAXUINT,
-                          0,
-                          G_PARAM_READABLE);
-
-    g_object_class_install_properties(gobject_class, TIMER_EVENT_DATA_TICK_PROP_COUNT,
-                                      timer_event_data_tick_props);
-}
-
-static void alsatimer_event_data_tick_init(ALSATimerEventDataTick *self)
+ALSATimerEventDataTick *timer_event_data_tick_copy(const ALSATimerEventDataTick *self)
 {
-    return;
+    return g_memdup(self, sizeof(*self));
 }
 
-void timer_event_data_tick_set_data(ALSATimerEventDataTick *self,
-                                    struct snd_timer_read *data)
-{
-    ALSATimerEventDataTickPrivate *priv =
-                        alsatimer_event_data_tick_get_instance_private(self);
-
-    priv->event = *data;
-}
+G_DEFINE_BOXED_TYPE(ALSATimerEventDataTick, alsatimer_event_data_tick, timer_event_data_tick_copy, g_free)
index 4ff4a5f38a358c7c63b2613be9ec324d54425f83..d26c359d217f454d3b291c9324a9d298fe49786d 100644 (file)
@@ -5,45 +5,13 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include <timer/event-data.h>
+#include <sound/asound.h>
 
 G_BEGIN_DECLS
 
 #define ALSATIMER_TYPE_EVENT_DATA_TICK   (alsatimer_event_data_tick_get_type())
 
-#define ALSATIMER_EVENT_DATA_TICK(obj)                              \
-    (G_TYPE_CHECK_INSTANCE_CAST((obj),                              \
-                                ALSATIMER_TYPE_EVENT_DATA_TICK,     \
-                                ALSATimerEventDataTick))
-#define ALSATIMER_IS_EVENT_DATA_TICK(obj)                           \
-    (G_TYPE_CHECK_INSTANCE_TYPE((obj),                              \
-                                ALSATIMER_TYPE_EVENT_DATA_TICK))
-
-#define ALSATIMER_EVENT_DATA_TICK_CLASS(klass)                      \
-    (G_TYPE_CHECK_CLASS_CAST((klass),                               \
-                             ALSATIMER_TYPE_EVENT_DATA_TICK,        \
-                             ALSATimerEventDataTickClass))
-#define ALSATIMER_IS_EVENT_DATA_TICK_CLASS(klass)                   \
-    (G_TYPE_CHECK_CLASS_TYPE((klass),                               \
-                             ALSATIMER_TYPE_EVENT_DATA_TICK))
-#define ALSATIMER_EVENT_DATA_TICK_GET_CLASS(obj)                    \
-    (G_TYPE_INSTANCE_GET_CLASS((obj),                               \
-                               ALSATIMER_TYPE_EVENT_DATA_TICK,      \
-                               ALSATimerEventDataTickkClass))
-
-typedef struct _ALSATimerEventDataTick          ALSATimerEventDataTick;
-typedef struct _ALSATimerEventDataTickClass     ALSATimerEventDataTickClass;
-typedef struct _ALSATimerEventDataTickPrivate   ALSATimerEventDataTickPrivate;
-
-struct _ALSATimerEventDataTick {
-    ALSATimerEventData parent_instance;
-
-    ALSATimerEventDataTickPrivate *priv;
-};
-
-struct _ALSATimerEventDataTickClass {
-    ALSATimerEventDataClass parent_class;
-};
+typedef struct snd_timer_read ALSATimerEventDataTick;
 
 GType alsatimer_event_data_tick_get_type() G_GNUC_CONST;
 
index 169db79cb3203ebdf7bf71a319995b442336ec65..d550987dcac0909ed2c0cc0212085b07019da6f5 100644 (file)
@@ -5,14 +5,14 @@
 #include <glib.h>
 #include <glib-object.h>
 
-#include <sound/asound.h>
+#include <timer/event-data-tick.h>
 
 G_BEGIN_DECLS
 
 #define ALSATIMER_TYPE_EVENT    (alsatimer_event_get_type())
 
 typedef union {
-    struct snd_timer_read tick;
+    ALSATimerEventDataTick tick;
     struct snd_timer_tread timestamp;
 } ALSATimerEvent;
 
index 90c770f0cbf8404dceefaa60294ced7e3532c2b6..0c03e7291a67ad91fd44a5f1ff52bb1d4f355d88 100644 (file)
@@ -8,7 +8,6 @@
 #include "instance-info.h"
 #include "instance-params.h"
 #include "instance-status.h"
-#include "event-data-tick.h"
 #include "event-data-timestamp.h"
 
 #include <sound/asound.h>
@@ -39,9 +38,6 @@ void timer_instance_params_refer_private(ALSATimerInstanceParams *self,
 void timer_instance_status_refer_private(ALSATimerInstanceStatus *self,
                                          struct snd_timer_status **status);
 
-void timer_event_data_tick_set_data(ALSATimerEventDataTick *self,
-                                    struct snd_timer_read *data);
-
 void timer_event_data_timestamp_set_data(ALSATimerEventDataTimestamp *self,
                                          struct snd_timer_tread *data);
 
diff --git a/tests/alsatimer-event-data-tick b/tests/alsatimer-event-data-tick
deleted file mode 100644 (file)
index 1a73f55..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env python3
-
-from sys import exit
-from errno import ENXIO
-
-from helper import test
-
-import gi
-gi.require_version('ALSATimer', '0.0')
-from gi.repository import ALSATimer
-
-target = ALSATimer.EventDataTick()
-props = (
-    'resolution',
-    'ticks',
-)
-methods = ()
-signals = ()
-
-if not test(target, props, methods, signals):
-    exit(ENXIO)
index c8b5e5b809ca2088bfb55fccb217069925ff2bbe..25406036b849c8172af2cf599cfa340c6a95c7be 100644 (file)
@@ -25,7 +25,6 @@ tests = {
     'alsatimer-instance-params',
     'alsatimer-instance-status',
     'alsatimer-event-data',
-    'alsatimer-event-data-tick',
     'alsatimer-event-data-timestamp',
   ],
   'seq': [