]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: device_id: add accessor methods and constructors
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 9 Feb 2020 03:20:53 +0000 (12:20 +0900)
committer坂本 貴史 <o-takashi@sakamocchi.jp>
Tue, 11 Feb 2020 04:28:18 +0000 (13:28 +0900)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
src/timer/alsatimer.map
src/timer/device-id.c
src/timer/device-id.h
tests/alsatimer-device-id [new file with mode: 0644]

index 5ecf1fb2a076ac7d8930ca569d68519e5b1e0a73..6d9dcb2821344fa6ae62c510d3146ff4dcae4192 100644 (file)
@@ -11,6 +11,11 @@ ALSA_GOBJECT_0_0_0 {
     "alsatimer_get_devnode";
 
     "alsatimer_device_id_get_type";
+    "alsatimer_device_id_new";
+    "alsatimer_device_id_get_class";
+    "alsatimer_device_id_get_card_id";
+    "alsatimer_device_id_get_device_id";
+    "alsatimer_device_id_get_subdevice_id";
   local:
     *;
 };
index e9238a0adb8cc96f32e1d324c339cccab59e65f9..65793e46bdfc5b9446607c0ef76603d9b80b0f91 100644 (file)
@@ -7,3 +7,80 @@ ALSATimerDeviceId *timer_device_id_copy(const ALSATimerDeviceId *self)
 }
 
 G_DEFINE_BOXED_TYPE(ALSATimerDeviceId, alsatimer_device_id, timer_device_id_copy, g_free)
+
+/**
+ * alsatimer_device_id_new:
+ * @class: The class of device, one of #ALSATImerClass.
+ * @card_id: The numerical ID of relevant sound card.
+ * @device_id: The numerical ID of relevant device.
+ * @subdevice_id: The numerical ID of relevant subdevice.
+ *
+ * Allocate and return an instance of ALSATimerDeviceId.
+ *
+ * Returns: (transfer full): A #ALSATimerDeviceId.
+ */
+ALSATimerDeviceId *alsatimer_device_id_new(ALSATimerClass class,
+                                           gint card_id, gint device_id,
+                                           gint subdevice_id)
+{
+    ALSATimerDeviceId *self = g_malloc0(sizeof(*self));
+
+    self->dev_class= class;
+    self->card = card_id;
+    self->device = device_id;
+    self->subdevice = subdevice_id;
+
+    return self;
+}
+
+/**
+ * alsatimer_device_id_get_class:
+ * @self: A #ALSATimerDeviceId.
+ * @class: (out): The class of timer, one of #ALSATimerClass.
+ *
+ * Get the class of timer.
+ */
+void alsatimer_device_id_get_class(const ALSATimerDeviceId *self,
+                                   ALSATimerClass *class)
+{
+    *class = self->dev_class;
+}
+
+/**
+ * alsatimer_device_id_get_card_id:
+ * @self: A #ALSATimerDeviceId.
+ * @card_id: (out): The numerical ID of sound card to which the timer belongs.
+ *
+ * Get the numerical ID of sound card to which the device belongs.
+ */
+void alsatimer_device_id_get_card_id(const ALSATimerDeviceId *self,
+                                     gint *card_id)
+{
+    *card_id = self->card;
+}
+
+/**
+ * alsatimer_device_id_get_device_id:
+ * @self: A #ALSATimerDeviceId.
+ * @device_id: (out): The numerical ID of device to which the timer belongs.
+ *
+ * Get the numerical ID of device to which the timer belongs.
+ */
+void alsatimer_device_id_get_device_id(const ALSATimerDeviceId *self,
+                                       gint *device_id)
+{
+    *device_id = self->device;
+}
+
+/**
+ * alsatimer_device_id_get_subdevice_id:
+ * @self: A #ALSATimerDeviceId.
+ * @subdevice_id: (out): The numerical ID of subdevice to which the timer belongs.
+ *
+ * Get the numerical ID of subdevice to which the timer belongs.
+ */
+void alsatimer_device_id_get_subdevice_id(const ALSATimerDeviceId *self,
+                                          gint *subdevice_id)
+{
+    *subdevice_id = self->subdevice;
+}
index 069d6208fce0cf966a116df47ffb917e22c83183..85f9f94862b84d9f37150094fe8dc9f41dc8ae1c 100644 (file)
@@ -5,6 +5,8 @@
 #include <glib.h>
 #include <glib-object.h>
 
+#include <timer/alsatimer-enums.h>
+
 #include <sound/asound.h>
 
 G_BEGIN_DECLS
@@ -15,6 +17,22 @@ typedef struct snd_timer_id ALSATimerDeviceId;
 
 GType alsatimer_device_id_get_type() G_GNUC_CONST;
 
+ALSATimerDeviceId *alsatimer_device_id_new(ALSATimerClass class,
+                                           gint card_id, gint device_id,
+                                           gint subdevice_id);
+
+void alsatimer_device_id_get_class(const ALSATimerDeviceId *self,
+                                   ALSATimerClass *class);
+
+void alsatimer_device_id_get_card_id(const ALSATimerDeviceId *self,
+                                     gint *card_id);
+
+void alsatimer_device_id_get_device_id(const ALSATimerDeviceId *self,
+                                       gint *device_id);
+
+void alsatimer_device_id_get_subdevice_id(const ALSATimerDeviceId *self,
+                                          gint *subdevice_id);
+
 G_END_DECLS
 
 #endif
diff --git a/tests/alsatimer-device-id b/tests/alsatimer-device-id
new file mode 100644 (file)
index 0000000..f5b1e25
--- /dev/null
@@ -0,0 +1,26 @@
+#!/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.DeviceId()
+props = (
+    'class',
+    'slave-class',
+    'card-id',
+    'device-id',
+    'subdevice-id',
+)
+methods = (
+    'new',
+)
+signals = ()
+
+if not test(target, props, methods, signals):
+    exit(ENXIO)