Update of /cvsroot/alsa/alsa-lib/src/pcm
In directory usw-pr-cvs1:/tmp/cvs-serv6809/src/pcm

Modified Files:
        pcm.c pcm_file.c pcm_hooks.c pcm_hw.c pcm_local.h pcm_meter.c 
        pcm_multi.c pcm_null.c pcm_plugin.c pcm_share.c pcm_shm.c 
Log Message:
Replaced snd_pcm_avail() with snd_pcm_hwsync()

Index: pcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm.c,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- pcm.c       12 Oct 2002 10:39:50 -0000      1.226
+++ pcm.c       12 Oct 2002 11:49:53 -0000      1.227
@@ -859,27 +859,19 @@
 }
 
 /**
- * \brief Obtain available frames for a running PCM handle
+ * \brief Synchronize stream position with hardware
  * \param pcm PCM handle
- * \param availp Returned available frames
  * \return 0 on success otherwise a negative error code
  *
- * Returns available frames to be filled inside ring buffer.
- * This value might be greater than buffer size when
- * underrun (playback) or overrun (capture) occurs.
- *
- * This function returns accurate value, because it updates
- * stream position from hardware.
- *
  * Note this function does not update the actual r/w pointer
  * for applications. The function \link ::snd_pcm_avail_update \endlink
  * have to be called before any read/write/begin+commit operation.
  */
-int snd_pcm_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+int snd_pcm_hwsync(snd_pcm_t *pcm)
 {
        assert(pcm);
        assert(pcm->setup);
-       return pcm->fast_ops->avail(pcm->fast_op_arg, availp);
+       return pcm->fast_ops->hwsync(pcm->fast_op_arg);
 }
 
 /**

Index: pcm_file.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_file.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- pcm_file.c  11 Oct 2002 18:39:24 -0000      1.54
+++ pcm_file.c  12 Oct 2002 11:49:54 -0000      1.55
@@ -162,10 +162,10 @@
        return snd_pcm_state(file->slave);
 }
 
-static int snd_pcm_file_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_file_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_file_t *file = pcm->private_data;
-       return snd_pcm_avail(file->slave, availp);
+       return snd_pcm_hwsync(file->slave);
 }
 
 static int snd_pcm_file_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -412,7 +412,7 @@
 static snd_pcm_fast_ops_t snd_pcm_file_fast_ops = {
        status: snd_pcm_file_status,
        state: snd_pcm_file_state,
-       avail: snd_pcm_file_avail,
+       hwsync: snd_pcm_file_hwsync,
        delay: snd_pcm_file_delay,
        prepare: snd_pcm_file_prepare,
        reset: snd_pcm_file_reset,

Index: pcm_hooks.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_hooks.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- pcm_hooks.c 11 Oct 2002 18:39:25 -0000      1.22
+++ pcm_hooks.c 12 Oct 2002 11:49:54 -0000      1.23
@@ -116,10 +116,10 @@
        return snd_pcm_state(h->slave);
 }
 
-static int snd_pcm_hooks_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_hooks_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_hooks_t *h = pcm->private_data;
-       return snd_pcm_avail(h->slave, availp);
+       return snd_pcm_hwsync(h->slave);
 }
 
 static int snd_pcm_hooks_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -298,7 +298,7 @@
 static snd_pcm_fast_ops_t snd_pcm_hooks_fast_ops = {
        status: snd_pcm_hooks_status,
        state: snd_pcm_hooks_state,
-       avail: snd_pcm_hooks_avail,
+       hwsync: snd_pcm_hooks_hwsync,
        delay: snd_pcm_hooks_delay,
        prepare: snd_pcm_hooks_prepare,
        reset: snd_pcm_hooks_reset,

Index: pcm_hw.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_hw.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- pcm_hw.c    11 Oct 2002 18:39:25 -0000      1.104
+++ pcm_hw.c    12 Oct 2002 11:49:54 -0000      1.105
@@ -77,8 +77,8 @@
 #define SND_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct sndrv_pcm_hw_params_old)
 #define SND_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct sndrv_pcm_hw_params_old)
 
-#define SND_PCM_IOCTL_AVAIL _IOR('A', 0x22, sndrv_pcm_uframes_t)
-#define SND_PCM_IOCTL_XRUN  _IO ('A', 0x48)
+#define SND_PCM_IOCTL_HWSYNC _IO ('A', 0x22)
+#define SND_PCM_IOCTL_XRUN   _IO ('A', 0x48)
 
 static int use_old_hw_params_ioctl(int fd, unsigned int cmd, snd_pcm_hw_params_t 
*params);
 static snd_pcm_sframes_t snd_pcm_hw_avail_update(snd_pcm_t *pcm);
@@ -395,28 +395,26 @@
        return 0;
 }
 
-static int snd_pcm_hw_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_hw_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_hw_t *hw = pcm->private_data;
        int fd = hw->fd;
        if (SNDRV_PROTOCOL_VERSION(2, 0, 3) <= hw->version) {
-               if (ioctl(fd, SND_PCM_IOCTL_AVAIL, availp) < 0) {
-                       // SYSERR("SND_PCM_IOCTL_AVAIL failed");
+               if (ioctl(fd, SND_PCM_IOCTL_HWSYNC) < 0) {
+                       // SYSERR("SND_PCM_IOCTL_HWSYNC failed");
                        return -errno;
                }
        } else {
                snd_pcm_sframes_t delay;
                int err = snd_pcm_hw_delay(pcm, &delay);
                if (err < 0) {
-                       delay = snd_pcm_hw_avail_update(pcm);
-                       if (delay < 0)
-                               return delay;
-                       *availp = delay;
-               } else {
-                       delay = pcm->stream == SND_PCM_STREAM_PLAYBACK ? 
pcm->buffer_size - delay : delay;
-                       if (delay < 0)
-                               delay = 0;
-                       *availp = delay;
+                       switch (snd_pcm_state(pcm)) {
+                       case SND_PCM_STATE_PREPARED:
+                       case SND_PCM_STATE_SUSPENDED:
+                               return 0;
+                       default:
+                               return err;
+                       }
                }
        }
        return 0;
@@ -786,7 +784,7 @@
 static snd_pcm_fast_ops_t snd_pcm_hw_fast_ops = {
        status: snd_pcm_hw_status,
        state: snd_pcm_hw_state,
-       avail: snd_pcm_hw_avail,
+       hwsync: snd_pcm_hw_hwsync,
        delay: snd_pcm_hw_delay,
        prepare: snd_pcm_hw_prepare,
        reset: snd_pcm_hw_reset,

Index: pcm_local.h
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_local.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- pcm_local.h 12 Oct 2002 10:39:50 -0000      1.117
+++ pcm_local.h 12 Oct 2002 11:49:54 -0000      1.118
@@ -144,7 +144,7 @@
        int (*drain)(snd_pcm_t *pcm);
        int (*pause)(snd_pcm_t *pcm, int enable);
        snd_pcm_state_t (*state)(snd_pcm_t *pcm);
-       int (*avail)(snd_pcm_t *pcm, snd_pcm_uframes_t *availp);
+       int (*hwsync)(snd_pcm_t *pcm);
        int (*delay)(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp);
        int (*resume)(snd_pcm_t *pcm);
        snd_pcm_sframes_t (*rewind)(snd_pcm_t *pcm, snd_pcm_uframes_t frames);

Index: pcm_meter.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_meter.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- pcm_meter.c 11 Oct 2002 18:39:25 -0000      1.35
+++ pcm_meter.c 12 Oct 2002 11:49:54 -0000      1.36
@@ -319,10 +319,10 @@
        return snd_pcm_state(meter->slave);
 }
 
-static int snd_pcm_meter_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_meter_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_meter_t *meter = pcm->private_data;
-       return snd_pcm_avail(meter->slave, availp);
+       return snd_pcm_hwsync(meter->slave);
 }
 
 static int snd_pcm_meter_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -599,7 +599,7 @@
 static snd_pcm_fast_ops_t snd_pcm_meter_fast_ops = {
        status: snd_pcm_meter_status,
        state: snd_pcm_meter_state,
-       avail: snd_pcm_meter_avail,
+       hwsync: snd_pcm_meter_hwsync,
        delay: snd_pcm_meter_delay,
        prepare: snd_pcm_meter_prepare,
        reset: snd_pcm_meter_reset,

Index: pcm_multi.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_multi.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- pcm_multi.c 11 Oct 2002 18:39:25 -0000      1.78
+++ pcm_multi.c 12 Oct 2002 11:49:54 -0000      1.79
@@ -351,11 +351,11 @@
        return snd_pcm_state(slave);
 }
 
-static int snd_pcm_multi_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_multi_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_multi_t *multi = pcm->private_data;
        snd_pcm_t *slave = multi->slaves[0].pcm;
-       return snd_pcm_avail(slave, availp);
+       return snd_pcm_hwsync(slave);
 }
 
 static int snd_pcm_multi_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -601,7 +601,7 @@
 static snd_pcm_fast_ops_t snd_pcm_multi_fast_ops = {
        status: snd_pcm_multi_status,
        state: snd_pcm_multi_state,
-       avail: snd_pcm_multi_avail,
+       hwsync: snd_pcm_multi_hwsync,
        delay: snd_pcm_multi_delay,
        prepare: snd_pcm_multi_prepare,
        reset: snd_pcm_multi_reset,

Index: pcm_null.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_null.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- pcm_null.c  11 Oct 2002 18:39:25 -0000      1.39
+++ pcm_null.c  12 Oct 2002 11:49:54 -0000      1.40
@@ -102,9 +102,8 @@
        return null->state;
 }
 
-static int snd_pcm_null_avail(snd_pcm_t *pcm ATTRIBUTE_UNUSED, snd_pcm_uframes_t 
*availp)
+static int snd_pcm_null_hwsync(snd_pcm_t *pcm ATTRIBUTE_UNUSED)
 {
-       *availp = pcm->buffer_size;
        return 0;
 }
 
@@ -326,7 +325,7 @@
 static snd_pcm_fast_ops_t snd_pcm_null_fast_ops = {
        status: snd_pcm_null_status,
        state: snd_pcm_null_state,
-       avail: snd_pcm_null_avail,
+       hwsync: snd_pcm_null_hwsync,
        delay: snd_pcm_null_delay,
        prepare: snd_pcm_null_prepare,
        reset: snd_pcm_null_reset,

Index: pcm_plugin.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_plugin.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- pcm_plugin.c        11 Oct 2002 18:39:26 -0000      1.82
+++ pcm_plugin.c        12 Oct 2002 11:49:54 -0000      1.83
@@ -188,17 +188,10 @@
        return snd_pcm_state(plugin->slave);
 }
 
-int snd_pcm_plugin_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+int snd_pcm_plugin_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_plugin_t *plugin = pcm->private_data;
-       snd_pcm_uframes_t sd;
-       int err = snd_pcm_avail(plugin->slave, &sd);
-       if (err < 0)
-               return err;
-       if (plugin->client_frames)
-               sd = plugin->client_frames(pcm, sd);
-       *availp = sd;
-       return 0;
+       return snd_pcm_hwsync(plugin->slave);
 }
 
 int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -640,7 +633,7 @@
 snd_pcm_fast_ops_t snd_pcm_plugin_fast_ops = {
        status: snd_pcm_plugin_status,
        state: snd_pcm_plugin_state,
-       avail: snd_pcm_plugin_avail,
+       hwsync: snd_pcm_plugin_hwsync,
        delay: snd_pcm_plugin_delay,
        prepare: snd_pcm_plugin_prepare,
        reset: snd_pcm_plugin_reset,

Index: pcm_share.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_share.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- pcm_share.c 11 Oct 2002 18:39:26 -0000      1.67
+++ pcm_share.c 12 Oct 2002 11:49:54 -0000      1.68
@@ -713,7 +713,7 @@
        return share->state;
 }
 
-static int _snd_pcm_share_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int _snd_pcm_share_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_share_t *share = pcm->private_data;
        snd_pcm_share_slave_t *slave = share->slave;
@@ -723,16 +723,16 @@
        default:
                break;
        }
-       return snd_pcm_avail(slave->pcm, availp);
+       return snd_pcm_hwsync(slave->pcm);
 }
 
-static int snd_pcm_share_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_share_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_share_t *share = pcm->private_data;
        snd_pcm_share_slave_t *slave = share->slave;
        int err;
        Pthread_mutex_lock(&slave->mutex);
-       err = _snd_pcm_share_avail(pcm, availp);
+       err = _snd_pcm_share_hwsync(pcm);
        Pthread_mutex_unlock(&slave->mutex);
        return err;
 }
@@ -1233,7 +1233,7 @@
 static snd_pcm_fast_ops_t snd_pcm_share_fast_ops = {
        status: snd_pcm_share_status,
        state: snd_pcm_share_state,
-       avail: snd_pcm_share_avail,
+       hwsync: snd_pcm_share_hwsync,
        delay: snd_pcm_share_delay,
        prepare: snd_pcm_share_prepare,
        reset: snd_pcm_share_reset,

Index: pcm_shm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_shm.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- pcm_shm.c   11 Oct 2002 18:39:26 -0000      1.52
+++ pcm_shm.c   12 Oct 2002 11:49:54 -0000      1.53
@@ -443,17 +443,12 @@
        return snd_pcm_shm_action(pcm);
 }
 
-static int snd_pcm_shm_avail(snd_pcm_t *pcm, snd_pcm_uframes_t *availp)
+static int snd_pcm_shm_hwsync(snd_pcm_t *pcm)
 {
        snd_pcm_shm_t *shm = pcm->private_data;
        volatile snd_pcm_shm_ctrl_t *ctrl = shm->ctrl;
-       int err;
-       ctrl->cmd = SND_PCM_IOCTL_AVAIL;
-       err = snd_pcm_shm_action(pcm);
-       if (err < 0)
-               return err;
-       *availp = ctrl->u.avail.frames;
-       return err;
+       ctrl->cmd = SND_PCM_IOCTL_HWSYNC;
+       return snd_pcm_shm_action(pcm);
 }
 
 static int snd_pcm_shm_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
@@ -623,6 +618,7 @@
 static snd_pcm_fast_ops_t snd_pcm_shm_fast_ops = {
        status: snd_pcm_shm_status,
        state: snd_pcm_shm_state,
+       hwsync: snd_pcm_shm_hwsync,
        delay: snd_pcm_shm_delay,
        prepare: snd_pcm_shm_prepare,
        reset: snd_pcm_shm_reset,



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to