]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: add an API to get information of instance
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/instance-info.c
src/timer/privates.h
src/timer/user-instance.c
src/timer/user-instance.h
tests/alsatimer-user-instance

index 9b0234a94677a5f5e478b1927c8ded46658a24fe..ee3ac32d63f50df88ff3e1203492c7843ca161dc 100644 (file)
@@ -32,6 +32,7 @@ ALSA_GOBJECT_0_0_0 {
     "alsatimer_user_instance_open";
     "alsatimer_user_instance_attach";
     "alsatimer_user_instance_attach_as_slave";
+    "alsatimer_user_instance_get_info";
 
     "alsatimer_instance_info_get_type";
   local:
index 61fbce12ec5110087535842ff6b63966ac19c1e9..c1cc9603f0479206c17d6b6eb16b38d77cd62e7f 100644 (file)
@@ -1,7 +1,5 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
-#include "instance-info.h"
-
-#include <sound/asound.h>
+#include "privates.h"
 
 struct _ALSATimerInstanceInfoPrivate {
     struct snd_timer_info info;
@@ -95,3 +93,12 @@ static void alsatimer_instance_info_init(ALSATimerInstanceInfo *self)
 {
     return;
 }
+
+void timer_instance_info_refer_private(ALSATimerInstanceInfo *self,
+                                     struct snd_timer_info **info)
+{
+    ALSATimerInstanceInfoPrivate *priv =
+                            alsatimer_instance_info_get_instance_private(self);
+
+    *info = &priv->info;
+}
index 552791490d1ed862225c49c6bb4c3ebfc826022c..e41770c2fae85dfb43a38fd53c8267e2022bb528 100644 (file)
@@ -5,6 +5,7 @@
 #include "device-info.h"
 #include "device-status.h"
 #include "device-params.h"
+#include "instance-info.h"
 
 #include <sound/asound.h>
 
@@ -25,6 +26,9 @@ void timer_device_status_refer_private(ALSATimerDeviceStatus *self,
 void timer_device_params_refer_private(ALSATimerDeviceParams *self,
                                        struct snd_timer_gparams **params);
 
+void timer_instance_info_refer_private(ALSATimerInstanceInfo *self,
+                                       struct snd_timer_info **info);
+
 G_END_DECLS
 
 #endif
index c5b8cbb6e4fe7534e43ce320bf6ebc188509148b..4f8d963ca641fa3d7a3a4d7caddae9d1c4fdf6be 100644 (file)
@@ -129,3 +129,30 @@ void alsatimer_user_instance_attach_as_slave(ALSATimerUserInstance *self,
     if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_SELECT, &sel) < 0)
         generate_error(error, errno);
 }
+
+/**
+ * alsatimer_user_instance_get_info:
+ * @self: A #ALSATimerUserInstance.
+ * @instance_info: (out): A #ALSATimerInstanceInfo.
+ * @error: A #GError.
+ *
+ * Return the information of device if attached to the instance.
+ */
+void alsatimer_user_instance_get_info(ALSATimerUserInstance *self,
+                                      ALSATimerInstanceInfo **instance_info,
+                                      GError **error)
+{
+    ALSATimerUserInstancePrivate *priv;
+    struct snd_timer_info *info;
+
+    g_return_if_fail(ALSATIMER_IS_USER_INSTANCE(self));
+    priv = alsatimer_user_instance_get_instance_private(self);
+
+    *instance_info = g_object_new(ALSATIMER_TYPE_INSTANCE_INFO, NULL);
+    timer_instance_info_refer_private(*instance_info, &info);
+
+    if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_INFO, info) < 0) {
+        generate_error(error, errno);
+        g_object_unref(*instance_info);
+    }
+}
index 0b0fb8ee0b85268db4786348c7ca3a6f1536b276..9ace1502a5c2cc0d2eb92c7eeaa716a05d153bf4 100644 (file)
@@ -6,6 +6,7 @@
 #include <glib-object.h>
 
 #include <timer/device-id.h>
+#include <timer/instance-info.h>
 
 G_BEGIN_DECLS
 
@@ -60,6 +61,10 @@ void alsatimer_user_instance_attach_as_slave(ALSATimerUserInstance *self,
                                         int slave_id,
                                         GError **error);
 
+void alsatimer_user_instance_get_info(ALSATimerUserInstance *self,
+                                      ALSATimerInstanceInfo **instance_info,
+                                      GError **error);
+
 G_END_DECLS
 
 #endif
index 39a5656bb068aac24fa81724d8cf905558c04e3d..a16e703a79cca77f17e8cbf1acc40f96ba60b92b 100644 (file)
@@ -16,6 +16,7 @@ methods = (
     'open',
     'attach',
     'attach_as_slave',
+    'get_info',
 )
 signals = ()