]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Moved mmap_size to setup struct
authorAbramo Bagnara <abramo@alsa-project.org>
Thu, 29 Jun 2000 09:20:27 +0000 (09:20 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Thu, 29 Jun 2000 09:20:27 +0000 (09:20 +0000)
src/pcm/pcm_local.h
src/pcm/pcm_mmap.c
src/pcm/pcm_multi.c
src/pcm/pcm_plug.c

index 9968927ec100c97c05a5aba9f81096a309b96c67..5055d6d1c736be71a608d626c87c8c7871aa10a4 100644 (file)
@@ -65,7 +65,6 @@ struct snd_pcm {
        snd_pcm_mmap_status_t *mmap_status;
        snd_pcm_mmap_control_t *mmap_control;
        char *mmap_data;
-       size_t mmap_data_size;
        enum { _INTERLEAVED, _NONINTERLEAVED, _COMPLEX } mmap_type;
        struct snd_pcm_ops *ops;
        void *op_arg;
index 8304975f6f9c233334b015b4056c13c89d1f0485..bdac8a6b8ea5db4dba60de396998b49959b17c0e 100644 (file)
@@ -507,8 +507,6 @@ int snd_pcm_mmap_get_areas(snd_pcm_t *handle, snd_pcm_channel_area_t *areas)
 
 int snd_pcm_mmap_data(snd_pcm_t *handle, void **data)
 {
-       snd_pcm_info_t info;
-       size_t bsize;
        int err;
        assert(handle);
        assert(handle->valid_setup);
@@ -518,17 +516,12 @@ int snd_pcm_mmap_data(snd_pcm_t *handle, void **data)
                return 0;
        }
 
-       err = snd_pcm_info(handle, &info);
-       if (err < 0)
-               return err;
-       bsize = info.mmap_size;
-       if (!(info.flags & SND_PCM_INFO_MMAP))
+       if (handle->setup.mmap_size == 0)
                return -ENXIO;
-       if ((err = handle->ops->mmap_data(handle->op_arg, (void**)&handle->mmap_data, bsize)) < 0)
+       if ((err = handle->ops->mmap_data(handle->op_arg, (void**)&handle->mmap_data, handle->setup.mmap_size)) < 0)
                return err;
        if (data) 
                *data = handle->mmap_data;
-       handle->mmap_data_size = bsize;
        err = snd_pcm_mmap_get_areas(handle, NULL);
        if (err < 0)
                return err;
@@ -582,12 +575,11 @@ int snd_pcm_munmap_data(snd_pcm_t *handle)
        int err;
        assert(handle);
        assert(handle->mmap_data);
-       if ((err = handle->ops->munmap_data(handle->op_arg, handle->mmap_data, handle->mmap_data_size)) < 0)
+       if ((err = handle->ops->munmap_data(handle->op_arg, handle->mmap_data, handle->setup.mmap_size)) < 0)
                return err;
        free(handle->channels);
        handle->channels = 0;
        handle->mmap_data = 0;
-       handle->mmap_data_size = 0;
        return 0;
 }
 
index 87469a2976c880c35ab2679040f6defb75f075d8..6b95a093e64119d11197820ae603cfb6a2d38dcb 100644 (file)
@@ -97,7 +97,6 @@ static int snd_pcm_multi_info(void *private, snd_pcm_info_t *info)
        err = snd_pcm_info(handle_0, info);
        if (err < 0)
                return err;
-       info->mmap_size = 0;
        info->buffer_size /= channels0;
        info->min_fragment_size /= channels0;
        info->max_fragment_size /= channels0;
@@ -239,6 +238,8 @@ static int snd_pcm_multi_setup(void *private, snd_pcm_setup_t *setup)
                        }
                }
        }
+       /* Loaded with a value != 0 if mmap is feasible */
+       setup->mmap_size = !multi->one_to_many;
        return 0;
 }
 
@@ -429,19 +430,19 @@ ssize_t snd_pcm_multi_write(void *private, const void *buf, size_t count)
 ssize_t snd_pcm_multi_read(void *private, void *buf, size_t count)
 {
        snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
-       return count;
+       return -ENOSYS;
 }
 
 ssize_t snd_pcm_multi_writev(void *private, const struct iovec *vector, unsigned long count)
 {
        snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
-       return count;
+       return -ENOSYS;
 }
 
 ssize_t snd_pcm_multi_readv(void *private, const struct iovec *vector, unsigned long count)
 {
        snd_pcm_multi_t *multi = (snd_pcm_multi_t*) private;
-       return count;
+       return -ENOSYS;
 }
 
 static int snd_pcm_multi_mmap_status(void *private, snd_pcm_mmap_status_t **status)
index d4e9a4faf09476fd21931459b72d36b410984ff7..8605402b56665698532cf93d4594644c0c39919b 100644 (file)
@@ -139,7 +139,6 @@ static int snd_pcm_plug_info(void *private, snd_pcm_info_t *info)
                info->fifo_size = snd_pcm_plug_client_size(plug, info->fifo_size);
                info->transfer_block_size = snd_pcm_plug_client_size(plug, info->transfer_block_size);
        }
-       info->mmap_size = 0;
        info->flags &= ~(SND_PCM_INFO_MMAP | SND_PCM_INFO_MMAP_VALID);
        return 0;
 }
@@ -177,7 +176,7 @@ static int snd_pcm_plug_setup(void *private, snd_pcm_setup_t *setup)
        setup->frames_align = snd_pcm_plug_client_size(plug, setup->frames_align);
        setup->frames_xrun_max = snd_pcm_plug_client_size(plug, setup->frames_xrun_max);
        setup->frames_fill_max = snd_pcm_plug_client_size(plug, setup->frames_fill_max);
-
+       setup->mmap_size = 0;
        if (plug->handle->stream == SND_PCM_STREAM_PLAYBACK)
                setup->format = plug->first->src_format;
        else