Do not store pause state in ControlToolBar...
... Move that into ProjectAudioManager instead, and update the button, only to reflect it, in idle time. However, AudioIO also has its mPaused member variable, and it is not obvious that it was always kept the same as the button state. No attempt was made here to identify and fix any bugs, but only to preserve behavior.
This commit is contained in:
parent
8b549ea07f
commit
923128731d
|
@ -35,6 +35,10 @@ public:
|
|||
void SetTimerRecordCancelled() { mTimerRecordCanceled = true; }
|
||||
void ResetTimerRecordCancelled() { mTimerRecordCanceled = false; }
|
||||
|
||||
bool Paused() const { return mPaused; }
|
||||
|
||||
void SetPaused( bool value ) { mPaused = value; }
|
||||
|
||||
private:
|
||||
// Audio IO callback methods
|
||||
void OnAudioIORate(int rate) override;
|
||||
|
@ -48,6 +52,8 @@ private:
|
|||
|
||||
//flag for cancellation of timer record.
|
||||
bool mTimerRecordCanceled{ false };
|
||||
|
||||
bool mPaused{ false };
|
||||
};
|
||||
|
||||
AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project );
|
||||
|
|
|
@ -110,8 +110,6 @@ END_EVENT_TABLE()
|
|||
ControlToolBar::ControlToolBar( AudacityProject &project )
|
||||
: ToolBar(project, TransportBarID, _("Transport"), wxT("Control"))
|
||||
{
|
||||
mPaused = false;
|
||||
|
||||
gPrefs->Read(wxT("/GUI/ErgonomicTransportButtons"), &mErgonomicTransportButtons, true);
|
||||
mStrLocale = gPrefs->Read(wxT("/Locale/Language"), wxT(""));
|
||||
|
||||
|
@ -496,8 +494,8 @@ void ControlToolBar::EnableDisableButtons()
|
|||
!(playing && !paused)
|
||||
);
|
||||
mStop->SetEnabled(CanStopAudioStream() && (playing || recording));
|
||||
mRewind->SetEnabled(IsPauseDown() || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (IsPauseDown() || (!playing && !recording)));
|
||||
mRewind->SetEnabled(paused || (!playing && !recording));
|
||||
mFF->SetEnabled(tracks && (paused || (!playing && !recording)));
|
||||
|
||||
mPause->SetEnabled(CanStopAudioStream());
|
||||
}
|
||||
|
@ -544,11 +542,6 @@ void ControlToolBar::SetRecord(bool down, bool altAppearance)
|
|||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsPauseDown() const
|
||||
{
|
||||
return mPause->IsDown();
|
||||
}
|
||||
|
||||
bool ControlToolBar::IsRecordDown() const
|
||||
{
|
||||
return mRecord->IsDown();
|
||||
|
@ -842,6 +835,7 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||
StopScrolling();
|
||||
|
||||
AudacityProject *project = &mProject;
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
if(project) {
|
||||
// Let scrubbing code do some appearance change
|
||||
|
@ -866,10 +860,9 @@ void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
|
|||
gAudioIO->AILADisable();
|
||||
#endif
|
||||
|
||||
mPause->PopUp();
|
||||
mPaused=false;
|
||||
projectAudioManager.SetPaused( false );
|
||||
//Make sure you tell gAudioIO to unpause
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
gAudioIO->SetPaused( false );
|
||||
|
||||
ClearCutPreviewTracks();
|
||||
|
||||
|
@ -1273,21 +1266,14 @@ bool ControlToolBar::DoRecord(AudacityProject &project,
|
|||
|
||||
void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
||||
{
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
|
||||
if (!CanStopAudioStream()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(mPaused)
|
||||
{
|
||||
mPause->PopUp();
|
||||
mPaused=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPause->PushDown();
|
||||
mPaused=true;
|
||||
}
|
||||
bool paused = !projectAudioManager.Paused();
|
||||
projectAudioManager.SetPaused( paused );
|
||||
|
||||
auto gAudioIO = AudioIO::Get();
|
||||
|
||||
|
@ -1298,7 +1284,7 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
|||
|
||||
// Bug 1494 - Pausing a seek or scrub should just STOP as
|
||||
// it is confusing to be in a paused scrub state.
|
||||
bool bStopInstead = mPaused &&
|
||||
bool bStopInstead = paused &&
|
||||
gAudioIO->IsScrubbing() &&
|
||||
!scrubber.IsSpeedPlaying();
|
||||
|
||||
|
@ -1309,18 +1295,26 @@ void ControlToolBar::OnPause(wxCommandEvent & WXUNUSED(evt))
|
|||
}
|
||||
|
||||
if (gAudioIO->IsScrubbing())
|
||||
scrubber.Pause(mPaused);
|
||||
scrubber.Pause(paused);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
gAudioIO->SetPaused(mPaused);
|
||||
gAudioIO->SetPaused(paused);
|
||||
}
|
||||
}
|
||||
|
||||
void ControlToolBar::OnIdle(wxIdleEvent & event)
|
||||
{
|
||||
event.Skip();
|
||||
|
||||
auto &projectAudioManager = ProjectAudioManager::Get( mProject );
|
||||
if ( projectAudioManager.Paused() )
|
||||
mPause->PushDown();
|
||||
else
|
||||
mPause->PopUp();
|
||||
|
||||
UpdateStatusBar();
|
||||
EnableDisableButtons();
|
||||
}
|
||||
|
||||
void ControlToolBar::OnRewind(wxCommandEvent & WXUNUSED(evt))
|
||||
|
|
|
@ -97,7 +97,6 @@ class ControlToolBar final : public ToolBar {
|
|||
void SetStop(bool down);
|
||||
void SetRecord(bool down, bool altAppearance = false);
|
||||
|
||||
bool IsPauseDown() const;
|
||||
bool IsRecordDown() const;
|
||||
|
||||
// A project is only allowed to stop an audio stream that it owns.
|
||||
|
@ -183,9 +182,6 @@ class ControlToolBar final : public ToolBar {
|
|||
|
||||
static AudacityProject *mBusyProject;
|
||||
|
||||
// Maybe button state values shouldn't be duplicated in this toolbar?
|
||||
bool mPaused; //Play or record is paused or not paused?
|
||||
|
||||
// Activate ergonomic order for transport buttons
|
||||
bool mErgonomicTransportButtons;
|
||||
|
||||
|
|
|
@ -869,9 +869,7 @@ void Scrubber::OnActivateOrDeactivateApp(wxActivateEvent &event)
|
|||
// Pause if Pause down, or not scrubbing.
|
||||
if (!mProject)
|
||||
Pause(true);
|
||||
else if ( !ControlToolBar::Find( *mProject ) )
|
||||
Pause( true );
|
||||
else if (ControlToolBar::Get( *mProject ).IsPauseDown())
|
||||
else if (ProjectAudioManager::Get( *mProject ).Paused())
|
||||
Pause( true );
|
||||
else if (!IsScrubbing())
|
||||
Pause( true );
|
||||
|
|
Loading…
Reference in New Issue