diff options
author | Tasuku Suzuki <tasuku.suzuki@qt.io> | 2016-12-09 10:28:18 +0900 |
---|---|---|
committer | Tasuku Suzuki <tasuku.suzuki@qt.io> | 2016-12-09 10:28:18 +0900 |
commit | bb08422f14659e811e11d15cc5365b3b91fccef0 (patch) | |
tree | 0e85a51d8ac450eeffa1a4b44f6d61e15e879f2e | |
parent | ddfe5552b3297236effc42f0c73e8b69654c976c (diff) |
add AM support
When ALS2016, this backend supported FM only, AM was never tested.
Change-Id: If8365d24441cd2310d85071cb0893341b12ba920
-rw-r--r-- | rtlfmradiotunercontrol.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/rtlfmradiotunercontrol.cpp b/rtlfmradiotunercontrol.cpp index 83096b6..863cb06 100644 --- a/rtlfmradiotunercontrol.cpp +++ b/rtlfmradiotunercontrol.cpp @@ -48,11 +48,11 @@ private: }; QMap<int, QString> fmFrequenciesTokyo = { - { 76100, QString::fromUtf8("Inter FM") } - , { 77100, QString::fromUtf8("The Open University of Japan") } - , { 80000, QString::fromUtf8("TOKYO FM") } - , { 81300, QString::fromUtf8("J-WAVE") } - , { 82500, QString::fromUtf8("NHK FM Tokyo") } + { 76100000, QString::fromUtf8("Inter FM") } + , { 77100000, QString::fromUtf8("The Open University of Japan") } + , { 80000000, QString::fromUtf8("TOKYO FM") } + , { 81300000, QString::fromUtf8("J-WAVE") } + , { 82500000, QString::fromUtf8("NHK FM Tokyo") } }; }; @@ -71,7 +71,6 @@ RtlFmRadioTunerControl::Private::Private(RtlFmRadioTunerControl *parent) , step(0) { connect(q, &RtlFmRadioTunerControl::stationFound, [this](int frequency, const QString &name) { - qDebug() << frequency << name; if (rtlFm.state() != QProcess::NotRunning) q->start(); }); @@ -89,11 +88,12 @@ RtlFmRadioTunerControl::Private::Private(RtlFmRadioTunerControl *parent) break; } if (knownBands.contains(frequency)) { - emit q->stationFound(frequency, knownBands.value(frequency)); + QMetaObject::invokeMethod(q, "stationFound", Qt::QueuedConnection, Q_ARG(int, frequency), Q_ARG(QString, knownBands.value(frequency))); if (timer.isActive() && searchOne) timer.stop(); } }); + connect(&timer, &QTimer::timeout, [this]() { q->setFrequency(frequency + step); }); @@ -167,7 +167,7 @@ int RtlFmRadioTunerControl::frequencyStep(QRadioTuner::Band band) const ret = 1000; // 1kHz break; case QRadioTuner::FM: - ret = 100; // 100Hz + ret = 100000; // 0.1 MHz break; default: break; @@ -180,10 +180,10 @@ QPair<int,int> RtlFmRadioTunerControl::frequencyRange(QRadioTuner::Band band) co QPair<int,int> ret; switch (band) { case QRadioTuner::AM: - ret = qMakePair<int,int>(594000, 1242000); + ret = qMakePair<int,int>(531000, 1602000); break; case QRadioTuner::FM: - ret = qMakePair<int,int>(76100, 82500); + ret = qMakePair<int,int>(76000000, 107900000); break; default: break; @@ -313,7 +313,19 @@ void RtlFmRadioTunerControl::start() d->aplay.start(QStringLiteral("aplay"), QStringList() << QStringLiteral("-r") << QStringLiteral("48000") << QStringLiteral("-f") << QStringLiteral("S16_LE")); d->aplay.waitForStarted(); // d->rtlFm.start(QStringLiteral("sudo"), QStringList() << QStringLiteral("rtl_fm -f %1 -M wbfm -s 200000 -r 48000").arg(d->frequency * 1000).split(" ")); - d->rtlFm.start(QStringLiteral("rtl_fm"), QStringList() << QStringLiteral("-f %1 -M wbfm -s 200000 -r 48000").arg(d->frequency * 1000).split(" ")); + QString modulation; + switch (d->band) { + case QRadioTuner::AM: + modulation = QStringLiteral("-M wbfm"); + break; + case QRadioTuner::FM: + modulation = QStringLiteral("-M am"); + break; + default: + break; + } + + d->rtlFm.start(QStringLiteral("rtl_fm"), QStringLiteral("-f %1 %2 -s 200000 -r 48000").arg(d->frequency).arg(modulation).split(" ")); d->rtlFm.waitForStarted(); d->state = QRadioTuner::ActiveState; } |