commit cfbc53bf939794fe99c57a4a8e000ec360e14262
parent 85cd6c40df9b80db20c54c5e558ba3eccf34aef9
Author: falkTX <falktx@falktx.com>
Date: Fri, 25 Nov 2022 19:30:43 +0000
Make macOS native audio behave like the others
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/distrho/src/DistrhoUtils.cpp b/distrho/src/DistrhoUtils.cpp
@@ -31,7 +31,10 @@
# include <stdlib.h>
#endif
-#if defined(DISTRHO_OS_WINDOWS) && !defined(STATIC_BUILD) && !DISTRHO_IS_STANDALONE
+#ifdef DISTRHO_OS_WINDOWS
+# if DISTRHO_IS_STANDALONE
+constexpr const HINSTANCE hInstance = nullptr;
+# else
static HINSTANCE hInstance = nullptr;
DISTRHO_PLUGIN_EXPORT
@@ -41,6 +44,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)
hInstance = hInst;
return 1;
}
+# endif
#endif
START_NAMESPACE_DISTRHO
@@ -51,25 +55,22 @@ const char* getBinaryFilename()
{
static String filename;
-#ifndef STATIC_BUILD
+ #ifndef STATIC_BUILD
if (filename.isNotEmpty())
return filename;
-# ifdef DISTRHO_OS_WINDOWS
- #if DISTRHO_IS_STANDALONE
- constexpr const HINSTANCE hInstance = nullptr;
- #endif
+ #ifdef DISTRHO_OS_WINDOWS
CHAR filenameBuf[MAX_PATH];
filenameBuf[0] = '\0';
GetModuleFileNameA(hInstance, filenameBuf, sizeof(filenameBuf));
filename = filenameBuf;
-# else
+ #else
Dl_info info;
dladdr((void*)getBinaryFilename, &info);
char filenameBuf[PATH_MAX];
filename = realpath(info.dli_fname, filenameBuf);
-# endif
-#endif
+ #endif
+ #endif
return filename;
}
diff --git a/distrho/src/jackbridge/RtAudioBridge.hpp b/distrho/src/jackbridge/RtAudioBridge.hpp
@@ -251,11 +251,6 @@ struct RtAudioBridge : NativeBridge {
return true;
}
- /* RtAudio in macOS uses a different than usual way to handle audio block size,
- * where RTAUDIO_MINIMIZE_LATENCY makes CoreAudio use very low latencies (around 15 samples).
- * As such, dynamic buffer sizes are meaningless there.
- */
- #ifndef DISTRHO_OS_MAC
bool supportsBufferSizeChanges() const override
{
return true;
@@ -285,7 +280,6 @@ struct RtAudioBridge : NativeBridge {
activate();
return ok;
}
- #endif
bool _open(const bool withInput)
{
@@ -321,7 +315,15 @@ struct RtAudioBridge : NativeBridge {
#endif
RtAudio::StreamOptions opts;
- opts.flags = RTAUDIO_NONINTERLEAVED | RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_ALSA_USE_DEFAULT;
+ opts.flags = RTAUDIO_NONINTERLEAVED | RTAUDIO_ALSA_USE_DEFAULT;
+ #ifndef DISTRHO_OS_MAC
+ /* RtAudio in macOS uses a different than usual way to handle audio block size,
+ * where RTAUDIO_MINIMIZE_LATENCY makes CoreAudio use very low latencies (around 15 samples).
+ * That has serious performance drawbacks, so we skip that here.
+ */
+ opts.flags |= RTAUDIO_MINIMIZE_LATENCY;
+ #endif
+ opts.numberOfBuffers = 2;
opts.streamName = name.buffer();
try {