1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-17 16:50:26 +02:00

Fix for bug #806

This was my bad.  I'd reset the number of capture channels
in AudioIO when the stream was stopped.  Unfortunately, two
methods depended on it being valid AFTER the stream had
stopped.

Those methods, TrackPanel::OnTimer and AudacityProjecT::OnCloseWindow,
were using it as an indicator if recording had been taking place
before they stopped the stream.  They then flushed the tracks, pushed
the state onto the undo stack and did some other post-recording tasks.

Turns out that the tracks are already flushed as part of the normal
AudioIO::StopStream processing, so that was redundant.

And, instead of duplicating the process, I've relocated most of each
methods processing to AudacityProject::OnAudioIOStopRecording.
This commit is contained in:
lllucius 2014-12-28 08:53:57 +00:00
parent 07fd731ec7
commit c305724561
2 changed files with 15 additions and 49 deletions

View File

@ -1994,37 +1994,11 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
if (GetAudioIOToken()>0 &&
gAudioIO->IsStreamActive(GetAudioIOToken())) {
wxBusyCursor busy;
gAudioIO->StopStream();
while(gAudioIO->IsBusy()) {
wxMilliSleep(100);
}
// We were playing or recording audio, but we've stopped the stream.
wxCommandEvent dummyEvent;
GetControlToolBar()->OnStop(dummyEvent);
if (gAudioIO->GetNumCaptureChannels() > 0) {
// Tracks are buffered during recording. This flushes
// them so that there's nothing left in the append
// buffers.
TrackListIterator iter(mTracks);
for (Track * t = iter.First(); t; t = iter.Next()) {
if (t->GetKind() == Track::Wave) {
((WaveTrack *)t)->Flush();
}
}
PushState(_("Recorded Audio"), _("Record"));
if(IsTimerRecordCancelled())
{
OnUndo();
ResetTimerRecordFlag();
}
}
FixScrollbars();
SetAudioIOToken(0);
RedrawProject();
}
else if (gAudioIO->IsMonitoring()) {
gAudioIO->StopStream();
@ -4751,6 +4725,20 @@ void AudacityProject::OnAudioIOStartRecording()
// This is called after recording has stopped and all tracks have flushed.
void AudacityProject::OnAudioIOStopRecording()
{
// Add to history
PushState(_("Recorded Audio"), _("Record"));
// Reset timer record
if (IsTimerRecordCancelled())
{
OnUndo();
ResetTimerRecordFlag();
}
// Refresh the project window
FixScrollbars();
RedrawProject();
// Write all cached files to disk, if any
mDirManager->WriteCacheToDisk();

View File

@ -1050,34 +1050,12 @@ void TrackPanel::OnTimer()
// Next, check to see if we were playing or recording
// audio, but now Audio I/O is completely finished.
// The main point of this is to properly push the state
// and flush the tracks once we've completely finished
// recording new state.
if (p->GetAudioIOToken()>0 &&
!gAudioIO->IsAudioTokenActive(p->GetAudioIOToken()))
{
if (gAudioIO->GetNumCaptureChannels() > 0) {
// Tracks are buffered during recording. This flushes
// them so that there's nothing left in the append
// buffers.
TrackListIterator iter(mTracks);
for (Track * t = iter.First(); t; t = iter.Next()) {
if (t->GetKind() == Track::Wave) {
((WaveTrack *)t)->Flush();
}
}
MakeParentPushState(_("Recorded Audio"), _("Record"));
if(p->IsTimerRecordCancelled())
{
p->OnUndo();
p->ResetTimerRecordFlag();
}
}
p->SetAudioIOToken(0);
mRedrawAfterStop = false;
MakeParentRedrawScrollbars();
p->SetAudioIOToken(0);
p->RedrawProject();
//ANSWER-ME: Was DisplaySelection added to solve a repaint problem?
DisplaySelection();
}