1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-18 07:35:47 -05:00

Deep redesign: fixed message dequeing so that non processed messages stay in queue

This commit is contained in:
f4exb 2015-08-30 02:19:59 +02:00
parent 6a050b2d35
commit 1fba7ba314
5 changed files with 52 additions and 16 deletions

View File

@ -608,13 +608,13 @@ void DSPEngine::handleSynchronousMessages()
void DSPEngine::handleInputMessages() void DSPEngine::handleInputMessages()
{ {
qDebug() << "DSPEngine::handleInputMessages";
Message* message; Message* message;
int queueSize = m_inputMessageQueue.size();
while ((message = m_inputMessageQueue.pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
qDebug("DSPEngine::handleInputMessages: message: %s", message->getIdentifier()); message = m_inputMessageQueue.pop();
qDebug() << "DSPEngine::handleInputMessages: " << message->getIdentifier();
if (DSPConfigureCorrection::match(*message)) if (DSPConfigureCorrection::match(*message))
{ {
@ -636,7 +636,11 @@ void DSPEngine::handleInputMessages()
m_imbalance = 65536; m_imbalance = 65536;
} }
delete message; delete message; // delete
}
else
{
m_inputMessageQueue.push(message); // repush
} }
} }
} }
@ -644,9 +648,11 @@ void DSPEngine::handleInputMessages()
void DSPEngine::handleSourceMessages() void DSPEngine::handleSourceMessages()
{ {
Message *message; Message *message;
int queueSize = m_inputMessageQueue.size();
while ((message = m_sampleSource->getOutputMessageQueue()->pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
message = m_inputMessageQueue.pop();
qDebug() << "DSPEngine::handleSourceMessages: " << message->getIdentifier(); qDebug() << "DSPEngine::handleSourceMessages: " << message->getIdentifier();
if (DSPSignalNotification::match(*message)) if (DSPSignalNotification::match(*message))
@ -683,6 +689,10 @@ void DSPEngine::handleSourceMessages()
delete message; delete message;
} }
else
{
m_inputMessageQueue.push(message);
}
} }
} }

View File

@ -13,13 +13,20 @@ SampleSink::~SampleSink()
void SampleSink::handleInputMessages() void SampleSink::handleInputMessages()
{ {
Message* message; Message* message;
int queueSize = m_inputMessageQueue.size();
while ((message = m_inputMessageQueue.pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
message = m_inputMessageQueue.pop();
if (handleMessage(*message)) if (handleMessage(*message))
{ {
delete message; delete message;
} }
else
{
m_inputMessageQueue.push(message);
}
} }
} }

View File

@ -29,12 +29,19 @@ SampleSource::~SampleSource()
void SampleSource::handleInputMessages() void SampleSource::handleInputMessages()
{ {
Message* message; Message* message;
int queueSize = m_inputMessageQueue.size();
while ((message = m_inputMessageQueue.pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
message = m_inputMessageQueue.pop();
if (handleMessage(*message)) if (handleMessage(*message))
{ {
delete message; delete message;
} }
else
{
m_inputMessageQueue.push(message);
}
} }
} }

View File

@ -332,12 +332,13 @@ void MainWindow::applySettings()
void MainWindow::handleDSPMessages() void MainWindow::handleDSPMessages()
{ {
Message* message; Message* message;
MessageQueue* messageQueue = m_dspEngine->getOutputMessageQueue();
int queueSize = messageQueue->size();
while ((message = m_dspEngine->getOutputMessageQueue()->pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
qDebug("Message: %s", message->getIdentifier()); message = messageQueue->pop();
qDebug() << "MainWindow::handleDSPMessages: " << message->getIdentifier();
std::cerr << "MainWindow::handleDSPMessages: " << message->getIdentifier() << std::endl;
if (DSPSignalNotification::match(*message)) if (DSPSignalNotification::match(*message))
{ {
@ -352,22 +353,31 @@ void MainWindow::handleDSPMessages()
delete message; delete message;
} }
else
{
messageQueue->push(message);
}
} }
} }
void MainWindow::handleMessages() void MainWindow::handleMessages()
{ {
Message* message; Message* message;
int queueSize = m_inputMessageQueue.size();
while ((message = m_inputMessageQueue.pop()) != 0) for (int i = 0; i < queueSize; i++)
{ {
qDebug("Message: %s", message->getIdentifier()); message = m_inputMessageQueue.pop();
std::cerr << "MainWindow::handleMessages: " << message->getIdentifier() << std::endl; qDebug() << "MainWindow::handleMessages: " << message->getIdentifier();
if (!m_pluginManager->handleMessage(*message)) if (m_pluginManager->handleMessage(*message))
{ {
delete message; delete message;
} }
else
{
m_inputMessageQueue.push(message);
}
} }
} }

View File

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include "util/messagequeue.h" #include "util/messagequeue.h"
#include "util/message.h" #include "util/message.h"
@ -31,6 +32,7 @@ MessageQueue::~MessageQueue()
while ((message = pop()) != 0) while ((message = pop()) != 0)
{ {
qDebug() << "MessageQueue::~MessageQueue: message: " << message->getIdentifier() << " was still in queue";
delete message; delete message;
} }
} }