Fixedd buffer overflow in audio IO

This commit is contained in:
Ryzerth 2020-07-20 13:45:05 +02:00
parent 379d6f8101
commit d47679c5cf
3 changed files with 6 additions and 7 deletions

View File

@ -39,7 +39,7 @@ namespace io {
outputParams.hostApiSpecificStreamInfo = NULL; outputParams.hostApiSpecificStreamInfo = NULL;
outputParams.device = Pa_GetDefaultOutputDevice(); outputParams.device = Pa_GetDefaultOutputDevice();
outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultLowOutputLatency; 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)); printf("%s\n", Pa_GetErrorText(err));
err = Pa_StartStream(stream); err = Pa_StartStream(stream);
printf("%s\n", Pa_GetErrorText(err)); printf("%s\n", Pa_GetErrorText(err));
@ -67,13 +67,8 @@ namespace io {
float vol = powf(_this->_volume, 2); float vol = powf(_this->_volume, 2);
for (int i = 0; i < frameCount; i++) { for (int i = 0; i < frameCount; i++) {
outbuf[(i * 2) + 0] = _this->buffer[i] * vol; outbuf[(i * 2) + 0] = _this->buffer[i] * vol;
outbuf[(i * 2) + 1] = _this->buffer[i] * vol; outbuf[(i * 2) + 1] = _this->buffer[i] * vol;
} }
return 0; return 0;
} }

View File

@ -43,6 +43,10 @@ namespace io {
devList = SoapySDR::Device::enumerate(); devList = SoapySDR::Device::enumerate();
txtDevList = ""; txtDevList = "";
if (devList.size() == 0) {
txtDevList += '\0';
return;
}
for (int i = 0; i < devList.size(); i++) { for (int i = 0; i < devList.size(); i++) {
txtDevList += devList[i]["label"]; txtDevList += devList[i]["label"];
txtDevList += '\0'; txtDevList += '\0';

View File

@ -29,7 +29,7 @@ void SignalPath::init(uint64_t sampleRate, int fftRate, int fftSize, dsp::stream
ssbDemod.init(mainVFO.output, 6000, 3000, 22); ssbDemod.init(mainVFO.output, 6000, 3000, 22);
audioResamp.init(&demod.output, 200000, 48000, 800); audioResamp.init(&demod.output, 200000, 48000, 800);
audio.init(&audioResamp.output, 16); audio.init(&audioResamp.output, 64);
} }
void SignalPath::setSampleRate(float sampleRate) { void SignalPath::setSampleRate(float sampleRate) {