From: Takashi Iwai Subject: Re: How to interrupt snd_pcm_writei in blocking mode? Date: Thu, 30 Jun 2005 21:16:07 +0200 Message-ID: References: <20050629180540.GA12922@brailcom.cz> <20050630184228.GA3755@brailcom.cz> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20050630184228.GA3755@brailcom.cz> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Hynek Hanke Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Thu, 30 Jun 2005 20:42:28 +0200, Hynek Hanke wrote: > > > > Hynek Hanke wrote: > > > > I'm running it in two separate threads. One does all the preparations and calls > > > > snd_pcm_writei() in blocking mode. The other one then decides it wants to stop > > > > playing, so it calls snd_pcm_drop(). This causes the device to switch from > > > > state RUNNING to state SETUP, but the snd_pcm_writei() hangs forever and never > > > > returns. Why is this so? > > Well, but pcm_lib.c::snd_pcm_lib_write1() should check the state SETUP > > and break the loop immediately. Ditto for snd_pcm_lib_read1(). > > The quick hack is below. Please give a shot. > > I tried to apply the patch to the 2.6.11 kernel but after > compilation/instalation, there is no difference. It still hangs. Logfiles say > it was in the state RUNNING just before snd_pcm_drop() was called and got into > state SETUP immediatelly after. The logfile from the other thread shows > snd_pcm_writei() never returns (not even after the sound would surely be > completed). Hmm, then still something is missing. I'll check on it later. > So, what can I do? Do I really have to use the non-blocking mode or is this > supposed to work (if I take care about all the other thread related issues > myself)? My colleague is reporting it's working for him under some different > configuration. The non-blocking mode and poll() should work (hopefully :) If not, let me know. > Can I enable some debugging messages or something to help you to see what's > wrong? Check the code flow in snd_pcm_lib_write1(). You can see the places my patch tried to fix. Basically, the thread should be woken up and get out of the loop. But according to your report, it didn't work as expected by some reason... Takashi ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click