From c7aeef5747fba1ff958cb5e6d7fd76b6d9719a46 Mon Sep 17 00:00:00 2001 From: Mike Dickey Date: Fri, 12 Jan 2024 13:18:58 -0800 Subject: [PATCH] Fixing simplex edge case when input device supports lower buffer sizes Fix compiler warning for Settings constructor Version bump and changelog update for 2.2.0-beta1 --- docs/changelog.yml | 6 ++++-- src/RtAudioInterface.cpp | 41 +++++++++++++++++++++++++++++++++++----- src/Settings.h | 4 +++- src/jacktrip_globals.h | 2 +- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/docs/changelog.yml b/docs/changelog.yml index 877d02238..50c0ac607 100644 --- a/docs/changelog.yml +++ b/docs/changelog.yml @@ -1,6 +1,8 @@ -- Version: "2.1.1" - Date: 2023-12-xx +- Version: "2.2.0-beta1" + Date: 2023-01-15 Description: + - (updated) Improved support for different input & output devices + - (updated) Various latency improvements for packet loss concealment - (updated) VS Mode error message for disconnected audio interfaces - (fixed) VS Mode refused to connect to studios not 48khz - Version: "2.1.0" diff --git a/src/RtAudioInterface.cpp b/src/RtAudioInterface.cpp index 2f5f5de95..41268f8d6 100644 --- a/src/RtAudioInterface.cpp +++ b/src/RtAudioInterface.cpp @@ -346,9 +346,23 @@ void RtAudioInterface::setup(bool verbose) mRtAudioInput->openStream( nullptr, &in_params, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, &RtAudioInterface::wrapperRtAudioCallback, this, &options, errorFunc); + const unsigned int inputBufferFrames = bufferFrames; mRtAudioOutput->openStream( &out_params, nullptr, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, &RtAudioInterface::wrapperRtAudioCallback, this, &options, errorFunc); + if (inputBufferFrames != bufferFrames) { + // output device doesn't support the same buffer size + // try to reopen the input device with new size + const unsigned int outputBufferFrames = bufferFrames; + mRtAudioInput->closeStream(); + mRtAudioInput->openStream( + nullptr, &in_params, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, + &RtAudioInterface::wrapperRtAudioCallback, this, &options, errorFunc); + if (outputBufferFrames != bufferFrames) { + // just give up if this still doesn't work + errorText = "The two devices selected are incompatible"; + } + } } } catch (RtAudioError& e) { errorText = e.getMessage(); @@ -374,11 +388,28 @@ void RtAudioInterface::setup(bool verbose) nullptr, &in_params, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, &RtAudioInterface::wrapperRtAudioCallback, this, &options)) { errorText = mRtAudioInput->getErrorText(); - } else if (RTAUDIO_NO_ERROR - != mRtAudioOutput->openStream( - &out_params, nullptr, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, - &RtAudioInterface::wrapperRtAudioCallback, this, &options)) { - errorText = mRtAudioOutput->getErrorText(); + } else { + const unsigned int inputBufferFrames = bufferFrames; + if (RTAUDIO_NO_ERROR + != mRtAudioOutput->openStream( + &out_params, nullptr, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, + &RtAudioInterface::wrapperRtAudioCallback, this, &options)) { + errorText = mRtAudioOutput->getErrorText(); + } else if (inputBufferFrames != bufferFrames) { + // output device doesn't support the same buffer size + // try to reopen the input device with new size + const unsigned int outputBufferFrames = bufferFrames; + mRtAudioInput->closeStream(); + if (RTAUDIO_NO_ERROR + != mRtAudioInput->openStream( + nullptr, &in_params, RTAUDIO_FLOAT32, sampleRate, &bufferFrames, + &RtAudioInterface::wrapperRtAudioCallback, this, &options)) { + errorText = mRtAudioInput->getErrorText(); + } else if (outputBufferFrames != bufferFrames) { + // just give up if this still doesn't work + errorText = "The two devices selected are incompatible"; + } + } } } #endif diff --git a/src/Settings.h b/src/Settings.h index a189a8e6f..99900cf98 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -62,7 +62,9 @@ class Settings : public QObject public: Settings(bool guiEnabled = false, QObject* parent = nullptr) : QObject(parent) -#ifndef NO_GUI +#ifdef NO_GUI + , mGuiEnabled(false) +#else , mGuiEnabled(guiEnabled) #endif , mAudioTester(new AudioTester) diff --git a/src/jacktrip_globals.h b/src/jacktrip_globals.h index 0e6473291..017277496 100644 --- a/src/jacktrip_globals.h +++ b/src/jacktrip_globals.h @@ -40,7 +40,7 @@ #include "AudioInterface.h" -constexpr const char* const gVersion = "2.1.1"; ///< JackTrip version +constexpr const char* const gVersion = "2.2.0-beta1"; ///< JackTrip version //******************************************************************************* /// \name Default Values