mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 13:47:01 -04:00
Remote input buffer size rework: member name changes. Adjust sample sink fifo size from sample rate
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
RemoteInputBuffer::RemoteInputBuffer() :
|
||||
m_decoderIndexHead(nbDecoderSlots/2),
|
||||
m_decoderIndexHead(m_nbDecoderSlots/2),
|
||||
m_frameHead(0),
|
||||
m_curNbBlocks(0),
|
||||
m_minNbBlocks(256),
|
||||
@@ -46,7 +46,7 @@ RemoteInputBuffer::RemoteInputBuffer() :
|
||||
m_balCorrLimit(0)
|
||||
{
|
||||
m_currentMeta.init();
|
||||
m_framesNbBytes = nbDecoderSlots * sizeof(BufferFrame);
|
||||
m_framesNbBytes = m_nbDecoderSlots * sizeof(BufferFrame);
|
||||
m_wrDeltaEstimate = m_framesNbBytes / 2;
|
||||
m_tvOut_sec = 0;
|
||||
m_tvOut_usec = 0;
|
||||
@@ -61,8 +61,8 @@ RemoteInputBuffer::RemoteInputBuffer() :
|
||||
m_cm256_OK = true;
|
||||
}
|
||||
|
||||
std::fill(m_decoderSlots, m_decoderSlots + nbDecoderSlots, DecoderSlot());
|
||||
std::fill(m_frames, m_frames + nbDecoderSlots, BufferFrame());
|
||||
std::fill(m_decoderSlots, m_decoderSlots + m_nbDecoderSlots, DecoderSlot());
|
||||
std::fill(m_frames, m_frames + m_nbDecoderSlots, BufferFrame());
|
||||
}
|
||||
|
||||
RemoteInputBuffer::~RemoteInputBuffer()
|
||||
@@ -74,7 +74,7 @@ RemoteInputBuffer::~RemoteInputBuffer()
|
||||
|
||||
void RemoteInputBuffer::initDecodeAllSlots()
|
||||
{
|
||||
for (int i = 0; i < nbDecoderSlots; i++)
|
||||
for (int i = 0; i < m_nbDecoderSlots; i++)
|
||||
{
|
||||
m_decoderSlots[i].m_blockCount = 0;
|
||||
m_decoderSlots[i].m_originalCount = 0;
|
||||
@@ -124,7 +124,7 @@ void RemoteInputBuffer::initDecodeSlot(int slotIndex)
|
||||
|
||||
void RemoteInputBuffer::initReadIndex()
|
||||
{
|
||||
m_readIndex = ((m_decoderIndexHead + (nbDecoderSlots/2)) % nbDecoderSlots) * sizeof(BufferFrame);
|
||||
m_readIndex = ((m_decoderIndexHead + (m_nbDecoderSlots/2)) % m_nbDecoderSlots) * sizeof(BufferFrame);
|
||||
m_wrDeltaEstimate = m_framesNbBytes / 2;
|
||||
m_nbReads = 0;
|
||||
m_nbWrites = 0;
|
||||
@@ -134,20 +134,20 @@ void RemoteInputBuffer::rwCorrectionEstimate(int slotIndex)
|
||||
{
|
||||
if (m_nbReads >= 40) // check every ~1s as tick is ~50ms
|
||||
{
|
||||
int targetPivotSlot = (slotIndex + (nbDecoderSlots/2)) % nbDecoderSlots; // slot at half buffer opposite of current write slot
|
||||
int targetPivotSlot = (slotIndex + (m_nbDecoderSlots/2)) % m_nbDecoderSlots; // slot at half buffer opposite of current write slot
|
||||
int targetPivotIndex = targetPivotSlot * sizeof(BufferFrame); // buffer index corresponding to start of above slot
|
||||
int normalizedReadIndex = (m_readIndex < targetPivotIndex ? m_readIndex + nbDecoderSlots * sizeof(BufferFrame) : m_readIndex)
|
||||
int normalizedReadIndex = (m_readIndex < targetPivotIndex ? m_readIndex + m_nbDecoderSlots * sizeof(BufferFrame) : m_readIndex)
|
||||
- (targetPivotSlot * sizeof(BufferFrame)); // normalize read index so it is positive and zero at start of pivot slot
|
||||
int dBytes;
|
||||
int rwDelta = (m_nbReads * m_readNbBytes) - (m_nbWrites * sizeof(BufferFrame));
|
||||
|
||||
if (normalizedReadIndex < (nbDecoderSlots/ 2) * (int) sizeof(BufferFrame)) // read leads
|
||||
if (normalizedReadIndex < (m_nbDecoderSlots/ 2) * (int) sizeof(BufferFrame)) // read leads
|
||||
{
|
||||
dBytes = - normalizedReadIndex - rwDelta;
|
||||
}
|
||||
else // read lags
|
||||
{
|
||||
int bufSize = (nbDecoderSlots * sizeof(BufferFrame));
|
||||
int bufSize = (m_nbDecoderSlots * sizeof(BufferFrame));
|
||||
dBytes = bufSize - normalizedReadIndex - rwDelta;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ void RemoteInputBuffer::checkSlotData(int slotIndex)
|
||||
{
|
||||
int pseudoWriteIndex = slotIndex * sizeof(BufferFrame);
|
||||
m_wrDeltaEstimate = pseudoWriteIndex - m_readIndex;
|
||||
int rwDelayBytes = (m_wrDeltaEstimate > 0 ? m_wrDeltaEstimate : sizeof(BufferFrame) * nbDecoderSlots + m_wrDeltaEstimate);
|
||||
int rwDelayBytes = (m_wrDeltaEstimate > 0 ? m_wrDeltaEstimate : sizeof(BufferFrame) * m_nbDecoderSlots + m_wrDeltaEstimate);
|
||||
int sampleRate = m_currentMeta.m_sampleRate;
|
||||
|
||||
if (sampleRate > 0)
|
||||
@@ -195,7 +195,7 @@ void RemoteInputBuffer::writeData(char *array)
|
||||
{
|
||||
RemoteSuperBlock *superBlock = (RemoteSuperBlock *) array;
|
||||
int frameIndex = superBlock->m_header.m_frameIndex;
|
||||
int decoderIndex = frameIndex % nbDecoderSlots;
|
||||
int decoderIndex = frameIndex % m_nbDecoderSlots;
|
||||
|
||||
// frame break
|
||||
|
||||
@@ -338,8 +338,8 @@ uint8_t *RemoteInputBuffer::readData(int32_t length)
|
||||
m_nbReads++;
|
||||
|
||||
// SEGFAULT FIX: arbitratily truncate so that it does not exceed buffer length
|
||||
if (length > framesSize) {
|
||||
length = framesSize;
|
||||
if (length > m_framesSize) {
|
||||
length = m_framesSize;
|
||||
}
|
||||
|
||||
if (m_readIndex + length < m_framesNbBytes) // ends before buffer bound
|
||||
|
||||
Reference in New Issue
Block a user