|
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_MultiThreadedNodePlayer.h"
Classes | |
| class | ThreadPool |
Public Member Functions | |
| MultiThreadedNodePlayer () | |
| Creates an empty MultiThreadedNodePlayer. | |
| ~MultiThreadedNodePlayer () | |
| 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. | |
Plays back a node with mutiple threads.
This uses a simpler internal mechanism than the LockFreeMultiThreadedNodePlayer but uses spin locks do do so so isn't completely wait-free.
The thread pool uses a hybrid method of trying to keep processing threads spinning where possible but falling back to a condition variable if they spin for too long.
This is mainly here to compare performance with the LockFreeMultiThreadedNodePlayer.
Definition at line 27 of file tracktion_MultiThreadedNodePlayer.h.
| tracktion::graph::MultiThreadedNodePlayer::MultiThreadedNodePlayer | ( | ) |
Creates an empty MultiThreadedNodePlayer.
Definition at line 190 of file tracktion_MultiThreadedNodePlayer.cpp.
| tracktion::graph::MultiThreadedNodePlayer::~MultiThreadedNodePlayer | ( | ) |
Destructor.
Definition at line 195 of file tracktion_MultiThreadedNodePlayer.cpp.
| void tracktion::graph::MultiThreadedNodePlayer::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 291 of file tracktion_MultiThreadedNodePlayer.cpp.
| Node * tracktion::graph::MultiThreadedNodePlayer::getNode | ( | ) |
Returns the current Node.
Definition at line 54 of file tracktion_MultiThreadedNodePlayer.h.
| double tracktion::graph::MultiThreadedNodePlayer::getSampleRate | ( | ) | const |
Returns the current sample rate.
Definition at line 75 of file tracktion_MultiThreadedNodePlayer.h.
| void tracktion::graph::MultiThreadedNodePlayer::prepareToPlay | ( | double | sampleRateToUse, |
| int | blockSizeToUse | ||
| ) |
Prepares the current Node to be played.
Definition at line 221 of file tracktion_MultiThreadedNodePlayer.cpp.
| int tracktion::graph::MultiThreadedNodePlayer::process | ( | const Node::ProcessContext & | pc | ) |
Process a block of the Node.
Definition at line 234 of file tracktion_MultiThreadedNodePlayer.cpp.
| void tracktion::graph::MultiThreadedNodePlayer::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 215 of file tracktion_MultiThreadedNodePlayer.cpp.
| void tracktion::graph::MultiThreadedNodePlayer::setNode | ( | std::unique_ptr< Node > | newNode | ) |
Sets the Node to process.
Definition at line 210 of file tracktion_MultiThreadedNodePlayer.cpp.
| void tracktion::graph::MultiThreadedNodePlayer::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 200 of file tracktion_MultiThreadedNodePlayer.cpp.