From 99e0545e72fe4e160961ccb2951cdf9fbcf2cf6c Mon Sep 17 00:00:00 2001 From: Sanny Sanoff Date: Sun, 10 Mar 2024 20:18:37 +0100 Subject: [PATCH] worked on rtaudio secondary streams, fixed it. fixed also cleanup. --- CMakeLists.txt | 5 +--- core/src/dsp/block.h | 16 +++++----- decoder_modules/radio/src/radio_module.h | 8 ++--- .../discord-rpc/CMakeLists.txt | 2 +- sink_modules/audio_sink/src/main.cpp | 30 ++++++++++++------- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1be1d0111..acd212ae0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,10 +247,7 @@ add_subdirectory("sink_modules/android_audio_sink") endif (OPT_BUILD_ANDROID_AUDIO_SINK) if (OPT_BUILD_AUDIO_SINK) -if(APPLE) -else() - add_subdirectory("sink_modules/audio_sink") -endif () +add_subdirectory("sink_modules/audio_sink") endif (OPT_BUILD_AUDIO_SINK) if (OPT_BUILD_PORTAUDIO_SINK) diff --git a/core/src/dsp/block.h b/core/src/dsp/block.h index 7dafef838..81b774899 100644 --- a/core/src/dsp/block.h +++ b/core/src/dsp/block.h @@ -108,14 +108,14 @@ namespace dsp { out->clearWriteStop(); } } - - void acquire() { - ctrlMtx.lock(); - } - - void release() { - ctrlMtx.unlock(); - } + // + // void acquire() { + // ctrlMtx.lock(); + // } + // + // void release() { + // ctrlMtx.unlock(); + // } void registerInput(untyped_stream* inStream) { if (inputs.size() == 1 && inStream) { diff --git a/decoder_modules/radio/src/radio_module.h b/decoder_modules/radio/src/radio_module.h index 9ef1c66bf..c7c7deda7 100644 --- a/decoder_modules/radio/src/radio_module.h +++ b/decoder_modules/radio/src/radio_module.h @@ -210,9 +210,9 @@ class RadioModule : public ModuleManager::Instance { return; auto index = pos - _this->streamNames.begin(); auto stream = _this->streams[index]; - if (_this->enabled) { - stream->stop(); - } + // if (_this->enabled) { + // stream->stop(); + // } _this->afsplitter.unbindStream(stream->getInput()); // stream->init(&srChangeHandler, audioSampleRate); _this->streams.erase(_this->streams.begin()+index); @@ -224,7 +224,7 @@ class RadioModule : public ModuleManager::Instance { if (iter != streamz.end()) { streamz.erase(iter); } - core::configManager.release(); + core::configManager.release(true); } diff --git a/misc_modules/discord_integration/discord-rpc/CMakeLists.txt b/misc_modules/discord_integration/discord-rpc/CMakeLists.txt index 1dc1c9139..e89084977 100644 --- a/misc_modules/discord_integration/discord-rpc/CMakeLists.txt +++ b/misc_modules/discord_integration/discord-rpc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.2.0) +cmake_minimum_required (VERSION 3.15) project (DiscordRPC) include(GNUInstallDirs) diff --git a/sink_modules/audio_sink/src/main.cpp b/sink_modules/audio_sink/src/main.cpp index 9fd5482fb..2aa34f7c7 100644 --- a/sink_modules/audio_sink/src/main.cpp +++ b/sink_modules/audio_sink/src/main.cpp @@ -26,10 +26,12 @@ SDRPP_MOD_INFO{ ConfigManager config; +#if RTAUDIO_VERSION_MAJOR >= 6 static bool rtaudioCallbackError; -static void rtaudioCallback(RtAudioError::Type type, const std::string& errorText) { +static void rtaudioCallback(int type, const std::string& errorText) { rtaudioCallbackError = true; } +#endif class AudioSink : SinkManager::Sink { @@ -285,8 +287,11 @@ class AudioSink : SinkManager::Sink { audio.startStream(); stereoPacker.start(); } - catch (const RtAudioError& e) { - flog::error("Could not open audio device: {}", e.getMessage()); + catch (const std::runtime_error& e) { + flog::error("Could not open audio device: {}", e.what()); + return false; + } catch (...) { + flog::error("Could not open audio device. generic exception"); return false; } @@ -307,8 +312,11 @@ class AudioSink : SinkManager::Sink { audio2.startStream(); flog::info("RtAudio2 input stream open"); } - catch (RtAudioError& e) { - flog::error("Could not open INPUT audio device: {}", e.getMessage()); + catch (const std::runtime_error& e) { + flog::error("Could not open INPUT audio device: {}", e.what()); + return false; + } catch (...) { + flog::error("Could not open audio device. generic exception"); return false; } } @@ -317,8 +325,6 @@ class AudioSink : SinkManager::Sink { sigpath::sinkManager.defaultInputAudio.start(); // microphone.setBufferSize(sampleRate / 60); // flog::info("_this->microphone.writeBuf={} after setsize", (void*)microphone.writeBuf); - } else { - sigpath::sinkManager.defaultInputAudio.setInput(nullptr); } return true; } @@ -328,10 +334,12 @@ class AudioSink : SinkManager::Sink { void doStop() { flog::info("Stopping RtAudio stream: {}", _streamName); - - sigpath::sinkManager.defaultInputAudio.stop(); - flog::info("sigpath::sinkManager.defaultInputAudio.setInput(nullptr)"); - sigpath::sinkManager.defaultInputAudio.setInput(nullptr); + bool isPrimary = SinkManager::getSecondaryStreamIndex(_streamName).second == 0; + if (isPrimary && micInput) { + sigpath::sinkManager.defaultInputAudio.stop(); + flog::info("sigpath::sinkManager.defaultInputAudio.setInput(nullptr)"); + sigpath::sinkManager.defaultInputAudio.setInput(nullptr); + } // s2m.stop(); // monoPacker.stop();