Audacity 3.2.0
Classes | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
anonymous_namespace{ScrubState.cpp}::ScrubQueue Struct Reference
Inheritance diagram for anonymous_namespace{ScrubState.cpp}::ScrubQueue:
[legend]
Collaboration diagram for anonymous_namespace{ScrubState.cpp}::ScrubQueue:
[legend]

Classes

struct  Data
 
struct  Message
 

Public Member Functions

 ScrubQueue ()
 
void Init (double t0, double rate, const ScrubbingOptions &options)
 
void Update (double end, const ScrubbingOptions &options)
 
void Get (sampleCount &startSample, sampleCount &endSample, sampleCount inDuration, sampleCount &duration)
 
void Stop ()
 
double LastTrackTime () const
 
 ~ScrubQueue ()
 
bool Started () const
 

Static Public Attributes

static ScrubQueue Instance
 

Private Attributes

double mStartTime {}
 
bool mStarted { false }
 
std::atomic< bool > mStopped { false }
 
Data mData
 
double mRate {}
 
MessageBuffer< MessagemMessage
 
sampleCount mAccumulatedSeekDuration {}
 

Detailed Description

Definition at line 16 of file ScrubState.cpp.

Constructor & Destructor Documentation

◆ ScrubQueue()

anonymous_namespace{ScrubState.cpp}::ScrubQueue::ScrubQueue ( )
inline

Definition at line 20 of file ScrubState.cpp.

20{}

◆ ~ScrubQueue()

anonymous_namespace{ScrubState.cpp}::ScrubQueue::~ScrubQueue ( )
inline

Definition at line 123 of file ScrubState.cpp.

123{}

Member Function Documentation

◆ Get()

void anonymous_namespace{ScrubState.cpp}::ScrubQueue::Get ( sampleCount startSample,
sampleCount endSample,
sampleCount  inDuration,
sampleCount duration 
)
inline

Definition at line 42 of file ScrubState.cpp.

44 {
45 // Called by the thread that calls AudioIO::SequenceBufferExchange
46 startSample = endSample = duration = -1LL;
47 sampleCount s0Init;
48
49 Message message( mMessage.Read() );
50 if ( !mStarted ) {
51 s0Init = llrint( mRate *
52 std::max( message.options.minTime,
53 std::min( message.options.maxTime, mStartTime ) ) );
54
55 // Make some initial silence. This is not needed in the case of
56 // keyboard scrubbing or play-at-speed, because the initial speed
57 // is known when this function is called the first time.
58 if ( !(message.options.isKeyboardScrubbing) ) {
59 mData.mS0 = mData.mS1 = s0Init;
60 mData.mGoal = -1;
61 mData.mDuration = duration = inDuration;
62 mData.mSilence = 0;
63 }
64 }
65
66 if (mStarted || message.options.isKeyboardScrubbing) {
67 Data newData;
68 inDuration += mAccumulatedSeekDuration;
69
70 // If already started, use the previous end as NEW start.
71 const auto s0 = mStarted ? mData.mS1 : s0Init;
72 const sampleCount s1 ( message.options.bySpeed
73 ? s0.as_double() +
74 lrint(inDuration.as_double() * message.end) // end is a speed
75 : lrint(message.end * mRate) // end is a time
76 );
77 auto success =
78 newData.Init(mData, s0, s1, inDuration, message.options, mRate);
79 if (success)
81 else {
82 mAccumulatedSeekDuration += inDuration;
83 return;
84 }
85 mData = newData;
86 };
87
88 mStarted = true;
89
90 Data &entry = mData;
91 if ( mStopped.load( std::memory_order_relaxed ) ) {
92 // We got the shut-down signal, or we discarded all the work.
93 // Output the -1 values.
94 }
95 else if (entry.mDuration > 0) {
96 // First use of the entry
97 startSample = entry.mS0;
98 endSample = entry.mS1;
99 duration = entry.mDuration;
100 entry.mDuration = 0;
101 }
102 else if (entry.mSilence > 0) {
103 // Second use of the entry
104 startSample = endSample = entry.mS1;
105 duration = entry.mSilence;
106 entry.mSilence = 0;
107 }
108 }
int min(int a, int b)
static ProjectFileIORegistry::AttributeWriterEntry entry
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
double as_double() const
Definition: SampleCount.h:46
#define lrint(dbl)
Definition: float_cast.h:169
TranslatableString Message(unsigned trackCount)

References sampleCount::as_double(), ScrubbingOptions::bySpeed, anonymous_namespace{ScrubState.cpp}::ScrubQueue::Message::end, entry, anonymous_namespace{ScrubState.cpp}::ScrubQueue::Data::Init(), ScrubbingOptions::isKeyboardScrubbing, lrint, ScrubbingOptions::maxTime, min(), ScrubbingOptions::minTime, and anonymous_namespace{ScrubState.cpp}::ScrubQueue::Message::options.

Here is the call graph for this function:

◆ Init()

void anonymous_namespace{ScrubState.cpp}::ScrubQueue::Init ( double  t0,
double  rate,
const ScrubbingOptions options 
)
inline

Definition at line 22 of file ScrubState.cpp.

25 {
26 mRate = rate;
27 mStartTime = t0;
28 const double t1 = options.bySpeed ? options.initSpeed : t0;
29 Update( t1, options );
30
31 mStarted = false;
32 mStopped = false;
34 }
double initSpeed
Definition: ScrubState.h:33
void Update(double end, const ScrubbingOptions &options)
Definition: ScrubState.cpp:36

References ScrubbingOptions::bySpeed, and ScrubbingOptions::initSpeed.

◆ LastTrackTime()

double anonymous_namespace{ScrubState.cpp}::ScrubQueue::LastTrackTime ( ) const
inline

Definition at line 117 of file ScrubState.cpp.

118 {
119 // Needed by the main thread sometimes
120 return mData.mS1.as_double() / mRate;
121 }

◆ Started()

bool anonymous_namespace{ScrubState.cpp}::ScrubQueue::Started ( ) const
inline

Definition at line 125 of file ScrubState.cpp.

125{ return mStarted; }

◆ Stop()

void anonymous_namespace{ScrubState.cpp}::ScrubQueue::Stop ( )
inline

Definition at line 110 of file ScrubState.cpp.

111 {
112 mStopped.store( true, std::memory_order_relaxed );
113 mStarted = false;
114 }

◆ Update()

void anonymous_namespace{ScrubState.cpp}::ScrubQueue::Update ( double  end,
const ScrubbingOptions options 
)
inline

Definition at line 36 of file ScrubState.cpp.

37 {
38 // Called by another thread
39 mMessage.Write({ end, options });
40 }
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::end().

Here is the call graph for this function:

Member Data Documentation

◆ Instance

ScrubQueue anonymous_namespace{ScrubState.cpp}::ScrubQueue::Instance
static

Definition at line 18 of file ScrubState.cpp.

◆ mAccumulatedSeekDuration

sampleCount anonymous_namespace{ScrubState.cpp}::ScrubQueue::mAccumulatedSeekDuration {}
private

Definition at line 287 of file ScrubState.cpp.

◆ mData

Data anonymous_namespace{ScrubState.cpp}::ScrubQueue::mData
private

Definition at line 278 of file ScrubState.cpp.

◆ mMessage

MessageBuffer<Message> anonymous_namespace{ScrubState.cpp}::ScrubQueue::mMessage
private

Definition at line 286 of file ScrubState.cpp.

◆ mRate

double anonymous_namespace{ScrubState.cpp}::ScrubQueue::mRate {}
private

Definition at line 279 of file ScrubState.cpp.

◆ mStarted

bool anonymous_namespace{ScrubState.cpp}::ScrubQueue::mStarted { false }
private

Definition at line 276 of file ScrubState.cpp.

◆ mStartTime

double anonymous_namespace{ScrubState.cpp}::ScrubQueue::mStartTime {}
private

Definition at line 275 of file ScrubState.cpp.

◆ mStopped

std::atomic<bool> anonymous_namespace{ScrubState.cpp}::ScrubQueue::mStopped { false }
private

Definition at line 277 of file ScrubState.cpp.


The documentation for this struct was generated from the following file: