1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-19 17:40:51 +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 } // end recording VU meter update
// Stop recording if 'silence' is detected // 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->mPauseRec && inputBuffer && gAudioIO->mInputMeter) {
if(gAudioIO->mInputMeter->GetMaxPeak() < gAudioIO->mSilenceLevel ) { if(gAudioIO->mInputMeter->GetMaxPeak() < gAudioIO->mSilenceLevel ) {
if(!gAudioIO->IsPaused()) { if(!gAudioIO->IsPaused()) {
AudacityProject *p = GetActiveProject(); AudacityProject *p = GetActiveProject();
wxCommandEvent dummyEvt; ControlToolBar *bar = p->GetControlToolBar();
p->GetControlToolBar()->OnPause(dummyEvt); bar->CallAfter(&ControlToolBar::Pause);
} }
} }
else { else {
if(gAudioIO->IsPaused()) { if(gAudioIO->IsPaused()) {
AudacityProject *p = GetActiveProject(); AudacityProject *p = GetActiveProject();
wxCommandEvent dummyEvt; ControlToolBar *bar = p->GetControlToolBar();
p->GetControlToolBar()->OnPause(dummyEvt); 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) void ControlToolBar::OnRecord(wxCommandEvent &evt)
{ {
if (gAudioIO->IsBusy()) { if (gAudioIO->IsBusy()) {

View File

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