1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02: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
// Return non-NULL or else throw
// May assume precondition: t0 <= t1
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) = 0;
// Create a NEW track and don't modify this track
// Return non-NULL or else throw
// Note that subclasses may want to distinguish tracks stored in a clipboard
// from those stored in a project
// May assume precondition: t0 <= t1
virtual Holder Copy
(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 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.
virtual void SyncLockAdjust(double oldT1, double newT1);
// May assume precondition: t0 <= t1
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 int GetKind() const { return None; }

View File

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

View File

@ -560,6 +560,9 @@ void WaveTrack::ConvertToSampleFormat(sampleFormat format)
bool WaveTrack::IsEmpty(double t0, double t1) const
{
if (t0 > t1)
return true;
//printf("Searching for overlap in %.6f...%.6f\n", t0, t1);
for (const auto &clip : mClips)
{
@ -658,8 +661,8 @@ void WaveTrack::Trim (double t0, double t1)
if(!inside1 && t1 < GetEndTime())
Clear(t1,GetEndTime());
if(!inside0)
SplitDelete(0,t0);
if(!inside0 && t0 > GetStartTime())
SplitDelete(GetStartTime(), t0);
}
@ -1281,7 +1284,10 @@ void WaveTrack::Paste(double t0, const Track *src)
bool singleClipMode = (other->GetNumClips() == 1 &&
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");
// 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 Paste(double t0, const Track *src) override;
// May assume precondition: t0 <= t1
void ClearAndPaste(double t0, double t1,
const Track *src,
bool preserve = true,
@ -205,15 +206,20 @@ class AUDACITY_DLL_API WaveTrack final : public PlayableTrack {
void SplitAt(double t) /* not override */;
void Split(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 */;
Track::Holder SplitCut(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void SplitDelete(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 */;
// May assume precondition: t0 <= t1
void Trim(double t0, double t1) /* not override */;
// May assume precondition: t0 <= t1
void HandleClear(double t0, double t1, bool addCutLines, bool split);
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,
double t0) const;
// May assume precondition: t0 <= t1
std::pair<float, float> GetMinMax(
double t0, double t1, bool mayThrow = true) const;
// May assume precondition: t0 <= t1
float GetRMS(double t0, double t1, bool mayThrow = true) const;
//

View File

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

View File

@ -557,7 +557,7 @@ ProgressResult FFmpegImportFileHandle::Import(TrackFactory *trackFactory,
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);
}
if (stream_delay != 0)
if (stream_delay > 0)
{
int c = -1;
for (auto &channel : stream)