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

Modified Files:
        pcm_lib.c pcm_native.c 
Log Message:
- updated poll/read/write functions to wait when buffer is full or
  stream is paused (waiting thread can be triggered from another)


Index: pcm_lib.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_lib.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- pcm_lib.c   12 Aug 2002 08:43:45 -0000      1.18
+++ pcm_lib.c   9 Oct 2002 20:22:41 -0000       1.19
@@ -1842,16 +1842,11 @@
                if (runtime->sleep_min == 0 && runtime->status->state == 
SNDRV_PCM_STATE_RUNNING)
                        snd_pcm_update_hw_ptr(substream);
                avail = snd_pcm_playback_avail(runtime);
-               if (runtime->status->state == SNDRV_PCM_STATE_PAUSED ||
-                   runtime->status->state == SNDRV_PCM_STATE_PREPARED) {
-                       if (avail < runtime->xfer_align) {
-                               err = -EPIPE;
-                               goto _end_unlock;
-                       }
-               } else if (((avail < runtime->control->avail_min && size > avail) ||
-                           (size >= runtime->xfer_align && avail < 
runtime->xfer_align))) {
+               if (((avail < runtime->control->avail_min && size > avail) ||
+                  (size >= runtime->xfer_align && avail < runtime->xfer_align))) {
                        wait_queue_t wait;
                        enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED } state;
+
                        if (nonblock) {
                                err = -EAGAIN;
                                goto _end_unlock;
@@ -1868,8 +1863,11 @@
                                spin_unlock_irq(&runtime->lock);
                                if (schedule_timeout(10 * HZ) == 0) {
                                        spin_lock_irq(&runtime->lock);
-                                       state = runtime->status->state == 
SNDRV_PCM_STATE_SUSPENDED ? SUSPENDED : EXPIRED;
-                                       break;
+                                       if (runtime->status->state != 
+SNDRV_PCM_STATE_PREPARED &&
+                                           runtime->status->state != 
+SNDRV_PCM_STATE_PAUSED) {
+                                               state = runtime->status->state == 
+SNDRV_PCM_STATE_SUSPENDED ? SUSPENDED : EXPIRED;
+                                               break;
+                                       }
                                }
                                spin_lock_irq(&runtime->lock);
                                switch (runtime->status->state) {
@@ -1916,10 +1914,6 @@
                cont = runtime->buffer_size - runtime->control->appl_ptr % 
runtime->buffer_size;
                if (frames > cont)
                        frames = cont;
-               if (frames == 0 && runtime->status->state == SNDRV_PCM_STATE_PAUSED) {
-                       err = -EPIPE;
-                       goto _end_unlock;
-               }
                snd_assert(frames != 0,
                           spin_unlock_irq(&runtime->lock);
                           return -EINVAL);
@@ -2135,21 +2129,16 @@
                if (runtime->sleep_min == 0 && runtime->status->state == 
SNDRV_PCM_STATE_RUNNING)
                        snd_pcm_update_hw_ptr(substream);
                avail = snd_pcm_capture_avail(runtime);
-               if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) {
+               if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
                        if (avail < runtime->xfer_align) {
                                err = -EPIPE;
                                goto _end_unlock;
                        }
-               } else if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
-                       if (avail < runtime->xfer_align) {
-                               runtime->status->state = SNDRV_PCM_STATE_SETUP;
-                               err = -EPIPE;
-                               goto _end_unlock;
-                       }
                } else if ((avail < runtime->control->avail_min && size > avail) ||
                           (size >= runtime->xfer_align && avail < 
runtime->xfer_align)) {
                        wait_queue_t wait;
                        enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED } state;
+
                        if (nonblock) {
                                err = -EAGAIN;
                                goto _end_unlock;
@@ -2166,8 +2155,11 @@
                                spin_unlock_irq(&runtime->lock);
                                if (schedule_timeout(10 * HZ) == 0) {
                                        spin_lock_irq(&runtime->lock);
-                                       state = runtime->status->state == 
SNDRV_PCM_STATE_SUSPENDED ? SUSPENDED : EXPIRED;
-                                       break;
+                                       if (runtime->status->state != 
+SNDRV_PCM_STATE_PREPARED &&
+                                           runtime->status->state != 
+SNDRV_PCM_STATE_PAUSED) {
+                                               state = runtime->status->state == 
+SNDRV_PCM_STATE_SUSPENDED ? SUSPENDED : EXPIRED;
+                                               break;
+                                       }
                                }
                                spin_lock_irq(&runtime->lock);
                                switch (runtime->status->state) {

Index: pcm_native.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_native.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- pcm_native.c        8 Oct 2002 17:18:47 -0000       1.26
+++ pcm_native.c        9 Oct 2002 20:22:41 -0000       1.27
@@ -2433,6 +2433,8 @@
        avail = snd_pcm_playback_avail(runtime);
        switch (runtime->status->state) {
        case SNDRV_PCM_STATE_RUNNING:
+       case SNDRV_PCM_STATE_PREPARED:
+       case SNDRV_PCM_STATE_PAUSED:
                if (avail >= runtime->control->avail_min) {
                        mask = POLLOUT | POLLWRNORM;
                        break;
@@ -2441,12 +2443,6 @@
        case SNDRV_PCM_STATE_DRAINING:
                mask = 0;
                break;
-       case SNDRV_PCM_STATE_PREPARED:
-               if (avail > 0) {
-                       mask = POLLOUT | POLLWRNORM;
-                       break;
-               }
-               /* Fall through */
        default:
                mask = POLLOUT | POLLWRNORM | POLLERR;
                break;
@@ -2475,6 +2471,8 @@
        avail = snd_pcm_capture_avail(runtime);
        switch (runtime->status->state) {
        case SNDRV_PCM_STATE_RUNNING:
+       case SNDRV_PCM_STATE_PREPARED:
+       case SNDRV_PCM_STATE_PAUSED:
                if (avail >= runtime->control->avail_min) {
                        mask = POLLIN | POLLRDNORM;
                        break;



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