From 8b0a6b9d5e6241e364733cac1c6f338b9901c277 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 10 Jan 2022 15:30:41 +0100 Subject: [PATCH] macos permission: address review comments --- src/citra_qt/CMakeLists.txt | 4 ++-- src/citra_qt/camera/qt_multimedia_camera.cpp | 8 +++++--- src/citra_qt/configuration/configure_audio.cpp | 2 +- src/citra_qt/configuration/configure_camera.cpp | 2 +- .../{usage_authorization.h => macos_authorization.h} | 0 .../{usage_authorization.mm => macos_authorization.mm} | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-) rename src/citra_qt/{usage_authorization.h => macos_authorization.h} (100%) rename src/citra_qt/{usage_authorization.mm => macos_authorization.mm} (94%) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 868c68e4a..025c817e6 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -237,8 +237,8 @@ if (APPLE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE TRUE) set_target_properties(citra-qt PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) target_sources(citra-qt PRIVATE - usage_authorization.h - usage_authorization.mm + macos_authorization.h + macos_authorization.mm ) elseif(WIN32) # compile as a win32 gui application instead of a console application diff --git a/src/citra_qt/camera/qt_multimedia_camera.cpp b/src/citra_qt/camera/qt_multimedia_camera.cpp index dd932cae0..00ba03afb 100644 --- a/src/citra_qt/camera/qt_multimedia_camera.cpp +++ b/src/citra_qt/camera/qt_multimedia_camera.cpp @@ -9,7 +9,10 @@ #include #include "citra_qt/camera/qt_multimedia_camera.h" #include "citra_qt/main.h" -#include "citra_qt/usage_authorization.h" + +#if defined(__APPLE__) +#include "citra_qt/macos_authorization.h" +#endif namespace Camera { @@ -189,8 +192,7 @@ void QtMultimediaCameraHandler::StopCamera() { void QtMultimediaCameraHandler::StartCamera() { #if defined(__APPLE__) - bool authorized = AppleAuthorization::CheckAuthorizationForCamera(); - if (!authorized) { + if (!AppleAuthorization::CheckAuthorizationForCamera()) { LOG_ERROR(Service_CAM, "Unable to start camera due to lack of authorization"); return; } diff --git a/src/citra_qt/configuration/configure_audio.cpp b/src/citra_qt/configuration/configure_audio.cpp index e9452923d..7e9dba159 100644 --- a/src/citra_qt/configuration/configure_audio.cpp +++ b/src/citra_qt/configuration/configure_audio.cpp @@ -16,7 +16,7 @@ #include "ui_configure_audio.h" #if defined(__APPLE__) -#include "citra_qt/usage_authorization.h" +#include "citra_qt/macos_authorization.h" #endif constexpr int DEFAULT_INPUT_DEVICE_INDEX = 0; diff --git a/src/citra_qt/configuration/configure_camera.cpp b/src/citra_qt/configuration/configure_camera.cpp index d84cac4f2..a89dc3151 100644 --- a/src/citra_qt/configuration/configure_camera.cpp +++ b/src/citra_qt/configuration/configure_camera.cpp @@ -18,7 +18,7 @@ #include "ui_configure_camera.h" #if defined(__APPLE__) -#include "citra_qt/usage_authorization.h" +#include "citra_qt/macos_authorization.h" #endif const std::array ConfigureCamera::Implementations = { diff --git a/src/citra_qt/usage_authorization.h b/src/citra_qt/macos_authorization.h similarity index 100% rename from src/citra_qt/usage_authorization.h rename to src/citra_qt/macos_authorization.h diff --git a/src/citra_qt/usage_authorization.mm b/src/citra_qt/macos_authorization.mm similarity index 94% rename from src/citra_qt/usage_authorization.mm rename to src/citra_qt/macos_authorization.mm index 5b4506f1e..165c35107 100644 --- a/src/citra_qt/usage_authorization.mm +++ b/src/citra_qt/macos_authorization.mm @@ -4,7 +4,7 @@ #import -#include "citra_qt/usage_authorization.h" +#include "citra_qt/macos_authorization.h" #include "common/logging/log.h" namespace AppleAuthorization { @@ -33,8 +33,8 @@ void CheckAuthorization(AuthMediaType type) { case AVAuthorizationStatusNotDetermined: { // The app hasn't yet asked the user for camera access. [AVCaptureDevice requestAccessForMediaType:media_type - completionHandler:^(BOOL) { - authorized = true; + completionHandler:^(BOOL granted) { + authorized = granted; }]; if (type == AuthMediaType::Camera) { LOG_INFO(Frontend, "Camera access requested.");