macos: request permission for microphone usage

master
Vitor Kiguchi 2022-01-10 14:38:49 +07:00
parent d5a4988f9e
commit 7bbc94d428
3 changed files with 19 additions and 5 deletions

@ -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));

@ -7,6 +7,6 @@
namespace AppleAuthorization {
bool CheckAuthorizationForCamera();
bool CheckAuthorizationForAudio();
bool CheckAuthorizationForMicrophone();
} // namespace AppleAuthorization

@ -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;
}