Audacity  3.0.3
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:
[legend]
Collaboration diagram for ODDecodeFlacTask:
[legend]

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...
 
TranslatableString 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, const std::shared_ptr< Track > &newTrack)
 Replaces all instances to a wavetrack with a NEW one, effectively transferring the task. More...
 
void AddWaveTrack (const std::shared_ptr< WaveTrack > &track)
 Adds a WaveTrack to do the task for. More...
 
virtual int GetNumWaveTracks ()
 
virtual std::shared_ptr< 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 > > mBlockFiles
 
std::vector< std::unique_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< std::weak_ptr< 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 46 of file ODDecodeFlacTask.h.

Constructor & Destructor Documentation

◆ ODDecodeFlacTask()

ODDecodeFlacTask::ODDecodeFlacTask ( )
inline

Constructs an ODTask.

Definition at line 51 of file ODDecodeFlacTask.h.

51 {}

◆ ~ODDecodeFlacTask()

ODDecodeFlacTask::~ODDecodeFlacTask ( )
virtual

Definition at line 30 of file ODDecodeFlacTask.cpp.

31 {
32 }

Member Function Documentation

◆ Clone()

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

Implements ODTask.

Definition at line 35 of file ODDecodeFlacTask.cpp.

36 {
37  auto clone = std::make_unique<ODDecodeFlacTask>();
38  clone->mDemandSample = GetDemandSample();
39 
40  //the decoders and blockfiles should not be copied. They are created as the task runs.
41  // This std::move is needed to "upcast" the pointer type
42  return std::move(clone);
43 }

References ODTask::GetDemandSample().

Here is the call graph for this function:

◆ CreateFileDecoder()

ODFileDecoder * ODDecodeFlacTask::CreateFileDecoder ( const wxString &  fileName)
overridevirtual

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

Implements ODDecodeTask.

Definition at line 278 of file ODDecodeFlacTask.cpp.

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

References ODDecodeTask::mDecoders.

◆ GetODType()

unsigned int ODDecodeFlacTask::GetODType ( )
inlineoverridevirtual

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

Reimplemented from ODTask.

Definition at line 61 of file ODDecodeFlacTask.h.

61 { return eODFLAC; }

References ODTask::eODFLAC.


The documentation for this class was generated from the following files:
ODDecodeTask::mDecoders
std::vector< std::unique_ptr< ODFileDecoder > > mDecoders
Definition: ODDecodeTask.h:92
ODTask::eODFLAC
@ eODFLAC
Definition: ODTask.h:44
ODTask::GetDemandSample
virtual sampleCount GetDemandSample() const
Definition: ODTask.cpp:221