1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Set frequency before first capture.

This commit is contained in:
John Greb 2014-12-03 00:13:18 +00:00
parent 6704651786
commit acdc87ccc5
5 changed files with 24 additions and 15 deletions

View File

@ -78,6 +78,7 @@ V4LInput::~V4LInput()
bool V4LInput::startInput(int device) bool V4LInput::startInput(int device)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
double freq;
if(m_V4LThread) if(m_V4LThread)
return false; return false;
@ -87,7 +88,8 @@ bool V4LInput::startInput(int device)
return false; return false;
} }
if((m_V4LThread = new V4LThread(&m_sampleFifo)) == NULL) { freq = (double)getCenterFrequency();
if((m_V4LThread = new V4LThread(&m_sampleFifo, freq)) == NULL) {
qFatal("out of memory"); qFatal("out of memory");
return false; return false;
} }
@ -95,8 +97,7 @@ bool V4LInput::startInput(int device)
m_deviceDescription = QString("RTL-SDR /dev/swradio0"); m_deviceDescription = QString("RTL-SDR /dev/swradio0");
qDebug("V4LInput: start"); qDebug("V4LInput: start");
MsgReportV4L::create(m_gains)->submit(m_guiMessageQueue); //MsgReportV4L::create(m_gains)->submit(m_guiMessageQueue);
// applySettings(m_generalSettings, m_settings, true);
return true; return true;
} }
@ -134,8 +135,7 @@ bool V4LInput::handleMessage(Message* message)
{ {
if(MsgConfigureV4L::match(message)) { if(MsgConfigureV4L::match(message)) {
MsgConfigureV4L* conf = (MsgConfigureV4L*)message; MsgConfigureV4L* conf = (MsgConfigureV4L*)message;
if(!applySettings(conf->getGeneralSettings(), conf->getSettings(), false)) applySettings(conf->getGeneralSettings(), conf->getSettings(), false);
qDebug("V4L config error");
message->completed(); message->completed();
return true; return true;
} else { } else {
@ -143,20 +143,25 @@ bool V4LInput::handleMessage(Message* message)
} }
} }
bool V4LInput::applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force) void V4LInput::applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
if (!m_V4LThread) {
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
return;
}
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) { if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) {
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency; m_V4LThread->set_center_freq( (double)(generalSettings.m_centerFrequency
if(m_V4LThread)
m_V4LThread->set_center_freq( (double)(generalSettings.m_centerFrequency
+ (SAMPLERATE / 4) )); + (SAMPLERATE / 4) ));
} }
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
#if 0
if((m_settings.m_gain != settings.m_gain) || force) { if((m_settings.m_gain != settings.m_gain) || force) {
m_settings.m_gain = settings.m_gain; m_settings.m_gain = settings.m_gain;
if(m_V4LThread) m_V4LThread->set_tuner_gain((double)m_settings.m_gain);
m_V4LThread->set_tuner_gain((double)m_settings.m_gain);
} }
return true; #endif
} }

View File

@ -100,7 +100,7 @@ private:
QString m_deviceDescription; QString m_deviceDescription;
std::vector<int> m_gains; std::vector<int> m_gains;
bool applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force); void applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force);
}; };
#endif // INCLUDE_V4L_H #endif // INCLUDE_V4L_H

View File

@ -120,6 +120,7 @@ V4LThread::OpenSource(const char *filename)
} }
set_sample_rate((double)SAMPLERATE); set_sample_rate((double)SAMPLERATE);
set_center_freq( centerFreq + (SAMPLERATE / 4) );
// start streaming // start streaming
type = V4L2_BUF_TYPE_SDR_CAPTURE; type = V4L2_BUF_TYPE_SDR_CAPTURE;
xioctl(fd, VIDIOC_STREAMON, &type); xioctl(fd, VIDIOC_STREAMON, &type);

View File

@ -20,12 +20,13 @@
#include "v4lthread.h" #include "v4lthread.h"
#include "dsp/samplefifo.h" #include "dsp/samplefifo.h"
V4LThread::V4LThread(SampleFifo* sampleFifo, QObject* parent) : V4LThread::V4LThread(SampleFifo* sampleFifo, double frequency, QObject* parent) :
QThread(parent), QThread(parent),
m_running(false), m_running(false),
m_convertBuffer(BLOCKSIZE), m_convertBuffer(BLOCKSIZE),
m_sampleFifo(sampleFifo) m_sampleFifo(sampleFifo)
{ {
centerFreq = frequency;
start(); start();
} }

View File

@ -31,7 +31,7 @@ class V4LThread : public QThread {
Q_OBJECT Q_OBJECT
public: public:
V4LThread(SampleFifo* sampleFifo, QObject* parent = NULL); V4LThread(SampleFifo* sampleFifo, double frequency, QObject* parent = NULL);
~V4LThread(); ~V4LThread();
void stopWork(); void stopWork();
@ -51,6 +51,8 @@ private:
unsigned int recebuf_len; unsigned int recebuf_len;
unsigned int recebuf_mmap_index; unsigned int recebuf_mmap_index;
double centerFreq;
QMutex m_startWaitMutex; QMutex m_startWaitMutex;
QWaitCondition m_startWaiter; QWaitCondition m_startWaiter;
bool m_running; bool m_running;