From ec6ed0b95ccd28ada441a9d760adc0b603f40dbc Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 8 Aug 2018 17:18:27 +0200 Subject: [PATCH] RtAudio: Allow custom numBuffers with minimize-latency flag set --- source/modules/rtaudio.diff | 12 +++++++++++- source/modules/rtaudio/RtAudio.cpp | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/modules/rtaudio.diff b/source/modules/rtaudio.diff index 9b395b4cf..54fd0e209 100644 --- a/source/modules/rtaudio.diff +++ b/source/modules/rtaudio.diff @@ -1,5 +1,5 @@ diff --git a/RtAudio.cpp b/RtAudio.cpp -index 2ac2179..2a4c918 100644 +index 2ac2179..18b238d 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -76,7 +76,7 @@ const unsigned int RtApi::SAMPLE_RATES[] = { @@ -510,6 +510,16 @@ index 2ac2179..2a4c918 100644 #include static AsioDrivers drivers; +@@ -5487,8 +5485,8 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned + // two. This is a judgement call and a value of two is probably too + // low for capture, but it should work for playback. + int nBuffers = 0; +- if ( options ) nBuffers = options->numberOfBuffers; + if ( options && options->flags & RTAUDIO_MINIMIZE_LATENCY ) nBuffers = 2; ++ if ( options && options->numberOfBuffers > 0 ) nBuffers = options->numberOfBuffers; + if ( nBuffers < 2 ) nBuffers = 3; + + // Check the lower range of the user-specified buffer size and set @@ -8012,12 +8010,14 @@ static void *alsaCallbackHandler( void *ptr ) } diff --git a/source/modules/rtaudio/RtAudio.cpp b/source/modules/rtaudio/RtAudio.cpp index 2a4c91832..18b238d37 100644 --- a/source/modules/rtaudio/RtAudio.cpp +++ b/source/modules/rtaudio/RtAudio.cpp @@ -5485,8 +5485,8 @@ bool RtApiDs :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned // two. This is a judgement call and a value of two is probably too // low for capture, but it should work for playback. int nBuffers = 0; - if ( options ) nBuffers = options->numberOfBuffers; if ( options && options->flags & RTAUDIO_MINIMIZE_LATENCY ) nBuffers = 2; + if ( options && options->numberOfBuffers > 0 ) nBuffers = options->numberOfBuffers; if ( nBuffers < 2 ) nBuffers = 3; // Check the lower range of the user-specified buffer size and set