Update of /cvsroot/alsa/alsa-kernel/core In directory usw-pr-cvs1:/tmp/cvs-serv32626
Modified Files: pcm_native.c Log Message: - implemented SNDRV_PCM_IOCTL_AVAIL ioctl - SNDRV_PCM_IOCTL_DELAY ioctl returns values also in the PREPARED state Index: pcm_native.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_native.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- pcm_native.c 10 Oct 2002 18:16:08 -0000 1.28 +++ pcm_native.c 11 Oct 2002 18:35:38 -0000 1.29 @@ -1962,36 +1962,35 @@ return ret; } -static int snd_pcm_playback_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res) +static int snd_pcm_playback_xavail(snd_pcm_substream_t *substream, snd_pcm_uframes_t +*res, int delay) { snd_pcm_runtime_t *runtime = substream->runtime; - int err = 0; - snd_pcm_sframes_t n; + 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 (snd_pcm_update_hw_ptr(substream) >= 0) { - n = snd_pcm_playback_hw_avail(runtime); + 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; - break; } else { - err = SNDRV_PCM_STATE_RUNNING ? -EPIPE : -EBADFD; + s = runtime->buffer_size - n; + if (put_user(s, res)) + err = -EFAULT; } break; case SNDRV_PCM_STATE_XRUN: err = -EPIPE; break; - case SNDRV_PCM_STATE_SUSPENDED: - if (runtime->status->suspended_state == SNDRV_PCM_STATE_RUNNING) { - n = snd_pcm_playback_hw_avail(runtime); - if (put_user(n, res)) - err = -EFAULT; - } else { - err = -EBADFD; - } - break; default: err = -EBADFD; break; @@ -2000,33 +1999,27 @@ return err; } -static int snd_pcm_capture_delay(snd_pcm_substream_t *substream, snd_pcm_sframes_t *res) +static int snd_pcm_capture_xavail(snd_pcm_substream_t *substream, snd_pcm_sframes_t +*res) { snd_pcm_runtime_t *runtime = substream->runtime; - int err = 0; - snd_pcm_sframes_t n; + int err; + snd_pcm_uframes_t n; spin_lock_irq(&runtime->lock); switch (runtime->status->state) { case SNDRV_PCM_STATE_RUNNING: - if (snd_pcm_update_hw_ptr(substream) >= 0) { - n = snd_pcm_capture_avail(runtime); - if (put_user(n, res)) - err = -EFAULT; + 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_capture_avail(runtime); + if (put_user(n, res)) + err = -EFAULT; + break; case SNDRV_PCM_STATE_XRUN: err = -EPIPE; break; - case SNDRV_PCM_STATE_SUSPENDED: - if (runtime->status->suspended_state == SNDRV_PCM_STATE_RUNNING) { - n = snd_pcm_capture_avail(runtime); - if (put_user(n, res)) - err = -EFAULT; - } else { - err = -EBADFD; - } - break; default: err = -EBADFD; break; @@ -2097,6 +2090,10 @@ 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; @@ -2156,8 +2153,6 @@ return snd_pcm_playback_drain(substream); case SNDRV_PCM_IOCTL_DROP: return snd_pcm_playback_drop(substream); - case SNDRV_PCM_IOCTL_DELAY: - return snd_pcm_playback_delay(substream, (snd_pcm_sframes_t*) arg); } return snd_pcm_common_ioctl1(substream, cmd, arg); } @@ -2168,6 +2163,11 @@ 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; @@ -2219,8 +2219,6 @@ return snd_pcm_capture_drain(substream); case SNDRV_PCM_IOCTL_DROP: return snd_pcm_capture_drop(substream); - case SNDRV_PCM_IOCTL_DELAY: - return snd_pcm_capture_delay(substream, (snd_pcm_sframes_t*) arg); } return snd_pcm_common_ioctl1(substream, cmd, 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