Audacity 3.2.0
|
#include <PlaybackSchedule.h>
Classes | |
struct | Node |
Public Member Functions | |
TimeQueue () | |
TimeQueue (const TimeQueue &)=delete | |
TimeQueue & | operator= (const TimeQueue &)=delete |
void | Clear () |
void | Init (size_t size) |
void | Producer (PlaybackSchedule &schedule, PlaybackSlice slice) |
Enqueue track time value advanced by the slice according to schedule 's PlaybackPolicy. More... | |
double | GetLastTime () const |
Return the last time saved by Producer. More... | |
void | SetLastTime (double time) |
double | Consumer (size_t nSamples, double rate) |
Find the track time value nSamples after the last consumed sample. More... | |
void | Prime (double time) |
Empty the queue and reassign the last produced time. More... | |
Private Attributes | |
double | mLastTime {} |
Node * | mConsumerNode {} |
Node * | mProducerNode {} |
std::vector< std::unique_ptr< Node > > | mNodePool |
Holds track time values corresponding to every nth sample in the playback buffers, for the large n == TimeQueueGrainSize.
The "producer" is the Audio thread that fetches samples from tracks and fills the playback RingBuffers. The "consumer" is the high-latency PortAudio thread that drains the RingBuffers. The atomics in the RingBuffer implement lock-free synchronization.
This other structure adds other information to the stream of samples: which track times they correspond to.
The consumer thread uses that information, and also makes known to the main thread, what the last consumed track time is. The main thread can use that for other purposes such as refreshing the display of the play head position.
Definition at line 207 of file PlaybackSchedule.h.
|
default |
|
delete |
void PlaybackSchedule::TimeQueue::Clear | ( | ) |
Definition at line 270 of file PlaybackSchedule.cpp.
References mConsumerNode, mNodePool, and mProducerNode.
Referenced by AudioIO::StartStream(), AudioIO::StartStreamCleanup(), and AudioIO::StopStream().
double PlaybackSchedule::TimeQueue::Consumer | ( | size_t | nSamples, |
double | rate | ||
) |
Find the track time value nSamples
after the last consumed sample.
Definition at line 403 of file PlaybackSchedule.cpp.
References TimeQueueGrainSize.
Referenced by AudioIoCallback::UpdateTimePosition().
double PlaybackSchedule::TimeQueue::GetLastTime | ( | ) | const |
Return the last time saved by Producer.
Definition at line 393 of file PlaybackSchedule.cpp.
Referenced by DefaultPlaybackPolicy::RepositionPlayback(), and DefaultPlaybackPolicy::RevertToOldDefault().
void PlaybackSchedule::TimeQueue::Init | ( | size_t | size | ) |
Definition at line 277 of file PlaybackSchedule.cpp.
References size.
Referenced by AudioIO::AllocateBuffers().
void PlaybackSchedule::TimeQueue::Prime | ( | double | time | ) |
Empty the queue and reassign the last produced time.
Assumes producer and consumer are suspended
Definition at line 455 of file PlaybackSchedule.cpp.
Referenced by AudioIoCallback::CallbackDoSeek(), and AudioIO::StartStream().
void PlaybackSchedule::TimeQueue::Producer | ( | PlaybackSchedule & | schedule, |
PlaybackSlice | slice | ||
) |
Enqueue track time value advanced by the slice according to schedule
's PlaybackPolicy.
Definition at line 287 of file PlaybackSchedule.cpp.
References PlaybackSlice::frames, PlaybackSchedule::GetPolicy(), PlaybackSchedule::TimeQueue::Node::head, PlaybackSchedule::TimeQueue::Node::next, PlaybackSchedule::TimeQueue::Node::records, PlaybackSchedule::TimeQueue::Node::tail, TimeQueueGrainSize, and PlaybackSlice::toProduce.
Referenced by AudioIO::ProcessPlaybackSlices().
void PlaybackSchedule::TimeQueue::SetLastTime | ( | double | time | ) |
Definition at line 398 of file PlaybackSchedule.cpp.
Referenced by DefaultPlaybackPolicy::RepositionPlayback().
|
private |
Definition at line 275 of file PlaybackSchedule.h.
Referenced by Clear().
|
private |
Definition at line 242 of file PlaybackSchedule.h.
|
private |
When node's buffer becomes full consumer will pick up a new one from the pool, which also will be linked to the previous node, so that producer could pick it up too.
Definition at line 281 of file PlaybackSchedule.h.
Referenced by Clear().
|
private |
Definition at line 276 of file PlaybackSchedule.h.
Referenced by Clear().