1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-07-31 05:02:24 -04:00

DATV modulator: fixed file source looping

This commit is contained in:
f4exb 2021-04-01 08:06:41 +02:00
parent 3d108d2b4a
commit cb657c72a1

View File

@ -316,7 +316,7 @@ void DATVModSource::modulateSample()
&& m_tsFileOK
&& !m_mpegTSStream.eof();
if ( tsFileReady
if (tsFileReady
&& (m_frameIdx/(m_frameCount+1.0f) < m_tsRatio) // Insert null packets if file rate is lower than DVB-S data rate
)
{
@ -325,7 +325,7 @@ void DATVModSource::modulateSample()
m_frameIdx++;
m_frameCount++;
}
else if ( (m_settings.m_source == DATVModSettings::SourceUDP)
else if ((m_settings.m_source == DATVModSettings::SourceUDP)
&& (m_udpBufferIdx < m_udpBufferCount)
)
{
@ -333,7 +333,7 @@ void DATVModSource::modulateSample()
memcpy(m_mpegTS, &m_udpBuffer[m_udpBufferIdx*sizeof(m_mpegTS)], sizeof(m_mpegTS));
m_udpBufferIdx++;
}
else if ( (m_settings.m_source == DATVModSettings::SourceUDP)
else if ((m_settings.m_source == DATVModSettings::SourceUDP)
&& ((m_udpSocket != nullptr) && m_udpSocket->hasPendingDatagrams())
)
{
@ -346,15 +346,22 @@ void DATVModSource::modulateSample()
if (size <= (int)sizeof(m_udpBuffer))
{
memcpy(m_mpegTS, data, sizeof(m_mpegTS));
if (size >= (int)sizeof(m_mpegTS))
if (size >= (int)sizeof(m_mpegTS)) {
memcpy(&m_udpBuffer[0], &data[sizeof(m_mpegTS)], size - sizeof(m_mpegTS));
}
m_udpBufferIdx = 0;
m_udpBufferCount = (size / sizeof(m_mpegTS)) - 1;
if (size % sizeof(m_mpegTS) != 0)
if (size % sizeof(m_mpegTS) != 0) {
qWarning() << "DATVModSource::modulateSample: UDP packet size (" << size << ") is not a multiple of " << sizeof(m_mpegTS);
}
}
else
{
qWarning() << "DATVModSource::modulateSample: UDP packet size (" << size << ") exceeds buffer size " << sizeof(m_udpBuffer) << ")";
}
m_udpByteCount += ba.size();
}
@ -367,8 +374,10 @@ void DATVModSource::modulateSample()
m_mpegTS[2] = 0xff;
m_mpegTS[3] = 0xff;
m_mpegTS[4] = 0x10;
if (tsFileReady)
if (tsFileReady) {
m_frameCount++;
}
//qDebug() << "null " << tsFileReady << " " << (m_frameIdx/(m_frameCount+1.0f)) << " " << m_tsRatio;
}
@ -385,11 +394,17 @@ void DATVModSource::modulateSample()
}
// Loop file if we reach the end
if ((m_frameIdx*DVBS::tsPacketLen >= m_mpegTSSize) && m_settings.m_tsFilePlayLoop)
if ((m_settings.m_source == DATVModSettings::SourceFile)
&& (m_frameIdx*DVBS::tsPacketLen >= m_mpegTSSize)
&& m_settings.m_tsFilePlayLoop
)
{
m_mpegTSStream.clear();
m_mpegTSStream.seekg(0, std::ios::beg);
m_frameIdx = 0;
m_frameCount = 0;
}
m_symbolIdx = 0;
}
@ -398,6 +413,7 @@ void DATVModSource::modulateSample()
// BPSK
i = m_pulseShapeI.filter(m_iqSymbols[m_symbolIdx*2+m_symbolSel] ? -1.0f : 1.0f);
q = 0.0f;
if (m_symbolSel == 1)
{
m_symbolIdx++;
@ -405,8 +421,10 @@ void DATVModSource::modulateSample()
m_symbolSel = 0;
}
else
{
m_symbolSel++;
}
}
else
{
// QPSK
@ -457,9 +475,12 @@ void DATVModSource::modulateSample()
i = m_pulseShapeI.filter(0.0f);
q = m_pulseShapeQ.filter(0.0f);
}
m_sampleIdx++;
if (m_sampleIdx >= m_samplesPerSymbol)
if (m_sampleIdx >= m_samplesPerSymbol) {
m_sampleIdx = 0;
}
m_modSample.real(i);
m_modSample.imag(q);