@@ -47,7 +47,7 @@ ifdef ARCH_MAC | |||||
SOURCES += $(wildcard src/*.mm src/*/*.mm) | SOURCES += $(wildcard src/*.mm src/*/*.mm) | ||||
SOURCES += dep/osdialog/osdialog_mac.m | SOURCES += dep/osdialog/osdialog_mac.m | ||||
LDFLAGS += -lpthread -ldl | 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 += -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 | 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 | endif | ||||
@@ -204,6 +204,13 @@ int main(int argc, char* argv[]) { | |||||
INFO("Initializing audio"); | INFO("Initializing audio"); | ||||
audio::init(); | audio::init(); | ||||
rtaudioInit(); | 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"); | INFO("Initializing MIDI"); | ||||
midi::init(); | midi::init(); | ||||
rtmidiInit(); | rtmidiInit(); | ||||
@@ -7,5 +7,10 @@ namespace rack { | |||||
PRIVATE void rtaudioInit(); | PRIVATE void rtaudioInit(); | ||||
#if defined ARCH_MAC | |||||
/** Checks if Microphone permission is blocked on Mac. */ | |||||
bool rtaudioIsMicrophoneBlocked(); | |||||
#endif | |||||
} // namespace rack | } // namespace rack |
@@ -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 |