From d47679c5cfa9d7f4efd5a1339952ebb4462c5166 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 20 Jul 2020 13:45:05 +0200 Subject: [PATCH] Fixedd buffer overflow in audio IO --- src/io/audio.h | 7 +------ src/io/soapy.h | 4 ++++ src/signal_path.cpp | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/io/audio.h b/src/io/audio.h index 070cba7b..a6dec185 100644 --- a/src/io/audio.h +++ b/src/io/audio.h @@ -39,7 +39,7 @@ namespace io { outputParams.hostApiSpecificStreamInfo = NULL; outputParams.device = Pa_GetDefaultOutputDevice(); outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultLowOutputLatency; - PaError err = Pa_OpenStream(&stream, NULL, &outputParams, 48000.0f, 64, paClipOff, _callback, this); + PaError err = Pa_OpenStream(&stream, NULL, &outputParams, 48000.0f, _bufferSize, paClipOff, _callback, this); printf("%s\n", Pa_GetErrorText(err)); err = Pa_StartStream(stream); printf("%s\n", Pa_GetErrorText(err)); @@ -67,13 +67,8 @@ namespace io { float vol = powf(_this->_volume, 2); for (int i = 0; i < frameCount; i++) { - - outbuf[(i * 2) + 0] = _this->buffer[i] * vol; outbuf[(i * 2) + 1] = _this->buffer[i] * vol; - - - } return 0; } diff --git a/src/io/soapy.h b/src/io/soapy.h index 2a91a014..1f1af4bb 100644 --- a/src/io/soapy.h +++ b/src/io/soapy.h @@ -43,6 +43,10 @@ namespace io { devList = SoapySDR::Device::enumerate(); txtDevList = ""; + if (devList.size() == 0) { + txtDevList += '\0'; + return; + } for (int i = 0; i < devList.size(); i++) { txtDevList += devList[i]["label"]; txtDevList += '\0'; diff --git a/src/signal_path.cpp b/src/signal_path.cpp index a8033d2e..0ef19947 100644 --- a/src/signal_path.cpp +++ b/src/signal_path.cpp @@ -29,7 +29,7 @@ void SignalPath::init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream ssbDemod.init(mainVFO.output, 6000, 3000, 22); audioResamp.init(&demod.output, 200000, 48000, 800); - audio.init(&audioResamp.output, 16); + audio.init(&audioResamp.output, 64); } void SignalPath::setSampleRate(float sampleRate) {