1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 06:09:47 +02:00

ODComputeSummaryTask is safe for exceptions; makes no progress then

This commit is contained in:
Paul Licameli 2016-12-26 14:56:32 -05:00
parent 5de19dc952
commit 1a3212611b
2 changed files with 29 additions and 14 deletions

View File

@ -4412,6 +4412,9 @@ void AudacityProject::PopState(const UndoState &state)
computeTask = make_movable<ODComputeSummaryTask>();
odUsed=true;
}
// PRL: Is it correct to add all tracks to one task, even if they
// are not partnered channels? Rather than
// make one task for each?
computeTask->AddWaveTrack((WaveTrack*)copyTrack);
}
}

View File

@ -64,32 +64,42 @@ void ODComputeSummaryTask::DoSomeInternal()
return;
}
sampleCount blockStartSample = 0;
sampleCount blockEndSample = 0;
bool success =false;
mBlockFilesMutex.Lock();
for(size_t i=0; i < mWaveTracks.size() && mBlockFiles.size();i++)
{
bool success = false;
const auto bf = mBlockFiles[0].lock();
sampleCount blockStartSample = 0;
sampleCount blockEndSample = 0;
if(bf)
{
bf->DoWriteSummary();
// WriteSummary might throw, but this is a worker thread, so stop
// the exceptions here!
success = true;
try { bf->DoWriteSummary(); }
catch(...) { success = false; }
blockStartSample = bf->GetStart();
blockEndSample = blockStartSample + bf->GetLength();
}
else
{
success = true;
// The block file disappeared.
//the waveform in the wavetrack now is shorter, so we need to update mMaxBlockFiles
//because now there is less work to do.
mMaxBlockFiles--;
}
if (success)
{
//take it out of the array - we are done with it.
mBlockFiles.erase(mBlockFiles.begin());
}
else
// The task does not make progress
;
//This is a bit of a convenience in case someone tries to terminate the task by closing the trackpanel or window.
//ODComputeSummaryTask::Terminate() uses this lock to remove everything, and we don't want it to wait since the UI is being blocked.
@ -97,9 +107,10 @@ void ODComputeSummaryTask::DoSomeInternal()
wxThread::This()->Yield();
mBlockFilesMutex.Lock();
//upddate the gui for all associated blocks. It doesn't matter that we're hitting more wavetracks then we should
//update the gui for all associated blocks. It doesn't matter that we're hitting more wavetracks then we should
//because this loop runs a number of times equal to the number of tracks, they probably are getting processed in
//the next iteration at the same sample window.
if (success && bf) {
mWaveTrackMutex.Lock();
for(size_t i=0;i<mWaveTracks.size();i++)
{
@ -108,6 +119,7 @@ void ODComputeSummaryTask::DoSomeInternal()
}
mWaveTrackMutex.Unlock();
}
}
mBlockFilesMutex.Unlock();