mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-09 06:06:24 +01:00
Revert "Bug 1823: Better interaction of undo and record..."
This reverts commit1e8aba968d, reversing changes made to6e75ae58ac.
This commit is contained in:
@@ -958,11 +958,24 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
shifted = !shifted;
|
||||
|
||||
TrackList *trackList = p->GetTracks();
|
||||
auto pTracksCopy = TrackList::Create();
|
||||
auto &tracksCopy = *pTracksCopy;
|
||||
bool tracksCopied = false;
|
||||
|
||||
WaveTrackArray recordingTracks;
|
||||
|
||||
auto cleanup = finally( [&] {
|
||||
if (!success) {
|
||||
if (tracksCopied)
|
||||
// Restore the tracks to remove any inserted silence
|
||||
*trackList = std::move(tracksCopy);
|
||||
|
||||
if ( ! shifted ) {
|
||||
// msmeyer: Delete recently added tracks if opening stream fails
|
||||
for ( auto track : recordingTracks )
|
||||
trackList->Remove(track.get());
|
||||
}
|
||||
|
||||
SetPlay(false);
|
||||
SetStop(false);
|
||||
SetRecord(false);
|
||||
@@ -1009,13 +1022,13 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
midiTracks = trackList->GetNoteTrackArray(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
playbackTracks = WaveTrackConstArray();
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
midiTracks = NoteTrackArray();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// If SHIFT key was down, the user wants append to tracks
|
||||
int recordingChannels = 0;
|
||||
@@ -1063,23 +1076,14 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
t1 = wt->GetEndTime();
|
||||
// less than or equal, not just less than, to ensure a clip boundary.
|
||||
// when append recording.
|
||||
|
||||
// A function that copies all the non-sample data between
|
||||
// wave tracks; in case the track recorded to changes scale
|
||||
// type (for instance), during the recording.
|
||||
auto updater = [](Track &d, const Track &s){
|
||||
auto &dst = static_cast<WaveTrack&>(d);
|
||||
auto &src = static_cast<const WaveTrack&>(s);
|
||||
dst.Reinit(src);
|
||||
};
|
||||
|
||||
// Get a copy of the track to be appended, to be pushed into
|
||||
// undo history only later.
|
||||
auto pending = std::static_pointer_cast<WaveTrack>(
|
||||
p->GetTracks()->RegisterPendingChangedTrack(
|
||||
updater, wt.get() ) );
|
||||
|
||||
if (t1 <= t0) {
|
||||
if (!tracksCopied) {
|
||||
// Duplicate all tracks before modifying any of them.
|
||||
// The duplicates are used to restore state in case
|
||||
// of failure.
|
||||
tracksCopied = true;
|
||||
tracksCopy = *trackList;
|
||||
}
|
||||
|
||||
// Pad the recording track with silence, up to the
|
||||
// maximum time.
|
||||
@@ -1087,10 +1091,10 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
newTrack->SetWaveColorIndex( wt->GetWaveColorIndex() );
|
||||
newTrack->InsertSilence(0.0, t0 - t1);
|
||||
newTrack->Flush();
|
||||
pending->Clear(t1, t0);
|
||||
pending->Paste(t1, newTrack.get());
|
||||
wt->Clear(t1, t0);
|
||||
wt->Paste(t1, newTrack.get());
|
||||
}
|
||||
recordingTracks.push_back(pending);
|
||||
recordingTracks.push_back(wt);
|
||||
// Don't record more channels than configured recording pref.
|
||||
if( (int)recordingTracks.size() >= recordingChannels ){
|
||||
break;
|
||||
@@ -1126,9 +1130,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
wxString baseTrackName = recordingNameCustom? defaultRecordingTrackName : defaultTrackName;
|
||||
|
||||
for (int c = 0; c < recordingChannels; c++) {
|
||||
std::shared_ptr<WaveTrack> newTrack{
|
||||
p->GetTrackFactory()->NewWaveTrack().release()
|
||||
};
|
||||
auto newTrack = p->GetTrackFactory()->NewWaveTrack();
|
||||
|
||||
newTrack->SetOffset(t0);
|
||||
wxString nameSuffix = wxString(wxT(""));
|
||||
@@ -1180,8 +1182,11 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
newTrack->SetChannel( Track::MonoChannel );
|
||||
}
|
||||
|
||||
p->GetTracks()->RegisterPendingNewTrack( newTrack );
|
||||
recordingTracks.push_back( newTrack );
|
||||
// Let the list hold the track, and keep a pointer to it
|
||||
recordingTracks.push_back(
|
||||
Track::Pointer<WaveTrack>(
|
||||
trackList->Add(
|
||||
std::move(newTrack))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,8 +1212,6 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
|
||||
StartScrollingIfPreferred();
|
||||
}
|
||||
else {
|
||||
CancelRecording();
|
||||
|
||||
// Show error message if stream could not be opened
|
||||
ShowErrorDialog(this, _("Error"),
|
||||
_("Error opening sound device.\nTry changing the audio host, recording device and the project sample rate."),
|
||||
@@ -1450,15 +1453,3 @@ void ControlToolBar::StopScrolling()
|
||||
project->GetPlaybackScroller().Activate
|
||||
(AudacityProject::PlaybackScroller::Mode::Off);
|
||||
}
|
||||
|
||||
void ControlToolBar::CommitRecording()
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
project->GetTracks()->ApplyPendingTracks();
|
||||
}
|
||||
|
||||
void ControlToolBar::CancelRecording()
|
||||
{
|
||||
const auto project = GetActiveProject();
|
||||
project->GetTracks()->ClearPendingTracks();
|
||||
}
|
||||
|
||||
@@ -112,12 +112,6 @@ class ControlToolBar final : public ToolBar {
|
||||
void StartScrolling();
|
||||
void StopScrolling();
|
||||
|
||||
// Commit the addition of temporary recording tracks into the project
|
||||
void CommitRecording();
|
||||
|
||||
// Cancel the addition of temporary recording tracks into the project
|
||||
void CancelRecording();
|
||||
|
||||
private:
|
||||
|
||||
AButton *MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,
|
||||
|
||||
Reference in New Issue
Block a user