[alsa-devel] How to interrupt snd_pcm_writei in blocking mode?
giridharakn at gmail.com
Fri Dec 20 11:58:16 CET 2013
Takashi Iwai <tiwai <at> suse.de> writes:
> 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
> > > > > 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.
> > it was in the state RUNNING just before snd_pcm_drop() was called and
> > 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...
> 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
We have the same problem.
snd_pcm_writei blocks when we switch between playback and record
continuously for several times.
Is this issue is fixed in any kernel versions.
I am running kernel version 2.6.31
Alsa version 1.0.18
is it a issue of buffers we allocate using
whats the way to calculate this value and how should be the ideal value.
I appreciate any help/suggestions in this regard.
Thanks and Regards,
More information about the Alsa-devel