OSDN Git Service

Added missing functions. Removed unused one
authorAbramo Bagnara <abramo@alsa-project.org>
Mon, 28 Aug 2000 09:14:37 +0000 (09:14 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Mon, 28 Aug 2000 09:14:37 +0000 (09:14 +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 a4b2d36..7750d9c 100644 (file)
@@ -136,6 +136,8 @@ int snd_pcm_info(snd_pcm_t *handle, snd_pcm_info_t *info);
 int snd_pcm_params_info(snd_pcm_t *handle, snd_pcm_params_info_t *info);
 int snd_pcm_params(snd_pcm_t *handle, snd_pcm_params_t *params);
 int snd_pcm_setup(snd_pcm_t *handle, snd_pcm_setup_t *setup);
+int snd_pcm_channel_info(snd_pcm_t *handle, snd_pcm_channel_info_t *info);
+int snd_pcm_channel_params(snd_pcm_t *handle, snd_pcm_channel_params_t *params);
 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);
index ef167b2..d37a425 100644 (file)
@@ -107,6 +107,18 @@ int snd_pcm_setup(snd_pcm_t *handle, snd_pcm_setup_t *setup)
        return 0;
 }
 
+int snd_pcm_channel_info(snd_pcm_t *handle, snd_pcm_channel_info_t *info)
+{
+       assert(handle && info);
+       return handle->fast_ops->channel_info(handle->fast_op_arg, info);
+}
+
+int snd_pcm_channel_params(snd_pcm_t *handle, snd_pcm_channel_params_t *params)
+{
+       assert(handle && params);
+       return handle->fast_ops->channel_params(handle->fast_op_arg, params);
+}
+
 int snd_pcm_channel_setup(snd_pcm_t *handle, snd_pcm_channel_setup_t *setup)
 {
        assert(handle && setup);
@@ -161,52 +173,6 @@ int snd_pcm_go(snd_pcm_t *handle)
        return handle->fast_ops->go(handle->fast_op_arg);
 }
 
-#if 0
-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;
-       int ret;
-       assert(reqs_count > 0 && reqs);
-       sync_reqs = __builtin_alloca(sizeof(*sync_reqs) * reqs_count);
-       switch (cmd) {
-       case SND_PCM_SYNCHRO_GO:
-               sync.cmd = SND_PCM_IOCTL_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)
-               ret = -errno;
-       else
-               ret = 0;
-       for (k = 0; k < reqs_count; ++k) {
-               reqs[k].tstamp = sync_reqs[k].tstamp;
-               reqs[k].result = sync_reqs[k].result;
-       }
-       return ret;
-}
-#endif
-
 int snd_pcm_drain(snd_pcm_t *handle)
 {
        assert(handle);
index 80f7fad..f0b80bb 100644 (file)
@@ -103,6 +103,24 @@ static int snd_pcm_hw_setup(void *private, snd_pcm_setup_t * setup)
        return 0;
 }
 
+static int snd_pcm_hw_channel_info(void *private, snd_pcm_channel_info_t * info)
+{
+       snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
+       int fd = hw->fd;
+       if (ioctl(fd, SND_PCM_IOCTL_CHANNEL_INFO, info) < 0)
+               return -errno;
+       return 0;
+}
+
+static int snd_pcm_hw_channel_params(void *private, snd_pcm_channel_params_t * params)
+{
+       snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
+       int fd = hw->fd;
+       if (ioctl(fd, SND_PCM_IOCTL_CHANNEL_PARAMS, params) < 0)
+               return -errno;
+       return 0;
+}
+
 static int snd_pcm_hw_channel_setup(void *private, snd_pcm_channel_setup_t * setup)
 {
        snd_pcm_hw_t *hw = (snd_pcm_hw_t*) private;
@@ -369,6 +387,8 @@ struct snd_pcm_ops snd_pcm_hw_ops = {
 
 struct snd_pcm_fast_ops snd_pcm_hw_fast_ops = {
        nonblock: snd_pcm_hw_nonblock,
+       channel_info: snd_pcm_hw_channel_info,
+       channel_params: snd_pcm_hw_channel_params,
        channel_setup: snd_pcm_hw_channel_setup,
        status: snd_pcm_hw_status,
        frame_io: snd_pcm_hw_frame_io,
index e432764..3ab5d8e 100644 (file)
@@ -34,6 +34,8 @@ struct snd_pcm_ops {
 struct snd_pcm_fast_ops {
        int (*nonblock)(void *private, int nonblock);
        int (*status)(void *private, snd_pcm_status_t *status);
+       int (*channel_info)(void *private, snd_pcm_channel_info_t *info);
+       int (*channel_params)(void *private, snd_pcm_channel_params_t *params);
        int (*channel_setup)(void *private, snd_pcm_channel_setup_t *setup);
        int (*prepare)(void *private);
        int (*go)(void *private);
index 7255dd9..6a84dd8 100644 (file)
@@ -313,6 +313,42 @@ static int snd_pcm_multi_pause(void *private, int enable)
        return snd_pcm_pause(multi->slaves[0].handle, enable);
 }
 
+static int snd_pcm_multi_channel_info(void *private, snd_pcm_channel_info_t *info)
+{
+       int err;
+       snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
+       unsigned int channel = info->channel;
+       unsigned int i;
+       for (i = 0; i < multi->bindings_count; ++i) {
+               if (multi->bindings[i].client_channel == channel) {
+                       info->channel = multi->bindings[i].slave_channel;
+                       err = snd_pcm_channel_info(multi->slaves[multi->bindings[i].slave].handle, info);
+                       info->channel = channel;
+                       return err;
+               }
+       }
+       info->channel = channel;
+       return -EINVAL;
+}
+
+static int snd_pcm_multi_channel_params(void *private, snd_pcm_channel_params_t *params)
+{
+       int err;
+       snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
+       unsigned int channel = params->channel;
+       unsigned int i;
+       for (i = 0; i < multi->bindings_count; ++i) {
+               if (multi->bindings[i].client_channel == channel) {
+                       params->channel = multi->bindings[i].slave_channel;
+                       err = snd_pcm_channel_params(multi->slaves[multi->bindings[i].slave].handle, params);
+                       params->channel = channel;
+                       return err;
+               }
+       }
+       params->channel = channel;
+       return -EINVAL;
+}
+
 static int snd_pcm_multi_channel_setup(void *private, snd_pcm_channel_setup_t *setup)
 {
        int err;
@@ -699,6 +735,8 @@ struct snd_pcm_ops snd_pcm_multi_ops = {
 
 struct snd_pcm_fast_ops snd_pcm_multi_fast_ops = {
        nonblock: snd_pcm_multi_nonblock,
+       channel_info: snd_pcm_multi_channel_info,
+       channel_params: snd_pcm_multi_channel_params,
        channel_setup: snd_pcm_multi_channel_setup,
        status: snd_pcm_multi_status,
        frame_io: snd_pcm_multi_frame_io,
index 862220b..a7d03e1 100644 (file)
@@ -377,10 +377,25 @@ static int snd_pcm_plug_pause(void *private, int enable)
        return 0;
 }
 
+static int snd_pcm_plug_channel_info(void *private ATTRIBUTE_UNUSED, snd_pcm_channel_info_t *info ATTRIBUTE_UNUSED)
+{
+       /* FIXME: if route plugin is not inserted or its ttable is trivial
+          this should be implemented */
+       return -ENOSYS;
+}
+
+static int snd_pcm_plug_channel_params(void *private ATTRIBUTE_UNUSED, snd_pcm_channel_params_t *params ATTRIBUTE_UNUSED)
+{
+       /* FIXME: if route plugin is not inserted or its ttable is trivial
+          this should be implemented */
+       return -ENOSYS;
+}
+
 static int snd_pcm_plug_channel_setup(void *private ATTRIBUTE_UNUSED, snd_pcm_channel_setup_t *setup ATTRIBUTE_UNUSED)
 {
-       /* FIXME: non mmap setups */
-       return -ENXIO;
+       /* FIXME: if route plugin is not inserted or its ttable is trivial
+          this should be implemented for non mmap setups */
+       return -ENOSYS;
 }
 
 static ssize_t snd_pcm_plug_frame_data(void *private, off_t offset)
@@ -642,6 +657,8 @@ struct snd_pcm_ops snd_pcm_plug_ops = {
 
 struct snd_pcm_fast_ops snd_pcm_plug_fast_ops = {
        nonblock: snd_pcm_plug_nonblock,
+       channel_info: snd_pcm_plug_channel_info,
+       channel_params: snd_pcm_plug_channel_params,
        channel_setup: snd_pcm_plug_channel_setup,
        status: snd_pcm_plug_status,
        frame_io: snd_pcm_plug_frame_io,