///Computes and writes the data for one BlockFile if it still has a refcount. void ODComputeSummaryTask::DoSomeInternal() { if(mBlockFiles.size()<=0) { mPercentCompleteMutex.Lock(); mPercentComplete = 1.0; mPercentCompleteMutex.Unlock(); return; } ODPCMAliasBlockFile* bf; bf = mBlockFiles[0]; //first check to see if the ref count is at least 2. It should have one //from when we added it to this instance's mBlockFiles array, and one from //the Wavetrack/sequence. If it doesn't it has been deleted and we should forget it. if(bf->RefCount()>=2) { bf->DoWriteSummary(); mComputedBlockFiles++; } else { //the waveform in the wavetrack now is shorter, so we need to update mMaxBlockFiles //because now there is less work to do. mMaxBlockFiles--; } //Release the refcount we placed on it. bf->Deref(); //take it out of the array - we are done with it. mBlockFiles.erase(mBlockFiles.begin()); //update percentage complete. mPercentCompleteMutex.Lock(); mPercentComplete = (float) 1.0 - ((float)mBlockFiles.size() / (mMaxBlockFiles+1)); mPercentCompleteMutex.Unlock(); //TODO: update track gui somehow.. or do it from a timer. How does the cursor move in playback? mWaveTrackMutex.Lock(); if(mWaveTrack) mWaveTrack->DeleteWaveCaches(); mWaveTrackMutex.Unlock(); }
///Computes and writes the data for one BlockFile if it still has a refcount. void ODComputeSummaryTask::DoSomeInternal() { if(mBlockFiles.size()<=0) { mPercentCompleteMutex.Lock(); mPercentComplete = 1.0; mPercentCompleteMutex.Unlock(); return; } ODPCMAliasBlockFile* bf; sampleCount blockStartSample = 0; sampleCount blockEndSample = 0; bool success =false; mBlockFilesMutex.Lock(); for(size_t i=0; i < mWaveTracks.size() && mBlockFiles.size();i++) { bf = mBlockFiles[0]; //first check to see if the ref count is at least 2. It should have one //from when we added it to this instance's mBlockFiles array, and one from //the Wavetrack/sequence. If it doesn't it has been deleted and we should forget it. if(bf->RefCount()>=2) { bf->DoWriteSummary(); success = true; blockStartSample = bf->GetStart(); blockEndSample = blockStartSample + bf->GetLength(); mComputedBlockFiles++; } else { //the waveform in the wavetrack now is shorter, so we need to update mMaxBlockFiles //because now there is less work to do. mMaxBlockFiles--; } //Release the refcount we placed on it. bf->Deref(); //take it out of the array - we are done with it. mBlockFiles.erase(mBlockFiles.begin()); //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. mBlockFilesMutex.Unlock(); 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 //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. mWaveTrackMutex.Lock(); for(size_t i=0;i<mWaveTracks.size();i++) { if(success && mWaveTracks[i]) mWaveTracks[i]->AddInvalidRegion(blockStartSample,blockEndSample); } mWaveTrackMutex.Unlock(); } mBlockFilesMutex.Unlock(); //update percentage complete. CalculatePercentComplete(); }