1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-09-09 02:07:47 -04:00
This commit is contained in:
John Greb 2014-11-12 18:22:49 +00:00
parent f78b2eebaf
commit 80a9d30fc3
7 changed files with 17 additions and 102 deletions

View File

@ -95,8 +95,6 @@ bool V4LGui::handleMessage(Message* message)
void V4LGui::displaySettings() void V4LGui::displaySettings()
{ {
ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000); ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000);
ui->samplerate->setValue(m_settings.m_samplerate);
if(m_gains.size() > 0) { if(m_gains.size() > 0) {
int dist = abs(m_settings.m_gain - m_gains[0]); int dist = abs(m_settings.m_gain - m_gains[0]);
int pos = 0; int pos = 0;
@ -139,15 +137,6 @@ void V4LGui::on_gain_valueChanged(int value)
sendSettings(); sendSettings();
} }
void V4LGui::on_samplerate_valueChanged(int value)
{
int Rates[] = { 2500, 1536, 3072, 288, 1000, 0};
int newrate = Rates[value];
ui->samplerateText->setText(tr("%1kHz").arg(newrate));
m_settings.m_samplerate = 1000 * newrate;
sendSettings();
}
void V4LGui::updateHardware() void V4LGui::updateHardware()
{ {
V4LInput::MsgConfigureV4L* message = V4LInput::MsgConfigureV4L::create(m_generalSettings, m_settings); V4LInput::MsgConfigureV4L* message = V4LInput::MsgConfigureV4L::create(m_generalSettings, m_settings);

View File

@ -45,8 +45,6 @@ private:
private slots: private slots:
void on_centerFrequency_changed(quint64 value); void on_centerFrequency_changed(quint64 value);
void on_gain_valueChanged(int value); void on_gain_valueChanged(int value);
void on_samplerate_valueChanged(int value);
void updateHardware(); void updateHardware();
}; };

View File

@ -100,58 +100,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="1">
<widget class="QSlider" name="samplerate">
<property name="toolTip">
<string>Device Samplerate</string>
</property>
<property name="maximum">
<number>4</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Samplerate</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="samplerateText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1:1</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<widget class="Line" name="line_3"> <widget class="Line" name="line_3">
<property name="orientation"> <property name="orientation">

View File

@ -39,7 +39,7 @@ QByteArray V4LInput::Settings::serialize() const
{ {
SimpleSerializer s(1); SimpleSerializer s(1);
s.writeS32(1, m_gain); s.writeS32(1, m_gain);
s.writeS32(2, m_samplerate); s.writeS32(2, SAMPLERATE);
return s.final(); return s.final();
} }
@ -54,7 +54,7 @@ bool V4LInput::Settings::deserialize(const QByteArray& data)
if(d.getVersion() == 1) { if(d.getVersion() == 1) {
d.readS32(1, &m_gain, 0); d.readS32(1, &m_gain, 0);
d.readS32(2, &m_samplerate, 0); //d.readS32(2, &m_samplerate, 0);
return true; return true;
} else { } else {
resetToDefaults(); resetToDefaults();
@ -65,7 +65,6 @@ bool V4LInput::Settings::deserialize(const QByteArray& data)
V4LInput::V4LInput(MessageQueue* msgQueueToGUI) : V4LInput::V4LInput(MessageQueue* msgQueueToGUI) :
SampleSource(msgQueueToGUI), SampleSource(msgQueueToGUI),
m_settings(), m_settings(),
m_dev(0),
m_V4LThread(NULL), m_V4LThread(NULL),
m_deviceDescription() m_deviceDescription()
{ {
@ -90,19 +89,8 @@ bool V4LInput::startInput(int device)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
if(m_dev > 0) if(m_V4LThread)
stopInput(); return false;
char vendor[256];
char product[256];
char serial[256];
int res;
int numberOfGains;
vendor[0] = '\0';
product[0] = '\0';
serial[0] = '\0';
if(!m_sampleFifo.setSize(4096*16)) { if(!m_sampleFifo.setSize(4096*16)) {
qCritical("Could not allocate SampleFifo"); qCritical("Could not allocate SampleFifo");
@ -111,27 +99,24 @@ bool V4LInput::startInput(int device)
if((m_V4LThread = new V4LThread(&m_sampleFifo)) == NULL) { if((m_V4LThread = new V4LThread(&m_sampleFifo)) == NULL) {
qFatal("out of memory"); qFatal("out of memory");
goto failed; return false;
} }
mutexLocker.unlock(); m_deviceDescription = QString("RTL-SDR /dev/swradio0");
//applySettings(m_generalSettings, m_settings, true);
qDebug("V4LInput: start"); qDebug("V4LInput: start");
MsgReportV4L::create(m_gains)->submit(m_guiMessageQueue); MsgReportV4L::create(m_gains)->submit(m_guiMessageQueue);
return true; return true;
failed:
return false;
} }
void V4LInput::stopInput() void V4LInput::stopInput()
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
if(m_V4LThread != NULL) { if(m_V4LThread) {
m_V4LThread->stopWork(); m_V4LThread->stopWork();
// wait for thread to quit ?
delete m_V4LThread; delete m_V4LThread;
m_V4LThread = NULL; m_V4LThread = NULL;
} }
@ -145,7 +130,7 @@ const QString& V4LInput::getDeviceDescription() const
int V4LInput::getSampleRate() const int V4LInput::getSampleRate() const
{ {
int result = m_settings.m_samplerate / 4; int result = SAMPLERATE / 4;
return result; return result;
} }
@ -173,13 +158,13 @@ bool V4LInput::applySettings(const GeneralSettings& generalSettings, const Setti
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_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
if(m_dev > 0) if(m_V4LThread)
m_V4LThread->set_center_freq( (double)(generalSettings.m_centerFrequency m_V4LThread->set_center_freq( (double)(generalSettings.m_centerFrequency
+ (settings.m_samplerate / 4) )); + (SAMPLERATE / 4) ));
} }
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_dev > 0) 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; return true;

View File

@ -32,7 +32,6 @@ class V4LInput : public SampleSource {
public: public:
struct Settings { struct Settings {
qint32 m_gain; qint32 m_gain;
qint32 m_samplerate;
Settings(); Settings();
void resetToDefaults(); void resetToDefaults();
@ -97,7 +96,6 @@ public:
private: private:
QMutex m_mutex; QMutex m_mutex;
Settings m_settings; Settings m_settings;
int m_dev;
V4LThread* m_V4LThread; V4LThread* m_V4LThread;
QString m_deviceDescription; QString m_deviceDescription;
std::vector<int> m_gains; std::vector<int> m_gains;

View File

@ -23,29 +23,29 @@
V4LThread::V4LThread(SampleFifo* sampleFifo, QObject* parent) : V4LThread::V4LThread(SampleFifo* sampleFifo, QObject* parent) :
QThread(parent), QThread(parent),
m_running(false), m_running(false),
m_dev(1),
m_convertBuffer(BLOCKSIZE), m_convertBuffer(BLOCKSIZE),
m_sampleFifo(sampleFifo) m_sampleFifo(sampleFifo)
{ {
} }
V4LThread::~V4LThread() V4LThread::~V4LThread()
{
}
void V4LThread::stopWork()
{ {
m_running = false; m_running = false;
} }
void V4LThread::run() void V4LThread::run()
{ {
m_running = true;
if (! Init() ) if (! Init() )
return; return;
m_running = true;
while(m_running) { while(m_running) {
work(BLOCKSIZE); work(BLOCKSIZE);
} }
m_running = false;
CloseSource(); CloseSource();
} }

View File

@ -36,7 +36,6 @@ public:
bool Init(); bool Init();
void stopWork(); void stopWork();
void setSamplerate(int samplerate);
void OpenSource(const char *filename); void OpenSource(const char *filename);
void CloseSource(); void CloseSource();
void set_sample_rate(double samp_rate); void set_sample_rate(double samp_rate);
@ -57,10 +56,8 @@ private:
QWaitCondition m_startWaiter; QWaitCondition m_startWaiter;
bool m_running; bool m_running;
int m_dev;
SampleVector m_convertBuffer; SampleVector m_convertBuffer;
SampleFifo* m_sampleFifo; SampleFifo* m_sampleFifo;
int m_samplerate;
void run(); void run();