add code to disable AppNap on OS X/MacOS

Should build on versions before 10.9 and run everywhere due to respondsToSelector check.
This commit is contained in:
Paul Davis 2016-08-19 11:12:05 -04:00
parent adf290446f
commit 25ec63968c
2 changed files with 16 additions and 0 deletions

View File

@ -50,6 +50,7 @@ using namespace ARDOUR;
using namespace std;
extern void set_language_preference (); // cocoacarbon.mm
extern void no_app_nap (); // cocoacarbon.mm
static void
setup_logging(void)
@ -81,6 +82,10 @@ setup_logging(void)
void
fixup_bundle_environment (int argc, char* argv[], string & localedir)
{
/* do this even for non-bundle runtimes */
no_app_nap ();
if (!g_getenv ("ARDOUR_BUNDLED")) {
return;
}

View File

@ -106,3 +106,14 @@ set_language_preference ()
setenv ("LANG", [nslocale UTF8String], 0);
CFRelease (cflocale);
}
/* Prevent "App Nap" */
void
no_app_nap ()
{
if ( [ [ NSProcessInfo processInfo ] respondsToSelector:@selector(beginActivityWithOptions:reason:) ] ) {
cout << "Disabling MacOS AppNap\n";
[ [ NSProcessInfo processInfo] beginActivityWithOptions:NSActivityLatencyCritical reason:@"realtime audio" ];
}
}