Blame src/TPCircularBuffer/README.markdown

rpm-build ca19af
A simple, fast circular buffer implementation for audio processing
rpm-build ca19af
==================================================================
rpm-build ca19af
rpm-build ca19af
A simple C implementation for a circular (ring) buffer. Thread-safe with a single producer and a single consumer, using OSAtomic.h primitives, and avoids any need for buffer wrapping logic by using a virtual memory map technique to place a virtual copy of the buffer straight after the end of the real buffer.
rpm-build ca19af
rpm-build ca19af
Usage
rpm-build ca19af
-----
rpm-build ca19af
rpm-build ca19af
Initialisation and cleanup: `TPCircularBufferInit` and `TPCircularBufferCleanup` to allocate and free resources.
rpm-build ca19af
rpm-build ca19af
Producing: Use `TPCircularBufferHead` to get a pointer to write to the buffer, followed by `TPCircularBufferProduce` to submit the written data.  `TPCircularBufferProduceBytes` is a convenience routine for writing data straight to the buffer.
rpm-build ca19af
rpm-build ca19af
Consuming: Use `TPCircularBufferTail` to get a pointer to the next data to read, followed by `TPCircularBufferConsume` to free up the space once processed.
rpm-build ca19af
rpm-build ca19af
TPCircularBuffer+AudioBufferList.(c,h) contain helper functions to queue and dequeue AudioBufferList
rpm-build ca19af
structures. These will automatically adjust the mData fields of each buffer to point to 16-byte aligned
rpm-build ca19af
regions within the circular buffer.
rpm-build ca19af
rpm-build ca19af
Thread safety
rpm-build ca19af
-------------
rpm-build ca19af
rpm-build ca19af
As long as you restrict multithreaded access to just one producer, and just one consumer, this utility should be thread safe. 
rpm-build ca19af
rpm-build ca19af
Only one shared variable is used (the buffer fill count), and OSAtomic primitives are used to write to this value to ensure atomicity.
rpm-build ca19af
rpm-build ca19af
License
rpm-build ca19af
-------
rpm-build ca19af
rpm-build ca19af
Copyright (C) 2012-2013 A Tasty Pixel
rpm-build ca19af
rpm-build ca19af
This software is provided 'as-is', without any express or implied
rpm-build ca19af
warranty.  In no event will the authors be held liable for any damages
rpm-build ca19af
arising from the use of this software.
rpm-build ca19af
rpm-build ca19af
Permission is granted to anyone to use this software for any purpose,
rpm-build ca19af
including commercial applications, and to alter it and redistribute it
rpm-build ca19af
freely, subject to the following restrictions:
rpm-build ca19af
rpm-build ca19af
1. The origin of this software must not be misrepresented; you must not
rpm-build ca19af
   claim that you wrote the original software. If you use this software
rpm-build ca19af
   in a product, an acknowledgment in the product documentation would be
rpm-build ca19af
   appreciated but is not required.
rpm-build ca19af
   
rpm-build ca19af
2. Altered source versions must be plainly marked as such, and must not be
rpm-build ca19af
   misrepresented as being the original software.
rpm-build ca19af
   
rpm-build ca19af
3. This notice may not be removed or altered from any source distribution.
rpm-build ca19af
rpm-build ca19af
rpm-build ca19af
-----------------------------------------------------
rpm-build ca19af
rpm-build ca19af
Virtual memory technique originally proposed by [Philip Howard](http://vrb.slashusr.org/), and [adapted to Darwin](http://www.snoize.com/Code/PlayBufferedSoundFile.tar.gz) by [Kurt Revis](http://www.snoize.com)
rpm-build ca19af
rpm-build ca19af
See more info at [atastypixel.com](http://atastypixel.com/blog/a-simple-fast-circular-buffer-implementation-for-audio-processing/)
rpm-build ca19af