Re: [PATCH] alsa-lib: snd_pcm_delay and friends do not account for a write being currently in progress

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2 June 2010 22:29, John Lindgren <john.lindgren@xxxxxxx> wrote:
> Hi,
>
> In a multi-threaded application it is possible for snd_pcm_delay or an
> equivalent function to be called by one thread while another is sitting
> in snd_pcm_writei.  In this case, snd_pcm_delay does not take into
> account that there may not be enough space for all the data passed to
> snd_pcm_writei to be written to the ring buffer at once, and will return
> incorrect values.
>

I believe the definition of snd_pcm_delay() is it returns a value that
would be fairly accurate at this instance of time. If you followed the
snd_pcm_delay() with a snd_pcm_writei(), the samples would reach the
speaker "delay" time later.

I think it would be fair to say that the value of snd_pcm_delay() is
undefined if called during a snd_pcm_writei() call, because you will
get a return value from snd_pcm_delay() but you will have no idea how
many samples of the current snd_pcm_writei() have been written and
thus no idea what the delay will be on the next snd_pcm_writei().

Even in multi-threaded applications calling two functions at the same
time that interfere with each other it not good.
If a function is re-entrant it is generally considered to be thread
safe. It does not necessarily mean that it is sensible to call two
different functions at the same time.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux