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

UDP sink plugin: block output at zero if read and write frame pointers are equal

This commit is contained in:
f4exb 2017-08-25 01:16:58 +02:00
parent 1b2df9f0fc
commit 7277757b7c

View File

@ -136,14 +136,29 @@ void UDPSinkUDPHandler::moveData(char *blk)
void UDPSinkUDPHandler::readSample(FixReal &t)
{
memcpy(&t, &m_udpBuf[m_readFrameIndex][m_readIndex], sizeof(FixReal));
advanceReadPointer((int) sizeof(FixReal));
if (m_readFrameIndex == m_writeIndex) // block until more writes
{
t = 0;
}
else
{
memcpy(&t, &m_udpBuf[m_readFrameIndex][m_readIndex], sizeof(FixReal));
advanceReadPointer((int) sizeof(FixReal));
}
}
void UDPSinkUDPHandler::readSample(Sample &s)
{
memcpy(&s, &m_udpBuf[m_readFrameIndex][m_readIndex], sizeof(Sample));
advanceReadPointer((int) sizeof(Sample));
if (m_readFrameIndex == m_writeIndex) // block until more writes
{
s.m_real = 0;
s.m_imag = 0;
}
else
{
memcpy(&s, &m_udpBuf[m_readFrameIndex][m_readIndex], sizeof(Sample));
advanceReadPointer((int) sizeof(Sample));
}
}
void UDPSinkUDPHandler::advanceReadPointer(int nbBytes)