From 7bbc94d4282bcfa14772d657fd67620b40bb7d03 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 10 Jan 2022 14:38:49 +0100 Subject: [PATCH] macos: request permission for microphone usage --- src/citra_qt/configuration/configure_audio.cpp | 9 +++++++++ src/citra_qt/usage_authorization.h | 2 +- src/citra_qt/usage_authorization.mm | 13 +++++++++---- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/citra_qt/configuration/configure_audio.cpp b/src/citra_qt/configuration/configure_audio.cpp index 40d2ae759..e9452923d 100644 --- a/src/citra_qt/configuration/configure_audio.cpp +++ b/src/citra_qt/configuration/configure_audio.cpp @@ -15,6 +15,10 @@ #include "core/settings.h" #include "ui_configure_audio.h" +#if defined(__APPLE__) +#include "citra_qt/usage_authorization.h" +#endif + constexpr int DEFAULT_INPUT_DEVICE_INDEX = 0; ConfigureAudio::ConfigureAudio(QWidget* parent) @@ -148,6 +152,11 @@ void ConfigureAudio::UpdateAudioOutputDevices(int sink_index) { } void ConfigureAudio::UpdateAudioInputDevices(int index) { +#if defined(__APPLE__) + if (index == 1) { + AppleAuthorization::CheckAuthorizationForMicrophone(); + } +#endif if (Settings::values.mic_input_device != Frontend::Mic::default_device_name) { ui->input_device_combo_box->setCurrentText( QString::fromStdString(Settings::values.mic_input_device)); diff --git a/src/citra_qt/usage_authorization.h b/src/citra_qt/usage_authorization.h index e9be685b6..c9292d1f9 100644 --- a/src/citra_qt/usage_authorization.h +++ b/src/citra_qt/usage_authorization.h @@ -7,6 +7,6 @@ namespace AppleAuthorization { bool CheckAuthorizationForCamera(); -bool CheckAuthorizationForAudio(); +bool CheckAuthorizationForMicrophone(); } // namespace AppleAuthorization diff --git a/src/citra_qt/usage_authorization.mm b/src/citra_qt/usage_authorization.mm index 6da39e8e8..5b4506f1e 100644 --- a/src/citra_qt/usage_authorization.mm +++ b/src/citra_qt/usage_authorization.mm @@ -38,6 +38,8 @@ void CheckAuthorization(AuthMediaType type) { }]; if (type == AuthMediaType::Camera) { LOG_INFO(Frontend, "Camera access requested."); + } else { // AuthMediaType::Microphone + LOG_INFO(Frontend, "Microphone access requested."); } break; } @@ -45,10 +47,13 @@ void CheckAuthorization(AuthMediaType type) { // The user has previously denied access. authorized = false; if (type == AuthMediaType::Camera) { - LOG_WARNING( - Frontend, - "Camera access denied. To change this you may modify the macos system settings " - "for Citra at 'System Preferences -> Security & Privacy -> Camera'"); + LOG_WARNING(Frontend, "Camera access denied. To change this you may modify the " + "macOS system permission settings " + "for Citra at 'System Preferences -> Security & Privacy'"); + } else { // AuthMediaType::Microphone + LOG_WARNING(Frontend, "Microphone access denied. To change this you may modify the " + "macOS system permission settings " + "for Citra at 'System Preferences -> Security & Privacy'"); } return; }