Jaroslav Kysela wrote: > > On Mon, 17 Feb 2003, Jaroslaw Sobierski wrote: > > > >> I see, the read/saturate/write must be atomic, too. In this case, it would > > >> be better to use a global (or a set of) mutex(es) to lock the hardware > > >> ring buffer. The futexes are nice. > > > > > >They are nice indeed, but definitely not the right solution here. > > > > > >Although I don't know if it's the absolute best solution, the 'retry' > > >approach I've proposed is far better and much more efficient. > > > > I have to agree with Abramo. A global mutex would cause long and unnecessary > > waits for the processes trying to write to the plugin. Locking access to > > individual parts of the buffer is messy. Notice that concurrent writes > > to the same sample in the buffer will occur sporadically, and the "re-read" > > in the loop costs almost nothing, while synchronization mechanisms could > > block often. > > Note that your all nice ideas go to some blind alley. Who will silence the > sum buffer? Driver silences only hardware buffer which will not be used > for the calculation in your algorithm.
Not so blind ;-) v = *src; if (cmpxchg(hw, 0, 1) == 0) v -= *sw; xadd(sw, v); do { v = *sw; if (v > 0x7fff) s = 0x7fff; else if (v < -0x8000) s = -0x8000; else s = v; *hw = s; } while (unlikely(v != *sw)); I've convinced you? However as I've written in the my first message the evil of dmix approach lies in details: they might destroy efficiency of approach rather easily. -- Abramo Bagnara mailto:[EMAIL PROTECTED] Opera Unica Phone: +39.546.656023 Via Emilia Interna, 140 48014 Castel Bolognese (RA) - Italy ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Alsa-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-devel