]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Implemented generic sync requests
authorAbramo Bagnara <abramo@alsa-project.org>
Tue, 4 Jul 2000 19:29:16 +0000 (19:29 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Tue, 4 Jul 2000 19:29:16 +0000 (19:29 +0000)
include/pcm.h
src/pcm/pcm.c
src/pcm/pcm_hw.c
src/pcm/pcm_local.h
src/pcm/pcm_multi.c
src/pcm/pcm_plug.c

index 9369f39e34c8a328d231e8fb40042a5a4be02060..637cda2a20645328fc219ba1411262a7c432e0f0 100644 (file)
@@ -100,6 +100,23 @@ typedef struct snd_pcm_loopback snd_pcm_loopback_t;
 
 typedef enum { SND_PCM_TYPE_HW, SND_PCM_TYPE_PLUG, SND_PCM_TYPE_MULTI } snd_pcm_type_t;
 
+typedef struct {
+       snd_pcm_t *handle;
+       snd_timestamp_t tstamp;
+       int result;
+       union {
+               char reserved[256];
+       } arg;
+} snd_pcm_synchro_request_t;
+
+typedef enum { SND_PCM_SYNCHRO_GO } snd_pcm_synchro_cmd_t;
+
+#define snd_pcm_synchro_mode_t snd_pcm_sync_mode_t
+#define SND_PCM_SYNCHRO_MODE_NORMAL SND_PCM_SYNC_MODE_NORMAL
+#define SND_PCM_SYNCHRO_MODE_HARDWARE SND_PCM_SYNC_MODE_HARDWARE
+#define SND_PCM_SYNCHRO_MODE_RELAXED SND_PCM_SYNC_MODE_RELAXED
+
+
 int snd_pcm_hw_open_subdevice(snd_pcm_t **handle, int card, int device, int subdevice, int stream, int mode);
 int snd_pcm_hw_open(snd_pcm_t **handle, int card, int device, int stream, int mode);
 
@@ -115,7 +132,9 @@ int snd_pcm_channel_setup(snd_pcm_t *handle, snd_pcm_channel_setup_t *setup);
 int snd_pcm_status(snd_pcm_t *handle, snd_pcm_status_t *status);
 int snd_pcm_prepare(snd_pcm_t *handle);
 int snd_pcm_go(snd_pcm_t *handle);
-int snd_pcm_sync_go(snd_pcm_t *handle, snd_pcm_sync_t *sync);
+int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd, 
+                   unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
+                   snd_pcm_synchro_mode_t mode);
 int snd_pcm_drain(snd_pcm_t *handle);
 int snd_pcm_flush(snd_pcm_t *handle);
 int snd_pcm_pause(snd_pcm_t *handle, int enable);
index 39dac4f623099a1462db223d5cfd25cfbb22a9d9..9a4b80f7a38abbdfd0c421d8448e2fcdaa6f64d2 100644 (file)
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <malloc.h>
 #include <errno.h>
+#include <sys/ioctl.h>
 #include <sys/poll.h>
 #include <sys/uio.h>
 #include "pcm_local.h"
@@ -167,12 +168,43 @@ int snd_pcm_go(snd_pcm_t *handle)
        return handle->ops->go(handle->op_arg);
 }
 
-int snd_pcm_sync_go(snd_pcm_t *handle, snd_pcm_sync_t *sync)
-{
-       assert(handle);
-       return handle->ops->sync_go(handle->op_arg, sync);
+int snd_pcm_synchro(snd_pcm_synchro_cmd_t cmd, 
+                   unsigned int reqs_count, snd_pcm_synchro_request_t *reqs,
+                   snd_pcm_synchro_mode_t mode)
+{
+       snd_pcm_sync_request_t *sync_reqs;
+       snd_pcm_sync_t sync;
+       unsigned int k;
+       assert(reqs_count > 0 && reqs);
+       sync_reqs = __builtin_alloca(sizeof(*sync_reqs) * reqs_count);
+       switch (cmd) {
+       case SND_PCM_SYNCHRO_GO:
+               break;
+       default:
+               assert(0);
+               return -EINVAL;
+       }
+       sync.mode = mode;
+       sync.requests_count = reqs_count;
+       sync.requests = sync_reqs;
+       for (k = 0; k < reqs_count; ++k) {
+               switch (snd_pcm_type(reqs[k].handle)) {
+               case SND_PCM_TYPE_HW:
+               case SND_PCM_TYPE_PLUG:
+                       sync_reqs[k].fd = snd_pcm_file_descriptor(reqs[k].handle);
+                       break;
+               default:
+                       /* Not yet implemented */
+                       assert(0);
+                       return -ENOSYS;
+               }
+       }
+       if (ioctl(sync_reqs[0].fd, SND_PCM_IOCTL_SYNC, &sync) < 0)
+               return -errno;
+       return 0;
 }
 
+
 int snd_pcm_drain(snd_pcm_t *handle)
 {
        assert(handle);
index ac375ad21a5466ebbe5e98d7b472675dadcedfb4..f6d8eae08a8821b84bb34790e95bc0e9b1967f76 100644 (file)
@@ -158,15 +158,6 @@ static int snd_pcm_hw_go(void *private)
        return 0;
 }
 
-static int snd_pcm_hw_sync_go(void *private, snd_pcm_sync_t *sync)
-{
-       snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
-       int fd = hw->fd;
-       if (ioctl(fd, SND_PCM_IOCTL_SYNC_GO, sync) < 0)
-               return -errno;
-       return 0;
-}
-
 static int snd_pcm_hw_drain(void *private)
 {
        snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
@@ -352,7 +343,6 @@ struct snd_pcm_ops snd_pcm_hw_ops = {
        state: snd_pcm_hw_state,
        prepare: snd_pcm_hw_prepare,
        go: snd_pcm_hw_go,
-       sync_go: snd_pcm_hw_sync_go,
        drain: snd_pcm_hw_drain,
        flush: snd_pcm_hw_flush,
        pause: snd_pcm_hw_pause,
index 75891ddf116f5378c782698e855169674bc5c2ca..65743a9eca7c03b19fa75cfd4ee9e15b9e2e02e6 100644 (file)
@@ -33,7 +33,6 @@ struct snd_pcm_ops {
        int (*status)(void *private, snd_pcm_status_t *status);
        int (*prepare)(void *private);
        int (*go)(void *private);
-       int (*sync_go)(void *private, snd_pcm_sync_t *sync);
        int (*drain)(void *private);
        int (*flush)(void *private);
        int (*pause)(void *private, int enable);
index 2ee152921d818ab3f9415318e82e6f717aa87491..6dfb62ab74f1576d2f8b41fe474e5b9add67a2aa 100644 (file)
@@ -292,19 +292,6 @@ static int snd_pcm_multi_go(void *private)
        return 0;
 }
 
-static int snd_pcm_multi_sync_go(void *private, snd_pcm_sync_t *sync)
-{
-       snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
-       unsigned int i;
-       for (i = 0; i < multi->slaves_count; ++i) {
-               snd_pcm_t *handle = multi->slaves[i].handle;
-               int err = snd_pcm_sync_go(handle, sync);
-               if (err < 0)
-                       return err;
-       }
-       return 0;
-}
-
 static int snd_pcm_multi_drain(void *private)
 {
        snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
@@ -603,7 +590,6 @@ struct snd_pcm_ops snd_pcm_multi_ops = {
        state: snd_pcm_multi_state,
        prepare: snd_pcm_multi_prepare,
        go: snd_pcm_multi_go,
-       sync_go: snd_pcm_multi_sync_go,
        drain: snd_pcm_multi_drain,
        flush: snd_pcm_multi_flush,
        pause: snd_pcm_multi_pause,
index 56378ea17854acde6b35c170047856bc69ce64fa..97b7a4925b00602bbd66bffad63eb2e4031308b7 100644 (file)
@@ -309,12 +309,6 @@ static int snd_pcm_plug_go(void *private)
        return snd_pcm_go(plug->slave);
 }
 
-static int snd_pcm_plug_sync_go(void *private, snd_pcm_sync_t *sync)
-{
-       snd_pcm_plug_t *plug = (snd_pcm_plug_t*) private;
-       return snd_pcm_sync_go(plug->slave, sync);
-}
-
 static int snd_pcm_plug_drain(void *private)
 {
        snd_pcm_plug_t *plug = (snd_pcm_plug_t*) private;
@@ -592,7 +586,6 @@ struct snd_pcm_ops snd_pcm_plug_ops = {
        state: snd_pcm_plug_state,
        prepare: snd_pcm_plug_prepare,
        go: snd_pcm_plug_go,
-       sync_go: snd_pcm_plug_sync_go,
        drain: snd_pcm_plug_drain,
        flush: snd_pcm_plug_flush,
        pause: snd_pcm_plug_pause,