[Ffmpeg-devel] alsa input / output

Reimar Döffinger Reimar.Doeffinger
Sun Mar 25 11:48:19 CEST 2007

On Sun, Mar 25, 2007 at 05:26:16AM +0200, Michael Niedermayer wrote:
> > I should also note that such a lock-free implementation depends on
> > volatile keyword working "well enough" and pointer reads and writes being
> > atomic on the architecture...
> could you show one example where volatile makes a difference in practice?

In practice maybe not, but in theory you could do
while (av_fifo_size(f) <= 0) sleep();
and the compiler might inline av_fifo_size (not gcc though unless we
move it into fifo.h one time) and without volatile that could be converted to
if (av_fifo_size(f) <= 0) while (1) sleep();
Actually a compiler could do this even without inlining as long as it
can find out that av_fifo_size has no side effects (it does not modify
anything besides its return value) and does not depend on volatile data.

Reimar D?ffinger

More information about the ffmpeg-devel mailing list