1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-07 15:49:42 +02:00

Fix some problems with asserts in 11308. Further wording corrections.

This commit is contained in:
v.audacity 2011-11-18 03:47:43 +00:00
parent e275189f1e
commit 458152070e
13 changed files with 76 additions and 44 deletions

View File

@ -1751,10 +1751,12 @@ void AudioIO::StopStream()
} }
if( appendRecord ) if( appendRecord )
{ // append-recording { // append-recording
bool bResult = true;
if (recordingOffset < 0) if (recordingOffset < 0)
track->Clear(mT0, mT0 - recordingOffset); // cut the latency out bResult = track->Clear(mT0, mT0 - recordingOffset); // cut the latency out
else else
wxASSERT(track->InsertSilence(mT0, recordingOffset)); // put silence in bResult = track->InsertSilence(mT0, recordingOffset); // put silence in
wxASSERT(bResult); // TO DO: Actually handle this.
} }
else else
{ // recording into a new track { // recording into a new track

View File

@ -3465,7 +3465,8 @@ void AudacityProject::OnPaste()
}else{ }else{
WaveTrack *tmp; WaveTrack *tmp;
tmp = mTrackFactory->NewWaveTrack( ((WaveTrack*)n)->GetSampleFormat(), ((WaveTrack*)n)->GetRate()); tmp = mTrackFactory->NewWaveTrack( ((WaveTrack*)n)->GetSampleFormat(), ((WaveTrack*)n)->GetRate());
wxASSERT(tmp->InsertSilence(0.0, msClipT1 - msClipT0)); // MJS: Is this correct? bool bResult = tmp->InsertSilence(0.0, msClipT1 - msClipT0); // MJS: Is this correct?
wxASSERT(bResult); // TO DO: Actually handle this.
tmp->Flush(); tmp->Flush();
bPastedSomething |= bPastedSomething |=
@ -3599,7 +3600,8 @@ bool AudacityProject::HandlePasteNothingSelected()
pNewTrack->SetChannel(pClip->GetChannel()); pNewTrack->SetChannel(pClip->GetChannel());
pNewTrack->SetName(pClip->GetName()); pNewTrack->SetName(pClip->GetName());
wxASSERT(pNewTrack->Paste(0.0, pClip)); bool bResult = pNewTrack->Paste(0.0, pClip);
wxASSERT(bResult); // TO DO: Actually handle this.
mTracks->Add(pNewTrack); mTracks->Add(pNewTrack);
pNewTrack->SetSelected(true); pNewTrack->SetSelected(true);

View File

@ -4192,7 +4192,8 @@ void AudacityProject::EditClipboardByLabel( WaveTrack::EditDestFunction action )
regions.Item(i+1)->start - regions.Item(i)->end); regions.Item(i+1)->start - regions.Item(i)->end);
} }
wxASSERT(merged->Paste( 0.0 , dest )); bool bResult = merged->Paste( 0.0 , dest );
wxASSERT(bResult); // TO DO: Actually handle this.
delete dest; delete dest;
} }
} }

View File

@ -80,7 +80,8 @@ Sequence::Sequence(const Sequence &orig, DirManager *projDirManager)
mBlock = new BlockArray(); mBlock = new BlockArray();
wxASSERT(Paste(0, &orig)); bool bResult = Paste(0, &orig);
wxASSERT(bResult); // TO DO: Actually handle this.
} }
Sequence::~Sequence() Sequence::~Sequence()

View File

@ -4885,7 +4885,10 @@ bool TrackPanel::HandleTrackLocationMouseEvent(WaveTrack * track, wxRect &r, wxM
{ {
WaveTrack* linked = (WaveTrack*)mTracks->GetLink(track); WaveTrack* linked = (WaveTrack*)mTracks->GetLink(track);
if (linked) if (linked)
wxASSERT(linked->ExpandCutLine(mCapturedTrackLocation.pos)); {
bool bResult = linked->ExpandCutLine(mCapturedTrackLocation.pos);
wxASSERT(bResult); // TO DO: Actually handle this.
}
mViewInfo->sel0 = cutlineStart; mViewInfo->sel0 = cutlineStart;
mViewInfo->sel1 = cutlineEnd; mViewInfo->sel1 = cutlineEnd;
DisplaySelection(); DisplaySelection();
@ -4894,10 +4897,14 @@ bool TrackPanel::HandleTrackLocationMouseEvent(WaveTrack * track, wxRect &r, wxM
} }
} else if (mCapturedTrackLocation.typ == WaveTrack::locationMergePoint) } else if (mCapturedTrackLocation.typ == WaveTrack::locationMergePoint)
{ {
wxASSERT(track->MergeClips(mCapturedTrackLocation.clipidx1, mCapturedTrackLocation.clipidx2)); bool bResult = track->MergeClips(mCapturedTrackLocation.clipidx1, mCapturedTrackLocation.clipidx2);
wxASSERT(bResult); // TO DO: Actually handle this.
WaveTrack* linked = (WaveTrack*)mTracks->GetLink(track); WaveTrack* linked = (WaveTrack*)mTracks->GetLink(track);
if (linked) if (linked)
wxASSERT(linked->MergeClips(mCapturedTrackLocation.clipidx1, mCapturedTrackLocation.clipidx2)); {
bResult = linked->MergeClips(mCapturedTrackLocation.clipidx1, mCapturedTrackLocation.clipidx2);
wxASSERT(bResult); // TO DO: Actually handle this.
}
MakeParentPushState(_("Merged Clips"),_("Merge"), PUSH_CONSOLIDATE|PUSH_CALC_SPACE); MakeParentPushState(_("Merged Clips"),_("Merge"), PUSH_CONSOLIDATE|PUSH_CALC_SPACE);
handled = true; handled = true;
} }
@ -7094,10 +7101,14 @@ void TrackPanel::OnFormatChange(wxCommandEvent & event)
break; break;
} }
wxASSERT(((WaveTrack*)mPopupMenuTarget)->ConvertToSampleFormat(newFormat)); bool bResult = ((WaveTrack*)mPopupMenuTarget)->ConvertToSampleFormat(newFormat);
wxASSERT(bResult); // TO DO: Actually handle this.
Track *partner = mTracks->GetLink(mPopupMenuTarget); Track *partner = mTracks->GetLink(mPopupMenuTarget);
if (partner) if (partner)
wxASSERT(((WaveTrack *) partner)->ConvertToSampleFormat(newFormat)); {
bResult = ((WaveTrack*)partner)->ConvertToSampleFormat(newFormat);
wxASSERT(bResult); // TO DO: Actually handle this.
}
MakeParentPushState(wxString::Format(_("Changed '%s' to %s"), MakeParentPushState(wxString::Format(_("Changed '%s' to %s"),
mPopupMenuTarget->GetName(). mPopupMenuTarget->GetName().

View File

@ -576,7 +576,8 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
// falls within it and this isn't the first clip in the track. // falls within it and this isn't the first clip in the track.
if (fabs(t1 - clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) { if (fabs(t1 - clip->GetStartTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) {
if (i > 0) { if (i > 0) {
wxASSERT(MergeClips(GetClipIndex(clips[i - 1]), GetClipIndex(clip))); bool bResult = MergeClips(GetClipIndex(clips[i - 1]), GetClipIndex(clip));
wxASSERT(bResult); // TO DO: Actually handle this.
} }
break; break;
} }
@ -594,7 +595,8 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
// falls within it and this isn't the last clip in the track. // falls within it and this isn't the last clip in the track.
if (fabs(t0 - clip->GetEndTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) { if (fabs(t0 - clip->GetEndTime()) < WAVETRACK_MERGE_POINT_TOLERANCE) {
if (i < clips.GetCount() - 1) { if (i < clips.GetCount() - 1) {
wxASSERT(MergeClips(GetClipIndex(clip), GetClipIndex(clips[i + 1]))); bool bResult = MergeClips(GetClipIndex(clip), GetClipIndex(clips[i + 1]));
wxASSERT(bResult); // TO DO: Actually handle this.
} }
break; break;
} }
@ -829,9 +831,11 @@ bool WaveTrack::SyncLockAdjust(double oldT1, double newT1)
if (!f) return false; if (!f) return false;
WaveTrack *tmp = f->NewWaveTrack(GetSampleFormat(), GetRate()); WaveTrack *tmp = f->NewWaveTrack(GetSampleFormat(), GetRate());
wxASSERT(tmp->InsertSilence(0.0, newT1 - oldT1)); bool bResult = tmp->InsertSilence(0.0, newT1 - oldT1);
wxASSERT(bResult); // TO DO: Actually handle this.
tmp->Flush(); tmp->Flush();
wxASSERT(Paste(oldT1, tmp)); bResult = Paste(oldT1, tmp);
wxASSERT(bResult); // TO DO: Actually handle this.
delete tmp; delete tmp;
} }
} }
@ -898,7 +902,8 @@ bool WaveTrack::Paste(double t0, Track *src)
if (!IsEmpty(t0, GetEndTime())) { if (!IsEmpty(t0, GetEndTime())) {
Track *tmp = NULL; Track *tmp = NULL;
Cut(t0, GetEndTime()+1.0/mRate, &tmp); Cut(t0, GetEndTime()+1.0/mRate, &tmp);
wxASSERT(Paste(t0 + insertDuration, tmp)); bool bResult = Paste(t0 + insertDuration, tmp);
wxASSERT(bResult); // TO DO: Actually handle this.
delete tmp; delete tmp;
} }
} else } else
@ -1202,12 +1207,14 @@ bool WaveTrack::Join(double t0, double t1)
if (clip->GetOffset() - t > (1.0 / mRate)) { if (clip->GetOffset() - t > (1.0 / mRate)) {
double addedSilence = (clip->GetOffset() - t); double addedSilence = (clip->GetOffset() - t);
//printf("Adding %.6f seconds of silence\n"); //printf("Adding %.6f seconds of silence\n");
wxASSERT(newClip->InsertSilence(t, addedSilence)); bool bResult = newClip->InsertSilence(t, addedSilence);
wxASSERT(bResult); // TO DO: Actually handle this.
t += addedSilence; t += addedSilence;
} }
//printf("Pasting at %.6f\n", t); //printf("Pasting at %.6f\n", t);
wxASSERT(newClip->Paste(t, clip)); bool bResult = newClip->Paste(t, clip);
wxASSERT(bResult); // TO DO: Actually handle this.
t = newClip->GetEndTime(); t = newClip->GetEndTime();
mClips.DeleteObject(clip); mClips.DeleteObject(clip);

View File

@ -213,7 +213,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
//Go through the track one buffer at a time. samplePos counts which //Go through the track one buffer at a time. samplePos counts which
//sample the current buffer starts at. //sample the current buffer starts at.
bool bLoopSuccess = true; bool bResult = true;
sampleCount blockSize; sampleCount blockSize;
sampleCount samplePos = start; sampleCount samplePos = start;
while (samplePos < end) { while (samplePos < end) {
@ -236,7 +236,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
outBuffer, outBuffer,
outBufferSize); outBufferSize);
if (outgen < 0) { if (outgen < 0) {
bLoopSuccess = false; bResult = false;
break; break;
} }
@ -249,7 +249,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
// Update the Progress meter // Update the Progress meter
if (TrackProgress(mCurTrackNum, (samplePos - start) / len)) { if (TrackProgress(mCurTrackNum, (samplePos - start) / len)) {
bLoopSuccess = false; bResult = false;
break; break;
} }
} }
@ -264,10 +264,10 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
// Take the output track and insert it in place of the original // Take the output track and insert it in place of the original
// sample data // sample data
double newLength = outputTrack->GetEndTime(); double newLength = outputTrack->GetEndTime();
if (bLoopSuccess) if (bResult)
{ {
SetTimeWarper(new LinearTimeWarper(mCurT0, mCurT0, mCurT1, mCurT0 + newLength)); SetTimeWarper(new LinearTimeWarper(mCurT0, mCurT0, mCurT1, mCurT0 + newLength));
wxASSERT(track->ClearAndPaste(mCurT0, mCurT1, outputTrack, true, false, GetTimeWarper())); bResult = track->ClearAndPaste(mCurT0, mCurT1, outputTrack, true, false, GetTimeWarper());
} }
if (newLength > mMaxNewLength) if (newLength > mMaxNewLength)
@ -276,7 +276,7 @@ bool EffectChangeSpeed::ProcessOne(WaveTrack * track,
// Delete the outputTrack now that its data is inserted in place // Delete the outputTrack now that its data is inserted in place
delete outputTrack; delete outputTrack;
return bLoopSuccess; return bResult;
} }

View File

@ -189,7 +189,8 @@ void Effect::GetSamples(WaveTrack *track, sampleCount *start, sampleCount *len)
t1 = t0 + mLength; t1 = t0 + mLength;
if (mT0 == mT1) { if (mT0 == mT1) {
// Not really part of the calculation, but convenient to put here // Not really part of the calculation, but convenient to put here
wxASSERT(track->InsertSilence(t0, t1)); bool bResult = track->InsertSilence(t0, t1);
wxASSERT(bResult); // TO DO: Actually handle this.
} }
} }

View File

@ -531,7 +531,8 @@ bool EffectEqualization::ProcessOne(int count, WaveTrack * t,
if(toClipOutput) if(toClipOutput)
{ {
//put the processed audio in //put the processed audio in
wxASSERT(t->Paste(clipStartEndTimes[i].first,toClipOutput)); bool bResult = t->Paste(clipStartEndTimes[i].first, toClipOutput);
wxASSERT(bResult); // TO DO: Actually handle this.
//if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this //if the clip was only partially selected, the Paste will have created a split line. Join is needed to take care of this
//This is not true when the selection is fully contained within one clip (second half of conditional) //This is not true when the selection is fully contained within one clip (second half of conditional)
if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first || if( (clipRealStartEndTimes[i].first != clipStartEndTimes[i].first ||

View File

@ -708,7 +708,8 @@ bool EffectNoiseRemoval::ProcessOne(int count, WaveTrack * track,
double tLen = mOutputTrack->LongSamplesToTime(len); double tLen = mOutputTrack->LongSamplesToTime(len);
// Filtering effects always end up with more data than they started with. Delete this 'tail'. // Filtering effects always end up with more data than they started with. Delete this 'tail'.
mOutputTrack->HandleClear(tLen, mOutputTrack->GetEndTime(), false, false); mOutputTrack->HandleClear(tLen, mOutputTrack->GetEndTime(), false, false);
wxASSERT(track->ClearAndPaste(t0, t0 + tLen, mOutputTrack, true, false)); bool bResult = track->ClearAndPaste(t0, t0 + tLen, mOutputTrack, true, false);
wxASSERT(bResult); // TO DO: Actually handle this.
} }
// Delete the outputTrack now that its data is inserted in place // Delete the outputTrack now that its data is inserted in place

View File

@ -363,14 +363,18 @@ bool EffectSBSMS::Process()
if(rightTrack) if(rightTrack)
rb.outputRightTrack->Flush(); rb.outputRightTrack->Flush();
wxASSERT(leftTrack->ClearAndPaste( bool bResult =
mCurT0, mCurT1, rb.outputLeftTrack, leftTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputLeftTrack,
true, false, GetTimeWarper())); true, false, GetTimeWarper());
wxASSERT(bResult); // TO DO: Actually handle this.
if(rightTrack) if(rightTrack)
wxASSERT(rightTrack->ClearAndPaste( {
mCurT0, mCurT1, rb.outputRightTrack, bResult =
true, false, GetTimeWarper())); rightTrack->ClearAndPaste(mCurT0, mCurT1, rb.outputRightTrack,
true, false, GetTimeWarper());
wxASSERT(bResult); // TO DO: Actually handle this.
}
} }
mCurTrackNum++; mCurTrackNum++;
} }

View File

@ -72,11 +72,11 @@ bool EffectStereoToMono::ProcessOne(int count)
sampleCount index = mStart; sampleCount index = mStart;
float *leftBuffer = new float[idealBlockLen]; float *leftBuffer = new float[idealBlockLen];
float *rightBuffer = new float[idealBlockLen]; float *rightBuffer = new float[idealBlockLen];
bool rc; bool bResult = true;
while (index < mEnd) { while (index < mEnd) {
rc = mLeftTrack->Get((samplePtr)leftBuffer, floatSample, index, idealBlockLen); bResult &= mLeftTrack->Get((samplePtr)leftBuffer, floatSample, index, idealBlockLen);
rc = mRightTrack->Get((samplePtr)rightBuffer, floatSample, index, idealBlockLen); bResult &= mRightTrack->Get((samplePtr)rightBuffer, floatSample, index, idealBlockLen);
sampleCount limit = idealBlockLen; sampleCount limit = idealBlockLen;
if ((index + idealBlockLen) > mEnd) { if ((index + idealBlockLen) > mEnd) {
limit = mEnd - index; limit = mEnd - index;
@ -88,15 +88,15 @@ bool EffectStereoToMono::ProcessOne(int count)
curMonoFrame = (curLeftFrame + curRightFrame) / 2.0; curMonoFrame = (curLeftFrame + curRightFrame) / 2.0;
leftBuffer[i] = curMonoFrame; leftBuffer[i] = curMonoFrame;
} }
rc = mOutTrack->Append((samplePtr)leftBuffer, floatSample, limit); bResult &= mOutTrack->Append((samplePtr)leftBuffer, floatSample, limit);
if (TrackProgress(count, 2.*((double)index / (double)(mEnd - mStart)))) if (TrackProgress(count, 2.*((double)index / (double)(mEnd - mStart))))
return false; return false;
} }
double minStart = wxMin(mLeftTrack->GetStartTime(), mRightTrack->GetStartTime()); double minStart = wxMin(mLeftTrack->GetStartTime(), mRightTrack->GetStartTime());
mLeftTrack->Clear(mLeftTrack->GetStartTime(), mLeftTrack->GetEndTime()); bResult &= mLeftTrack->Clear(mLeftTrack->GetStartTime(), mLeftTrack->GetEndTime());
mOutTrack->Flush(); bResult &= mOutTrack->Flush();
wxASSERT(mLeftTrack->Paste(minStart, mOutTrack)); bResult &= mLeftTrack->Paste(minStart, mOutTrack);
mLeftTrack->SetLinked(false); mLeftTrack->SetLinked(false);
mRightTrack->SetLinked(false); mRightTrack->SetLinked(false);
mLeftTrack->SetChannel(Track::MonoChannel); mLeftTrack->SetChannel(Track::MonoChannel);
@ -106,7 +106,7 @@ bool EffectStereoToMono::ProcessOne(int count)
delete [] leftBuffer; delete [] leftBuffer;
delete [] rightBuffer; delete [] rightBuffer;
return true; return bResult;
} }
bool EffectStereoToMono::Process() bool EffectStereoToMono::Process()

View File

@ -856,7 +856,8 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
newTrack->InsertSilence(0.0, t0 - t1); newTrack->InsertSilence(0.0, t0 - t1);
newTrack->Flush(); newTrack->Flush();
wt->Clear(t1, t0); wt->Clear(t1, t0);
wxASSERT(wt->Paste(t1, newTrack)); bool bResult = wt->Paste(t1, newTrack);
wxASSERT(bResult); // TO DO: Actually handle this.
delete newTrack; delete newTrack;
} }
newRecordingTracks.Add(wt); newRecordingTracks.Add(wt);