1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-19 14:54:54 -04:00

LocalSink: refactored getLocalDevice method

This commit is contained in:
f4exb 2024-05-12 23:24:26 +02:00
parent a85731d3f7
commit 69be0d28bf

View File

@ -258,51 +258,52 @@ bool LocalSink::deserialize(const QByteArray& data)
} }
} }
DeviceSampleSource *LocalSink::getLocalDevice(int index) DeviceSampleSource *LocalSink::getLocalDevice(int deviceSetIndex)
{ {
if (index < 0) { if (deviceSetIndex < 0) {
return nullptr; return nullptr;
} }
DSPEngine *dspEngine = DSPEngine::instance(); MainCore *mainCore = MainCore::instance();
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
if (index < (int) dspEngine->getDeviceSourceEnginesNumber()) if (deviceSetIndex < (int) deviceSets.size())
{
DeviceSet *sourceDeviceSet = deviceSets[deviceSetIndex];
DSPDeviceSourceEngine *deviceSourceEngine = sourceDeviceSet->m_deviceSourceEngine;
if (deviceSourceEngine)
{ {
DSPDeviceSourceEngine *deviceSourceEngine = dspEngine->getDeviceSourceEngineByIndex(index);
DeviceSampleSource *deviceSource = deviceSourceEngine->getSource(); DeviceSampleSource *deviceSource = deviceSourceEngine->getSource();
if (deviceSource->getDeviceDescription() == "LocalInput") if (deviceSource->getDeviceDescription() == "LocalInput") {
{
if (!getDeviceAPI()) {
qDebug("LocalSink::getLocalDevice: the parent device is unset");
} else if (getDeviceAPI()->getDeviceUID() == deviceSourceEngine->getUID()) {
qDebug("LocalSink::getLocalDevice: source device at index %u is the parent device", index);
} else {
return deviceSource; return deviceSource;
} else {
qDebug("LocalSink::getLocalDevice: source device at index %u is not a Local Input source", deviceSetIndex);
} }
} }
else else
{ {
qDebug("LocalSink::getLocalDevice: source device at index %u is not a Local Input source", index); qDebug("LocalSink::getLocalDevice: device set at index %d has not a source device", deviceSetIndex);
} }
} }
else else
{ {
qDebug("LocalSink::getLocalDevice: non existent source device index: %u", index); qDebug("LocalSink::getLocalDevice: non existent device set at index: %d", deviceSetIndex);
} }
return nullptr; return nullptr;
} }
void LocalSink::propagateSampleRateAndFrequency(int index, uint32_t log2Decim) void LocalSink::propagateSampleRateAndFrequency(int deviceSetIndex, uint32_t log2Decim)
{ {
qDebug() << "LocalSink::propagateSampleRateAndFrequency:" qDebug() << "LocalSink::propagateSampleRateAndFrequency:"
<< " index: " << index << " index: " << deviceSetIndex
<< " baseband_freq: " << m_basebandSampleRate << " baseband_freq: " << m_basebandSampleRate
<< " log2Decim: " << log2Decim << " log2Decim: " << log2Decim
<< " frequency: " << m_centerFrequency + m_frequencyOffset; << " frequency: " << m_centerFrequency + m_frequencyOffset;
DeviceSampleSource *deviceSource = getLocalDevice(index); DeviceSampleSource *deviceSource = getLocalDevice(deviceSetIndex);
if (deviceSource) if (deviceSource)
{ {
@ -311,7 +312,7 @@ void LocalSink::propagateSampleRateAndFrequency(int index, uint32_t log2Decim)
} }
else else
{ {
qDebug("LocalSink::propagateSampleRateAndFrequency: no suitable device at index %u", index); qDebug("LocalSink::propagateSampleRateAndFrequency: no suitable device at index %u", deviceSetIndex);
} }
} }