1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-08 17:37:08 +01:00

Reviewed uses of InconsistencyException outside Sequence.cpp

This commit is contained in:
Paul Licameli
2017-11-18 22:18:49 -05:00
parent 2f40c1c77e
commit f136b5c530
6 changed files with 28 additions and 7 deletions

View File

@@ -282,15 +282,18 @@ class AUDACITY_DLL_API Track /* not final */
// Create a NEW track and modify this track // Create a NEW track and modify this track
// Return non-NULL or else throw // Return non-NULL or else throw
// May assume precondition: t0 <= t1
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) = 0; virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
// Create a NEW track and don't modify this track // Create a NEW track and don't modify this track
// Return non-NULL or else throw // Return non-NULL or else throw
// Note that subclasses may want to distinguish tracks stored in a clipboard // Note that subclasses may want to distinguish tracks stored in a clipboard
// from those stored in a project // from those stored in a project
// May assume precondition: t0 <= t1
virtual Holder Copy virtual Holder Copy
(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const = 0; (double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const = 0;
// May assume precondition: t0 <= t1
virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1)) = 0; virtual void Clear(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
virtual void Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) = 0; virtual void Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) = 0;
@@ -299,7 +302,10 @@ class AUDACITY_DLL_API Track /* not final */
// is replaced by one of a different length. // is replaced by one of a different length.
virtual void SyncLockAdjust(double oldT1, double newT1); virtual void SyncLockAdjust(double oldT1, double newT1);
// May assume precondition: t0 <= t1
virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1)) = 0; virtual void Silence(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
// May assume precondition: t0 <= t1
virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) = 0; virtual void InsertSilence(double WXUNUSED(t), double WXUNUSED(len)) = 0;
virtual int GetKind() const { return None; } virtual int GetKind() const { return None; }

View File

@@ -1833,8 +1833,9 @@ void WaveClip::ExpandCutLine(double cutLinePosition)
[=](const WaveClipHolder &p) { return p.get() == cutline; }); [=](const WaveClipHolder &p) { return p.get() == cutline; });
if (it != end) if (it != end)
mCutLines.erase(it); // deletes cutline! mCutLines.erase(it); // deletes cutline!
else else {
THROW_INCONSISTENCY_EXCEPTION; wxASSERT(false);
}
} }
} }

View File

@@ -560,6 +560,9 @@ void WaveTrack::ConvertToSampleFormat(sampleFormat format)
bool WaveTrack::IsEmpty(double t0, double t1) const bool WaveTrack::IsEmpty(double t0, double t1) const
{ {
if (t0 > t1)
return true;
//printf("Searching for overlap in %.6f...%.6f\n", t0, t1); //printf("Searching for overlap in %.6f...%.6f\n", t0, t1);
for (const auto &clip : mClips) for (const auto &clip : mClips)
{ {
@@ -658,8 +661,8 @@ void WaveTrack::Trim (double t0, double t1)
if(!inside1 && t1 < GetEndTime()) if(!inside1 && t1 < GetEndTime())
Clear(t1,GetEndTime()); Clear(t1,GetEndTime());
if(!inside0) if(!inside0 && t0 > GetStartTime())
SplitDelete(0,t0); SplitDelete(GetStartTime(), t0);
} }
@@ -1281,7 +1284,10 @@ void WaveTrack::Paste(double t0, const Track *src)
bool singleClipMode = (other->GetNumClips() == 1 && bool singleClipMode = (other->GetNumClips() == 1 &&
other->GetStartTime() == 0.0); other->GetStartTime() == 0.0);
double insertDuration = other->GetEndTime(); const double insertDuration = other->GetEndTime();
if( insertDuration < 1.0/mRate )
return;
//printf("Check if we need to make room for the pasted data\n"); //printf("Check if we need to make room for the pasted data\n");
// Make room for the pasted data // Make room for the pasted data

View File

@@ -193,6 +193,7 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
void Clear(double t0, double t1) override; void Clear(double t0, double t1) override;
void Paste(double t0, const Track *src) override; void Paste(double t0, const Track *src) override;
// May assume precondition: t0 <= t1
void ClearAndPaste(double t0, double t1, void ClearAndPaste(double t0, double t1,
const Track *src, const Track *src,
bool preserve = true, bool preserve = true,
@@ -205,15 +206,20 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
void SplitAt(double t) /* not override */; void SplitAt(double t) /* not override */;
void Split(double t0, double t1) /* not override */; void Split(double t0, double t1) /* not override */;
// Track::Holder CutAndAddCutLine(double t0, double t1) /* not override */; // Track::Holder CutAndAddCutLine(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void ClearAndAddCutLine(double t0, double t1) /* not override */; void ClearAndAddCutLine(double t0, double t1) /* not override */;
Track::Holder SplitCut(double t0, double t1) /* not override */; Track::Holder SplitCut(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void SplitDelete(double t0, double t1) /* not override */; void SplitDelete(double t0, double t1) /* not override */;
void Join(double t0, double t1) /* not override */; void Join(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void Disjoin(double t0, double t1) /* not override */; void Disjoin(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void Trim(double t0, double t1) /* not override */; void Trim(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void HandleClear(double t0, double t1, bool addCutLines, bool split); void HandleClear(double t0, double t1, bool addCutLines, bool split);
void SyncLockAdjust(double oldT1, double newT1) override; void SyncLockAdjust(double oldT1, double newT1) override;
@@ -278,8 +284,10 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
void GetEnvelopeValues(double *buffer, size_t bufferLen, void GetEnvelopeValues(double *buffer, size_t bufferLen,
double t0) const; double t0) const;
// May assume precondition: t0 <= t1
std::pair<float, float> GetMinMax( std::pair<float, float> GetMinMax(
double t0, double t1, bool mayThrow = true) const; double t0, double t1, bool mayThrow = true) const;
// May assume precondition: t0 <= t1
float GetRMS(double t0, double t1, bool mayThrow = true) const; float GetRMS(double t0, double t1, bool mayThrow = true) const;
// //

View File

@@ -471,7 +471,7 @@ bool EffectTruncSilence::DoRemoval
mTruncLongestAllowedSilence); mTruncLongestAllowedSilence);
} }
double cutLen = inLength - outLength; double cutLen = std::max(0.0, inLength - outLength);
totalCutLen += cutLen; totalCutLen += cutLen;
TrackListIterator iterOut(mOutputTracks.get()); TrackListIterator iterOut(mOutputTracks.get());

View File

@@ -557,7 +557,7 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
stream_delay = sc->m_stream->start_time; stream_delay = sc->m_stream->start_time;
wxLogDebug(wxT("Stream %d start_time = %lld, that would be %f milliseconds."), s, (long long) sc->m_stream->start_time, double(sc->m_stream->start_time)/AV_TIME_BASE*1000); wxLogDebug(wxT("Stream %d start_time = %lld, that would be %f milliseconds."), s, (long long) sc->m_stream->start_time, double(sc->m_stream->start_time)/AV_TIME_BASE*1000);
} }
if (stream_delay != 0) if (stream_delay > 0)
{ {
int c = -1; int c = -1;
for (auto &channel : stream) for (auto &channel : stream)