mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-24 07:01:16 +01:00
Reimplement the insertion of zeroes at drop-outs...
... and correct for latency only when there is at least one playback track
This commit is contained in:
@@ -2716,10 +2716,6 @@ void AudioIO::StopStream()
|
||||
double recordingOffset =
|
||||
mLastRecordingOffset + latencyCorrection / 1000.0;
|
||||
|
||||
for (auto &interval : mLostCaptureIntervals)
|
||||
interval.first += recordingOffset,
|
||||
interval.second += recordingOffset;
|
||||
|
||||
for (unsigned int i = 0; i < mCaptureTracks.size(); i++) {
|
||||
// The calls to Flush, and (less likely) Clear and InsertSilence,
|
||||
// may cause exceptions because of exhaustion of disk space.
|
||||
@@ -2791,6 +2787,19 @@ void AudioIO::StopStream()
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
for (auto &interval : mLostCaptureIntervals) {
|
||||
auto &start = interval.first;
|
||||
if (mPlaybackTracks.size() > 0)
|
||||
// only do latency correction if some tracks are being played back
|
||||
start += recordingOffset;
|
||||
auto duration = interval.second;
|
||||
for (auto &track : mCaptureTracks) {
|
||||
GuardedCall([&] {
|
||||
track->SyncLockAdjust(start, start + duration);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5181,10 +5190,9 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
||||
len < framesPerBuffer) ) {
|
||||
// Assume that any good partial buffer should be written leftmost
|
||||
// and zeroes will be padded after; label the zeroes.
|
||||
auto start = gAudioIO->mTime;
|
||||
auto end = start + framesPerBuffer / gAudioIO->mRate;
|
||||
auto middle = start + len / gAudioIO->mRate;
|
||||
auto interval = std::make_pair( middle, end );
|
||||
auto start = gAudioIO->mTime + len / gAudioIO->mRate;
|
||||
auto duration = (framesPerBuffer - len) / gAudioIO->mRate;
|
||||
auto interval = std::make_pair( start, duration );
|
||||
gAudioIO->mLostCaptureIntervals.push_back( interval );
|
||||
}
|
||||
|
||||
@@ -5239,20 +5247,6 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
|
||||
wxUnusedVar(put);
|
||||
}
|
||||
}
|
||||
|
||||
if (gAudioIO->mDetectDropouts &&
|
||||
len < framesPerBuffer) {
|
||||
for(unsigned t = 0; t < numCaptureChannels; t++) {
|
||||
// Get here probably because of failure to keep up with real
|
||||
// time, causing loss of input samples.
|
||||
// Pad with zeroes
|
||||
const auto put = gAudioIO->mCaptureBuffers[t]->Clear(
|
||||
gAudioIO->mCaptureFormat, framesPerBuffer - len);
|
||||
// wxASSERT(put == len);
|
||||
// but we can't assert in this thread
|
||||
wxUnusedVar(put);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the current time position if not scrubbing
|
||||
|
||||
Reference in New Issue
Block a user