Skip to content

Commit

Permalink
worked on rtaudio secondary streams, fixed it. fixed also cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sannysanoff committed Mar 10, 2024
1 parent 67b4ff7 commit 99e0545
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 28 deletions.
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions core/src/dsp/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions decoder_modules/radio/src/radio_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -224,7 +224,7 @@ class RadioModule : public ModuleManager::Instance {
if (iter != streamz.end()) {
streamz.erase(iter);
}
core::configManager.release();
core::configManager.release(true);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.2.0)
cmake_minimum_required (VERSION 3.15)
project (DiscordRPC)

include(GNUInstallDirs)
Expand Down
30 changes: 19 additions & 11 deletions sink_modules/audio_sink/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down

0 comments on commit 99e0545

Please sign in to comment.