Audacity  2.2.0
ODTask Class Referenceabstract

A class representing a modular task to be used with the On-Demand structures. More...

#include <ODTask.h>

Inheritance diagram for ODTask:
ODComputeSummaryTask ODDecodeTask ODDecodeFlacTask

Public Types

enum  {
  eODNone = 0x00000000, eODFLAC = 0x00000001, eODMP3 = 0x00000002, eODFFMPEG = 0x00000004,
  eODPCMSummary = 0x00001000, eODOTHER = 0x10000000
}
 

Public Member Functions

 ODTask ()
 Constructs an ODTask. More...
 
virtual ~ODTask ()
 
virtual movable_ptr< ODTaskClone () const =0
 
virtual unsigned int GetODType ()
 Subclasses should override to return respective type. More...
 
void DoSome (float amountWork=0.0)
 
void DoAll ()
 Call DoSome until PercentComplete >= 1.0. More...
 
virtual float PercentComplete ()
 return the amount of the task that has been completed. 0.0 to 1.0 More...
 
virtual bool UsesCustomWorkUntilPercentage ()
 
virtual float ComputeNextWorkUntilPercentageComplete ()
 
virtual bool CanMergeWith (ODTask *otherTask)
 
virtual void StopUsingWaveTrack (WaveTrack *track)
 
virtual void ReplaceWaveTrack (WaveTrack *oldTrack, WaveTrack *newTrack)
 Replaces all instances to a wavetrack with a NEW one, effectively transferring the task. More...
 
void AddWaveTrack (WaveTrack *track)
 Adds a WaveTrack to do the task for. More...
 
virtual int GetNumWaveTracks ()
 
virtual WaveTrackGetWaveTrack (int i)
 
virtual void DemandTrackUpdate (WaveTrack *track, double seconds)
 changes the tasks associated with this Waveform to process the task from a different point in the track More...
 
bool IsComplete ()
 return More...
 
void TerminateAndBlock ()
 
virtual void Terminate ()
 releases memory that the ODTask owns. Subclasses should override. More...
 
virtual const char * GetTaskName ()
 
virtual sampleCount GetDemandSample () const
 
virtual void SetDemandSample (sampleCount sample)
 
virtual void RecalculatePercentComplete ()
 does an od update and then recalculates the data. More...
 
int GetTaskNumber ()
 returns the number of tasks created before this instance. More...
 
void SetNeedsODUpdate ()
 
bool GetNeedsODUpdate ()
 
void ResetNeedsODUpdate ()
 
virtual const wxChar * GetTip ()=0
 
virtual bool IsTaskAssociatedWithProject (AudacityProject *proj)
 returns true if the task is associated with the project. More...
 
bool IsRunning ()
 

Public Attributes

enum ODTask:: { ... }  ODTypeEnum
 

Protected Member Functions

virtual void CalculatePercentComplete ()=0
 calculates the percentage complete from existing data. More...
 
virtual void DoSomeInternal ()=0
 
virtual void Update ()
 virtual method called before DoSomeInternal is used from DoSome. More...
 
virtual void ODUpdate ()
 
void SetIsRunning (bool value)
 

Protected Attributes

int mTaskNumber
 
volatile float mPercentComplete
 
ODLock mPercentCompleteMutex
 
volatile bool mDoingTask
 
volatile bool mTaskStarted
 
volatile bool mTerminate
 
ODLock mTerminateMutex
 
ODLock mBlockUntilTerminateMutex
 
std::vector< WaveTrack * > mWaveTracks
 
ODLock mWaveTrackMutex
 
sampleCount mDemandSample
 
ODLock mDemandSampleMutex
 
volatile bool mIsRunning
 
ODLock mIsRunningMutex
 

Private Attributes

volatile bool mNeedsODUpdate
 
ODLock mNeedsODUpdateMutex
 

Detailed Description

A class representing a modular task to be used with the On-Demand structures.

ODTask is an abstract class that outlines the methods that will be used to support On-Demand background loading of files. These ODTasks are generally meant to be run in a background thread.

Member Enumeration Documentation

anonymous enum
Enumerator
eODNone 
eODFLAC 
eODMP3 
eODFFMPEG 
eODPCMSummary 
eODOTHER 

Constructor & Destructor Documentation

ODTask::ODTask ( )

Constructs an ODTask.

virtual ODTask::~ODTask ( )
inlinevirtual

Member Function Documentation

void ODTask::AddWaveTrack ( WaveTrack track)

Adds a WaveTrack to do the task for.

Sets the wavetrack that will be analyzed for ODPCMAliasBlockFiles that will have their summaries computed and written to disk.

References mWaveTracks.

Referenced by AudacityProject::EnqueueODTasks(), and AudacityProject::PopState().

virtual void ODTask::CalculatePercentComplete ( )
protectedpure virtual

calculates the percentage complete from existing data.

Implemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by RecalculatePercentComplete().

virtual bool ODTask::CanMergeWith ( ODTask otherTask)
inlinevirtual

returns whether or not this task and another task can merge together, as when we make two mono tracks stereo. for Loading/Summarizing, this is not an issue because the entire track is processed Effects that affect portions of a track will need to check this.

References GetTaskName().

virtual movable_ptr<ODTask> ODTask::Clone ( ) const
pure virtual

Implemented in ODDecodeFlacTask, and ODComputeSummaryTask.

virtual float ODTask::ComputeNextWorkUntilPercentageComplete ( )
inlinevirtual

Reimplemented in ODComputeSummaryTask.

Referenced by DoSome().

void ODTask::DemandTrackUpdate ( WaveTrack track,
double  seconds 
)
virtual

changes the tasks associated with this Waveform to process the task from a different point in the track

changes the tasks associated with this Waveform to process the task from a different point in the track

Parameters
trackthe track to update
secondsthe point in the track from which the tasks associated with track should begin processing from.

Reimplemented in ODDecodeTask.

References GetDemandSample(), WaveTrack::GetRate(), mWaveTrackMutex, mWaveTracks, SetDemandSample(), and SetNeedsODUpdate().

Referenced by ODDecodeTask::DemandTrackUpdate().

void ODTask::DoAll ( )

Call DoSome until PercentComplete >= 1.0.

void ODTask::DoSome ( float  amountWork = 0.0)

Do a modular part of the task. For example, if the task is to load the entire file, load one BlockFile. Relies on DoSomeInternal(), which is the subclasses must implement.

Parameters
amountWorkthe percent amount of the total job to do. 1.0 represents the entire job. the default of 0.0 will do the smallest unit of work possible

References ODManager::AddTask(), AudacityProject::AllProjectDeleteMutex(), ComputeNextWorkUntilPercentageComplete(), DoSomeInternal(), gAudacityProjects, GetNeedsODUpdate(), ODManager::Instance, IsTaskAssociatedWithProject(), mBlockUntilTerminateMutex, mDoingTask, mTaskStarted, mTerminate, mTerminateMutex, ODUpdate(), PercentComplete(), SetIsRunning(), Update(), and UsesCustomWorkUntilPercentage().

virtual void ODTask::DoSomeInternal ( )
protectedpure virtual

pure virtual function that does some part of the task this object represents. this function is meant to be called repeatedly until the IsComplete is true. Does the smallest unit of work for this task.

Implemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by DoSome().

sampleCount ODTask::GetDemandSample ( ) const
virtual
bool ODTask::GetNeedsODUpdate ( )
int ODTask::GetNumWaveTracks ( )
virtual
virtual unsigned int ODTask::GetODType ( )
inlinevirtual

Subclasses should override to return respective type.

Reimplemented in ODDecodeFlacTask, ODDecodeTask, and ODComputeSummaryTask.

virtual const char* ODTask::GetTaskName ( )
inlinevirtual

Reimplemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by CanMergeWith().

int ODTask::GetTaskNumber ( )
inline

returns the number of tasks created before this instance.

virtual const wxChar* ODTask::GetTip ( )
pure virtual

Implemented in ODDecodeTask, and ODComputeSummaryTask.

WaveTrack * ODTask::GetWaveTrack ( int  i)
virtual
bool ODTask::IsComplete ( )

return

References IsRunning(), and PercentComplete().

bool ODTask::IsRunning ( )

References mIsRunning, and mIsRunningMutex.

Referenced by IsComplete().

bool ODTask::IsTaskAssociatedWithProject ( AudacityProject proj)
virtual

returns true if the task is associated with the project.

References TrackListIterator::First(), Track::GetKind(), AudacityProject::GetTracks(), mWaveTrackMutex, mWaveTracks, TrackListIterator::Next(), and Track::Wave.

Referenced by DoSome().

void ODTask::ODUpdate ( )
protectedvirtual

virtual method called in DoSome everytime the user has demanded some OD function so that the ODTask can readjust its computation order. By default just calls Update(), but subclasses with special needs can override this

References ResetNeedsODUpdate(), and Update().

Referenced by DoSome(), and RecalculatePercentComplete().

float ODTask::PercentComplete ( )
virtual

return the amount of the task that has been completed. 0.0 to 1.0

References mPercentComplete, and mPercentCompleteMutex.

Referenced by DoSome(), and IsComplete().

void ODTask::RecalculatePercentComplete ( )
virtual

does an od update and then recalculates the data.

References CalculatePercentComplete(), GetNeedsODUpdate(), and ODUpdate().

void ODTask::ReplaceWaveTrack ( WaveTrack oldTrack,
WaveTrack newTrack 
)
virtual

Replaces all instances to a wavetrack with a NEW one, effectively transferring the task.

Replaces all instances to a wavetrack with a NEW one, effectively transferring the task. ODTask has no wavetrack, so it does nothing. But subclasses that do should override this.

References mWaveTrackMutex, and mWaveTracks.

void ODTask::ResetNeedsODUpdate ( )

References mNeedsODUpdate, and mNeedsODUpdateMutex.

Referenced by ODUpdate().

void ODTask::SetDemandSample ( sampleCount  sample)
virtual

References mDemandSample, and mDemandSampleMutex.

Referenced by DemandTrackUpdate().

void ODTask::SetIsRunning ( bool  value)
protected

References mIsRunning, and mIsRunningMutex.

Referenced by DoSome().

void ODTask::SetNeedsODUpdate ( )

References mNeedsODUpdate, and mNeedsODUpdateMutex.

Referenced by DemandTrackUpdate().

void ODTask::StopUsingWaveTrack ( WaveTrack track)
virtual

References mWaveTrackMutex, and mWaveTracks.

virtual void ODTask::Terminate ( )
inlinevirtual

releases memory that the ODTask owns. Subclasses should override.

Reimplemented in ODComputeSummaryTask.

Referenced by TerminateAndBlock().

void ODTask::TerminateAndBlock ( )
virtual void ODTask::Update ( )
inlineprotectedvirtual

virtual method called before DoSomeInternal is used from DoSome.

Reimplemented in ODDecodeTask, and ODComputeSummaryTask.

Referenced by DoSome(), and ODUpdate().

virtual bool ODTask::UsesCustomWorkUntilPercentage ( )
inlinevirtual

Reimplemented in ODComputeSummaryTask.

Referenced by DoSome().

Member Data Documentation

ODLock ODTask::mBlockUntilTerminateMutex
protected

Referenced by DoSome(), and TerminateAndBlock().

sampleCount ODTask::mDemandSample
protected

Referenced by GetDemandSample(), and SetDemandSample().

ODLock ODTask::mDemandSampleMutex
mutableprotected

Referenced by GetDemandSample(), and SetDemandSample().

volatile bool ODTask::mDoingTask
protected

Referenced by DoSome().

volatile bool ODTask::mIsRunning
protected

Referenced by IsRunning(), and SetIsRunning().

ODLock ODTask::mIsRunningMutex
protected

Referenced by IsRunning(), and SetIsRunning().

volatile bool ODTask::mNeedsODUpdate
private
ODLock ODTask::mNeedsODUpdateMutex
private
int ODTask::mTaskNumber
protected
volatile bool ODTask::mTaskStarted
protected

Referenced by DoSome().

volatile bool ODTask::mTerminate
protected

Referenced by DoSome(), and TerminateAndBlock().

ODLock ODTask::mTerminateMutex
protected

Referenced by DoSome(), and TerminateAndBlock().

enum { ... } ODTask::ODTypeEnum

The documentation for this class was generated from the following files: