Audacity
3.0.3
|
An AliasBlockFile that references uncompressed data in an existing file. More...
#include <ODDecodeBlockFile.h>
Public Member Functions | |
ODDecodeBlockFile (wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, unsigned int decodeType) | |
Create a disk file and write summary and sample data to it. More... | |
ODDecodeBlockFile (wxFileNameWrapper &&existingFile, wxFileNameWrapper &&audioFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, unsigned int decodeType, float min, float max, float rms, bool dataAvailable) | |
Create the memory structure to refer to the given block file. More... | |
virtual | ~ODDecodeBlockFile () |
bool | IsSummaryAvailable () const override |
bool | IsDataAvailable () const override |
Returns TRUE if this block's complete data is ready to be accessed by Read() More... | |
bool | IsSummaryBeingComputed () override |
Returns TRUE if the summary has not yet been written, but is actively being computed and written to disk. More... | |
const wxFileNameWrapper & | GetExternalFileName () const override |
void | SetExternalFileName (wxFileNameWrapper &&newName) override |
DiskByteCount | GetSpaceUsage () const override |
MinMaxRMS | GetMinMaxRMS (size_t start, size_t len, bool mayThrow) const override |
Gets extreme values for the specified region. More... | |
MinMaxRMS | GetMinMaxRMS (bool mayThrow) const override |
Gets extreme values for the entire block. More... | |
bool | Read256 (float *buffer, size_t start, size_t len) override |
Returns the 256 byte summary data block. More... | |
bool | Read64K (float *buffer, size_t start, size_t len) override |
Returns the 64K summary data block. More... | |
BlockFilePtr | Copy (wxFileNameWrapper &&fileName) override |
Makes NEW ODDecodeBlockFile or SimpleBlockFile depending on summary availability. More... | |
void | SaveXML (XMLWriter &xmlFile) override |
Saves as xml ODDecodeBlockFile or SimpleBlockFile depending on summary availability. More... | |
void | Recover (void) override |
Writes the summary file if summary data is available. More... | |
int | DoWriteBlockFile () |
int | WriteODDecodeBlockFile () |
void | SetStart (sampleCount startSample) |
Sets the value that indicates where the first sample in this block corresponds to the global sequence/clip. Only for display use. More... | |
sampleCount | GetStart () const |
Gets the value that indicates where the first sample in this block corresponds to the global sequence/clip. Only for display use. More... | |
sampleCount | GetGlobalStart () const |
sampleCount | GetGlobalEnd () const |
size_t | ReadData (samplePtr data, sampleFormat format, size_t start, size_t len, bool mayThrow) const override |
Reads the specified data from the aliased file using libsndfile. More... | |
bool | ReadSummary (ArrayOf< char > &data) override |
Read the summary into a buffer. More... | |
unsigned int | GetDecodeType () const |
Returns the type of audiofile this blockfile is loaded from. More... | |
void | SetClipOffset (sampleCount numSamples) |
sets the amount of samples the clip associated with this blockfile is offset in the wavetrack (non effecting) More... | |
sampleCount | GetClipOffset () const |
Gets the number of samples the clip associated with this blockfile is offset by. More... | |
void | SetODFileDecoder (ODFileDecoder *decoder) |
set the decoder, More... | |
const wxFileName & | GetAudioFileName () |
void | SetFileName (wxFileNameWrapper &&name) override |
sets the file name the summary info will be saved in. threadsafe. More... | |
GetFileNameResult | GetFileName () const override |
sets the file name the summary info will be saved in. threadsafe. More... | |
void | LockRead () const override |
Prevents a read on other threads of the encoded audio file. More... | |
void | UnlockRead () const override |
Allows reading of encoded file on other threads. More... | |
const wxFileNameWrapper & | GetEncodedAudioFilename () const |
void | ChangeAudioFile (wxFileNameWrapper &&newAudioFile) |
Public Member Functions inherited from SimpleBlockFile | |
SimpleBlockFile (wxFileNameWrapper &&baseFileName, samplePtr sampleData, size_t sampleLen, sampleFormat format) | |
Create a disk file and write summary and sample data to it. More... | |
SimpleBlockFile (wxFileNameWrapper &&existingFile, size_t len, float min, float max, float rms) | |
Create the memory structure to refer to the given block file. More... | |
virtual | ~SimpleBlockFile () |
bool | ReadSummary (ArrayOf< char > &data) override |
Read the summary section of the disk file. More... | |
size_t | ReadData (samplePtr data, sampleFormat format, size_t start, size_t len, bool mayThrow) const override |
Read the data section of the disk file. More... | |
BlockFilePtr | Copy (wxFileNameWrapper &&newFileName) override |
Create a NEW block file identical to this one. More... | |
void | SaveXML (XMLWriter &xmlFile) override |
Write an XML representation of this file. More... | |
DiskByteCount | GetSpaceUsage () const override |
void | Recover () override |
Static Public Member Functions | |
static BlockFilePtr | BuildFromXML (DirManager &dm, const wxChar **attrs) |
Reconstructs from XML a ODDecodeBlockFile and reschedules it for OD loading. More... | |
Static Public Member Functions inherited from SimpleBlockFile | |
static BlockFilePtr | BuildFromXML (DirManager &dm, const wxChar **attrs) |
static More... | |
Protected Member Functions | |
void * | CalcSummary (samplePtr buffer, size_t len, sampleFormat format, ArrayOf< char > &cleanup) override |
Protected Member Functions inherited from SimpleBlockFile | |
bool | WriteSimpleBlockFile (samplePtr sampleData, size_t sampleLen, sampleFormat format, void *summaryData) |
Protected Attributes | |
unsigned int | mType |
ODLock | mFileNameMutex |
wxFileNameWrapper | mAudioFileName |
The original file the audio came from. More... | |
wxAtomicInt | mDataAvailable { 0 } |
bool | mDataBeingComputed |
ODFileDecoder * | mDecoder |
ODLock | mDecoderMutex |
ODLock | mReadDataMutex |
For accessing the audio file that will be decoded. Used by dir manager;. More... | |
sampleCount | mStart |
for reporting after task is complete. Only for display use. More... | |
sampleCount | mClipOffset |
the ODTask needs to know where this blockfile lies in the track, so for convenience, we have this here. More... | |
sampleFormat | mFormat |
sampleCount | mAliasStart |
const int | mAliasChannel |
An AliasBlockFile that references uncompressed data in an existing file.
ODDecodeBlockFile is a special type of SimpleBlockFile that does not necessarily have summary OR audio data available The summary and audio is eventually computed and written to a file in a background thread.
ODDecodeBlockFile is a special type of SimpleBlockFile that does not necessarily have summary OR audio data available The summary is eventually computed and written to a file in a background thread. See ODPCMAliasBlockFile for a similar class.
Load On-Demand implementation of the SimpleBlockFile for audio files that need to be decoded (mp3,flac,etc..).
Also, see ODPCMAliasBlockFile for a similar file.
Definition at line 36 of file ODDecodeBlockFile.h.
ODDecodeBlockFile::ODDecodeBlockFile | ( | wxFileNameWrapper && | baseFileName, |
wxFileNameWrapper && | audioFileName, | ||
sampleCount | aliasStart, | ||
size_t | aliasLen, | ||
int | aliasChannel, | ||
unsigned int | decodeType | ||
) |
Create a disk file and write summary and sample data to it.
Definition at line 41 of file ODDecodeBlockFile.cpp.
References floatSample.
ODDecodeBlockFile::ODDecodeBlockFile | ( | wxFileNameWrapper && | existingFile, |
wxFileNameWrapper && | audioFileName, | ||
sampleCount | aliasStart, | ||
size_t | aliasLen, | ||
int | aliasChannel, | ||
unsigned int | decodeType, | ||
float | min, | ||
float | max, | ||
float | rms, | ||
bool | dataAvailable | ||
) |
Create the memory structure to refer to the given block file.
Definition at line 66 of file ODDecodeBlockFile.cpp.
References min().
|
virtual |
Definition at line 83 of file ODDecodeBlockFile.cpp.
|
static |
Reconstructs from XML a ODDecodeBlockFile and reschedules it for OD loading.
Constructs a ODDecodeBlockFile from the xml output of WriteXML. Also schedules the ODDecodeBlockFile for OD loading.
Definition at line 242 of file ODDecodeBlockFile.cpp.
References XMLValueChecker::IsGoodFileName(), XMLValueChecker::IsGoodFileString(), XMLValueChecker::IsGoodInt(), XMLValueChecker::IsGoodInt64(), XMLValueChecker::IsGoodPathName(), XMLValueChecker::IsGoodPathString(), anonymous_namespace{WaveTrack.cpp}::IsValidChannel(), and PLATFORM_MAX_PATH.
|
overrideprotected |
A thread-safe version of CalcSummary. BlockFile::CalcSummary uses a static summary array across the class, which we can't use. Get a buffer containing a summary block describing this sample data. This must be called by derived classes when they are constructed, to allow them to construct their summary data, after which they should write that data to their disk file.
This method also has the side effect of setting the mMin, mMax, and mRMS members of this class.
Unlike BlockFile's implementation You SHOULD DELETE the returned buffer. this is protected so it shouldn't be hard to deal with - just override all BlockFile methods that use this method.
buffer | A buffer containing the sample data to be analyzed |
len | The length of the sample data |
format | The format of the sample data. |
Definition at line 406 of file ODDecodeBlockFile.cpp.
References bheaderTag, bheaderTagLen, CopySamples(), floatSample, format, and ArrayOf< X >::reinit().
void ODDecodeBlockFile::ChangeAudioFile | ( | wxFileNameWrapper && | newAudioFile | ) |
Modify this block to point at a different file. This is generally looked down on, but it is necessary in one case: see DirManager::EnsureSafeFilename().
Definition at line 521 of file ODDecodeBlockFile.cpp.
References mAudioFileName.
Referenced by SetExternalFileName().
|
override |
Makes NEW ODDecodeBlockFile or SimpleBlockFile depending on summary availability.
returns true before decoding is complete, because it is linked to the encoded file until then. returns false afterwards.
If the summary has been computed, Construct a NEW SimpleBlockFile based on this one. otherwise construct an ODDecodeBlockFile that still needs to be computed.
newFileName | The filename to copy the summary data to. |
Definition at line 179 of file ODDecodeBlockFile.cpp.
References SimpleBlockFile::Copy(), IsSummaryAvailable(), mAliasChannel, mAliasStart, mAudioFileName, and mType.
|
inline |
Definition at line 92 of file ODDecodeBlockFile.h.
References WriteODDecodeBlockFile().
|
inline |
Definition at line 132 of file ODDecodeBlockFile.h.
References mAudioFileName.
Referenced by ODDecodeTask::GetOrCreateMatchingFileDecoder().
|
inline |
Gets the number of samples the clip associated with this blockfile is offset by.
Definition at line 125 of file ODDecodeBlockFile.h.
References mClipOffset.
Referenced by ODDecodeTask::Update().
|
inline |
Returns the type of audiofile this blockfile is loaded from.
Definition at line 118 of file ODDecodeBlockFile.h.
References mType.
Referenced by ODDecodeTask::GetOrCreateMatchingFileDecoder().
|
inline |
Get the name of the file where the audio data for this block is stored.
Definition at line 145 of file ODDecodeBlockFile.h.
References mAudioFileName.
Referenced by GetExternalFileName().
|
override |
Definition at line 506 of file ODDecodeBlockFile.cpp.
References GetEncodedAudioFilename(), and IsDataAvailable().
|
override |
sets the file name the summary info will be saved in. threadsafe.
Definition at line 384 of file ODDecodeBlockFile.cpp.
References mFileNameMutex.
|
inline |
Definition at line 106 of file ODDecodeBlockFile.h.
References mClipOffset, and mStart.
Referenced by ODDecodeTask::OrderBlockFiles().
|
inline |
Definition at line 103 of file ODDecodeBlockFile.h.
References mClipOffset, and mStart.
Referenced by ODDecodeTask::OrderBlockFiles().
|
override |
|
override |
|
override |
Definition at line 90 of file ODDecodeBlockFile.cpp.
References IsSummaryAvailable().
|
inline |
Gets the value that indicates where the first sample in this block corresponds to the global sequence/clip. Only for display use.
Definition at line 100 of file ODDecodeBlockFile.h.
References mStart.
Referenced by ODDecodeTask::Update().
|
override |
Returns TRUE if this block's complete data is ready to be accessed by Read()
Definition at line 320 of file ODDecodeBlockFile.cpp.
References mDataAvailable.
Referenced by GetExternalFileName(), and IsSummaryAvailable().
|
override |
Definition at line 315 of file ODDecodeBlockFile.cpp.
References IsDataAvailable().
Referenced by Copy(), GetSpaceUsage(), Read256(), Read64K(), ReadData(), ReadSummary(), Recover(), and SaveXML().
|
inlineoverride |
Returns TRUE if the summary has not yet been written, but is actively being computed and written to disk.
Definition at line 58 of file ODDecodeBlockFile.h.
|
override |
Prevents a read on other threads of the encoded audio file.
Prevents a read on other threads.
Definition at line 496 of file ODDecodeBlockFile.cpp.
References mReadDataMutex.
|
override |
Returns the 256 byte summary data block.
Returns the 256 byte summary data block Fill with zeroes and return false if data are unavailable for any reason.
Definition at line 147 of file ODDecodeBlockFile.cpp.
References ClearSamples(), floatSample, and IsSummaryAvailable().
|
override |
Returns the 64K summary data block.
Returns the 64K summary data block Fill with zeroes and return false if data are unavailable for any reason.
Definition at line 162 of file ODDecodeBlockFile.cpp.
References ClearSamples(), floatSample, and IsSummaryAvailable().
|
override |
Reads the specified data from the aliased file using libsndfile.
Reads the specified data from the aliased file, using libsndfile, and converts it to the given sample format.
data | The buffer to read the sample data into. |
format | The format to convert the data into |
start | The offset within the block to begin reading |
len | The number of samples to read |
Definition at line 448 of file ODDecodeBlockFile.cpp.
References ClearSamples(), format, IsSummaryAvailable(), mAudioFileName, and SimpleBlockFile::ReadData().
|
override |
Read the summary into a buffer.
Read the summary of this alias block from disk. Since the audio data is elsewhere, this consists of reading the entire summary file. Fill with zeroes and return false if data are unavailable for any reason.
*data | The buffer where the summary data will be stored. It must be at least mSummaryInfo.totalSummaryBytes long. |
Definition at line 472 of file ODDecodeBlockFile.cpp.
References IsSummaryAvailable(), SimpleBlockFile::ReadSummary(), and ArrayOf< X >::reinit().
|
override |
Writes the summary file if summary data is available.
Definition at line 307 of file ODDecodeBlockFile.cpp.
References IsSummaryAvailable(), and WriteODDecodeBlockFile().
|
override |
Saves as xml ODDecodeBlockFile or SimpleBlockFile depending on summary availability.
Writes the xml as a SimpleBlockFile if we can (if we have a summary file) Otherwise writes XML as a subset of attributes with 'odpcmaliasblockfile as the start tag. Most notably, the summaryfile attribute refers to a file that does not yet, so when the project file is read back in and this object reconstructed, it needs to avoid trying to open it as well as schedule itself for OD loading
Definition at line 209 of file ODDecodeBlockFile.cpp.
References sampleCount::as_long_long(), XMLWriter::EndTag(), IsSummaryAvailable(), mAliasChannel, mAliasStart, mAudioFileName, mFileNameMutex, mType, SimpleBlockFile::SaveXML(), XMLWriter::StartTag(), and XMLWriter::WriteAttr().
|
inline |
sets the amount of samples the clip associated with this blockfile is offset in the wavetrack (non effecting)
Definition at line 122 of file ODDecodeBlockFile.h.
References mClipOffset.
Referenced by ODDecodeTask::Update().
|
override |
Definition at line 513 of file ODDecodeBlockFile.cpp.
References ChangeAudioFile().
|
override |
sets the file name the summary info will be saved in. threadsafe.
Definition at line 372 of file ODDecodeBlockFile.cpp.
References mFileNameMutex, and name.
void ODDecodeBlockFile::SetODFileDecoder | ( | ODFileDecoder * | decoder | ) |
set the decoder,
Definition at line 484 of file ODDecodeBlockFile.cpp.
References mDecoder, and mDecoderMutex.
|
inline |
Sets the value that indicates where the first sample in this block corresponds to the global sequence/clip. Only for display use.
Definition at line 97 of file ODDecodeBlockFile.h.
References mStart.
Referenced by ODDecodeTask::Update().
|
override |
Allows reading of encoded file on other threads.
Definition at line 501 of file ODDecodeBlockFile.cpp.
References mReadDataMutex.
int ODDecodeBlockFile::WriteODDecodeBlockFile | ( | ) |
Write the summary to disk, using the derived ReadData() to get the data Here, the decoder ODTask associated with this file must fetch the samples with the ODDecodeTask::Decode() method.
Definition at line 328 of file ODDecodeBlockFile.cpp.
References ODFileDecoder::Decode(), mAliasChannel, mAliasStart, mDataAvailable, mDecoder, mDecoderMutex, mFileNameMutex, mFormat, SampleBuffer::ptr(), and SimpleBlockFile::WriteSimpleBlockFile().
Referenced by DoWriteBlockFile(), and Recover().
|
protected |
Definition at line 188 of file ODDecodeBlockFile.h.
Referenced by Copy(), SaveXML(), and WriteODDecodeBlockFile().
|
protected |
Definition at line 187 of file ODDecodeBlockFile.h.
Referenced by Copy(), SaveXML(), and WriteODDecodeBlockFile().
|
protected |
The original file the audio came from.
Definition at line 168 of file ODDecodeBlockFile.h.
Referenced by ChangeAudioFile(), Copy(), GetAudioFileName(), GetEncodedAudioFilename(), ReadData(), and SaveXML().
|
protected |
the ODTask needs to know where this blockfile lies in the track, so for convenience, we have this here.
Definition at line 183 of file ODDecodeBlockFile.h.
Referenced by GetClipOffset(), GetGlobalEnd(), GetGlobalStart(), and SetClipOffset().
|
protected |
Definition at line 170 of file ODDecodeBlockFile.h.
Referenced by IsDataAvailable(), and WriteODDecodeBlockFile().
|
protected |
Definition at line 171 of file ODDecodeBlockFile.h.
|
protected |
Definition at line 173 of file ODDecodeBlockFile.h.
Referenced by SetODFileDecoder(), and WriteODDecodeBlockFile().
|
protected |
Definition at line 174 of file ODDecodeBlockFile.h.
Referenced by SetODFileDecoder(), and WriteODDecodeBlockFile().
|
mutableprotected |
This lock is for the filename (string) of the blockfile that contains summary/audio data after decoding
Definition at line 165 of file ODDecodeBlockFile.h.
Referenced by GetFileName(), SaveXML(), SetFileName(), and WriteODDecodeBlockFile().
|
protected |
Definition at line 185 of file ODDecodeBlockFile.h.
Referenced by WriteODDecodeBlockFile().
|
mutableprotected |
For accessing the audio file that will be decoded. Used by dir manager;.
Definition at line 177 of file ODDecodeBlockFile.h.
Referenced by LockRead(), and UnlockRead().
|
protected |
for reporting after task is complete. Only for display use.
Definition at line 180 of file ODDecodeBlockFile.h.
Referenced by GetGlobalEnd(), GetGlobalStart(), GetStart(), and SetStart().
|
protected |
Definition at line 161 of file ODDecodeBlockFile.h.
Referenced by Copy(), GetDecodeType(), and SaveXML().