mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-08-13 11:12:25 -04:00
AMBE processing: handle the case where the decoder is too slow
This commit is contained in:
parent
0af803551a
commit
d1bd6ee7eb
@ -108,6 +108,17 @@ void AMBEWorker::handleInputMessages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
audioFifo = decodeMsg->getAudioFifo();
|
audioFifo = decodeMsg->getAudioFifo();
|
||||||
|
|
||||||
|
if (audioFifo && (m_audioBufferFill >= m_audioBuffer.size() - 960))
|
||||||
|
{
|
||||||
|
uint res = audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
|
||||||
|
|
||||||
|
if (res != m_audioBufferFill) {
|
||||||
|
qDebug("AMBEWorker::handleInputMessages: %u/%u audio samples written", res, m_audioBufferFill);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_audioBufferFill = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -116,16 +127,24 @@ void AMBEWorker::handleInputMessages()
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete message;
|
delete message;
|
||||||
|
|
||||||
|
if (m_inputMessageQueue.size() > 100)
|
||||||
|
{
|
||||||
|
qDebug("AMBEWorker::handleInputMessages: MsgMbeDecode: too many messages in queue. Flushing...");
|
||||||
|
m_inputMessageQueue.clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audioFifo)
|
if (audioFifo)
|
||||||
{
|
{
|
||||||
uint res = audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
|
uint res = audioFifo->write((const quint8*)&m_audioBuffer[0], m_audioBufferFill);
|
||||||
|
|
||||||
if (res != m_audioBufferFill)
|
if (res != m_audioBufferFill) {
|
||||||
{
|
|
||||||
qDebug("AMBEWorker::handleInputMessages: %u/%u audio samples written", res, m_audioBufferFill);
|
qDebug("AMBEWorker::handleInputMessages: %u/%u audio samples written", res, m_audioBufferFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_audioBufferFill = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_timestamp = QDateTime::currentDateTime();
|
m_timestamp = QDateTime::currentDateTime();
|
||||||
@ -172,18 +191,17 @@ void AMBEWorker::upsample(int upsampling, short *in, int nbSamplesIn, unsigned c
|
|||||||
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? m_compressor.compress(upsample) : 0;
|
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? m_compressor.compress(upsample) : 0;
|
||||||
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? m_compressor.compress(upsample) : 0;
|
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? m_compressor.compress(upsample) : 0;
|
||||||
|
|
||||||
if (m_audioBufferFill < m_audioBuffer.size() - 1)
|
if (m_audioBufferFill < m_audioBuffer.size() - 1) {
|
||||||
{
|
|
||||||
++m_audioBufferFill;
|
++m_audioBufferFill;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug("AMBEWorker::upsample6: audio buffer is full check its size");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_upsamplerLastValue = cur;
|
m_upsamplerLastValue = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_audioBufferFill >= m_audioBuffer.size() - 1) {
|
||||||
|
qDebug("AMBEWorker::upsample(%d): audio buffer is full check its size", upsampling);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMBEWorker::noUpsample(short *in, int nbSamplesIn, unsigned char channels)
|
void AMBEWorker::noUpsample(short *in, int nbSamplesIn, unsigned char channels)
|
||||||
@ -194,14 +212,13 @@ void AMBEWorker::noUpsample(short *in, int nbSamplesIn, unsigned char channels)
|
|||||||
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? cur*m_upsamplingFactors[0] : 0;
|
m_audioBuffer[m_audioBufferFill].l = channels & 1 ? cur*m_upsamplingFactors[0] : 0;
|
||||||
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? cur*m_upsamplingFactors[0] : 0;
|
m_audioBuffer[m_audioBufferFill].r = (channels>>1) & 1 ? cur*m_upsamplingFactors[0] : 0;
|
||||||
|
|
||||||
if (m_audioBufferFill < m_audioBuffer.size() - 1)
|
if (m_audioBufferFill < m_audioBuffer.size() - 1) {
|
||||||
{
|
|
||||||
++m_audioBufferFill;
|
++m_audioBufferFill;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug("AMBEWorker::noUpsample: audio buffer is full check its size");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_audioBufferFill >= m_audioBuffer.size() - 1) {
|
||||||
|
qDebug("AMBEWorker::noUpsample: audio buffer is full check its size");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,5 +78,8 @@ int MessageQueue::size()
|
|||||||
void MessageQueue::clear()
|
void MessageQueue::clear()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&m_lock);
|
QMutexLocker locker(&m_lock);
|
||||||
m_queue.clear();
|
|
||||||
|
while (!m_queue.isEmpty()) {
|
||||||
|
delete m_queue.takeFirst();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user