From 71250b1dc3cb6f6eb02d20ec1a568305cd2906d1 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 5 Jun 2019 11:54:13 -0400 Subject: [PATCH] WaveTrack.cpp does not depend on ODDecodeBlockFile.cpp... ... cutting off ODDecodeBlockFile and ODDecodeTask into a small cycle of 2 --- src/ProjectFileManager.cpp | 22 +++++++++++++++++++++- src/ProjectFileManager.h | 1 + src/Sequence.h | 3 ++- src/WaveClip.h | 1 + src/WaveTrack.cpp | 21 --------------------- src/WaveTrack.h | 3 --- src/effects/Normalize.cpp | 3 ++- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index 340b19fa3..eff8a6d54 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -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()) { //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;iGetSequence(); - 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) diff --git a/src/WaveTrack.h b/src/WaveTrack.h index 7fc0b56f9..c131fd422 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -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(); diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index d1f8e75b5..2efb7ca2a 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -29,6 +29,7 @@ #include #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...")) )