[alsa-devel] snd_pcsp locking mess
tiwai at suse.de
Tue Oct 21 08:27:08 CEST 2008
At Tue, 21 Oct 2008 01:51:57 +0400,
Stas Sergeev wrote:
> Takashi Iwai wrote:
> > Indeed, the async trigger is nice to have in the common place.
> > However, the change wouldn't be as trivial as it sounds, as you
> > mentioned. By async nature, there can be a transition phase between
> > the XRUN and STOP, which can cause races.
> Could you please elaborate on how my
> proposed patch could possibly affect
> that? It basically doesn't do anything
> at all except providing one more callback
> for what would otherwise had to be done
> in a trigger() callback anyway.
> If there is a race with that patch, then
> I pretty much suspect it was with an old
> code too. I can't imagine any possible
> change. What have changed?
The PCM status is changed immediately after calling trigger(_async)
callback XRUN or SETUP. That is, you can start the stream again soon
after snd_pcm_stop(). In the case of async operation, the hardware
may be likely still running, but the PCM core doesn't know about it
and allows you to restart the stream. So it's racy, at least from the
PCM core viewpoint.
Usually async operation has a way to indicate the pending status,
either setting the state to WORKING/PENDING, or having an additional
flag. In either way, we need the change in the PCM core side.
More information about the Alsa-devel