1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00

FileSink plugin: fixed possible segfault

This commit is contained in:
f4exb 2017-01-03 23:22:06 +01:00
parent cb207e26c7
commit 9b72a3c064

View File

@ -17,6 +17,7 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <assert.h> #include <assert.h>
#include <algorithm>
#include <QDebug> #include <QDebug>
#include "dsp/samplesourcefifo.h" #include "dsp/samplesourcefifo.h"
@ -195,25 +196,27 @@ void FileSinkThread::tick()
} }
else else
{ {
int chunkSize = std::min((int) m_samplesChunkSize, m_samplerate);
switch (m_log2Interpolation) switch (m_log2Interpolation)
{ {
case 1: case 1:
m_interpolators.interpolate2_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate2_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
case 2: case 2:
m_interpolators.interpolate4_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate4_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
case 3: case 3:
m_interpolators.interpolate8_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate8_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
case 4: case 4:
m_interpolators.interpolate16_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate16_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
case 5: case 5:
m_interpolators.interpolate32_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate32_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
case 6: case 6:
m_interpolators.interpolate64_cen(&beginRead, m_buf, m_samplesChunkSize*(1<<m_log2Interpolation)*2); m_interpolators.interpolate64_cen(&beginRead, m_buf, chunkSize*(1<<m_log2Interpolation)*2);
break; break;
default: default:
break; break;