[alsa-devel] [PATCH] ASoC: imx-ssi: Fix mono playback

Trent Piepho tpiepho at gmail.com
Tue Aug 7 19:53:42 CEST 2012


On Tue, Aug 7, 2012 at 8:00 AM, Tabi Timur-B04825 <B04825 at freescale.com> wrote:
>> There is the race issue in that playback and record must both match
>> mono and stereo and ALSA doesn't handle substreams with constraints
>> that depend on other substreams in a race free manner.
>
> Isn't that only a problem if both streams are opened literally
> simultaneously?  I would assume that most apps will open one stream at a time.

The problem comes up if another stream is opened before the hw_params
are fixed on the other stream.  So if the first stream is configured
past the hw_params level before the next is opened there is no
problem.  But if not there is a race.  There could be two different
independent processes using the hardware which might be running at the
same time.

I remember posting something about this race in more detail.  One can
mostly make it work by dynamically adding constraints in the open()
method based on the configuration of the linked substream and then
checking the hw_params again for correctness in the hw_params()
method.

There end up being two problems.  One is on the userspace side.  An
app could get a set constraints, choose hwparams that are valid
according to those constraints, and then get told hwparams are not
valid anyway.  While an app could handle this, it has never been
documented as something an app should handle in a certain way.  So
apps will most likely not handle it well.

The other problem is that if two substreams call hw_params at the same
time there is a race internal to ALSA.  I don't remember what the
problem is exactly, just that there was one.


More information about the Alsa-devel mailing list