kopia lustrzana https://github.com/f4exb/sdrangel
Remote input: limit m_readLengthSamples range
rodzic
9a39d0d898
commit
f9107b78b2
|
@ -318,7 +318,7 @@ void RemoteInputBuffer::writeData(char *array)
|
||||||
if (sampleRate != 0)
|
if (sampleRate != 0)
|
||||||
{
|
{
|
||||||
m_bufferLenSec = (float) m_framesNbBytes / (float) (sampleRate * metaData->m_sampleBytes * 2);
|
m_bufferLenSec = (float) m_framesNbBytes / (float) (sampleRate * metaData->m_sampleBytes * 2);
|
||||||
m_balCorrLimit = sampleRate / 100; // +/- 10 ms correction max per read
|
m_balCorrLimit = sampleRate / 400; // +/- 5% correction max per read
|
||||||
m_readNbBytes = (sampleRate * metaData->m_sampleBytes * 2) / 20;
|
m_readNbBytes = (sampleRate * metaData->m_sampleBytes * 2) / 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,8 +256,13 @@ void RemoteInputUDPHandler::tick()
|
||||||
m_throttleToggle = !m_throttleToggle;
|
m_throttleToggle = !m_throttleToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_autoCorrBuffer) {
|
if (m_autoCorrBuffer)
|
||||||
|
{
|
||||||
m_readLengthSamples += m_remoteInputBuffer.getRWBalanceCorrection();
|
m_readLengthSamples += m_remoteInputBuffer.getRWBalanceCorrection();
|
||||||
|
// Eliminate negative or excessively high values
|
||||||
|
m_readLengthSamples = m_readLengthSamples < 0 ?
|
||||||
|
0 : m_readLengthSamples > (int) m_remoteInputBuffer.getCurrentMeta().m_sampleRate/5 ?
|
||||||
|
m_remoteInputBuffer.getCurrentMeta().m_sampleRate/5 : m_readLengthSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RemoteMetaDataFEC& metaData = m_remoteInputBuffer.getCurrentMeta();
|
const RemoteMetaDataFEC& metaData = m_remoteInputBuffer.getCurrentMeta();
|
||||||
|
@ -265,7 +270,7 @@ void RemoteInputUDPHandler::tick()
|
||||||
|
|
||||||
if ((metaData.m_sampleBits == 16) && (SDR_RX_SAMP_SZ == 24)) // 16 -> 24 bits
|
if ((metaData.m_sampleBits == 16) && (SDR_RX_SAMP_SZ == 24)) // 16 -> 24 bits
|
||||||
{
|
{
|
||||||
if (m_readLengthSamples > m_converterBufferNbSamples)
|
if (m_readLengthSamples > (int) m_converterBufferNbSamples)
|
||||||
{
|
{
|
||||||
if (m_converterBuffer) { delete[] m_converterBuffer; }
|
if (m_converterBuffer) { delete[] m_converterBuffer; }
|
||||||
m_converterBuffer = new int32_t[m_readLengthSamples*2];
|
m_converterBuffer = new int32_t[m_readLengthSamples*2];
|
||||||
|
@ -273,7 +278,7 @@ void RemoteInputUDPHandler::tick()
|
||||||
|
|
||||||
uint8_t *buf = m_remoteInputBuffer.readData(m_readLength);
|
uint8_t *buf = m_remoteInputBuffer.readData(m_readLength);
|
||||||
|
|
||||||
for (unsigned int is = 0; is < m_readLengthSamples; is++)
|
for (int is = 0; is < m_readLengthSamples; is++)
|
||||||
{
|
{
|
||||||
m_converterBuffer[2*is] = ((int16_t*)buf)[2*is]; // I
|
m_converterBuffer[2*is] = ((int16_t*)buf)[2*is]; // I
|
||||||
m_converterBuffer[2*is]<<=8;
|
m_converterBuffer[2*is]<<=8;
|
||||||
|
@ -285,7 +290,7 @@ void RemoteInputUDPHandler::tick()
|
||||||
}
|
}
|
||||||
else if ((metaData.m_sampleBits == 24) && (SDR_RX_SAMP_SZ == 16)) // 24 -> 16 bits
|
else if ((metaData.m_sampleBits == 24) && (SDR_RX_SAMP_SZ == 16)) // 24 -> 16 bits
|
||||||
{
|
{
|
||||||
if (m_readLengthSamples > m_converterBufferNbSamples)
|
if (m_readLengthSamples > (int) m_converterBufferNbSamples)
|
||||||
{
|
{
|
||||||
if (m_converterBuffer) { delete[] m_converterBuffer; }
|
if (m_converterBuffer) { delete[] m_converterBuffer; }
|
||||||
m_converterBuffer = new int32_t[m_readLengthSamples];
|
m_converterBuffer = new int32_t[m_readLengthSamples];
|
||||||
|
@ -293,7 +298,7 @@ void RemoteInputUDPHandler::tick()
|
||||||
|
|
||||||
uint8_t *buf = m_remoteInputBuffer.readData(m_readLength);
|
uint8_t *buf = m_remoteInputBuffer.readData(m_readLength);
|
||||||
|
|
||||||
for (unsigned int is = 0; is < m_readLengthSamples; is++)
|
for (int is = 0; is < m_readLengthSamples; is++)
|
||||||
{
|
{
|
||||||
m_converterBuffer[is] = ((int32_t *)buf)[2*is+1]>>8; // Q -> MSB
|
m_converterBuffer[is] = ((int32_t *)buf)[2*is+1]>>8; // Q -> MSB
|
||||||
m_converterBuffer[is] <<=16;
|
m_converterBuffer[is] <<=16;
|
||||||
|
|
|
@ -80,7 +80,7 @@ private:
|
||||||
|
|
||||||
QElapsedTimer m_elapsedTimer;
|
QElapsedTimer m_elapsedTimer;
|
||||||
int m_throttlems;
|
int m_throttlems;
|
||||||
uint32_t m_readLengthSamples;
|
int32_t m_readLengthSamples;
|
||||||
uint32_t m_readLength;
|
uint32_t m_readLength;
|
||||||
int32_t *m_converterBuffer;
|
int32_t *m_converterBuffer;
|
||||||
uint32_t m_converterBufferNbSamples;
|
uint32_t m_converterBufferNbSamples;
|
||||||
|
|
Ładowanie…
Reference in New Issue