mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 09:09:47 +02:00
Restore tracks if recording fails to start
During an append record, silence may need to be added to the end of the existing track(s) to fill any gap between the end and the common recording start time. But, if the recording fails to start, this silence is left at the ends of the tracks. This change fixes that by making a copy of the tracks before recording starts and restoring the tracks from that copy if the start fails.
This commit is contained in:
parent
c38d863158
commit
8ab7c271c9
@ -819,6 +819,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
|
||||
// If SHIFT key was down, the user wants append to tracks
|
||||
int recordingChannels = 0;
|
||||
TrackList *tracksCopy = NULL;
|
||||
bool shifted = mRecord->WasShiftDown();
|
||||
if (shifted) {
|
||||
bool sel = false;
|
||||
@ -858,6 +859,16 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
playbackTracks.Remove(wt);
|
||||
t1 = wt->GetEndTime();
|
||||
if (t1 < t0) {
|
||||
if (!tracksCopy) {
|
||||
tracksCopy = new TrackList();
|
||||
TrackListIterator iter(t);
|
||||
Track *trk = iter.First();
|
||||
while (trk) {
|
||||
tracksCopy->Add(trk->Duplicate());
|
||||
trk = iter.Next();
|
||||
}
|
||||
}
|
||||
|
||||
WaveTrack *newTrack = p->GetTrackFactory()->NewWaveTrack();
|
||||
newTrack->InsertSilence(0.0, t0 - t1);
|
||||
newTrack->Flush();
|
||||
@ -926,7 +937,21 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
}
|
||||
else {
|
||||
// msmeyer: Delete recently added tracks if opening stream fails
|
||||
if (!shifted) {
|
||||
if (shifted) {
|
||||
if (tracksCopy) {
|
||||
t->Clear(true);
|
||||
TrackListIterator iter(tracksCopy);
|
||||
Track *trk = iter.First();
|
||||
while (trk)
|
||||
{
|
||||
Track *tmp = trk;
|
||||
trk = iter.RemoveCurrent();
|
||||
t->Add(tmp);
|
||||
}
|
||||
delete tracksCopy;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (unsigned int i = 0; i < newRecordingTracks.GetCount(); i++) {
|
||||
t->Remove(newRecordingTracks[i]);
|
||||
delete newRecordingTracks[i];
|
||||
|
Loading…
x
Reference in New Issue
Block a user