1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

WaveTrack.cpp does not depend on ODDecodeBlockFile.cpp...

... cutting off ODDecodeBlockFile and ODDecodeTask into a small cycle of 2
This commit is contained in:
Paul Licameli 2019-06-05 11:54:13 -04:00
parent f1b04c79d8
commit 71250b1dc3
7 changed files with 27 additions and 27 deletions

View File

@ -43,6 +43,7 @@ Paul Licameli split from AudacityProject.cpp
#include "WaveTrack.h"
#include "wxFileNameWrapper.h"
#include "effects/EffectManager.h"
#include "blockfile/ODDecodeBlockFile.h"
#include "export/Export.h"
#include "import/Import.h"
#include "commands/CommandContext.h"
@ -169,6 +170,25 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName )
return { false, bParseSuccess, err, xmlFile.GetErrorStr() };
}
///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc.
unsigned int ProjectFileManager::GetODFlags( const WaveTrack &track )
{
unsigned int ret = 0;
for ( const auto &clip : track.GetClips() )
{
auto sequence = clip->GetSequence();
const auto &blocks = sequence->GetBlockArray();
for ( const auto &block : blocks ) {
const auto &file = block.f;
if(!file->IsDataAvailable())
ret |= (static_cast< ODDecodeBlockFile * >( &*file ))->GetDecodeType();
else if(!file->IsSummaryAvailable())
ret |= ODTask::eODPCMSummary;
}
}
return ret;
}
void ProjectFileManager::EnqueueODTasks()
{
//check the ODManager to see if we should add the tracks to the ODManager.
@ -185,7 +205,7 @@ void ProjectFileManager::EnqueueODTasks()
for (auto wt : tracks.Any<WaveTrack>()) {
//check the track for blocks that need decoding.
//There may be more than one type e.g. FLAC/FFMPEG/lame
unsigned int odFlags = wt->GetODFlags();
unsigned int odFlags = GetODFlags( *wt );
//add the track to the already created tasks that correspond to the od flags in the wavetrack.
for(unsigned int i=0;i<newTasks.size();i++) {

View File

@ -49,6 +49,7 @@ public:
};
ReadProjectResults ReadProjectFile( const FilePath &fileName );
static unsigned int GetODFlags( const WaveTrack &track );
void EnqueueODTasks();
// To be called when closing a project that has been saved, so that

View File

@ -186,7 +186,8 @@ class PROFILE_DLL_API Sequence final : public XMLTagHandler{
// you're doing!
//
BlockArray &GetBlockArray() {return mBlock;}
BlockArray &GetBlockArray() { return mBlock; }
const BlockArray &GetBlockArray() const { return mBlock; }
///
void LockDeleteUpdateMutex(){mDeleteUpdateMutex.Lock();}

View File

@ -246,6 +246,7 @@ public:
// but use more high-level functions inside WaveClip (or add them if you
// think they are useful for general use)
Sequence* GetSequence() { return mSequence.get(); }
const Sequence* GetSequence() const { return mSequence.get(); }
/** WaveTrack calls this whenever data in the wave clip changes. It is
* called automatically when WaveClip has a chance to know that something

View File

@ -1506,27 +1506,6 @@ void WaveTrack::Append(samplePtr buffer, sampleFormat format,
blockFileLog);
}
///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc.
#include "blockfile/ODDecodeBlockFile.h"
unsigned int WaveTrack::GetODFlags() const
{
unsigned int ret = 0;
for (const auto &clip : mClips)
{
auto sequence = clip->GetSequence();
const auto &blocks = sequence->GetBlockArray();
for ( const auto &block : blocks ) {
const auto &file = block.f;
if(!file->IsDataAvailable())
ret |= (static_cast< ODDecodeBlockFile * >( &*file ))->GetDecodeType();
else if(!file->IsSummaryAvailable())
ret |= ODTask::eODPCMSummary;
}
}
return ret;
}
sampleCount WaveTrack::GetBlockStart(sampleCount s) const
{
for (const auto &clip : mClips)

View File

@ -220,9 +220,6 @@ private:
/// Flush must be called after last Append
void Flush();
///gets an int with OD flags so that we can determine which ODTasks should be run on this track after save/open, etc.
unsigned int GetODFlags() const;
///Invalidates all clips' wavecaches. Careful, This may not be threadsafe.
void ClearWaveCaches();

View File

@ -29,6 +29,7 @@
#include <wx/valgen.h>
#include "../Prefs.h"
#include "../ProjectFileManager.h"
#include "../Shuttle.h"
#include "../ShuttleGui.h"
#include "../WaveTrack.h"
@ -474,7 +475,7 @@ bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
// Since we need complete summary data, we need to block until the OD tasks are done for this track
// This is needed for track->GetMinMax
// TODO: should we restrict the flags to just the relevant block files (for selections)
while (track->GetODFlags()) {
while (ProjectFileManager::GetODFlags( *track )) {
// update the gui
if (ProgressResult::Cancelled == mProgress->Update(
0, _("Waiting for waveform to finish computing...")) )