Audacity  2.3.1
Public Member Functions | List of all members
ODDecodeFlacTask Class Referencefinal

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

#include <ODDecodeFlacTask.h>

Inheritance diagram for ODDecodeFlacTask:
ODDecodeTask ODTask

Public Member Functions

 ODDecodeFlacTask ()
 Constructs an ODTask. More...
virtual ~ODDecodeFlacTask ()
std::unique_ptr< ODTaskClone () const override
ODFileDecoderCreateFileDecoder (const wxString &fileName) override
 Creates an ODFileDecoder that decodes a file of filetype the subclass handles. More...
unsigned int GetODType () override
- Public Member Functions inherited from ODDecodeTask
 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 ODFileDecoderGetOrCreateMatchingFileDecoder (ODDecodeBlockFile *blockFile)
virtual int GetNumFileDecoders ()
- Public Member Functions inherited from ODTask
 ODTask ()
 Constructs an ODTask. More...
virtual ~ODTask ()
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 (Track *oldTrack, Track *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 ()

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
- Protected Member Functions inherited from ODDecodeTask
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 inherited from ODDecodeTask
std::vector< std::weak_ptr
< ODDecodeBlockFile > > 
std::vector< std::unique_ptr
< ODFileDecoder > > 
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

Detailed Description

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

Decodes a flac file into a oddecodeBlockFile, but not immediately.

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.

Definition at line 45 of file ODDecodeFlacTask.h.

Constructor & Destructor Documentation

ODDecodeFlacTask::ODDecodeFlacTask ( )

Constructs an ODTask.

Definition at line 50 of file ODDecodeFlacTask.h.

50 {}
ODDecodeFlacTask::~ODDecodeFlacTask ( )

Definition at line 31 of file ODDecodeFlacTask.cpp.

32 {
33 }

Member Function Documentation

std::unique_ptr< ODTask > ODDecodeFlacTask::Clone ( ) const

Implements ODTask.

Definition at line 36 of file ODDecodeFlacTask.cpp.

References ODTask::GetDemandSample().

37 {
38  auto clone = std::make_unique<ODDecodeFlacTask>();
39  clone->mDemandSample = GetDemandSample();
41  //the decoders and blockfiles should not be copied. They are created as the task runs.
42  // This std::move is needed to "upcast" the pointer type
43  return std::move(clone);
44 }
virtual sampleCount GetDemandSample() const
Definition: ODTask.cpp:219
ODFileDecoder * ODDecodeFlacTask::CreateFileDecoder ( const wxString &  fileName)

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

Implements ODDecodeTask.

Definition at line 279 of file ODDecodeFlacTask.cpp.

References ODDecodeTask::mDecoders.

280 {
281  // First check if it really is a FLAC file
282 /*
283  int cnt;
284  wxFile binaryFile;
285  if (!binaryFile.Open(fileName)) {
286  return NULL; // File not found
287  }
289 #ifdef USE_LIBID3TAG
290  // Skip any ID3 tags that might be present
291  id3_byte_t query[ID3_TAG_QUERYSIZE];
292  cnt = binaryFile.Read(query, sizeof(query));
293  cnt = id3_tag_query(query, cnt);
294  binaryFile.Seek(cnt);
295 #endif
297  char buf[5];
298  cnt = binaryFile.Read(buf, 4);
299  binaryFile.Close();
301  if (cnt == wxInvalidOffset || strncmp(buf, FLAC_HEADER, 4) != 0) {
302  // File is not a FLAC file
303  return NULL;
304  }
306  // Open the file for import
307  auto decoder = std::std::make_unique<ODFlacDecoder>(fileName);
308 */
309 /*
310  bool success = decoder->Init();
311  if (!success) {
312  return NULL;
313  }
314 */
315  // Open the file for import
316  auto decoder = std::make_unique<ODFlacDecoder>(fileName);
318  mDecoders.push_back(std::move(decoder));
319  return mDecoders.back().get();
321 }
std::vector< std::unique_ptr< ODFileDecoder > > mDecoders
Definition: ODDecodeTask.h:93
unsigned int ODDecodeFlacTask::GetODType ( )

Lets other classes know that this class handles flac Subclasses should override to return respective type.

Reimplemented from ODTask.

Definition at line 60 of file ODDecodeFlacTask.h.

References ODTask::eODFLAC.

60 { return eODFLAC; }

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