]> git.alsa-project.org Git - alsa-gobject.git/commitdiff
timer: user_instance: add an API to attach user instance to another instance as slave
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/user-instance.c
src/timer/user-instance.h
tests/alsatimer-user-instance

index 5d2143d57342a85a6ee62efa4afd896efde5946b..c5b8cbb6e4fe7534e43ce320bf6ebc188509148b 100644 (file)
@@ -96,3 +96,36 @@ void alsatimer_user_instance_attach(ALSATimerUserInstance *self,
     if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_SELECT, &sel) < 0)
         generate_error(error, errno);
 }
+
+/**
+ * alsatimer_user_instance_attach_as_slave:
+ * @self: A #ALSATimerUserInstance.
+ * @slave_class: The class identifier of master instance, one of
+ *               #ALSATimerSlaveClass.
+ * @slave_id: The numerical identifier of master instance.
+ * @error: A #GError.
+ *
+ * Attach the instance to timer device as an slave to another instance indicated
+ * by a pair of slave_class and slave_id. If the slave_class is for application
+ * (=ALSATIMER_SLAVE_CLASS_APPLICATION), the slave_id is for the PID of
+ * application process which owns the instance of timer. If the slave_class is
+ * for ALSA sequencer (=ALSATIMER_SLAVE_CLASS_SEQUENCER), the slave_id is the
+ * numerical ID of queue bound for timer device.
+ */
+void alsatimer_user_instance_attach_as_slave(ALSATimerUserInstance *self,
+                                        ALSATimerSlaveClass slave_class,
+                                        int slave_id,
+                                        GError **error)
+{
+    ALSATimerUserInstancePrivate *priv;
+    struct snd_timer_select sel = {0};
+
+    g_return_if_fail(ALSATIMER_IS_USER_INSTANCE(self));
+    priv = alsatimer_user_instance_get_instance_private(self);
+
+    sel.id.dev_class = SNDRV_TIMER_CLASS_SLAVE;
+    sel.id.dev_sclass = slave_class;
+    sel.id.device = slave_id;
+    if (ioctl(priv->fd, SNDRV_TIMER_IOCTL_SELECT, &sel) < 0)
+        generate_error(error, errno);
+}
index 004135082a5f1110e51d878ddc9f5bc7c7252c8d..0b0fb8ee0b85268db4786348c7ca3a6f1536b276 100644 (file)
@@ -55,6 +55,11 @@ void alsatimer_user_instance_attach(ALSATimerUserInstance *self,
                                     ALSATimerDeviceId *device_id,
                                     GError **error);
 
+void alsatimer_user_instance_attach_as_slave(ALSATimerUserInstance *self,
+                                        ALSATimerSlaveClass slave_class,
+                                        int slave_id,
+                                        GError **error);
+
 G_END_DECLS
 
 #endif
index 5e7c1a5b08602bfd79dab9f5287309d6c5a5d5db..39a5656bb068aac24fa81724d8cf905558c04e3d 100644 (file)
@@ -15,6 +15,7 @@ methods = (
     'new',
     'open',
     'attach',
+    'attach_as_slave',
 )
 signals = ()