Update of /cvsroot/alsa/alsa-kernel/core
In directory usw-pr-cvs1:/tmp/cvs-serv6629

Modified Files:
        pcm_native.c 
Log Message:
Reimplemented delay() - one function, added hwsync() ioctl implementation

Index: pcm_native.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_native.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- pcm_native.c        11 Oct 2002 18:35:38 -0000      1.29
+++ pcm_native.c        12 Oct 2002 11:49:01 -0000      1.30
@@ -1962,36 +1962,29 @@
        return ret;
 }
 
-static int snd_pcm_playback_xavail(snd_pcm_substream_t *substream, snd_pcm_uframes_t 
*res, int delay)
+static int snd_pcm_hwsync(snd_pcm_substream_t *substream)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
        int err;
-       snd_pcm_uframes_t n;
-       snd_pcm_sframes_t s;
+
        spin_lock_irq(&runtime->lock);
        switch (runtime->status->state) {
-       case SNDRV_PCM_STATE_RUNNING:
        case SNDRV_PCM_STATE_DRAINING:
+               if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+                       goto __badfd;
+       case SNDRV_PCM_STATE_RUNNING:
                if ((err = snd_pcm_update_hw_ptr(substream)) < 0)
                        break;
                /* Fall through */
        case SNDRV_PCM_STATE_PREPARED:
        case SNDRV_PCM_STATE_SUSPENDED:
                err = 0;
-               n = snd_pcm_playback_avail(runtime);
-               if (!delay) {
-                       if (put_user(n, res))
-                               err = -EFAULT;
-               } else {
-                       s = runtime->buffer_size - n;
-                       if (put_user(s, res))
-                               err = -EFAULT;
-               }
                break;
        case SNDRV_PCM_STATE_XRUN:
                err = -EPIPE;
                break;
        default:
+             __badfd:
                err = -EBADFD;
                break;
        }
@@ -1999,13 +1992,17 @@
        return err;
 }
                
-static int snd_pcm_capture_xavail(snd_pcm_substream_t *substream, snd_pcm_sframes_t 
*res)
+static int snd_pcm_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res)
 {
        snd_pcm_runtime_t *runtime = substream->runtime;
        int err;
-       snd_pcm_uframes_t n;
+       snd_pcm_sframes_t n;
+
        spin_lock_irq(&runtime->lock);
        switch (runtime->status->state) {
+       case SNDRV_PCM_STATE_DRAINING:
+               if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
+                       goto __badfd;
        case SNDRV_PCM_STATE_RUNNING:
                if ((err = snd_pcm_update_hw_ptr(substream)) < 0)
                        break;
@@ -2013,7 +2010,10 @@
        case SNDRV_PCM_STATE_PREPARED:
        case SNDRV_PCM_STATE_SUSPENDED:
                err = 0;
-               n = snd_pcm_capture_avail(runtime);
+               if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+                       n = snd_pcm_playback_hw_avail(runtime);
+               else
+                       n = snd_pcm_capture_avail(runtime);
                if (put_user(n, res))
                        err = -EFAULT;
                break;
@@ -2021,13 +2021,14 @@
                err = -EPIPE;
                break;
        default:
+             __badfd:
                err = -EBADFD;
                break;
        }
        spin_unlock_irq(&runtime->lock);
        return err;
 }
-
+               
 static int snd_pcm_playback_ioctl1(snd_pcm_substream_t *substream,
                                   unsigned int cmd, void *arg);
 static int snd_pcm_capture_ioctl1(snd_pcm_substream_t *substream,
@@ -2075,6 +2076,10 @@
                return snd_pcm_resume(substream);
        case SNDRV_PCM_IOCTL_XRUN:
                return snd_pcm_xrun(substream);
+       case SNDRV_PCM_IOCTL_HWSYNC:
+               return snd_pcm_hwsync(substream);
+       case SNDRV_PCM_IOCTL_DELAY:
+               return snd_pcm_delay(substream, (snd_pcm_sframes_t *) arg);
        case SNDRV_PCM_IOCTL_HW_REFINE_OLD:
                return snd_pcm_hw_refine_old_user(substream, (struct 
sndrv_pcm_hw_params_old *) arg);
        case SNDRV_PCM_IOCTL_HW_PARAMS_OLD:
@@ -2090,10 +2095,6 @@
        snd_assert(substream != NULL, return -ENXIO);
        snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL);
        switch (cmd) {
-       case SNDRV_PCM_IOCTL_AVAIL:
-               return snd_pcm_playback_xavail(substream, (snd_pcm_uframes_t*) arg, 0);
-       case SNDRV_PCM_IOCTL_DELAY:
-               return snd_pcm_playback_xavail(substream, (snd_pcm_sframes_t*) arg, 1);
        case SNDRV_PCM_IOCTL_WRITEI_FRAMES:
        {
                snd_xferi_t xferi, *_xferi = arg;
@@ -2163,11 +2164,6 @@
        snd_assert(substream != NULL, return -ENXIO);
        snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL);
        switch (cmd) {
-       case SNDRV_PCM_IOCTL_AVAIL:
-               return snd_pcm_capture_xavail(substream, (snd_pcm_uframes_t*) arg);
-       case SNDRV_PCM_IOCTL_DELAY:
-               /* really, avail and delay callback are same */
-               return snd_pcm_capture_xavail(substream, (snd_pcm_sframes_t*) arg);
        case SNDRV_PCM_IOCTL_READI_FRAMES:
        {
                snd_xferi_t xferi, *_xferi = arg;



-------------------------------------------------------
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