mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-18 07:35:47 -05:00
Multi device support: SDRdaemon and FileSource plugins: allow one instance per device set with only the one coresponding to the device set accessible for selection
This commit is contained in:
parent
a32175eccb
commit
3e1236f898
@ -194,6 +194,7 @@ void MainWindow::addDevice()
|
|||||||
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
|
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
|
||||||
|
|
||||||
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
|
||||||
|
m_pluginManager->duplicateLocalSampleSourceDevices(dspDeviceEngineUID);
|
||||||
m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), dspDeviceEngineUID);
|
m_pluginManager->fillSampleSourceSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), dspDeviceEngineUID);
|
||||||
|
|
||||||
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSource_confirmClicked(bool)));
|
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSource_confirmClicked(bool)));
|
||||||
@ -658,21 +659,21 @@ void MainWindow::on_action_DV_Serial_triggered(bool checked)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
//void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
||||||
{
|
//{
|
||||||
// Do it in the currently selected source tab
|
// // Do it in the currently selected source tab
|
||||||
int currentSourceTabIndex = ui->tabInputsSelect->currentIndex();
|
// int currentSourceTabIndex = ui->tabInputsSelect->currentIndex();
|
||||||
|
//
|
||||||
if (currentSourceTabIndex >= 0)
|
// if (currentSourceTabIndex >= 0)
|
||||||
{
|
// {
|
||||||
qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
|
// qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
|
||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
// DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||||
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
// deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
// m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
||||||
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
// m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
||||||
deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset());
|
// deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void MainWindow::on_sampleSource_confirmClicked(bool checked)
|
void MainWindow::on_sampleSource_confirmClicked(bool checked)
|
||||||
{
|
{
|
||||||
@ -684,7 +685,10 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked)
|
|||||||
qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
|
qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
|
||||||
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
|
||||||
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
deviceUI->m_deviceAPI->saveSourceSettings(m_settings.getWorkingPreset());
|
||||||
m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex();
|
||||||
|
void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value<void *>();
|
||||||
|
m_pluginManager->selectSampleSourceByDevice(devicePtr, deviceUI->m_deviceAPI);
|
||||||
|
// m_pluginManager->selectSampleSourceByIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex(), deviceUI->m_deviceAPI);
|
||||||
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
|
||||||
deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset());
|
deviceUI->m_deviceAPI->loadSourceSettings(m_settings.getWorkingPreset());
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ private slots:
|
|||||||
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column);
|
void on_presetTree_itemActivated(QTreeWidgetItem *item, int column);
|
||||||
void on_action_Audio_triggered();
|
void on_action_Audio_triggered();
|
||||||
void on_action_DV_Serial_triggered(bool checked);
|
void on_action_DV_Serial_triggered(bool checked);
|
||||||
void on_sampleSource_currentIndexChanged(int index);
|
// void on_sampleSource_currentIndexChanged(int index);
|
||||||
void on_sampleSource_confirmClicked(bool checked);
|
void on_sampleSource_confirmClicked(bool checked);
|
||||||
void on_action_Loaded_Plugins_triggered();
|
void on_action_Loaded_Plugins_triggered();
|
||||||
void on_action_About_triggered();
|
void on_action_About_triggered();
|
||||||
|
@ -84,21 +84,81 @@ void PluginManager::updateSampleSourceDevices()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PluginManager::duplicateLocalSampleSourceDevices(uint deviceUID)
|
||||||
|
{
|
||||||
|
if (deviceUID == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleSourceDevice *sdrDaemonSSD0 = 0;
|
||||||
|
SampleSourceDevice *fileSourceSSD0 = 0;
|
||||||
|
bool duplicateSDRDaemon = true;
|
||||||
|
bool duplicateFileSource = true;
|
||||||
|
|
||||||
|
for(int i = 0; i < m_sampleSourceDevices.count(); ++i)
|
||||||
|
{
|
||||||
|
if (m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonDeviceTypeID) // SDRdaemon
|
||||||
|
{
|
||||||
|
if (m_sampleSourceDevices[i].m_sourceSequence == 0) { // reference to device 0
|
||||||
|
sdrDaemonSSD0 = &m_sampleSourceDevices[i];
|
||||||
|
}
|
||||||
|
else if (m_sampleSourceDevices[i].m_sourceSequence == deviceUID) { // already there
|
||||||
|
duplicateSDRDaemon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_sampleSourceDevices[i].m_sourceId == m_fileSourceDeviceTypeID) // File Source
|
||||||
|
{
|
||||||
|
if (m_sampleSourceDevices[i].m_sourceSequence == 0) { // reference to device 0
|
||||||
|
fileSourceSSD0 = &m_sampleSourceDevices[i];
|
||||||
|
}
|
||||||
|
else if (m_sampleSourceDevices[i].m_sourceSequence == deviceUID) { // already there
|
||||||
|
duplicateFileSource = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sdrDaemonSSD0 && duplicateSDRDaemon) // append item for a new instance
|
||||||
|
{
|
||||||
|
m_sampleSourceDevices.append(
|
||||||
|
SampleSourceDevice(
|
||||||
|
sdrDaemonSSD0->m_plugin,
|
||||||
|
QString("SDRdaemon[%1]").arg(deviceUID),
|
||||||
|
sdrDaemonSSD0->m_sourceId,
|
||||||
|
sdrDaemonSSD0->m_sourceSerial,
|
||||||
|
deviceUID
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fileSourceSSD0 && duplicateFileSource) // append item for a new instance
|
||||||
|
{
|
||||||
|
m_sampleSourceDevices.append(
|
||||||
|
SampleSourceDevice(
|
||||||
|
fileSourceSSD0->m_plugin,
|
||||||
|
QString("FileSource[%1]").arg(deviceUID),
|
||||||
|
fileSourceSSD0->m_sourceId,
|
||||||
|
fileSourceSSD0->m_sourceSerial,
|
||||||
|
deviceUID
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PluginManager::fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID)
|
void PluginManager::fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID)
|
||||||
{
|
{
|
||||||
comboBox->clear();
|
comboBox->clear();
|
||||||
|
|
||||||
for(int i = 0; i < m_sampleSourceDevices.count(); i++)
|
for(int i = 0; i < m_sampleSourceDevices.count(); i++)
|
||||||
{
|
{
|
||||||
// There can be only one instance of file source and SDRdaemon plugins
|
// For "local" devices show only ones that concern this device set
|
||||||
if ((m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonDeviceTypeID) || (m_sampleSourceDevices[i].m_sourceId == m_fileSourceDeviceTypeID))
|
if ((m_sampleSourceDevices[i].m_sourceId == m_sdrDaemonDeviceTypeID) || (m_sampleSourceDevices[i].m_sourceId == m_fileSourceDeviceTypeID))
|
||||||
{
|
{
|
||||||
if (deviceUID != 0) {
|
if (deviceUID != m_sampleSourceDevices[i].m_sourceSequence) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
comboBox->addItem(m_sampleSourceDevices[i].m_displayName, i);
|
comboBox->addItem(m_sampleSourceDevices[i].m_displayName, qVariantFromValue((void *) &m_sampleSourceDevices[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,6 +326,29 @@ int PluginManager::selectSampleSourceBySerialOrSequence(const QString& sourceId,
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PluginManager::selectSampleSourceByDevice(void *devicePtr, DeviceAPI *deviceAPI)
|
||||||
|
{
|
||||||
|
SampleSourceDevice *sampleSourceDevice = (SampleSourceDevice *) devicePtr;
|
||||||
|
|
||||||
|
qDebug() << "PluginManager::selectSampleSourceByDevice: "
|
||||||
|
<< " id: " << sampleSourceDevice->m_sourceId.toStdString().c_str()
|
||||||
|
<< " ser: " << sampleSourceDevice->m_sourceSerial.toStdString().c_str()
|
||||||
|
<< " seq: " << sampleSourceDevice->m_sourceSequence;
|
||||||
|
|
||||||
|
deviceAPI->stopAcquisition();
|
||||||
|
deviceAPI->setSampleSourcePluginGUI(0); // this effectively destroys the previous GUI if it exists
|
||||||
|
|
||||||
|
QWidget *gui;
|
||||||
|
PluginGUI *pluginGUI = sampleSourceDevice->m_plugin->createSampleSourcePluginGUI(sampleSourceDevice->m_sourceId, &gui, deviceAPI);
|
||||||
|
|
||||||
|
// m_sampleSourcePluginGUI = pluginGUI;
|
||||||
|
deviceAPI->setSampleSourceSequence(sampleSourceDevice->m_sourceSequence);
|
||||||
|
deviceAPI->setSampleSourceId(sampleSourceDevice->m_sourceId);
|
||||||
|
deviceAPI->setSampleSourceSerial(sampleSourceDevice->m_sourceSerial);
|
||||||
|
deviceAPI->setSampleSourcePluginGUI(pluginGUI);
|
||||||
|
deviceAPI->setInputGUI(gui, sampleSourceDevice->m_displayName);
|
||||||
|
}
|
||||||
|
|
||||||
void PluginManager::loadPlugins(const QDir& dir)
|
void PluginManager::loadPlugins(const QDir& dir)
|
||||||
{
|
{
|
||||||
QDir pluginsDir(dir);
|
QDir pluginsDir(dir);
|
||||||
|
@ -48,11 +48,13 @@ public:
|
|||||||
PluginAPI::ChannelRegistrations *getChannelRegistrations() { return &m_channelRegistrations; }
|
PluginAPI::ChannelRegistrations *getChannelRegistrations() { return &m_channelRegistrations; }
|
||||||
|
|
||||||
void updateSampleSourceDevices();
|
void updateSampleSourceDevices();
|
||||||
|
void duplicateLocalSampleSourceDevices(uint deviceUID);
|
||||||
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
|
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
|
||||||
|
|
||||||
int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI);
|
int selectSampleSourceByIndex(int index, DeviceAPI *deviceAPI);
|
||||||
int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI);
|
int selectFirstSampleSource(const QString& sourceId, DeviceAPI *deviceAPI);
|
||||||
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI);
|
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, int sourceSequence, DeviceAPI *deviceAPI);
|
||||||
|
void selectSampleSourceByDevice(void *devicePtr, DeviceAPI *deviceAPI);
|
||||||
|
|
||||||
void populateChannelComboBox(QComboBox *channels);
|
void populateChannelComboBox(QComboBox *channels);
|
||||||
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
|
void createChannelInstance(int channelPluginIndex, DeviceAPI *deviceAPI);
|
||||||
@ -99,8 +101,9 @@ private:
|
|||||||
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
SampleSourceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
||||||
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
SampleSourceDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
||||||
|
|
||||||
static const QString m_sdrDaemonDeviceTypeID;
|
// "Local" sample source device IDs
|
||||||
static const QString m_fileSourceDeviceTypeID;
|
static const QString m_sdrDaemonDeviceTypeID; //!< SDRdaemon source plugin ID
|
||||||
|
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
|
||||||
|
|
||||||
// QString m_sampleSourceId;
|
// QString m_sampleSourceId;
|
||||||
// QString m_sampleSourceSerial;
|
// QString m_sampleSourceSerial;
|
||||||
|
Loading…
Reference in New Issue
Block a user