Browse Source

Make macOS native audio behave like the others

Signed-off-by: falkTX <falktx@falktx.com>
pull/392/head
falkTX 2 years ago
parent
commit
cfbc53bf93
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 19 additions and 16 deletions
  1. +10
    -9
      distrho/src/DistrhoUtils.cpp
  2. +9
    -7
      distrho/src/jackbridge/RtAudioBridge.hpp

+ 10
- 9
distrho/src/DistrhoUtils.cpp View File

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


+ 9
- 7
distrho/src/jackbridge/RtAudioBridge.hpp View File

@@ -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 {


Loading…
Cancel
Save