1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

FCDPro: open/close new style

This commit is contained in:
f4exb 2017-04-14 03:24:21 +02:00
parent b05897d221
commit f456293b84
3 changed files with 61 additions and 20 deletions

View File

@ -35,6 +35,9 @@ FCDProGui::FCDProGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
{
m_sampleSource = new FCDProInput(m_deviceAPI);
m_deviceAPI->setSource(m_sampleSource);
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 64000U, 1700000U);
@ -141,9 +144,6 @@ FCDProGui::FCDProGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
displaySettings();
m_sampleSource = new FCDProInput(m_deviceAPI);
m_deviceAPI->setSource(m_sampleSource);
char recFileNameCStr[30];
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
m_fileSink = new FileRecord(std::string(recFileNameCStr));

View File

@ -42,31 +42,61 @@ FCDProInput::FCDProInput(DeviceSourceAPI *deviceAPI) :
m_deviceDescription(fcd_traits<Pro>::displayedName),
m_running(false)
{
openDevice();
}
FCDProInput::~FCDProInput()
{
stop();
if (m_running) stop();
closeDevice();
}
bool FCDProInput::openDevice()
{
int device = m_deviceAPI->getSampleSourceSequence();
if (m_dev != 0)
{
closeDevice();
}
qDebug() << "FCDProInput::openDevice with device #" << device;
m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);
if (m_dev == 0)
{
qCritical("FCDProInput::start: could not open FCD");
return false;
}
return true;
}
bool FCDProInput::start(int device)
{
qDebug() << "FCDProInput::start with device #" << device;
qDebug() << "FCDProInput::start";
QMutexLocker mutexLocker(&m_mutex);
// QMutexLocker mutexLocker(&m_mutex);
if (m_FCDThread)
{
return false;
}
if (!m_dev) {
return false;
}
m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);
if (m_running) stop();
if (m_dev == 0)
{
qCritical("FCDProInput::start: could not open FCD");
return false;
}
// if (m_FCDThread)
// {
// return false;
// }
// m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);
//
// if (m_dev == 0)
// {
// qCritical("FCDProInput::start: could not open FCD");
// return false;
// }
/* Apply settings before streaming to avoid bus contention;
* there is very little spare bandwidth on a full speed USB device.
@ -89,16 +119,24 @@ bool FCDProInput::start(int device)
m_FCDThread->startWork();
mutexLocker.unlock();
// mutexLocker.unlock();
applySettings(m_settings, true);
qDebug("FCDProInput::started");
m_running = true;
return true;
}
void FCDProInput::closeDevice()
{
fcdClose(m_dev);
m_dev = 0;
}
void FCDProInput::stop()
{
QMutexLocker mutexLocker(&m_mutex);
// QMutexLocker mutexLocker(&m_mutex);
if (m_FCDThread)
{
@ -108,8 +146,9 @@ void FCDProInput::stop()
m_FCDThread = 0;
}
fcdClose(m_dev);
m_dev = 0;
m_running = false;
// fcdClose(m_dev);
// m_dev = 0;
}
const QString& FCDProInput::getDeviceDescription() const

View File

@ -87,6 +87,8 @@ public:
void set_gain6(int index);
private:
bool openDevice();
void closeDevice();
void applySettings(const FCDProSettings& settings, bool force);
void set_lo_ppm();