Audacity
3.0.3
|
An AliasBlockFile that references uncompressed data in an existing file. More...
#include <ODPCMAliasBlockFile.h>
Public Member Functions | |
ODPCMAliasBlockFile (wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel) | |
Constructs a PCMAliasBlockFile, writing the summary to disk. More... | |
ODPCMAliasBlockFile (wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, float min, float max, float rms, bool summaryAvailable) | |
summaryAvailable should be true if the file has been written already. More... | |
virtual | ~ODPCMAliasBlockFile () |
bool | IsSummaryAvailable () const override |
bool | IsSummaryBeingComputed () override |
Returns TRUE if the summary has not yet been written, but is actively being computed and written to disk. More... | |
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 ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability. More... | |
void | SaveXML (XMLWriter &xmlFile) override |
Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability. More... | |
void | Recover (void) override |
Writes the summary file if summary data is available. More... | |
void | DoWriteSummary () |
A public interface to WriteSummary. More... | |
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... | |
void | Lock () override |
Locks the blockfile only if it has a file that exists. More... | |
void | Unlock () override |
Unlocks the blockfile only if it has a file that exists. 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... | |
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... | |
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 | CloseLock () override |
void | LockRead () const override |
Prevents a read on other threads. More... | |
void | UnlockRead () const override |
Allows reading on other threads. More... | |
Public Member Functions inherited from PCMAliasBlockFile | |
PCMAliasBlockFile (wxFileNameWrapper &&baseFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel) | |
Constructs a PCMAliasBlockFile, writing the summary to disk. More... | |
PCMAliasBlockFile (wxFileNameWrapper &&fileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, bool writeSummary) | |
Constructs a PCMAliasBlockFile with the option of not writing to disk. More... | |
PCMAliasBlockFile (wxFileNameWrapper &&existingSummaryFileName, wxFileNameWrapper &&aliasedFileName, sampleCount aliasStart, size_t aliasLen, int aliasChannel, float min, float max, float rms) | |
virtual | ~PCMAliasBlockFile () |
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... | |
void | SaveXML (XMLWriter &xmlFile) override |
BlockFilePtr | Copy (wxFileNameWrapper &&fileName) override |
void | Recover () override |
Static Public Member Functions | |
static BlockFilePtr | BuildFromXML (DirManager &dm, const wxChar **attrs) |
Reconstructs from XML a ODPCMAliasBlockFile and reschedules it for OD loading. More... | |
Static Public Member Functions inherited from PCMAliasBlockFile | |
static BlockFilePtr | BuildFromXML (DirManager &dm, const wxChar **attrs) |
Protected Member Functions | |
void | WriteSummary () override |
Write the summary to disk, using the derived ReadData() to get the data. More... | |
void * | CalcSummary (samplePtr buffer, size_t len, sampleFormat format, ArrayOf< char > &cleanup) override |
Private Attributes | |
ODLock | mWriteSummaryMutex |
ODLock | mFileNameMutex |
ODLock | mAliasedFileNameMutex |
Also need to protect the aliased file name. More... | |
ODLock | mReadDataMutex |
ODLock | mSummaryAvailableMutex |
bool | mSummaryAvailable |
bool | mSummaryBeingComputed |
bool | mHasBeenSaved |
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... | |
An AliasBlockFile that references uncompressed data in an existing file.
ODPCMAliasBlockFile is a special type of PCMAliasBlockFile that does not necessarily have summary data available The summary is eventually computed and written to a file in a background thread.
Load On-Demand implementation of the AliasBlockFile for PCM files.
to load large files more quickly, we skip computing the summary data and put ODPCMAliasBlockFiles in the sequence as place holders. A background thread loads and computes the summary data into these classes. ODPCMAliasBlockFiles unlike all other BlockFiles are not immutable (for the most part,) because when NEW summary data is computed for an existing ODPCMAliasBlockFile we save the buffer then and write the Summary File.
All BlockFile methods that treat the summary data as a buffer that exists in its BlockFile are implemented here to behave when the data is not available yet.
Some of these methods have been overridden only because they used the unsafe wxLog calls in the base class.
Definition at line 42 of file ODPCMAliasBlockFile.h.
ODPCMAliasBlockFile::ODPCMAliasBlockFile | ( | wxFileNameWrapper && | baseFileName, |
wxFileNameWrapper && | aliasedFileName, | ||
sampleCount | aliasStart, | ||
size_t | aliasLen, | ||
int | aliasChannel | ||
) |
Constructs a PCMAliasBlockFile, writing the summary to disk.
Definition at line 44 of file ODPCMAliasBlockFile.cpp.
ODPCMAliasBlockFile::ODPCMAliasBlockFile | ( | wxFileNameWrapper && | existingSummaryFileName, |
wxFileNameWrapper && | aliasedFileName, | ||
sampleCount | aliasStart, | ||
size_t | aliasLen, | ||
int | aliasChannel, | ||
float | min, | ||
float | max, | ||
float | rms, | ||
bool | summaryAvailable | ||
) |
summaryAvailable should be true if the file has been written already.
Definition at line 56 of file ODPCMAliasBlockFile.cpp.
References mHasBeenSaved, mSummaryAvailable, and mSummaryBeingComputed.
|
virtual |
Definition at line 70 of file ODPCMAliasBlockFile.cpp.
|
static |
Reconstructs from XML a ODPCMAliasBlockFile and reschedules it for OD loading.
Constructs a ODPCMAliasBlockFile from the xml output of WriteXML. Does not schedule the ODPCMAliasBlockFile for OD loading. Client code must do this.
Definition at line 272 of file ODPCMAliasBlockFile.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 450 of file ODPCMAliasBlockFile.cpp.
References aheaderTag, aheaderTagLen, CopySamples(), floatSample, format, and ArrayOf< X >::reinit().
Referenced by WriteSummary().
|
override |
Definition at line 104 of file ODPCMAliasBlockFile.cpp.
References mHasBeenSaved.
|
override |
Makes NEW ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability.
If the summary has been computed, Construct a NEW PCMAliasBlockFile based on this one. otherwise construct an ODPCMAliasBlockFile that still needs to be computed.
newFileName | The filename to copy the summary data to. |
Definition at line 201 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable(), and mHasBeenSaved.
void ODPCMAliasBlockFile::DoWriteSummary | ( | ) |
A public interface to WriteSummary.
Calls write summary, and makes sure it is only done once in a thread-safe fashion.
Definition at line 352 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable(), mWriteSummaryMutex, and WriteSummary().
|
inline |
Gets the number of samples the clip associated with this blockfile is offset by.
Definition at line 104 of file ODPCMAliasBlockFile.h.
References mClipOffset.
Referenced by ODComputeSummaryTask::Update().
|
override |
sets the file name the summary info will be saved in. threadsafe.
Definition at line 368 of file ODPCMAliasBlockFile.cpp.
References mFileNameMutex.
|
inline |
Definition at line 110 of file ODPCMAliasBlockFile.h.
References mClipOffset, and mStart.
Referenced by ODComputeSummaryTask::OrderBlockFiles().
|
inline |
Definition at line 107 of file ODPCMAliasBlockFile.h.
References mClipOffset, and mStart.
Referenced by ODComputeSummaryTask::OrderBlockFiles().
|
override |
|
override |
Gets extreme values for the specified region.
Definition at line 121 of file ODPCMAliasBlockFile.cpp.
|
override |
Definition at line 77 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable(), and mFileNameMutex.
|
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 92 of file ODPCMAliasBlockFile.h.
References mStart.
Referenced by ODComputeSummaryTask::Update().
|
override |
Definition at line 342 of file ODPCMAliasBlockFile.cpp.
References mSummaryAvailable, and mSummaryAvailableMutex.
Referenced by Copy(), DoWriteSummary(), GetSpaceUsage(), Lock(), Read256(), Read64K(), Recover(), SaveXML(), and Unlock().
|
inlineoverride |
Returns TRUE if the summary has not yet been written, but is actively being computed and written to disk.
Definition at line 59 of file ODPCMAliasBlockFile.h.
References mSummaryBeingComputed.
|
override |
Locks the blockfile only if it has a file that exists.
Locks the blockfile only if it has a file that exists. This needs to be done so that the unsaved ODPCMAliasBlockfiles are deleted upon exit
Definition at line 96 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable(), and mHasBeenSaved.
|
override |
Prevents a read on other threads.
Definition at line 551 of file ODPCMAliasBlockFile.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 167 of file ODPCMAliasBlockFile.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 183 of file ODPCMAliasBlockFile.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. Copied from PCMAliasBlockFIle but wxLog calls taken out for thread safety
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 493 of file ODPCMAliasBlockFile.cpp.
References format, and SAMPLE_SIZE.
Referenced by WriteSummary().
|
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 515 of file ODPCMAliasBlockFile.cpp.
References mFileNameMutex, and ArrayOf< X >::reinit().
|
override |
Writes the summary file if summary data is available.
Definition at line 334 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable(), and WriteSummary().
|
override |
Saves as xml ODPCMAliasBlockFile or PCMAliasBlockFile depending on summary availability.
Writes the xml as a PCMAliasBlockFile 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 exist, 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 236 of file ODPCMAliasBlockFile.cpp.
References XMLWriter::EndTag(), IsSummaryAvailable(), mFileNameMutex, mHasBeenSaved, PCMAliasBlockFile::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 101 of file ODPCMAliasBlockFile.h.
References mClipOffset.
|
override |
sets the file name the summary info will be saved in. threadsafe.
Definition at line 360 of file ODPCMAliasBlockFile.cpp.
References mFileNameMutex, and name.
|
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 89 of file ODPCMAliasBlockFile.h.
References mStart.
|
override |
Unlocks the blockfile only if it has a file that exists.
unlocks the blockfile only if it has a file that exists. This needs to be done so that the unsaved ODPCMAliasBlockfiles are deleted upon exit
Definition at line 113 of file ODPCMAliasBlockFile.cpp.
References IsSummaryAvailable().
|
override |
Allows reading on other threads.
Definition at line 556 of file ODPCMAliasBlockFile.cpp.
References mReadDataMutex.
|
overrideprotected |
Write the summary to disk, using the derived ReadData() to get the data.
Definition at line 374 of file ODPCMAliasBlockFile.cpp.
References CalcSummary(), floatSample, mFileNameMutex, mSummaryAvailable, mSummaryAvailableMutex, FileException::Open, SampleBuffer::ptr(), ReadData(), and ArrayOf< X >::reinit().
Referenced by DoWriteSummary(), and Recover().
|
private |
Also need to protect the aliased file name.
Definition at line 149 of file ODPCMAliasBlockFile.h.
|
private |
the ODTask needs to know where this blockfile lies in the track, so for convenience, we have this here.
Definition at line 163 of file ODPCMAliasBlockFile.h.
Referenced by GetClipOffset(), GetGlobalEnd(), GetGlobalStart(), and SetClipOffset().
|
mutableprivate |
Definition at line 146 of file ODPCMAliasBlockFile.h.
Referenced by GetFileName(), GetSpaceUsage(), ReadSummary(), SaveXML(), SetFileName(), and WriteSummary().
|
private |
Definition at line 157 of file ODPCMAliasBlockFile.h.
Referenced by CloseLock(), Copy(), Lock(), ODPCMAliasBlockFile(), and SaveXML().
|
mutableprivate |
Definition at line 152 of file ODPCMAliasBlockFile.h.
Referenced by LockRead(), and UnlockRead().
|
private |
for reporting after task is complete. Only for display use.
Definition at line 160 of file ODPCMAliasBlockFile.h.
Referenced by GetGlobalEnd(), GetGlobalStart(), GetStart(), and SetStart().
|
private |
Definition at line 155 of file ODPCMAliasBlockFile.h.
Referenced by IsSummaryAvailable(), ODPCMAliasBlockFile(), and WriteSummary().
|
mutableprivate |
Definition at line 154 of file ODPCMAliasBlockFile.h.
Referenced by IsSummaryAvailable(), and WriteSummary().
|
private |
Definition at line 156 of file ODPCMAliasBlockFile.h.
Referenced by IsSummaryBeingComputed(), and ODPCMAliasBlockFile().
|
private |
Definition at line 143 of file ODPCMAliasBlockFile.h.
Referenced by DoWriteSummary().