Om
1.0.0
A universal framework for multimedia simulation
|
A class that provides a pool of thread-safe temporary SoundBuffer objects for efficient DSP processing. More...
#include <omSoundSharedBufferPool.h>
Public Member Functions | |
SharedBufferPool () | |
Create a new empty shared buffer pool. More... | |
SharedSoundBuffer | getBuffer () |
Return a handle to a shared sound buffer. More... | |
SharedSoundBuffer | getBuffer (Size numChannels, Size numSamples, SampleRate sampleRate) |
Return a handle to a shared sound buffer with the specified attributes. More... | |
void | reset () |
Clear all buffers from this buffer pool that are not in use. More... | |
Static Public Member Functions | |
static SharedSoundBuffer | getGlobalBuffer () |
Return a handle to a shared global sound buffer. More... | |
static SharedSoundBuffer | getGlobalBuffer (Size numChannels, Size numSamples, SampleRate sampleRate) |
Return a handle to a shared global sound buffer with the specified attributes. More... | |
static void | globalReset () |
Clear all buffers from the global buffer pool that are not in use. More... | |
A class that provides a pool of thread-safe temporary SoundBuffer objects for efficient DSP processing.
Often when doing DSP, a temporary buffer of sound samples is needed for intermediate processing. This class provides a way for DSP classes to access a reference to a temporary buffer that is shared among them. These buffers are locked for use when requested and unlocked when the returned SharedSoundBuffer goes out of scope.
When requesting a buffer, the user can specify the attributes of that buffer, and the buffer pool will return a buffer (creating one if necessary) that matches those characteristics.
|
inline |
Create a new empty shared buffer pool.
SharedSoundBuffer om::sound::base::SharedBufferPool::getBuffer | ( | ) |
Return a handle to a shared sound buffer.
This method looks at the available buffers in the pool and returns the first one, ignoring its format. It then locks that buffer and returns a handle to it. When that handle is destructed, the buffer is reclaimed by the pool and can no longer be used.
SharedSoundBuffer om::sound::base::SharedBufferPool::getBuffer | ( | Size | numChannels, |
Size | numSamples, | ||
SampleRate | sampleRate | ||
) |
Return a handle to a shared sound buffer with the specified attributes.
This method looks at the available buffers in the pool and picks one that matches the requested number of channels, number of samples, and sample rate. It then locks that buffer and returns a handle to it. When that handle is destructed, the buffer is reclaimed by the pool and can no longer be used.
void om::sound::base::SharedBufferPool::reset | ( | ) |
Clear all buffers from this buffer pool that are not in use.
|
inlinestatic |
Return a handle to a shared global sound buffer.
|
inlinestatic |
Return a handle to a shared global sound buffer with the specified attributes.
|
inlinestatic |
Clear all buffers from the global buffer pool that are not in use.