diff --git a/resources/ui/carla_settings_driver.ui b/resources/ui/carla_settings_driver.ui index 6d0990438..821a9d35d 100644 --- a/resources/ui/carla_settings_driver.ui +++ b/resources/ui/carla_settings_driver.ui @@ -6,7 +6,7 @@ 0 0 - 262 + 310 136 diff --git a/source/backend/engine/CarlaEngineRtAudio.cpp b/source/backend/engine/CarlaEngineRtAudio.cpp index 37277ce88..c1faab649 100644 --- a/source/backend/engine/CarlaEngineRtAudio.cpp +++ b/source/backend/engine/CarlaEngineRtAudio.cpp @@ -149,13 +149,37 @@ public: fBufferSize = fOptions.rtaudioBufferSize; + carla_stdout("Open RtAudio with device \"%s\"", (const char*)fOptions.rtaudioDevice); + // Audio { RtAudio::StreamParameters iParams, oParams; - iParams.deviceId = fAudio.getDefaultInputDevice(); - oParams.deviceId = fAudio.getDefaultOutputDevice(); - iParams.nChannels = 2; - oParams.nChannels = 2; + iParams.nChannels = 2; // todo + oParams.nChannels = 2; // todo + + bool deviceSet = false; + + if (fOptions.rtaudioDevice.isNotEmpty()) + { + for (unsigned int i=0, count=fAudio.getDeviceCount(); i < count; ++i) + { + RtAudio::DeviceInfo devInfo(fAudio.getDeviceInfo(i)); + + if (devInfo.probed && devInfo.outputChannels > 0 && devInfo.name == (const char*)fOptions.rtaudioDevice) + { + deviceSet = true; + iParams.deviceId = i; + oParams.deviceId = i; + break; + } + } + } + + if (! deviceSet) + { + iParams.deviceId = fAudio.getDefaultInputDevice(); + oParams.deviceId = fAudio.getDefaultOutputDevice(); + } RtAudio::StreamOptions rtOptions; rtOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_HOG_DEVICE | RTAUDIO_SCHEDULE_REALTIME; @@ -168,7 +192,7 @@ public: rtOptions.flags |= RTAUDIO_NONINTERLEAVED; fAudioIsInterleaved = false; - if (fAudio.getCurrentApi() == RtAudio::LINUX_ALSA) + if (fAudio.getCurrentApi() == RtAudio::LINUX_ALSA && ! deviceSet) rtOptions.flags |= RTAUDIO_ALSA_USE_DEFAULT; } else diff --git a/source/backend/standalone/CarlaStandalone.cpp b/source/backend/standalone/CarlaStandalone.cpp index b3735aebc..c198481f2 100644 --- a/source/backend/standalone/CarlaStandalone.cpp +++ b/source/backend/standalone/CarlaStandalone.cpp @@ -712,14 +712,14 @@ void carla_set_engine_option(CarlaOptionsType option, int value, const char* val #ifdef WANT_RTAUDIO case CarlaBackend::OPTION_RTAUDIO_BUFFER_SIZE: if (value <= 0) - return carla_stderr2("carla_set_engine_option(OPTION_PREFERRED_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr); + return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_BUFFER_SIZE, %i, \"%s\") - invalid value", value, valueStr); standalone.options.rtaudioBufferSize = static_cast(value); break; case CarlaBackend::OPTION_RTAUDIO_SAMPLE_RATE: if (value <= 0) - return carla_stderr2("carla_set_engine_option(OPTION_PREFERRED_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr); + return carla_stderr2("carla_set_engine_option(OPTION_RTAUDIO_SAMPLE_RATE, %i, \"%s\") - invalid value", value, valueStr); standalone.options.rtaudioSampleRate = static_cast(value); break; diff --git a/source/carla.py b/source/carla.py index e0f12d5d1..9158a7027 100755 --- a/source/carla.py +++ b/source/carla.py @@ -1093,7 +1093,7 @@ class CarlaMainW(QMainWindow): Carla.host.set_engine_option(OPTION_RTAUDIO_BUFFER_SIZE, rtaudioBufferSize, "") Carla.host.set_engine_option(OPTION_RTAUDIO_SAMPLE_RATE, rtaudioSampleRate, "") - Carla.host.set_engine_option(OPTION_RTAUDIO_SAMPLE_RATE, 0, rtaudioDevice) + Carla.host.set_engine_option(OPTION_RTAUDIO_DEVICE, 0, rtaudioDevice) # --------------------------------------------- # Start