Audacity 3.2.0
DefaultPlaybackPolicy.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file DefaultPlaybackPolicy.h
6
7 Paul Licameli split from PlaybackSchedule.h
8
9 **********************************************************************/
10#ifndef __AUDACITY_DEFAULT_PLAYBACK_POLICY__
11#define __AUDACITY_DEFAULT_PLAYBACK_POLICY__
12
13#include "PlaybackSchedule.h"
14
16
21 : public PlaybackPolicy
22 , public NonInterferingBase
23{
24public:
26 double trackEndTime, double loopEndTime, std::optional<double> pStartTime,
27 bool loopEnabled, bool variableSpeed);
29
30 void Initialize( PlaybackSchedule &schedule, double rate ) override;
31
33
35
36 bool Done( PlaybackSchedule &schedule, unsigned long ) override;
37
38 double OffsetSequenceTime(PlaybackSchedule& schedule, double offset) override;
39
41 PlaybackSchedule &schedule, size_t available ) override;
42
43 std::pair<double, double>
45 double trackTime, size_t nSamples ) override;
46
48 PlaybackSchedule &schedule, const Mixers &playbackMixers,
49 size_t frames, size_t available ) override;
50
51 bool Looping( const PlaybackSchedule & ) const override;
52
53private:
54 bool RevertToOldDefault( const PlaybackSchedule &schedule ) const;
55 void WriteMessage();
56 double GetPlaySpeed();
57
59
60 // The main thread writes changes in response to user events, and
61 // the audio thread later reads, and changes the playback.
62 struct SlotData {
63 double mPlaySpeed;
64 double mT0;
65 double mT1;
67 };
69
72
73 double mLastPlaySpeed{ 1.0 };
74 const double mTrackEndTime;
76 std::optional<double> mpStartTime;
77 size_t mRemaining{ 0 };
78 bool mProgress{ true };
79 bool mLoopEnabled{ true };
80 bool mVariableSpeed{ false };
81};
82
83#endif
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
The PlaybackPolicy used by Audacity for most playback.
PlaybackSlice GetPlaybackSlice(PlaybackSchedule &schedule, size_t available) override
Choose length of one fetch of samples from tracks in a call to AudioIO::FillPlayBuffers.
BufferTimes SuggestedBufferTimes(PlaybackSchedule &schedule) override
Provide hints for construction of playback RingBuffer objects.
bool RepositionPlayback(PlaybackSchedule &schedule, const Mixers &playbackMixers, size_t frames, size_t available) override
AudioIO::FillPlayBuffers calls this to update its cursors into tracks for changes of position or spee...
void Initialize(PlaybackSchedule &schedule, double rate) override
Called before starting an audio stream.
MessageBuffer< SlotData > mMessageChannel
Observer::Subscription mSpeedSubscription
bool RevertToOldDefault(const PlaybackSchedule &schedule) const
Mixer::WarpOptions MixerWarpOptions(PlaybackSchedule &schedule) override
Options to use when constructing mixers for each playback track.
AudacityProject & mProject
std::optional< double > mpStartTime
~DefaultPlaybackPolicy() override
std::pair< double, double > AdvancedTrackTime(PlaybackSchedule &schedule, double trackTime, size_t nSamples) override
Compute a new point in a track's timeline from an old point and a real duration.
Observer::Subscription mRegionSubscription
double OffsetSequenceTime(PlaybackSchedule &schedule, double offset) override
Called when the play head needs to jump a certain distance.
bool Looping(const PlaybackSchedule &) const override
DefaultPlaybackPolicy(AudacityProject &project, double trackEndTime, double loopEndTime, std::optional< double > pStartTime, bool loopEnabled, bool variableSpeed)
bool Done(PlaybackSchedule &schedule, unsigned long) override
Returns true if schedule.GetSequenceTime() has reached the end of playback.
Communicate data atomically from one writer thread to one reader.
Definition: MessageBuffer.h:23
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
Directs which parts of tracks to fetch for playback.
std::vector< std::unique_ptr< Mixer > > Mixers
Immutable structure is an argument to Mixer's constructor.
Definition: MixerOptions.h:56
Times are in seconds.
Describes an amount of contiguous (but maybe time-warped) data to be extracted from tracks to play.