Simplify iterations over WaveClips outside of WaveTrack/WaveClip; ...
... also add some const qualifiers
This commit is contained in:
parent
cb7872f980
commit
b548e641ae
|
@ -73,12 +73,6 @@ bool CrossFader::CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount
|
|||
//we should use one of the size len, because this has already
|
||||
//been determined to be good in Mixer
|
||||
|
||||
//Get a pointer to the sequence in each clip.
|
||||
WaveClip * tmpclip = NULL;
|
||||
|
||||
WaveClipList::compatibility_iterator it;
|
||||
|
||||
|
||||
//Go through each clip, adding it to the total in the appropriate way.
|
||||
|
||||
//this could be 'optimized' by getting all of the sequences and then
|
||||
|
@ -94,10 +88,8 @@ bool CrossFader::CrossFadeMix(samplePtr buffer, sampleFormat format, sampleCount
|
|||
|
||||
unsigned int i = 0;
|
||||
//Now, go through the clips and load up the vectors.
|
||||
for(it = mClips.GetFirst(); it; it = it->GetNext())
|
||||
for(const auto &tmpclip: mClips)
|
||||
{
|
||||
|
||||
tmpclip = it->GetData();
|
||||
tmpSequence[i] = tmpclip->GetSequence();
|
||||
|
||||
|
||||
|
|
|
@ -62,16 +62,13 @@ static void GetAllSeqBlocks(AudacityProject *project,
|
|||
Track *t = iter.First();
|
||||
while (t) {
|
||||
if (t->GetKind() == Track::Wave) {
|
||||
WaveTrack *waveTrack = (WaveTrack *)t;
|
||||
WaveClipList::compatibility_iterator node = waveTrack->GetClipIterator();
|
||||
while(node) {
|
||||
WaveClip *clip = node->GetData();
|
||||
WaveTrack *waveTrack = static_cast<WaveTrack*>(t);
|
||||
for(const auto &clip : waveTrack->GetClips()) {
|
||||
Sequence *sequence = clip->GetSequence();
|
||||
BlockArray &blocks = sequence->GetBlockArray();
|
||||
int i;
|
||||
for (i = 0; i < (int)blocks.size(); i++)
|
||||
outBlocks->push_back(&blocks[i]);
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
t = iter.Next();
|
||||
|
|
|
@ -1230,14 +1230,9 @@ void AudacityProject::RedrawProject(const bool bForceWaveTracks /*= false*/)
|
|||
{
|
||||
if (pTrack->GetKind() == Track::Wave)
|
||||
{
|
||||
WaveTrack* pWaveTrack = (WaveTrack*)pTrack;
|
||||
WaveClipList::compatibility_iterator node = pWaveTrack->GetClipIterator();
|
||||
while (node)
|
||||
{
|
||||
WaveClip *clip = node->GetData();
|
||||
WaveTrack* pWaveTrack = static_cast<WaveTrack*>(pTrack);
|
||||
for (const auto &clip: pWaveTrack->GetClips())
|
||||
clip->MarkChanged();
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
pTrack = iter.Next();
|
||||
}
|
||||
|
@ -2954,10 +2949,8 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
|
|||
if (t->GetKind() == Track::Wave)
|
||||
{
|
||||
// Only wave tracks have a notion of "changed".
|
||||
for (WaveClipList::compatibility_iterator clipIter = ((WaveTrack*)t)->GetClipIterator();
|
||||
clipIter;
|
||||
clipIter=clipIter->GetNext())
|
||||
clipIter->GetData()->MarkChanged();
|
||||
for (const auto &clip: static_cast<WaveTrack*>(t)->GetClips())
|
||||
clip->MarkChanged();
|
||||
}
|
||||
t = iter.Next();
|
||||
}
|
||||
|
|
|
@ -128,11 +128,9 @@ void SnapManager::Reinit()
|
|||
}
|
||||
else if (track->GetKind() == Track::Wave)
|
||||
{
|
||||
WaveTrack *waveTrack = (WaveTrack *)track;
|
||||
WaveClipList::compatibility_iterator it;
|
||||
for (it = waveTrack->GetClipIterator(); it; it = it->GetNext())
|
||||
WaveTrack *waveTrack = static_cast<WaveTrack *>(track);
|
||||
for (const auto &clip: waveTrack->GetClips())
|
||||
{
|
||||
WaveClip *clip = it->GetData();
|
||||
if (mClipExclusions)
|
||||
{
|
||||
bool skip = false;
|
||||
|
|
|
@ -450,9 +450,9 @@ void TrackArtist::DrawTrack(const Track * t,
|
|||
switch (t->GetKind()) {
|
||||
case Track::Wave:
|
||||
{
|
||||
WaveTrack* wt = (WaveTrack*)t;
|
||||
for (WaveClipList::compatibility_iterator it=wt->GetClipIterator(); it; it=it->GetNext()) {
|
||||
it->GetData()->ClearDisplayRect();
|
||||
const WaveTrack* wt = static_cast<const WaveTrack*>(t);
|
||||
for (const auto &clip : wt->GetClips()) {
|
||||
clip->ClearDisplayRect();
|
||||
}
|
||||
|
||||
bool muted = (hasSolo || t->GetMute()) && !t->GetSolo();
|
||||
|
@ -1471,9 +1471,8 @@ void TrackArtist::DrawWaveform(const WaveTrack *track,
|
|||
DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush,
|
||||
selectedRegion, zoomInfo);
|
||||
|
||||
for (WaveClipList::compatibility_iterator it =
|
||||
const_cast<WaveTrack*>(track)->GetClipIterator(); it; it = it->GetNext())
|
||||
DrawClipWaveform(track, it->GetData(), dc, rect, selectedRegion, zoomInfo,
|
||||
for (const auto &clip: track->GetClips())
|
||||
DrawClipWaveform(track, clip, dc, rect, selectedRegion, zoomInfo,
|
||||
drawEnvelope, bigPoints,
|
||||
dB, muted);
|
||||
|
||||
|
@ -2011,9 +2010,8 @@ void TrackArtist::DrawSpectrum(const WaveTrack *track,
|
|||
selectedRegion, zoomInfo);
|
||||
|
||||
WaveTrackCache cache(track);
|
||||
for (WaveClipList::compatibility_iterator it =
|
||||
const_cast<WaveTrack*>(track)->GetClipIterator(); it; it = it->GetNext()) {
|
||||
DrawClipSpectrum(cache, it->GetData(), dc, rect, selectedRegion, zoomInfo);
|
||||
for (const auto &clip: track->GetClips()) {
|
||||
DrawClipSpectrum(cache, clip, dc, rect, selectedRegion, zoomInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3422,12 +3422,8 @@ void TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1)
|
|||
{
|
||||
if (t->GetKind() == Track::Wave)
|
||||
{
|
||||
WaveClipList::compatibility_iterator it =
|
||||
((WaveTrack *)t)->GetClipIterator();
|
||||
while (it)
|
||||
for(const auto &clip: static_cast<WaveTrack*>(t)->GetClips())
|
||||
{
|
||||
WaveClip *clip = it->GetData();
|
||||
|
||||
if ( ! clip->AfterClip(t0) && ! clip->BeforeClip(t1) )
|
||||
{
|
||||
// Avoid getting clips that were already captured
|
||||
|
@ -3442,7 +3438,6 @@ void TrackPanel::AddClipsToCaptured(Track *t, double t0, double t1)
|
|||
if (newClip)
|
||||
mCapturedClipArray.push_back(TrackClip(t, clip));
|
||||
}
|
||||
it = it->GetNext();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -94,11 +94,10 @@ void UndoManager::CalculateSpaceUsage()
|
|||
while (wt)
|
||||
{
|
||||
// Scan all clips within current track
|
||||
WaveClipList::compatibility_iterator it = wt->GetClipIterator();
|
||||
while (it)
|
||||
for(const auto &clip: wt->GetClips())
|
||||
{
|
||||
// Scan all blockfiles within current clip
|
||||
BlockArray *blocks = it->GetData()->GetSequenceBlockArray();
|
||||
BlockArray *blocks = clip->GetSequenceBlockArray();
|
||||
for (const auto &block : *blocks)
|
||||
{
|
||||
BlockFile *file = block.f;
|
||||
|
@ -113,8 +112,6 @@ void UndoManager::CalculateSpaceUsage()
|
|||
// Add file to current set
|
||||
cur->insert(file);
|
||||
}
|
||||
|
||||
it = it->GetNext();
|
||||
}
|
||||
|
||||
wt = (WaveTrack *) iter.Next();
|
||||
|
|
|
@ -2631,9 +2631,8 @@ void WaveTrack::FillSortedClipArray(WaveClipArray& clips) const
|
|||
{
|
||||
clips.Empty();
|
||||
|
||||
for (WaveClipList::compatibility_iterator it =
|
||||
const_cast<WaveTrack*>(this)->GetClipIterator(); it; it=it->GetNext())
|
||||
clips.Add(it->GetData());
|
||||
for (const auto &clip: GetClips())
|
||||
clips.Add(clip);
|
||||
|
||||
clips.Sort(SortClipArrayCmpFunc);
|
||||
}
|
||||
|
|
|
@ -333,9 +333,9 @@ class AUDACITY_DLL_API WaveTrack final : public Track {
|
|||
*/
|
||||
double LongSamplesToTime(sampleCount pos) const;
|
||||
|
||||
// Get access to the clips in the tracks. This is used by
|
||||
// track artists and also by TrackPanel when sliding...it would
|
||||
// be cleaner if this could be removed, though...
|
||||
// Get access to the clips in the tracks.
|
||||
const WaveClipList &GetClips() const { return mClips; }
|
||||
|
||||
WaveClipList::compatibility_iterator GetClipIterator() { return mClips.GetFirst(); }
|
||||
|
||||
// Create NEW clip and add it to this track. Returns a pointer
|
||||
|
|
|
@ -1162,13 +1162,11 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
|
|||
//Find the bits of clips that need replacing
|
||||
std::vector<std::pair<double, double> > clipStartEndTimes;
|
||||
std::vector<std::pair<double, double> > clipRealStartEndTimes; //the above may be truncated due to a clip being partially selected
|
||||
for (WaveClipList::compatibility_iterator it=t->GetClipIterator(); it; it=it->GetNext())
|
||||
for (const auto &clip : t->GetClips())
|
||||
{
|
||||
WaveClip *clip;
|
||||
double clipStartT;
|
||||
double clipEndT;
|
||||
|
||||
clip = it->GetData();
|
||||
clipStartT = clip->GetStartTime();
|
||||
clipEndT = clip->GetEndTime();
|
||||
if( clipEndT <= startT )
|
||||
|
|
|
@ -520,13 +520,11 @@ bool EffectEqualization48x::ProcessTail(WaveTrack * t, WaveTrack * output, sampl
|
|||
//Find the bits of clips that need replacing
|
||||
std::vector<std::pair<double, double> > clipStartEndTimes;
|
||||
std::vector<std::pair<double, double> > clipRealStartEndTimes; //the above may be truncated due to a clip being partially selected
|
||||
for (WaveClipList::compatibility_iterator it=t->GetClipIterator(); it; it=it->GetNext())
|
||||
for (const auto &clip: t->GetClips())
|
||||
{
|
||||
WaveClip *clip;
|
||||
double clipStartT;
|
||||
double clipEndT;
|
||||
|
||||
clip = it->GetData();
|
||||
clipStartT = clip->GetStartTime();
|
||||
clipEndT = clip->GetEndTime();
|
||||
if( clipEndT <= startT )
|
||||
|
|
|
@ -112,9 +112,10 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
|||
// STEP 1:
|
||||
// If a reverse selection begins and/or ends at the inside of a clip
|
||||
// perform a split at the start and/or end of the reverse selection
|
||||
WaveClipList::compatibility_iterator node = track->GetClipIterator();
|
||||
while (node) {
|
||||
WaveClip *clip = node->GetData();
|
||||
const auto &clips = track->GetClips();
|
||||
// Beware, the array grows as we loop over it. Use integer subscripts, not iterators.
|
||||
for (int ii = 0; ii < clips.size(); ++ii) {
|
||||
const auto &clip = clips[ii];
|
||||
sampleCount clipStart = clip->GetStartSample();
|
||||
sampleCount clipEnd = clip->GetEndSample();
|
||||
if (clipStart < start && clipEnd > start && clipEnd <= end) { // the reverse selection begins at the inside of a clip
|
||||
|
@ -131,7 +132,6 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
|||
splitTime = track->LongSamplesToTime(end);
|
||||
track->SplitAt(splitTime);
|
||||
}
|
||||
node = node->GetNext();
|
||||
}
|
||||
|
||||
//STEP 2:
|
||||
|
@ -192,29 +192,26 @@ bool EffectReverse::ProcessOneWave(int count, WaveTrack * track, sampleCount sta
|
|||
|
||||
clip = track->RemoveAndReturnClip(clip); // detach the clip from track
|
||||
clip->SetOffset(track->LongSamplesToTime(track->TimeToLongSamples(offsetStartTime))); // align time to a sample and set offset
|
||||
revClips.Append(clip);
|
||||
revClips.push_back(clip);
|
||||
|
||||
}
|
||||
}
|
||||
else if (clipStart >= end) { // clip is after the selection region
|
||||
clip = track->RemoveAndReturnClip(clip); // simply remove and append to otherClips
|
||||
otherClips.Append(clip);
|
||||
otherClips.push_back(clip);
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 3: Append the clips from
|
||||
// revClips and otherClips back to the track
|
||||
size_t revClipsCount = revClips.GetCount();
|
||||
for (i = 0; i < revClipsCount; i++) {
|
||||
WaveClipList::compatibility_iterator node = revClips.Item(revClipsCount - 1 - i); // the last clip of revClips is appended to the track first
|
||||
WaveClip *clip = node->GetData();
|
||||
track->AddClip(clip);
|
||||
}
|
||||
// the last clip of revClips is appended to the track first
|
||||
// PRL: I don't think that matters, the sequence of storage of clips in the track
|
||||
// is not elsewhere assumed to be by time
|
||||
for (auto it = revClips.rbegin(), end = revClips.rend(); it != end; ++it)
|
||||
track->AddClip(*it);
|
||||
|
||||
for (i = 0; i < otherClips.GetCount(); i++) {
|
||||
WaveClipList::compatibility_iterator node = otherClips.Item(i);
|
||||
track->AddClip(node->GetData());
|
||||
}
|
||||
for (const auto &clip : otherClips)
|
||||
track->AddClip(clip);
|
||||
|
||||
return rValue;
|
||||
}
|
||||
|
|
|
@ -178,15 +178,11 @@ void ODComputeSummaryTask::Update()
|
|||
{
|
||||
if(mWaveTracks[j])
|
||||
{
|
||||
WaveClip *clip;
|
||||
BlockArray *blocks;
|
||||
Sequence *seq;
|
||||
|
||||
//gather all the blockfiles that we should process in the wavetrack.
|
||||
WaveClipList::compatibility_iterator node = mWaveTracks[j]->GetClipIterator();
|
||||
|
||||
while(node) {
|
||||
clip = node->GetData();
|
||||
for (const auto &clip : mWaveTracks[j]->GetClips()) {
|
||||
seq = clip->GetSequence();
|
||||
//This lock may be way too big since the whole file is one sequence.
|
||||
//TODO: test for large files and find a way to break it down.
|
||||
|
@ -223,7 +219,6 @@ void ODComputeSummaryTask::Update()
|
|||
tempBlocks.insert(tempBlocks.begin() + insertCursor++, odpcmaFile);
|
||||
}
|
||||
}
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,15 +136,11 @@ void ODDecodeTask::Update()
|
|||
{
|
||||
if(mWaveTracks[j])
|
||||
{
|
||||
WaveClip *clip;
|
||||
BlockArray *blocks;
|
||||
Sequence *seq;
|
||||
|
||||
//gather all the blockfiles that we should process in the wavetrack.
|
||||
WaveClipList::compatibility_iterator node = mWaveTracks[j]->GetClipIterator();
|
||||
|
||||
while(node) {
|
||||
clip = node->GetData();
|
||||
for (const auto &clip : mWaveTracks[j]->GetClips()) {
|
||||
seq = clip->GetSequence();
|
||||
//TODO:this lock is way to big since the whole file is one sequence. find a way to break it down.
|
||||
seq->LockDeleteUpdateMutex();
|
||||
|
@ -179,7 +175,6 @@ void ODDecodeTask::Update()
|
|||
}
|
||||
|
||||
seq->UnlockDeleteUpdateMutex();
|
||||
node = node->GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue