mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-01 21:54:55 -04:00
XTRX output
This commit is contained in:
@@ -305,6 +305,7 @@ bool XTRXInput::start()
|
||||
delete xtrxInputThread;
|
||||
xtrxInputThread = new XTRXInputThread(m_deviceShared.m_dev->getDevice(), 2); // MI mode (2 channels)
|
||||
m_XTRXInputThread = xtrxInputThread; // take ownership
|
||||
m_deviceShared.m_thread = xtrxInputThread;
|
||||
|
||||
for (int i = 0; i < 2; i++) // restore original FIFO references
|
||||
{
|
||||
@@ -316,8 +317,10 @@ bool XTRXInput::start()
|
||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||
|
||||
for (; it != sourceBuddies.end(); ++it) {
|
||||
for (; it != sourceBuddies.end(); ++it)
|
||||
{
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0;
|
||||
}
|
||||
|
||||
// was used as temporary storage:
|
||||
@@ -336,6 +339,7 @@ bool XTRXInput::start()
|
||||
qDebug("XTRXInput::start: allocate thread and take ownership");
|
||||
xtrxInputThread = new XTRXInputThread(m_deviceShared.m_dev->getDevice(), 1, requestedChannel);
|
||||
m_XTRXInputThread = xtrxInputThread; // take ownership
|
||||
m_deviceShared.m_thread = xtrxInputThread;
|
||||
needsStart = true;
|
||||
}
|
||||
|
||||
@@ -387,13 +391,16 @@ void XTRXInput::stop()
|
||||
xtrxInputThread->stopWork();
|
||||
delete xtrxInputThread;
|
||||
m_XTRXInputThread = 0;
|
||||
m_deviceShared.m_thread = 0;
|
||||
|
||||
// remove old thread address from buddies (reset in all buddies)
|
||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||
|
||||
for (; it != sourceBuddies.end(); ++it) {
|
||||
for (; it != sourceBuddies.end(); ++it)
|
||||
{
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0;
|
||||
}
|
||||
}
|
||||
else if (nbOriginalChannels == 2) // Reduce from MI to SI by deleting and re-creating the thread
|
||||
@@ -401,10 +408,10 @@ void XTRXInput::stop()
|
||||
qDebug("XTRXInput::stop: MI mode. Reduce by deleting and re-creating the thread");
|
||||
xtrxInputThread->stopWork();
|
||||
delete xtrxInputThread;
|
||||
m_XTRXInputThread = 0;
|
||||
|
||||
xtrxInputThread = new XTRXInputThread(m_deviceShared.m_dev->getDevice(), 1, requestedChannel);
|
||||
m_XTRXInputThread = xtrxInputThread; // take ownership
|
||||
m_deviceShared.m_thread = xtrxInputThread;
|
||||
|
||||
xtrxInputThread->setFifo(requestedChannel, &m_sampleFifo);
|
||||
xtrxInputThread->setLog2Decimation(requestedChannel, m_settings.m_log2SoftDecim);
|
||||
|
||||
@@ -412,8 +419,10 @@ void XTRXInput::stop()
|
||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||
|
||||
for (; it != sourceBuddies.end(); ++it) {
|
||||
for (; it != sourceBuddies.end(); ++it)
|
||||
{
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||
((DeviceXTRXShared*) (*it)->getBuddySharedPtr())->m_thread = 0;
|
||||
}
|
||||
|
||||
xtrxInputThread->startWork();
|
||||
@@ -425,58 +434,42 @@ void XTRXInput::stop()
|
||||
|
||||
void XTRXInput::suspendTxThread()
|
||||
{
|
||||
// TODO: activate when output is managed
|
||||
// XTRXOutputThread *xtrxOutputThread = 0;
|
||||
//
|
||||
// // find a buddy that has allocated the thread
|
||||
// const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
// std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin()
|
||||
//
|
||||
// for (; itSink != sinkBuddies.end(); ++itSink)
|
||||
// {
|
||||
// XTRXOutput *buddySink = ((DeviceXTRXShared*) (*itSink)->getBuddySharedPtr())->m_sink;
|
||||
//
|
||||
// if (buddySink)
|
||||
// {
|
||||
// xtrxOutputThread = buddySink->getThread();
|
||||
//
|
||||
// if (xtrxOutputThread) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (xtrxOutputThread) {
|
||||
// xtrxOutputThread->stopWork();
|
||||
// }
|
||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||
|
||||
qDebug("XTRXInput::suspendTxThread (%lu)", sinkBuddies.size());
|
||||
|
||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||
{
|
||||
DeviceXTRXShared *buddySharedPtr = (DeviceXTRXShared *) (*itSink)->getBuddySharedPtr();
|
||||
|
||||
if ((buddySharedPtr->m_thread) && buddySharedPtr->m_thread->isRunning())
|
||||
{
|
||||
buddySharedPtr->m_thread->stopWork();
|
||||
buddySharedPtr->m_threadWasRunning = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
buddySharedPtr->m_threadWasRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XTRXInput::resumeTxThread()
|
||||
{
|
||||
// TODO: activate when output is managed
|
||||
// XTRXOutputThread *xtrxOutputThread = 0;
|
||||
//
|
||||
// // find a buddy that has allocated the thread
|
||||
// const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
// std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin()
|
||||
//
|
||||
// for (; itSink != sinkBuddies.end(); ++itSink)
|
||||
// {
|
||||
// XTRXOutput *buddySink = ((DeviceXTRXShared*) (*itSink)->getBuddySharedPtr())->m_sink;
|
||||
//
|
||||
// if (buddySink)
|
||||
// {
|
||||
// xtrxOutputThread = buddySink->getThread();
|
||||
//
|
||||
// if (xtrxOutputThread) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (xtrxOutputThread) {
|
||||
// xtrxOutputThread->startWork();
|
||||
// }
|
||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||
|
||||
qDebug("XTRXInput::resumeTxThread (%lu)", sinkBuddies.size());
|
||||
|
||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||
{
|
||||
DeviceXTRXShared *buddySharedPtr = (DeviceXTRXShared *) (*itSink)->getBuddySharedPtr();
|
||||
|
||||
if (buddySharedPtr->m_threadWasRunning) {
|
||||
buddySharedPtr->m_thread->startWork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray XTRXInput::serialize() const
|
||||
@@ -616,9 +609,12 @@ bool XTRXInput::handleMessage(const Message& message)
|
||||
m_settings.m_centerFrequency + ncoShift);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
|
||||
DeviceXTRXShared::MsgReportBuddyChange *reportToGUI = DeviceXTRXShared::MsgReportBuddyChange::create(
|
||||
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
DeviceXTRXShared::MsgReportBuddyChange *reportToGUI = DeviceXTRXShared::MsgReportBuddyChange::create(
|
||||
m_settings.m_devSampleRate, m_settings.m_log2HardDecim, m_settings.m_centerFrequency, true);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -629,9 +625,12 @@ bool XTRXInput::handleMessage(const Message& message)
|
||||
m_settings.m_extClock = report.getExtClock();
|
||||
m_settings.m_extClockFreq = report.getExtClockFeq();
|
||||
|
||||
DeviceXTRXShared::MsgReportClockSourceChange *reportToGUI = DeviceXTRXShared::MsgReportClockSourceChange::create(
|
||||
m_settings.m_extClock, m_settings.m_extClockFreq);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
DeviceXTRXShared::MsgReportClockSourceChange *reportToGUI = DeviceXTRXShared::MsgReportClockSourceChange::create(
|
||||
m_settings.m_extClock, m_settings.m_extClockFreq);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user