The Magic Ring Buffer (2012)
fgiesen.wordpress.com
fgiesen.wordpress.com
Interesting bits of the implementation are here: https://github.com/andrewrk/libsoundio/blob/1fe64770bde0a4fb...
Can you prove they are always safe? (at least on the level of linux kernel LOCKDEP) I bet you cannot, because 1.1.0 changelog mentions "fixing" a deadlock by tossing functionality.
Likewise, I see a lot of places that do reference counting (those _ref/_unref calls). Those are probable deallocations on heap from RT side, which have unbounded runtime unless you have a realtime memory allocator. I haven't noticed anything like that in the code.
This coming from a guy who supposedly "has carefully read the documentation for every audio backend and understands the purpose of every line of code."
For people who want to get a primer on such issues, I recommend this book: http://www.amazon.com/Real-Time-Systems-Programming-Language... It's a bit old despite updates (e.g. no C++11, no C99), but still highly relevant. The techniques themselves and the analysis parts are well written.
SFML: http://www.sfml-dev.org/
FMOD: http://www.fmod.org/wpfb-file/fmodapi375xbox-zip/
OpenAL: http://openal.org
.. I think the problem is there are too many of these libraries .. seems like nobody does a search, decides to roll their own, and we now have a glut ..
Thankfully I don't put up with any of this now that all the software I use works correctly in 64 bit. Still, latency is often a huge PITA with realtime audio.
What's interesting is that as processors get faster, audio plugin makers publish stuff that uses more and more processor. So much that I'm now considering getting one of those new 16-core processors for my next workstation.
Uggh. I know how you feel. For a while now, I've wanted to create some sort of audio processing engine (either a very versatile LADSPA/VST/AU/etc plugin or a minimal DAW) wherein all the different components that usually run their own code to generate/process audio are described as data instead (e.g. transfer functions), and then the host decides how to actually compute the audio. This would give lots of room to try new optimizations that aren't usually possible, and you only have to optimize one area of critical code, rather than optimizing each individual plugin. This is especially beneficial when trying to make conditional use of processor extensions like SSE.
Instead of applying a series of filters individually, Core Image assembles a dynamic instruction pipeline so that only one calculation needs to be applied to the pixel data to achieve a cumulative effect... Regardless of the number of filters, Core Image assembles the code for this instruction pipeline with a just-in-time compiler
On recent kernels the fast implementation of remap_file_pages has been removed because keeping non linear mapping from regressing was too much of a burden; instead a slow emulation has been added. The emulation should still be faster than doing the mmap dance by hand.
The documentation is pretty terrible, though, so some experimentation may be necessary. It's also even less like the POSIX parts than the NS bits are...
(Apple doesn't seem to tell you much; OK references are https://www.gnu.org/software/hurd/gnumach-doc/Virtual-Memory... http://www.amazon.co.uk/Mac-OS-Internals-Systems-Approach/dp..., and, of course, http://www.opensource.apple.com/source/xnu/. The source has some reference-style documentation in it.
> There are a couple of in-depth articles about implementing this same idea on Mach / OS X:
> http://www.mikeash.com/pyblog/friday-qa-2012-02-03-ring-buff...
> http://www.mikeash.com/pyblog/friday-qa-2012-02-17-ring-buff...
I dug around in the history and was able to dig it out:
https://en.wikipedia.org/w/index.php?title=Circular_buffer&o...