SDRPlay: use device sequence number from device API

This commit is contained in:
f4exb 2017-04-14 02:49:41 +02:00
parent d001099f7e
commit 3fa28dab30
2 changed files with 19 additions and 5 deletions

View File

@ -37,7 +37,8 @@ SDRPlayInput::SDRPlayInput(DeviceSourceAPI *deviceAPI) :
m_dev(0), m_dev(0),
m_sdrPlayThread(0), m_sdrPlayThread(0),
m_deviceDescription("SDRPlay"), m_deviceDescription("SDRPlay"),
m_devNumber(0) m_devNumber(0),
m_running(false)
{ {
} }
@ -46,11 +47,21 @@ SDRPlayInput::~SDRPlayInput()
stop(); stop();
} }
bool openDevice()
{
}
void closeDevice()
{
}
bool SDRPlayInput::start(int device) bool SDRPlayInput::start(int device)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_devNumber = device; m_devNumber = m_deviceAPI->getSampleSourceSequence();
if (m_dev != 0) if (m_dev != 0)
{ {
@ -69,9 +80,9 @@ bool SDRPlayInput::start(int device)
return false; return false;
} }
if ((res = mirisdr_open(&m_dev, MIRISDR_HW_SDRPLAY, device)) < 0) if ((res = mirisdr_open(&m_dev, MIRISDR_HW_SDRPLAY, m_devNumber)) < 0)
{ {
qCritical("SDRPlayInput::start: could not open SDRPlay #%d: %s", device, strerror(errno)); qCritical("SDRPlayInput::start: could not open SDRPlay #%d: %s", m_devNumber, strerror(errno));
return false; return false;
} }
@ -79,7 +90,7 @@ bool SDRPlayInput::start(int device)
product[0] = '\0'; product[0] = '\0';
serial[0] = '\0'; serial[0] = '\0';
if ((res = mirisdr_get_device_usb_strings(device, vendor, product, serial)) < 0) if ((res = mirisdr_get_device_usb_strings(m_devNumber, vendor, product, serial)) < 0)
{ {
qCritical("SDRPlayInput::start: error accessing USB device"); qCritical("SDRPlayInput::start: error accessing USB device");
stop(); stop();

View File

@ -91,6 +91,8 @@ public:
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
private: private:
bool openDevice();
void closeDevice();
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force); bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
bool setCenterFrequency(quint64 freq); bool setCenterFrequency(quint64 freq);
@ -101,6 +103,7 @@ private:
SDRPlayThread* m_sdrPlayThread; SDRPlayThread* m_sdrPlayThread;
QString m_deviceDescription; QString m_deviceDescription;
int m_devNumber; int m_devNumber;
bool m_running;
}; };
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */ #endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */