1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-19 09:30:06 +02:00
This commit is contained in:
Leland Lucius 2015-08-26 00:13:14 -05:00
parent f6cbc5e6db
commit 133c0ec61d
3 changed files with 23 additions and 4 deletions

View File

@ -4023,19 +4023,29 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
} // end recording VU meter update
// Stop recording if 'silence' is detected
//
// LL: We'd gotten a little "dangerous" with the control toolbar calls
// here because we are not running in the main GUI thread. Eventually
// the toolbar attempts to update the active project's status bar.
// But, since we're not in the main thread, we can get all manner of
// really weird failures. Or none at all which is even worse, since
// we don't know a problem exists.
//
// By using CallAfter(), we can schedule the call to the toolbar
// to run in the main GUI thread after the next event loop iteration.
if(gAudioIO->mPauseRec && inputBuffer && gAudioIO->mInputMeter) {
if(gAudioIO->mInputMeter->GetMaxPeak() < gAudioIO->mSilenceLevel ) {
if(!gAudioIO->IsPaused()) {
AudacityProject *p = GetActiveProject();
wxCommandEvent dummyEvt;
p->GetControlToolBar()->OnPause(dummyEvt);
ControlToolBar *bar = p->GetControlToolBar();
bar->CallAfter(&ControlToolBar::Pause);
}
}
else {
if(gAudioIO->IsPaused()) {
AudacityProject *p = GetActiveProject();
wxCommandEvent dummyEvt;
p->GetControlToolBar()->OnPause(dummyEvt);
ControlToolBar *bar = p->GetControlToolBar();
bar->CallAfter(&ControlToolBar::Pause);
}
}
}

View File

@ -776,6 +776,12 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
}
}
void ControlToolBar::Pause()
{
wxCommandEvent dummy;
OnPause(dummy);
}
void ControlToolBar::OnRecord(wxCommandEvent &evt)
{
if (gAudioIO->IsBusy()) {

View File

@ -79,6 +79,9 @@ class ControlToolBar:public ToolBar {
// Stop playing
void StopPlaying(bool stopStream = true);
// Pause - used by AudioIO to pause sound activate recording
void Pause();
void Populate();
virtual void Repaint(wxDC *dc);
virtual void EnableDisableButtons();