]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Added mmaped avail_min
authorAbramo Bagnara <abramo@alsa-project.org>
Mon, 16 Oct 2000 11:34:11 +0000 (11:34 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Mon, 16 Oct 2000 11:34:11 +0000 (11:34 +0000)
aserver/aserver.c
include/aserver.h
include/pcm.h
src/pcm/pcm.c
src/pcm/pcm_file.c
src/pcm/pcm_hw.c
src/pcm/pcm_local.h
src/pcm/pcm_multi.c
src/pcm/pcm_plugin.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c

index b334465bd48ee3bd37662150222fc9f49b345c90..a69fae3bca99769c627762c5123a7e21493579cc 100644 (file)
@@ -474,6 +474,9 @@ int pcm_shm_cmd(client_t *client)
                ctrl->result = snd_pcm_mmap_forward(pcm, ctrl->u.mmap_forward.frames);
                ctrl->appl_ptr = *pcm->appl_ptr;
                break;
+       case SND_PCM_IOCTL_SET_AVAIL_MIN:
+               ctrl->result = snd_pcm_set_avail_min(pcm, ctrl->u.set_avail_min.frames);
+               break;
        case SND_PCM_IOCTL_POLL_DESCRIPTOR:
                ctrl->result = 0;
                return shm_ack_fd(client, snd_pcm_poll_descriptor(pcm));
index 643c5684c51d74bc93a722113ebff25ad0beccca..3469b043753d6dd035b451621d8b48785b2e47d1 100644 (file)
@@ -30,6 +30,7 @@
 #define SND_PCM_IOCTL_CLOSE            _IO ('A', 0xfa)
 #define SND_PCM_IOCTL_MMAP_INFO                _IO ('A', 0xfb)
 #define SND_PCM_IOCTL_POLL_DESCRIPTOR  _IO ('A', 0xfc)
+#define SND_PCM_IOCTL_SET_AVAIL_MIN    _IO ('A', 0xfd)
 
 typedef struct {
        long result;
@@ -65,6 +66,9 @@ typedef struct {
                struct {
                        ssize_t frames;
                } mmap_forward;
+               struct {
+                       ssize_t frames;
+               } set_avail_min;
        } u;
        char data[0];
 } snd_pcm_shm_ctrl_t;
index 0b07f2b5eb648224e7a9fe982b9e7813986e98ea..364ec5c4853222dfef5ad276a444a61e8e7fa4a7 100644 (file)
@@ -169,6 +169,7 @@ int snd_pcm_unlink(snd_pcm_t *pcm);
 int snd_pcm_channels_mask(snd_pcm_t *pcm, bitset_t *cmask);
 int snd_pcm_wait(snd_pcm_t *pcm, int timeout);
 ssize_t snd_pcm_avail_update(snd_pcm_t *pcm);
+int snd_pcm_set_avail_min(snd_pcm_t *pcm, size_t size);
 
 
 /* mmap */
index d77a80670e012d223c6ee25585fc3a64efc979f5..49772a830ee5dde621f1c4f01ed92106eba94403 100644 (file)
@@ -222,6 +222,19 @@ ssize_t snd_pcm_rewind(snd_pcm_t *pcm, size_t frames)
        return pcm->fast_ops->rewind(pcm->fast_op_arg, frames);
 }
 
+int snd_pcm_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       int err;
+       assert(pcm);
+       assert(pcm->valid_setup);
+       assert(frames > 0 && frames < pcm->setup.buffer_size);
+       err = pcm->fast_ops->set_avail_min(pcm->fast_op_arg, frames);
+       if (err < 0)
+               return err;
+       pcm->setup.avail_min = frames;
+       return 0;
+}
+
 ssize_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, size_t size)
 {
        assert(pcm);
index 530f238e1dddb5a9cfa49c36da57263432393e5e..1f25bcfe40392f75ab0972a0814644b170dfdf52 100644 (file)
@@ -244,6 +244,12 @@ static ssize_t snd_pcm_file_avail_update(snd_pcm_t *pcm)
        return snd_pcm_avail_update(file->slave);
 }
 
+int snd_pcm_file_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_file_t *file = pcm->private;
+       return snd_pcm_set_avail_min(file->slave, frames);
+}
+
 static int snd_pcm_file_mmap(snd_pcm_t *pcm)
 {
        snd_pcm_file_t *file = pcm->private;
@@ -338,6 +344,7 @@ snd_pcm_fast_ops_t snd_pcm_file_fast_ops = {
        channels_mask: snd_pcm_file_channels_mask,
        avail_update: snd_pcm_file_avail_update,
        mmap_forward: snd_pcm_file_mmap_forward,
+       set_avail_min: snd_pcm_file_set_avail_min,
 };
 
 int snd_pcm_file_open(snd_pcm_t **pcmp, char *name, char *fname, int fd, snd_pcm_t *slave, int close_slave)
index 6a19e60467035ad74bb6fe5a80532ae3a8ef8c87..b6570d4ee124a99cbeb10de2b0f8f66925efe85d 100644 (file)
@@ -523,6 +523,13 @@ static ssize_t snd_pcm_hw_avail_update(snd_pcm_t *pcm)
        return avail;
 }
 
+static int snd_pcm_hw_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_hw_t *hw = pcm->private;
+       hw->mmap_control->avail_min = frames;
+       return 0;
+}
+
 static int snd_pcm_hw_channels_mask(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
                                    bitset_t *cmask ATTRIBUTE_UNUSED)
 {
@@ -576,6 +583,7 @@ snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = {
        channels_mask: snd_pcm_hw_channels_mask,
        avail_update: snd_pcm_hw_avail_update,
        mmap_forward: snd_pcm_hw_mmap_forward,
+       set_avail_min: snd_pcm_hw_set_avail_min,
 };
 
 int snd_pcm_hw_open_subdevice(snd_pcm_t **pcmp, int card, int device, int subdevice, int stream, int mode)
index 58c8e81c640e173106dabf8984a65ecf24330574..1f9fee2819819ff08030cb88f02a91d1b44d6bc2 100644 (file)
@@ -67,6 +67,7 @@ typedef struct {
        int (*channels_mask)(snd_pcm_t *pcm, bitset_t *cmask);
        ssize_t (*avail_update)(snd_pcm_t *pcm);
        ssize_t (*mmap_forward)(snd_pcm_t *pcm, size_t size);
+       int (*set_avail_min)(snd_pcm_t *pcm, size_t frames);
 } snd_pcm_fast_ops_t;
 
 typedef struct {
index e8541c2034013684368245e6fc7a2a2ce0c900d0..94ccc44cba257c0b57f6cf6ec7ac322a2d6b201c 100644 (file)
@@ -407,6 +407,12 @@ static ssize_t snd_pcm_multi_mmap_forward(snd_pcm_t *pcm, size_t size)
        return size;
 }
 
+int snd_pcm_multi_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_multi_t *multi = pcm->private;
+       return snd_pcm_set_avail_min(multi->slaves[0].pcm, frames);
+}
+
 static int snd_pcm_multi_channels_mask(snd_pcm_t *pcm, bitset_t *cmask)
 {
        snd_pcm_multi_t *multi = pcm->private;
@@ -507,6 +513,7 @@ snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = {
        channels_mask: snd_pcm_multi_channels_mask,
        avail_update: snd_pcm_multi_avail_update,
        mmap_forward: snd_pcm_multi_mmap_forward,
+       set_avail_min: snd_pcm_multi_set_avail_min,
 };
 
 int snd_pcm_multi_open(snd_pcm_t **pcmp, char *name,
index bf56c8bdfa4475c5e35f81e6424b30567ee635bd..e0880776937ebb8e995a05f5318bf1ea29060008 100644 (file)
@@ -304,6 +304,13 @@ ssize_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
        return err;
 }
 
+int snd_pcm_plugin_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_plugin_t *plugin = pcm->private;
+       snd_pcm_t *slave = plugin->slave;
+       return snd_pcm_set_avail_min(slave, frames);
+}
+
 int snd_pcm_plugin_mmap(snd_pcm_t *pcm)
 {
        snd_pcm_plugin_t *plugin = pcm->private;
@@ -424,5 +431,6 @@ snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = {
        channels_mask: snd_pcm_plugin_channels_mask,
        avail_update: snd_pcm_plugin_avail_update,
        mmap_forward: snd_pcm_plugin_mmap_forward,
+       set_avail_min: snd_pcm_plugin_set_avail_min,
 };
 
index 65e105da73386d03028d7967ac74f8c4eebab140..ace777d985e57a154a0a4403e5d7e63e8b99be8d 100644 (file)
@@ -789,6 +789,17 @@ static ssize_t snd_pcm_share_rewind(snd_pcm_t *pcm, size_t frames)
        return ret;
 }
 
+static int snd_pcm_share_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_share_t *share = pcm->private;
+       snd_pcm_share_slave_t *slave = share->slave;
+       pthread_mutex_lock(&slave->mutex);
+       pcm->setup.avail_min = frames;
+       _snd_pcm_update_poll(pcm);
+       pthread_mutex_unlock(&slave->mutex);
+       return 0;
+}
+
 static int snd_pcm_share_channels_mask(snd_pcm_t *pcm, bitset_t *cmask)
 {
        snd_pcm_share_t *share = pcm->private;
@@ -997,6 +1008,7 @@ snd_pcm_fast_ops_t snd_pcm_share_fast_ops = {
        channels_mask: snd_pcm_share_channels_mask,
        avail_update: snd_pcm_share_avail_update,
        mmap_forward: snd_pcm_share_mmap_forward,
+       set_avail_min: snd_pcm_share_set_avail_min,
 };
 
 int snd_pcm_share_open(snd_pcm_t **pcmp, char *name, char *sname,
index 575af6621d661a141a5ea1e2c98fea962752ed63..6ebbf3b36debc72e9383494f41a2a19e8618ad40 100644 (file)
@@ -445,6 +445,15 @@ static ssize_t snd_pcm_shm_mmap_forward(snd_pcm_t *pcm, size_t size)
        return snd_pcm_shm_action(pcm);
 }
 
+static int snd_pcm_shm_set_avail_min(snd_pcm_t *pcm, size_t frames)
+{
+       snd_pcm_shm_t *shm = pcm->private;
+       volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
+       ctrl->cmd = SND_PCM_IOCTL_SET_AVAIL_MIN;
+       ctrl->u.set_avail_min.frames = frames;
+       return snd_pcm_shm_action(pcm);
+}
+
 static int snd_pcm_shm_poll_descriptor(snd_pcm_t *pcm)
 {
        snd_pcm_shm_t *shm = pcm->private;
@@ -519,6 +528,7 @@ snd_pcm_fast_ops_t snd_pcm_shm_fast_ops = {
        channels_mask: snd_pcm_shm_channels_mask,
        avail_update: snd_pcm_shm_avail_update,
        mmap_forward: snd_pcm_shm_mmap_forward,
+       set_avail_min: snd_pcm_shm_set_avail_min,
 };
 
 static int make_local_socket(const char *filename)