mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-04 22:27:53 -04:00
BladerRF2 input support. Transfer thread ownership before closing the source if it has the allocated thread
This commit is contained in:
parent
5f2a4e8c83
commit
fcaf22418d
@ -204,6 +204,10 @@ void BladeRF2Input::closeDevice()
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_thread) { // stills own the thread => transfer to a buddy
|
||||||
|
moveThreadToBuddy();
|
||||||
|
}
|
||||||
|
|
||||||
m_deviceShared.m_channel = -1;
|
m_deviceShared.m_channel = -1;
|
||||||
m_deviceShared.m_source = 0;
|
m_deviceShared.m_source = 0;
|
||||||
|
|
||||||
@ -254,6 +258,23 @@ BladeRF2InputThread *BladeRF2Input::findThread()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BladeRF2Input::moveThreadToBuddy()
|
||||||
|
{
|
||||||
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
|
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||||
|
|
||||||
|
for (; it != sourceBuddies.end(); ++it)
|
||||||
|
{
|
||||||
|
BladeRF2Input *buddySource = ((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source;
|
||||||
|
|
||||||
|
if (buddySource)
|
||||||
|
{
|
||||||
|
buddySource->setThread(m_thread);
|
||||||
|
m_thread = 0; // zero for others
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool BladeRF2Input::start()
|
bool BladeRF2Input::start()
|
||||||
{
|
{
|
||||||
if (!m_deviceShared.m_dev)
|
if (!m_deviceShared.m_dev)
|
||||||
@ -299,7 +320,7 @@ bool BladeRF2Input::start()
|
|||||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||||
|
|
||||||
for (; it != sourceBuddies.end(); ++it) {
|
for (; it != sourceBuddies.end(); ++it) {
|
||||||
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->resetThread();
|
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
needsStart = true;
|
needsStart = true;
|
||||||
@ -354,7 +375,7 @@ void BladeRF2Input::stop()
|
|||||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||||
|
|
||||||
for (; it != sourceBuddies.end(); ++it) {
|
for (; it != sourceBuddies.end(); ++it) {
|
||||||
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->resetThread();
|
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_deviceShared.m_channel == nbOriginalChannels - 1) // remove last MI channel => reduce by deleting and re-creating the thread
|
else if (m_deviceShared.m_channel == nbOriginalChannels - 1) // remove last MI channel => reduce by deleting and re-creating the thread
|
||||||
@ -387,7 +408,7 @@ void BladeRF2Input::stop()
|
|||||||
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
std::vector<DeviceSourceAPI*>::const_iterator it = sourceBuddies.begin();
|
||||||
|
|
||||||
for (; it != sourceBuddies.end(); ++it) {
|
for (; it != sourceBuddies.end(); ++it) {
|
||||||
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->resetThread();
|
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bladerf2InputThread->startWork();
|
bladerf2InputThread->startWork();
|
||||||
|
@ -101,7 +101,7 @@ public:
|
|||||||
virtual bool start();
|
virtual bool start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
BladeRF2InputThread *getThread() { return m_thread; }
|
BladeRF2InputThread *getThread() { return m_thread; }
|
||||||
void resetThread() { m_thread = 0; }
|
void setThread(BladeRF2InputThread *thread) { m_thread = thread; }
|
||||||
|
|
||||||
virtual QByteArray serialize() const;
|
virtual QByteArray serialize() const;
|
||||||
virtual bool deserialize(const QByteArray& data);
|
virtual bool deserialize(const QByteArray& data);
|
||||||
@ -155,6 +155,7 @@ private:
|
|||||||
bool openDevice();
|
bool openDevice();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
BladeRF2InputThread *findThread();
|
BladeRF2InputThread *findThread();
|
||||||
|
void moveThreadToBuddy();
|
||||||
bool applySettings(const BladeRF2InputSettings& settings, bool force = false);
|
bool applySettings(const BladeRF2InputSettings& settings, bool force = false);
|
||||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const BladeRF2InputSettings& settings);
|
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const BladeRF2InputSettings& settings);
|
||||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user