|
tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications
« « « Anklang Documentation |
Plays back a node with mutiple threads. More...
#include "tracktion_LockFreeMultiThreadedNodePlayer.h"
Classes | |
| struct | ThreadPool |
| Base class for thread pools which can be customised to determine how cooperative threads should behave. More... | |
Public Types | |
| using | ThreadPoolCreator = std::function< std::unique_ptr< ThreadPool >(LockFreeMultiThreadedNodePlayer &)> |
Public Member Functions | |
| LockFreeMultiThreadedNodePlayer () | |
| Creates an empty LockFreeMultiThreadedNodePlayer. | |
| LockFreeMultiThreadedNodePlayer (ThreadPoolCreator, juce::AudioWorkgroup={}) | |
| Creates an empty LockFreeMultiThreadedNodePlayer with a specified ThreadPool type. | |
| ~LockFreeMultiThreadedNodePlayer () | |
| Destructor. | |
| void | setNumThreads (size_t) |
| Sets the number of threads to use for rendering. | |
| void | setNode (std::unique_ptr< Node >) |
| Sets the Node to process. | |
| void | setNode (std::unique_ptr< Node > newNode, double sampleRateToUse, int blockSizeToUse) |
| Sets the Node to process with a new sample rate and block size. | |
| void | prepareToPlay (double sampleRateToUse, int blockSizeToUse) |
| Prepares the current Node to be played. | |
| Node * | getNode () |
| Returns the current Node. | |
| int | process (const Node::ProcessContext &) |
| Process a block of the Node. | |
| void | clearNode () |
| Clears the current Node. | |
| double | getSampleRate () const |
| Returns the current sample rate. | |
| int | getBlockSize () const |
| Returns the current block size. | |
| void | enablePooledMemoryAllocations (bool) |
| Enables or disables the use on an AudioBufferPool to reduce memory consumption. | |
| void | enableNodeMemorySharing (bool shouldBeEnabled) |
Plays back a node with mutiple threads.
The setting of Nodes and processing are all lock-free. This means the player can be real-time safe as long as your provided ThreadPool doesn't do any non-real-time operations in the wait/signal methods.
Definition at line 33 of file tracktion_LockFreeMultiThreadedNodePlayer.h.
| using tracktion::graph::LockFreeMultiThreadedNodePlayer::ThreadPoolCreator = std::function<std::unique_ptr<ThreadPool> (LockFreeMultiThreadedNodePlayer&)> |
Definition at line 195 of file tracktion_LockFreeMultiThreadedNodePlayer.h.
| tracktion::graph::LockFreeMultiThreadedNodePlayer::LockFreeMultiThreadedNodePlayer | ( | ) |
Creates an empty LockFreeMultiThreadedNodePlayer.
Definition at line 21 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| tracktion::graph::LockFreeMultiThreadedNodePlayer::LockFreeMultiThreadedNodePlayer | ( | ThreadPoolCreator | poolCreator, |
| juce::AudioWorkgroup | audioWorkgroup_ = {} |
||
| ) |
Creates an empty LockFreeMultiThreadedNodePlayer with a specified ThreadPool type.
Definition at line 26 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| tracktion::graph::LockFreeMultiThreadedNodePlayer::~LockFreeMultiThreadedNodePlayer | ( | ) |
Destructor.
Definition at line 32 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::clearNode | ( | ) |
Clears the current Node.
Note that this shouldn't be called concurrently with setNode. If it's called concurrently with process, it will block until the current process call has finished. This should be used sparingly as its a heavyweight operation which has to stop any processing threads and restart them again afterwrds.
Definition at line 149 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::enableNodeMemorySharing | ( | bool | shouldBeEnabled | ) |
Definition at line 169 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::enablePooledMemoryAllocations | ( | bool | usePool | ) |
Enables or disables the use on an AudioBufferPool to reduce memory consumption.
Don't rely on this, it is a temporary method used for benchmarking and will go away in the future.
Definition at line 163 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| int tracktion::graph::LockFreeMultiThreadedNodePlayer::getBlockSize | ( | ) | const |
Returns the current block size.
Definition at line 245 of file tracktion_LockFreeMultiThreadedNodePlayer.h.
| Node * tracktion::graph::LockFreeMultiThreadedNodePlayer::getNode | ( | ) |
Returns the current Node.
Definition at line 222 of file tracktion_LockFreeMultiThreadedNodePlayer.h.
| double tracktion::graph::LockFreeMultiThreadedNodePlayer::getSampleRate | ( | ) | const |
Returns the current sample rate.
Definition at line 239 of file tracktion_LockFreeMultiThreadedNodePlayer.h.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::prepareToPlay | ( | double | sampleRateToUse, |
| int | blockSizeToUse | ||
| ) |
Prepares the current Node to be played.
Calling this will cause a drop in the output stream as the Node is re-prepared.
Definition at line 61 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| int tracktion::graph::LockFreeMultiThreadedNodePlayer::process | ( | const Node::ProcessContext & | pc | ) |
Process a block of the Node.
Definition at line 84 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::setNode | ( | std::unique_ptr< Node > | newNode, |
| double | sampleRateToUse, | ||
| int | blockSizeToUse | ||
| ) |
Sets the Node to process with a new sample rate and block size.
Definition at line 53 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::setNode | ( | std::unique_ptr< Node > | newNode | ) |
Sets the Node to process.
Definition at line 48 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.
| void tracktion::graph::LockFreeMultiThreadedNodePlayer::setNumThreads | ( | size_t | newNumThreads | ) |
Sets the number of threads to use for rendering.
This can be 0 in which case only the process calling thread will be used for processing. N.B. this will pause processing whilst updating the threads so there will be a gap in the audio.
Definition at line 38 of file tracktion_LockFreeMultiThreadedNodePlayer.cpp.