mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 16:39:30 +02:00
Bug1338 fixed again, with fewer Mac busy-waits; CHANGES WX BUILD...
... Busy-waiting will happen on Mac when modal dialogs are open, and a LADSPA, VST, or AudioUnits effect is also open with "fancy" interface. Busy-waiting will not happen for modal dialogs at other times.
This commit is contained in:
parent
e05d8aedd5
commit
c8e570797f
@ -1,13 +1,79 @@
|
|||||||
|
From aed0a3ed0df16f04dc39c8366d9c399fcc172009 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Licameli <paul.licameli@audacityteam.org>
|
||||||
|
Date: Sun, 31 Jul 2016 11:55:29 -0400
|
||||||
|
Subject: [PATCH 1/3] Mac modal loops won't hang when other code uses old
|
||||||
|
Mutiprocessing...
|
||||||
|
|
||||||
|
... if you call the new wxEventLoopBase::SetBusyWaiting(true).
|
||||||
|
|
||||||
|
But this has the undesirable consequence of high CPU usage while the loop idles,
|
||||||
|
so this fix must be turned on only as needed by the application.
|
||||||
|
|
||||||
|
See the Audacity bug report that motivated this change:
|
||||||
|
|
||||||
|
http://bugzilla.audacityteam.org/show_bug.cgi?id=1338
|
||||||
|
---
|
||||||
|
include/wx/evtloop.h | 9 +++++++++
|
||||||
|
src/common/evtloopcmn.cpp | 14 ++++++++++++++
|
||||||
|
src/osx/core/evtloop_cf.cpp | 3 ++-
|
||||||
|
3 files changed, 25 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/include/wx/evtloop.h b/include/wx/evtloop.h
|
||||||
|
index 1133473..db87431 100644
|
||||||
|
--- a/include/wx/evtloop.h
|
||||||
|
+++ b/include/wx/evtloop.h
|
||||||
|
@@ -177,6 +177,15 @@ public:
|
||||||
|
// set currently active (running) event loop
|
||||||
|
static void SetActive(wxEventLoopBase* loop);
|
||||||
|
|
||||||
|
+#ifdef __WXMAC__
|
||||||
|
+ static bool GetBusyWaiting();
|
||||||
|
+
|
||||||
|
+ // If the argument is true, cause modal dialogs to busy-wait for events,
|
||||||
|
+ // which seems to be necessary to avoid hanging when other code is using
|
||||||
|
+ // the old Multiprocessing API
|
||||||
|
+ static void SetBusyWaiting(bool busyWaiting);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// real implementation of Run()
|
||||||
|
diff --git a/src/common/evtloopcmn.cpp b/src/common/evtloopcmn.cpp
|
||||||
|
index f7b5138..325fd54 100644
|
||||||
|
--- a/src/common/evtloopcmn.cpp
|
||||||
|
+++ b/src/common/evtloopcmn.cpp
|
||||||
|
@@ -56,6 +56,20 @@ void wxEventLoopBase::SetActive(wxEventLoopBase* loop)
|
||||||
|
wxTheApp->OnEventLoopEnter(loop);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool g_busyWaiting = false;
|
||||||
|
+
|
||||||
|
+/* static */
|
||||||
|
+bool wxEventLoopBase::GetBusyWaiting()
|
||||||
|
+{
|
||||||
|
+ return g_busyWaiting;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* static */
|
||||||
|
+void wxEventLoopBase::SetBusyWaiting(bool busyWaiting)
|
||||||
|
+{
|
||||||
|
+ g_busyWaiting = busyWaiting;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int wxEventLoopBase::Run()
|
||||||
|
{
|
||||||
|
// event loops are not recursive, you need to create another loop!
|
||||||
diff --git a/src/osx/core/evtloop_cf.cpp b/src/osx/core/evtloop_cf.cpp
|
diff --git a/src/osx/core/evtloop_cf.cpp b/src/osx/core/evtloop_cf.cpp
|
||||||
index 7e70dec..37b22b5 100644
|
index 7e70dec..510af80 100644
|
||||||
--- src/osx/core/evtloop_cf.cpp
|
--- a/src/osx/core/evtloop_cf.cpp
|
||||||
+++ src/osx/core/evtloop_cf.cpp
|
+++ b/src/osx/core/evtloop_cf.cpp
|
||||||
@@ -243,7 +243,7 @@ int wxCFEventLoop::DoProcessEvents()
|
@@ -243,7 +243,8 @@ int wxCFEventLoop::DoProcessEvents()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
- return DispatchTimeout( m_isInsideYield ? 0 : 1000 );
|
- return DispatchTimeout( m_isInsideYield ? 0 : 1000 );
|
||||||
+ return DispatchTimeout( 0 );
|
+ return DispatchTimeout
|
||||||
|
+ (m_isInsideYield || wxEventLoopBase::GetBusyWaiting() ? 0 : 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxCFEventLoop::Dispatch()
|
bool wxCFEventLoop::Dispatch()
|
||||||
|
@ -1787,6 +1787,10 @@ bool VSTEffect::HideUI()
|
|||||||
|
|
||||||
bool VSTEffect::CloseUI()
|
bool VSTEffect::CloseUI()
|
||||||
{
|
{
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
mParent->RemoveEventHandler(this);
|
mParent->RemoveEventHandler(this);
|
||||||
|
|
||||||
PowerOff();
|
PowerOff();
|
||||||
@ -2835,6 +2839,10 @@ void VSTEffect::BuildFancy()
|
|||||||
|
|
||||||
mDialog->Connect(wxEVT_SIZE, wxSizeEventHandler(VSTEffect::OnSize));
|
mDialog->Connect(wxEVT_SIZE, wxSizeEventHandler(VSTEffect::OnSize));
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@
|
|||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
#include <wx/control.h>
|
#include <wx/control.h>
|
||||||
#include <wx/dir.h>
|
#include <wx/dir.h>
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
#include <wx/evtloop.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
@ -1792,6 +1797,10 @@ bool AudioUnitEffect::PopulateUI(wxWindow *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mParent->SetMinSize(wxDefaultSize);
|
mParent->SetMinSize(wxDefaultSize);
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
mParent->PushEventHandler(this);
|
mParent->PushEventHandler(this);
|
||||||
@ -1838,6 +1847,10 @@ bool AudioUnitEffect::HideUI()
|
|||||||
|
|
||||||
bool AudioUnitEffect::CloseUI()
|
bool AudioUnitEffect::CloseUI()
|
||||||
{
|
{
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
mParent->RemoveEventHandler(this);
|
mParent->RemoveEventHandler(this);
|
||||||
|
|
||||||
mUIHost = NULL;
|
mUIHost = NULL;
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
#include <wx/dcbuffer.h>
|
#include <wx/dcbuffer.h>
|
||||||
#include <wx/dialog.h>
|
#include <wx/dialog.h>
|
||||||
#include <wx/dynarray.h>
|
#include <wx/dynarray.h>
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
#include <wx/evtloop.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <wx/math.h>
|
#include <wx/math.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
@ -1133,6 +1138,10 @@ bool LV2Effect::HideUI()
|
|||||||
|
|
||||||
bool LV2Effect::CloseUI()
|
bool LV2Effect::CloseUI()
|
||||||
{
|
{
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
mParent->RemoveEventHandler(this);
|
mParent->RemoveEventHandler(this);
|
||||||
|
|
||||||
if (mSliders)
|
if (mSliders)
|
||||||
@ -1561,6 +1570,10 @@ bool LV2Effect::BuildFancy()
|
|||||||
|
|
||||||
TransferDataToWindow();
|
TransferDataToWindow();
|
||||||
|
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
wxEventLoop::SetBusyWaiting(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user