mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Add API to query OSX/MacOS version
This commit is contained in:
parent
2f0914c730
commit
853bf6d178
2 changed files with 41 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ using namespace std;
|
||||||
|
|
||||||
extern void set_language_preference (); // cocoacarbon.mm
|
extern void set_language_preference (); // cocoacarbon.mm
|
||||||
extern void no_app_nap (); // cocoacarbon.mm
|
extern void no_app_nap (); // cocoacarbon.mm
|
||||||
|
extern int query_darwin_version (); // cocoacarbon.mm
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_logging (void)
|
setup_logging (void)
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <pbd/error.h>
|
#include <pbd/error.h>
|
||||||
#include <gtkmm2ext/gtkapplication.h>
|
#include <gtkmm2ext/gtkapplication.h>
|
||||||
#include <gdk/gdkquartz.h>
|
#include <gdk/gdkquartz.h>
|
||||||
|
|
||||||
#undef check
|
#undef check
|
||||||
#undef YES
|
#undef YES
|
||||||
#undef NO
|
#undef NO
|
||||||
|
|
@ -124,3 +128,39 @@ no_app_nap ()
|
||||||
[ [ NSProcessInfo processInfo] beginActivityWithOptions:NSActivityLatencyCritical reason:@"realtime audio" ];
|
[ [ NSProcessInfo processInfo] beginActivityWithOptions:NSActivityLatencyCritical reason:@"realtime audio" ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Query Darwin kernel version.
|
||||||
|
* @return major kernel version or -1 on failure
|
||||||
|
*
|
||||||
|
* kernel version is 4 ahead of OS X release
|
||||||
|
* 19.x.x - OS 10.15 (Catalina)
|
||||||
|
* 18.x.x - OS 10.14 (Mojave)
|
||||||
|
* 17.x.x - OS 10.13 (High Sierra)
|
||||||
|
* 16.x.x - OS 10.12 (Sierra)
|
||||||
|
* ...
|
||||||
|
* 10.x.x - OS 10.6 (Snow Leopard)
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
query_darwin_version ()
|
||||||
|
{
|
||||||
|
char str[256] = {0};
|
||||||
|
size_t size = sizeof(str);
|
||||||
|
|
||||||
|
if (0 == sysctlbyname ("kern.osrelease", str, &size, NULL, 0)) {
|
||||||
|
short int v[3];
|
||||||
|
if (3 == sscanf (str, "%hd.%hd.%hd", &v[0], &v[1], &v[2])) {
|
||||||
|
return v[0]; // major version only
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
struct utsname name;
|
||||||
|
uname (&name);
|
||||||
|
int v[3];
|
||||||
|
if (3 == sscanf (name.release, "%d.%d.%d", &v[0], &v[1], &v[2])) {
|
||||||
|
return v[0]; // major version only
|
||||||
|
}
|
||||||
|
if (2 == sscanf (name.release, "%d.%d", &v[0], &v[1])) {
|
||||||
|
return v[0]; // major version only
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue