]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[ALSA] Fix PCM write blocking
authorTakashi Iwai <tiwai@suse.de>
Tue, 8 Jan 2008 17:00:04 +0000 (18:00 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 31 Jan 2008 16:29:46 +0000 (17:29 +0100)
The snd_pcm_lib_write1() may block in some weird condition:
  - the stream isn't started
  - avail_min is big (e.g. period size)
  - partial write up to buffer_size - avail_min
The patch fixes this invalid blocking problem.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/core/pcm_lib.c

index 48ffa40967a4ddf7932ae5efabe3744324b09bfd..f9f9b3fe956e44fd0c35b20549f589cb4493c46c 100644 (file)
@@ -1655,8 +1655,11 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream,
                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 (((avail < runtime->control->avail_min && size > avail) ||
-                  (size >= runtime->xfer_align && avail < runtime->xfer_align))) {
+               if (!avail ||
+                   (snd_pcm_running(substream) &&
+                    ((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, DROPPED } state;
                        long tout;