From 5b3db72e942c9d950f6e878e0b760f4a1937dfe1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?IOhannes=20m=20zm=C3=B6lnig=20=28Debian/GNU=29?= Date: Fri, 17 Dec 2021 10:40:12 +0100 Subject: [PATCH] Patch to allow compilation with RtAudio-5.2 --- debian/patches/RtAudio52.patch | 168 +++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 169 insertions(+) create mode 100644 debian/patches/RtAudio52.patch diff --git a/debian/patches/RtAudio52.patch b/debian/patches/RtAudio52.patch new file mode 100644 index 0000000..215b85e --- /dev/null +++ b/debian/patches/RtAudio52.patch @@ -0,0 +1,168 @@ +From: =?utf-8?q?IOhannes_m_zm=C3=B6lnig?= +Date: Fri, 17 Dec 2021 10:35:28 +0100 +Subject: RtAudio-5.2.0 support + +Upstream vendored in a RtAudio-6 git snapshot and called it 5.2.0 +--- + src/core/kernelAudio.cpp | 107 ++++++++++++++++++++++++++--------------------- + 1 file changed, 60 insertions(+), 47 deletions(-) + +diff --git a/src/core/kernelAudio.cpp b/src/core/kernelAudio.cpp +index 4a52d88..df7ae5b 100644 +--- a/src/core/kernelAudio.cpp ++++ b/src/core/kernelAudio.cpp +@@ -94,10 +94,6 @@ int KernelAudio::openDevice(const Conf::Data& conf) + return 0; + } + +- m_rtAudio->setErrorCallback([](RtAudioErrorType type, const std::string& msg) { +- u::log::print("[KA] RtAudio error %d: %s\n", type, msg.c_str()); +- }); +- + u::log::print("[KA] Opening device out=%d, in=%d, samplerate=%d\n", + conf.soundDeviceOut, conf.soundDeviceIn, conf.samplerate); + +@@ -158,33 +154,33 @@ int KernelAudio::openDevice(const Conf::Data& conf) + + #endif + +- m_callbackInfo = { +- /* kernelAudio = */ this, +- /* ready = */ true, +- /* withJack = */ getAPI() == G_SYS_API_JACK, +- /* outBuf = */ nullptr, // filled later on in audio callback +- /* inBuf = */ nullptr, // filled later on in audio callback +- /* bufferSize = */ 0, // filled later on in audio callback +- /* channelsOutCount = */ m_channelsOutCount, +- /* channelsInCount = */ m_channelsInCount}; +- +- RtAudioErrorType res = m_rtAudio->openStream( +- &outParams, // output params +- conf.soundDeviceIn != -1 ? &inParams : nullptr, // input params if inDevice is selected +- RTAUDIO_FLOAT32, // audio format +- m_realSampleRate, // sample rate +- &m_realBufferSize, // buffer size in byte +- &audioCallback, // audio callback +- &m_callbackInfo, // user data passed to callback +- &options); +- +- if (res == RtAudioErrorType::RTAUDIO_NO_ERROR) ++ try + { ++ m_callbackInfo = { ++ /* kernelAudio = */ this, ++ /* ready = */ true, ++ /* withJack = */ getAPI() == G_SYS_API_JACK, ++ /* outBuf = */ nullptr, // filled later on in audio callback ++ /* inBuf = */ nullptr, // filled later on in audio callback ++ /* bufferSize = */ 0, // filled later on in audio callback ++ /* channelsOutCount = */ m_channelsOutCount, ++ /* channelsInCount = */ m_channelsInCount}; ++ ++ m_rtAudio->openStream( ++ &outParams, // output params ++ conf.soundDeviceIn != -1 ? &inParams : nullptr, // input params if inDevice is selected ++ RTAUDIO_FLOAT32, // audio format ++ m_realSampleRate, // sample rate ++ &m_realBufferSize, // buffer size in byte ++ &audioCallback, // audio callback ++ &m_callbackInfo, // user data passed to callback ++ &options); + m_ready = true; + return 1; + } +- else ++ catch (RtAudioError& e) + { ++ u::log::print("[KA] RtAudio init error: %s\n", e.getMessage()); + closeDevice(); + return 0; + } +@@ -194,24 +190,33 @@ int KernelAudio::openDevice(const Conf::Data& conf) + + int KernelAudio::startStream() + { +- if (m_rtAudio->startStream() == RtAudioErrorType::RTAUDIO_NO_ERROR) ++ try + { +- u::log::print("[KA] Start stream - latency = %lu\n", m_rtAudio->getStreamLatency()); ++ m_rtAudio->startStream(); ++ u::log::print("[KA] latency = %lu\n", m_rtAudio->getStreamLatency()); + return 1; + } +- return 0; ++ catch (RtAudioError& e) ++ { ++ u::log::print("[KA] Start stream error: %s\n", e.getMessage()); ++ return 0; ++ } + } + + /* -------------------------------------------------------------------------- */ + + int KernelAudio::stopStream() + { +- if (m_rtAudio->stopStream() == RtAudioErrorType::RTAUDIO_NO_ERROR) ++ try + { +- u::log::print("[KA] Stop stream\n"); ++ m_rtAudio->stopStream(); + return 1; + } +- return 0; ++ catch (RtAudioError& /*e*/) ++ { ++ u::log::print("[KA] Stop stream error\n"); ++ return 0; ++ } + } + + /* -------------------------------------------------------------------------- */ +@@ -328,24 +333,32 @@ void KernelAudio::logCompiledAPIs() + + m::KernelAudio::Device KernelAudio::fetchDevice(size_t deviceIndex) const + { +- RtAudio::DeviceInfo info = m_rtAudio->getDeviceInfo(deviceIndex); ++ try ++ { ++ RtAudio::DeviceInfo info = m_rtAudio->getDeviceInfo(deviceIndex); + +- if (!info.probed) ++ if (!info.probed) ++ { ++ u::log::print("[KA] Can't probe device %d\n", deviceIndex); ++ return {deviceIndex}; ++ } ++ ++ return { ++ deviceIndex, ++ true, ++ info.name, ++ static_cast(info.outputChannels), ++ static_cast(info.inputChannels), ++ static_cast(info.duplexChannels), ++ info.isDefaultOutput, ++ info.isDefaultInput, ++ u::vector::cast(info.sampleRates)}; ++ } ++ catch (RtAudioError& e) + { +- u::log::print("[KA] Can't probe device %d\n", deviceIndex); +- return {deviceIndex}; ++ u::log::print("[KA] Error fetching device %d: %s\n", deviceIndex, e.getMessage()); ++ return {0}; + } +- +- return { +- deviceIndex, +- true, +- info.name, +- static_cast(info.outputChannels), +- static_cast(info.inputChannels), +- static_cast(info.duplexChannels), +- info.isDefaultOutput, +- info.isDefaultInput, +- u::vector::cast(info.sampleRates)}; + } + + /* -------------------------------------------------------------------------- */ diff --git a/debian/patches/series b/debian/patches/series index d26eddc..f31c8b4 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,3 +1,4 @@ 02-geompp.patch 03-system-rtaudio.patch 04-system-json.patch +RtAudio52.patch -- 2.30.2