Browse Source

If Microphone permission is blocked on Mac, show error dialog with instructions to give permission.

tags/v2.5.0
Andrew Belt 7 months ago
parent
commit
89cb56ae95
4 changed files with 31 additions and 1 deletions
  1. +1
    -1
      Makefile
  2. +7
    -0
      adapters/standalone.cpp
  3. +5
    -0
      include/rtaudio.hpp
  4. +18
    -0
      src/rtaudio.mm

+ 1
- 1
Makefile View File

@@ -47,7 +47,7 @@ ifdef ARCH_MAC
SOURCES += $(wildcard src/*.mm src/*/*.mm)
SOURCES += dep/osdialog/osdialog_mac.m
LDFLAGS += -lpthread -ldl
LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI
LDFLAGS += -framework SystemConfiguration -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo -framework CoreAudio -framework CoreMIDI -framework AVFoundation
LDFLAGS += -Wl,-all_load
LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a -Wl,-load_hidden,dep/lib/libarchive.a -Wl,-load_hidden,dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a -Wl,-load_hidden,dep/lib/librtmidi.a -Wl,-load_hidden,dep/lib/librtaudio.a
endif


+ 7
- 0
adapters/standalone.cpp View File

@@ -204,6 +204,13 @@ int main(int argc, char* argv[]) {
INFO("Initializing audio");
audio::init();
rtaudioInit();
#if defined ARCH_MAC
if (rtaudioIsMicrophoneBlocked()) {
std::string msg = "Rack cannot access audio input because Microphone permission is blocked.";
msg += "\n\nGive permission to Rack by opening Apple's System Settings and enabling Privacy & Security > Microphone > " + APP_NAME + " " + APP_VERSION_MAJOR + " " + APP_EDITION_NAME + ".";
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, msg.c_str());
}
#endif
INFO("Initializing MIDI");
midi::init();
rtmidiInit();


+ 5
- 0
include/rtaudio.hpp View File

@@ -7,5 +7,10 @@ namespace rack {

PRIVATE void rtaudioInit();

#if defined ARCH_MAC
/** Checks if Microphone permission is blocked on Mac. */
bool rtaudioIsMicrophoneBlocked();
#endif


} // namespace rack

+ 18
- 0
src/rtaudio.mm View File

@@ -0,0 +1,18 @@
#include <rtaudio.hpp>
#import <AVFoundation/AVFoundation.h>

namespace rack {


bool rtaudioIsMicrophoneBlocked() {
// authorizationStatusForMediaType is only available on Mac 10.14+.
if (@available(macOS 10.14, *)) {
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
return status == AVAuthorizationStatusRestricted || status == AVAuthorizationStatusDenied;
}
// On earlier versions, assume microphone is not blocked.
return true;
}


} // namespace rack

Loading…
Cancel
Save