Switchboard SDK
Loading...
Searching...
No Matches
switchboard::AudioBufferPool< T > Class Template Reference

Allocates memory for multiple AudioBuffer instances. More...

#include <AudioBufferPool.hpp>

Public Member Functions

 AudioBufferPool (const uint maxNumberOfBuffers, const uint maxNumberOfChannels, const uint maxNumberOfFrames)
 Creates an AudioBufferPool instance.
 
 ~AudioBufferPool ()
 AudioBufferPool destructor.
 
uint getNumberOfAvailableBuffers () const
 Returns the number of available audio buffers in the pool.
 
AudioBuffer< T > & takeAudioBuffer (const uint numberOfChannels, const uint numberOfFrames)
 Takes an audio buffer from the pool.
 
void returnAudioBuffer (AudioBuffer< T > &audioBuffer)
 Returns an audio buffer to the pool.
 

Detailed Description

template<typename T>
class switchboard::AudioBufferPool< T >

Allocates memory for multiple AudioBuffer instances.

AudioBufferPool class.

This class can be used to avoid allocations on the real-time audio thread by pre-allocating enough memory for the audio buffers. Only supports non-interleaved buffers.

Constructor & Destructor Documentation

◆ AudioBufferPool()

template<typename T >
switchboard::AudioBufferPool< T >::AudioBufferPool ( const uint maxNumberOfBuffers,
const uint maxNumberOfChannels,
const uint maxNumberOfFrames )

Creates an AudioBufferPool instance.

Parameters
maxNumberOfBuffersMaximum number of AudioBuffer instances that can be taked from the pool.
maxNumberOfChannelsMaximum number of channels for each audio buffer.
maxNumberOfFramesMaximum number of channels for each audio buffer.

Member Function Documentation

◆ getNumberOfAvailableBuffers()

template<typename T >
uint switchboard::AudioBufferPool< T >::getNumberOfAvailableBuffers ( ) const

Returns the number of available audio buffers in the pool.

Returns
The number of available audio buffers.

◆ returnAudioBuffer()

template<typename T >
void switchboard::AudioBufferPool< T >::returnAudioBuffer ( AudioBuffer< T > & audioBuffer)

Returns an audio buffer to the pool.

Parameters
audioBufferThe returned audio buffer.

◆ takeAudioBuffer()

template<typename T >
AudioBuffer< T > & switchboard::AudioBufferPool< T >::takeAudioBuffer ( const uint numberOfChannels,
const uint numberOfFrames )

Takes an audio buffer from the pool.

Parameters
numberOfChannelsThe number of channels for the audio buffer.
numberOfFramesThe number of frames for the audio buffer.
Returns
The AudioBuffer instance.