diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-01-08 12:00:04 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:29:46 -0500 |
commit | fa5717f2099aadb2083d5df4d19af8f9685fa03e (patch) | |
tree | 563694ca22b8dd11467208457ccde81240c080f9 /sound | |
parent | 8ace4f3c9d83fd60e7539526a3a70bf5730db8c0 (diff) |
[ALSA] Fix PCM write blocking
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>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/pcm_lib.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 48ffa40967a4..f9f9b3fe956e 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c | |||
@@ -1655,8 +1655,11 @@ static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, | |||
1655 | if (runtime->sleep_min == 0 && runtime->status->state == SNDRV_PCM_STATE_RUNNING) | 1655 | if (runtime->sleep_min == 0 && runtime->status->state == SNDRV_PCM_STATE_RUNNING) |
1656 | snd_pcm_update_hw_ptr(substream); | 1656 | snd_pcm_update_hw_ptr(substream); |
1657 | avail = snd_pcm_playback_avail(runtime); | 1657 | avail = snd_pcm_playback_avail(runtime); |
1658 | if (((avail < runtime->control->avail_min && size > avail) || | 1658 | if (!avail || |
1659 | (size >= runtime->xfer_align && avail < runtime->xfer_align))) { | 1659 | (snd_pcm_running(substream) && |
1660 | ((avail < runtime->control->avail_min && size > avail) || | ||
1661 | (size >= runtime->xfer_align && | ||
1662 | avail < runtime->xfer_align)))) { | ||
1660 | wait_queue_t wait; | 1663 | wait_queue_t wait; |
1661 | enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state; | 1664 | enum { READY, SIGNALED, ERROR, SUSPENDED, EXPIRED, DROPPED } state; |
1662 | long tout; | 1665 | long tout; |