Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 140

kernel-2.6.18-238.el5.src.rpm

From: Jaroslav Kysela <jkysela@redhat.com>
Date: Fri, 21 Nov 2008 07:15:02 -0500
Subject: [alsa] fix PCM write blocking
Message-id: 200811211215.mALCF20x009555@ns3.rdu.redhat.com
O-Subject: [RHEL 5.3 PATCH] ALSA - Fix PCM write blocking
Bugzilla: 468202
RH-Acked-by: Pete Zaitcev <zaitcev@redhat.com>
RH-Acked-by: Brian Maly <bmaly@redhat.com>

Bugzilla
========
BZ#468202
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=468202

Description
===========
The snd_pcm_lib_write1() may block in some conditions:
  - 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.

Upstream Status of the patch
============================
In upstream.

Test Status
===========
Tested.

diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 9fefcaa..ea6022c 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -1651,8 +1651,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;