mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-10-01 01:06:35 -04:00
BladeRF2 input: do not re-create the thread if there are no more channels active
This commit is contained in:
parent
d5a33b7448
commit
7078cd868e
@ -385,7 +385,7 @@ void BladeRF2Input::stop()
|
|||||||
//
|
//
|
||||||
// If the thread is currently managing many channels (MI mode) and we are removing the last channel. The transition
|
// If the thread is currently managing many channels (MI mode) and we are removing the last channel. The transition
|
||||||
// from MI to SI or reduction of MI size is handled by stopping the thread, deleting it and creating a new one
|
// from MI to SI or reduction of MI size is handled by stopping the thread, deleting it and creating a new one
|
||||||
// with one channel less. Then the channel is closed (disabled).
|
// with one channel less if (and only if) there is still a channel active.
|
||||||
//
|
//
|
||||||
// If the thread is currently managing many channels (MI mode) but the channel being stopped is not the last
|
// If the thread is currently managing many channels (MI mode) but the channel being stopped is not the last
|
||||||
// channel then the FIFO reference is simply removed from the thread so that it will not stream into this FIFO
|
// channel then the FIFO reference is simply removed from the thread so that it will not stream into this FIFO
|
||||||
@ -430,15 +430,21 @@ void BladeRF2Input::stop()
|
|||||||
SampleSinkFifo **fifos = new SampleSinkFifo*[nbOriginalChannels-1];
|
SampleSinkFifo **fifos = new SampleSinkFifo*[nbOriginalChannels-1];
|
||||||
unsigned int *log2Decims = new unsigned int[nbOriginalChannels-1];
|
unsigned int *log2Decims = new unsigned int[nbOriginalChannels-1];
|
||||||
int *fcPoss = new int[nbOriginalChannels-1];
|
int *fcPoss = new int[nbOriginalChannels-1];
|
||||||
|
bool stillActiveFIFO = false;
|
||||||
|
|
||||||
for (int i = 0; i < nbOriginalChannels-1; i++) // save original FIFO references
|
for (int i = 0; i < nbOriginalChannels-1; i++) // save original FIFO references
|
||||||
{
|
{
|
||||||
fifos[i] = bladerf2InputThread->getFifo(i);
|
fifos[i] = bladerf2InputThread->getFifo(i);
|
||||||
|
stillActiveFIFO = stillActiveFIFO || (bladerf2InputThread->getFifo(i) != 0);
|
||||||
log2Decims[i] = bladerf2InputThread->getLog2Decimation(i);
|
log2Decims[i] = bladerf2InputThread->getLog2Decimation(i);
|
||||||
fcPoss[i] = bladerf2InputThread->getFcPos(i);
|
fcPoss[i] = bladerf2InputThread->getFcPos(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete bladerf2InputThread;
|
delete bladerf2InputThread;
|
||||||
|
m_thread = 0;
|
||||||
|
|
||||||
|
if (stillActiveFIFO)
|
||||||
|
{
|
||||||
bladerf2InputThread = new BladeRF2InputThread(m_deviceShared.m_dev->getDev(), nbOriginalChannels-1);
|
bladerf2InputThread = new BladeRF2InputThread(m_deviceShared.m_dev->getDev(), nbOriginalChannels-1);
|
||||||
m_thread = bladerf2InputThread; // take ownership
|
m_thread = bladerf2InputThread; // take ownership
|
||||||
|
|
||||||
@ -448,6 +454,11 @@ void BladeRF2Input::stop()
|
|||||||
bladerf2InputThread->setLog2Decimation(i, log2Decims[i]);
|
bladerf2InputThread->setLog2Decimation(i, log2Decims[i]);
|
||||||
bladerf2InputThread->setFcPos(i, fcPoss[i]);
|
bladerf2InputThread->setFcPos(i, fcPoss[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("BladeRF2Input::stop: do not re-create thread as there are no more FIFOs active");
|
||||||
|
}
|
||||||
|
|
||||||
// remove old thread address from buddies (reset in all buddies)
|
// remove old thread address from buddies (reset in all buddies)
|
||||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||||
@ -458,8 +469,11 @@ void BladeRF2Input::stop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_deviceShared.m_dev->closeRx(requestedChannel); // close the last channel
|
m_deviceShared.m_dev->closeRx(requestedChannel); // close the last channel
|
||||||
|
|
||||||
|
if (stillActiveFIFO) {
|
||||||
bladerf2InputThread->startWork();
|
bladerf2InputThread->startWork();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else // remove channel from existing thread
|
else // remove channel from existing thread
|
||||||
{
|
{
|
||||||
qDebug("BladeRF2Input::stop: MI mode. Not changing MI configuration. Just remove FIFO reference");
|
qDebug("BladeRF2Input::stop: MI mode. Not changing MI configuration. Just remove FIFO reference");
|
||||||
|
@ -22,6 +22,7 @@ BladeRF2InputThread::BladeRF2InputThread(struct bladerf* dev, unsigned int nbRxC
|
|||||||
m_dev(dev),
|
m_dev(dev),
|
||||||
m_nbChannels(nbRxChannels)
|
m_nbChannels(nbRxChannels)
|
||||||
{
|
{
|
||||||
|
qDebug("BladeRF2InputThread::BladeRF2InputThread");
|
||||||
m_channels = new Channel[nbRxChannels];
|
m_channels = new Channel[nbRxChannels];
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nbRxChannels; i++) {
|
for (unsigned int i = 0; i < nbRxChannels; i++) {
|
||||||
@ -86,6 +87,7 @@ void BladeRF2InputThread::run()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug("BladeRF2InputThread::run: start running loop");
|
||||||
while (m_running)
|
while (m_running)
|
||||||
{
|
{
|
||||||
res = bladerf_sync_rx(m_dev, m_buf, DeviceBladeRF2::blockSize, NULL, 10000);
|
res = bladerf_sync_rx(m_dev, m_buf, DeviceBladeRF2::blockSize, NULL, 10000);
|
||||||
@ -102,6 +104,7 @@ void BladeRF2InputThread::run()
|
|||||||
callbackSI(m_buf, 2*DeviceBladeRF2::blockSize);
|
callbackSI(m_buf, 2*DeviceBladeRF2::blockSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
qDebug("BladeRF2InputThread::run: stop running loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user