1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-01 13:47:01 -04:00

Plugins device enumeration optimization

This commit is contained in:
f4exb
2019-09-17 00:34:11 +02:00
parent b7e5e2bbc5
commit e9bbf0b266
64 changed files with 1377 additions and 480 deletions
+44 -14
View File
@@ -14,7 +14,7 @@
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
QString("RTL-SDR Input"),
QString("4.11.6"),
QString("4.11.10"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@@ -39,33 +39,63 @@ void RTLSDRPlugin::initPlugin(PluginAPI* pluginAPI)
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources()
void RTLSDRPlugin::enumOriginDevices(QStringList& listedHwIds, OriginDevices& originDevices)
{
SamplingDevices result;
if (listedHwIds.contains(m_hardwareID)) { // check if it was done
return;
}
int count = rtlsdr_get_device_count();
char vendor[256];
char product[256];
char serial[256];
for(int i = 0; i < count; i++) {
for(int i = 0; i < count; i++)
{
vendor[0] = '\0';
product[0] = '\0';
serial[0] = '\0';
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
continue;
QString displayedName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
QString displayableName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
QString(serial),
i,
PluginInterface::SamplingDevice::PhysicalDevice,
PluginInterface::SamplingDevice::StreamSingleRx,
1,
0));
originDevices.append(OriginDevice(
displayableName,
m_hardwareID,
serial,
i, // sequence
1, // Nb Rx
0 // Nb Tx
));
}
listedHwIds.append(m_hardwareID);
}
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources(const OriginDevices& originDevices)
{
SamplingDevices result;
for (OriginDevices::const_iterator it = originDevices.begin(); it != originDevices.end(); ++it)
{
if (it->hardwareId == m_hardwareID)
{
result.append(SamplingDevice(
it->displayableName,
it->hardwareId,
m_deviceTypeID,
it->serial,
it->sequence,
PluginInterface::SamplingDevice::PhysicalDevice,
PluginInterface::SamplingDevice::StreamSingleRx,
1,
0
));
qDebug("RTLSDRPlugin::enumSampleSources: enumerated RTL-SDR device #%d", it->sequence);
}
}
return result;
}