소스 검색

UI: Add Rosetta Detection

Adds a check that detects if OBS is running on Rosetta on macOS and logs
the result.
gxalpha 3 년 전
부모
커밋
8298f040fe
3개의 변경된 파일21개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      UI/obs-app.cpp
  2. 14 0
      UI/platform-osx.mm
  3. 1 0
      UI/platform.hpp

+ 6 - 0
UI/obs-app.cpp

@@ -2116,6 +2116,12 @@ static int run_program(fstream &logFile, int argc, char *argv[])
 		}
 #endif
 
+#ifdef __APPLE__
+		bool rosettaTranslated = ProcessIsRosettaTranslated();
+		blog(LOG_INFO, "Rosetta translation used: %s",
+		     rosettaTranslated ? "true" : "false");
+#endif
+
 		if (!created_log) {
 			create_log_file(logFile);
 			created_log = true;

+ 14 - 0
UI/platform-osx.mm

@@ -23,6 +23,7 @@
 #include "obs-app.hpp"
 
 #include <unistd.h>
+#include <sys/sysctl.h>
 
 #import <AppKit/AppKit.h>
 
@@ -235,6 +236,19 @@ void EnableOSXDockIcon(bool enable)
 				NSApplicationActivationPolicyProhibited];
 }
 
+bool ProcessIsRosettaTranslated()
+{
+#ifdef __aarch64__
+	return false;
+#else
+	int ret = 0;
+	size_t size = sizeof(ret);
+	if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1)
+		return false;
+	return ret == 1;
+#endif
+}
+
 /*
  * This custom NSApplication subclass makes the app compatible with CEF. Qt
  * also has an NSApplication subclass, but it doesn't conflict thanks to Qt

+ 1 - 0
UI/platform.hpp

@@ -69,6 +69,7 @@ void EnableOSXDockIcon(bool enable);
 void InstallNSApplicationSubclass();
 void disableColorSpaceConversion(QWidget *window);
 void CheckAppWithSameBundleID(bool &already_running);
+bool ProcessIsRosettaTranslated();
 #endif
 #ifdef __linux__
 void RunningInstanceCheck(bool &already_running);