Audacity  2.2.0
ODDecodeTask Class Referenceabstract

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

#include <ODDecodeTask.h>

Inheritance diagram for ODDecodeTask:
ODTask ODDecodeFlacTask

Public Member Functions

 ODDecodeTask ()
 Creates a NEW task that decodes files. More...
 
virtual ~ODDecodeTask ()
 
virtual bool SeekingAllowed ()
 
void DemandTrackUpdate (WaveTrack *track, double seconds) override
 
const char * GetTaskName () override
 Return the task name. More...
 
const wxChar * GetTip () override
 
unsigned int GetODType () override
 Subclasses should override to return respective type. More...
 
virtual ODFileDecoderCreateFileDecoder (const wxString &fileName)=0
 Creates an ODFileDecoder that decodes a file of filetype the subclass handles. More...
 
virtual ODFileDecoderGetOrCreateMatchingFileDecoder (ODDecodeBlockFile *blockFile)
 
virtual int GetNumFileDecoders ()
 
- Public Member Functions inherited from ODTask
 ODTask ()
 Constructs an ODTask. More...
 
virtual ~ODTask ()
 
virtual movable_ptr< ODTaskClone () const =0
 
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)
 
bool IsComplete ()
 return More...
 
void TerminateAndBlock ()
 
virtual void Terminate ()
 releases memory that the ODTask owns. Subclasses should override. More...
 
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 bool IsTaskAssociatedWithProject (AudacityProject *proj)
 returns true if the task is associated with the project. More...
 
bool IsRunning ()
 

Protected Member Functions

void CalculatePercentComplete () override
 recalculates the percentage complete. More...
 
void DoSomeInternal () override
 Computes and writes the data for one BlockFile if it still has a refcount. More...
 
void Update () override
 by default creates the order of the wavetrack to load. More...
 
void OrderBlockFiles (std::vector< std::weak_ptr< ODDecodeBlockFile > > &unorderedBlocks)
 Orders the input as either On-Demand or default layered order. More...
 
- Protected Member Functions inherited from ODTask
virtual void ODUpdate ()
 
void SetIsRunning (bool value)
 

Protected Attributes

std::vector< std::weak_ptr
< ODDecodeBlockFile > > 
mBlockFiles
 
std::vector< movable_ptr
< ODFileDecoder > > 
mDecoders
 
int mMaxBlockFiles
 
- Protected Attributes inherited from ODTask
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
 

Additional Inherited Members

- Public Types inherited from ODTask
enum  {
  eODNone = 0x00000000, eODFLAC = 0x00000001, eODMP3 = 0x00000002, eODFFMPEG = 0x00000004,
  eODPCMSummary = 0x00001000, eODOTHER = 0x10000000
}
 
- Public Attributes inherited from ODTask
enum ODTask:: { ... }  ODTypeEnum
 

Detailed Description

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

Decodes a file into a simpleBlockFile, but not immediately.

Decodes files and writes block files in .au format, updating the ODDecodeBlockFile and the GUI of the newly available data.

This is an abstract class that subclasses will have to derive the types from. For any type there should only be one ODDecodeTask associated with a given track. There could be the ODDecodeBlockFiles of several FLACs in one track (after copy and pasting), so things aren't as simple as they seem - the implementation needs to be robust enough to allow all the user changes such as copy/paste, DELETE, and so on.

Constructor & Destructor Documentation

ODDecodeTask::ODDecodeTask ( )

Creates a NEW task that decodes files.

References mMaxBlockFiles.

virtual ODDecodeTask::~ODDecodeTask ( )
inlinevirtual

Member Function Documentation

void ODDecodeTask::CalculatePercentComplete ( )
overrideprotectedvirtual

recalculates the percentage complete.

Implements ODTask.

References mBlockFiles, mMaxBlockFiles, ODTask::mPercentComplete, and ODTask::mPercentCompleteMutex.

Referenced by DoSomeInternal().

virtual ODFileDecoder* ODDecodeTask::CreateFileDecoder ( const wxString &  fileName)
pure virtual

Creates an ODFileDecoder that decodes a file of filetype the subclass handles.

Implemented in ODDecodeFlacTask.

Referenced by GetOrCreateMatchingFileDecoder().

void ODDecodeTask::DemandTrackUpdate ( WaveTrack track,
double  seconds 
)
overridevirtual

changes the tasks associated with this Waveform to process the task from a different point in the track this is overridden from ODTask because certain classes don't allow users to seek sometimes, or not at all.

Reimplemented from ODTask.

References ODTask::DemandTrackUpdate(), and SeekingAllowed().

void ODDecodeTask::DoSomeInternal ( )
overrideprotectedvirtual
int ODDecodeTask::GetNumFileDecoders ( )
virtual

References mDecoders.

unsigned int ODDecodeTask::GetODType ( )
inlineoverridevirtual

Subclasses should override to return respective type.

Reimplemented from ODTask.

References ODTask::eODNone.

Referenced by GetOrCreateMatchingFileDecoder(), and Update().

ODFileDecoder * ODDecodeTask::GetOrCreateMatchingFileDecoder ( ODDecodeBlockFile blockFile)
virtual

there could be the ODDecodeBlockFiles of several FLACs in one track (after copy and pasting) so we keep a list of decoders that keep track of the file names, etc, and check the blocks against them. Blocks that have IsDataAvailable()==false are blockfiles to be decoded. if BlockFile::GetDecodeType()==ODDecodeTask::GetODType() then this decoder should handle it. Decoders are accessible with the methods below. These aren't thread-safe and should only be called from the decoding thread.

References CreateFileDecoder(), ODDecodeBlockFile::GetAudioFileName(), ODDecodeBlockFile::GetDecodeType(), GetODType(), and mDecoders.

Referenced by DoSomeInternal().

const char* ODDecodeTask::GetTaskName ( )
inlineoverridevirtual

Return the task name.

Reimplemented from ODTask.

const wxChar* ODDecodeTask::GetTip ( )
inlineoverridevirtual

Implements ODTask.

References _().

void ODDecodeTask::OrderBlockFiles ( std::vector< std::weak_ptr< ODDecodeBlockFile > > &  unorderedBlocks)
protected

Orders the input as either On-Demand or default layered order.

Referenced by Update().

bool ODDecodeTask::SeekingAllowed ( )
virtual

References mDecoders.

Referenced by DemandTrackUpdate().

void ODDecodeTask::Update ( )
overrideprotectedvirtual

by default creates the order of the wavetrack to load.

Readjusts the blockfile order in the default manner. If we have had an ODRequest Then it updates in the OD manner.

Reimplemented from ODTask.

References SeqBlock::f, GetODType(), Sequence::LockDeleteUpdateMutex(), ODTask::mWaveTrackMutex, ODTask::mWaveTracks, OrderBlockFiles(), SeqBlock::start, and Sequence::UnlockDeleteUpdateMutex().

Member Data Documentation

std::vector<std::weak_ptr<ODDecodeBlockFile> > ODDecodeTask::mBlockFiles
protected
int ODDecodeTask::mMaxBlockFiles
protected

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