-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfmradiotunercontrol.cpp
219 lines (180 loc) · 5.59 KB
/
fmradiotunercontrol.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
Copyright (C) 2016 Matti Lehtimäki
Contact: Matti Lehtimäki <[email protected]>
All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "fmradiotunercontrol.h"
QT_BEGIN_NAMESPACE
FMRadioTunerControl::FMRadioTunerControl(QObject *parent, FMRadioIrisControl *ctrl)
: QRadioTunerControl(parent), control(ctrl)
{
connect(control, SIGNAL(tunerAvailabilityChanged(bool)),
this, SIGNAL(availabilityChanged(bool)));
connect(control, SIGNAL(tunerAvailabilityChanged(QMultimedia::AvailabilityStatus)),
this, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)));
connect(control, SIGNAL(stateChanged(QRadioTuner::State)),
this, SIGNAL(stateChanged(QRadioTuner::State)));
connect(control, SIGNAL(bandChanged(QRadioTuner::Band)),
this, SIGNAL(bandChanged(QRadioTuner::Band)));
connect(control, SIGNAL(frequencyChanged(int)),
this, SIGNAL(frequencyChanged(int)));
connect(control, SIGNAL(stereoStatusChanged(bool)),
this, SIGNAL(stereoStatusChanged(bool)));
connect(control, SIGNAL(searchingChanged(bool)),
this, SIGNAL(searchingChanged(bool)));
connect(control, SIGNAL(signalStrengthChanged(int)),
this, SIGNAL(signalStrengthChanged(int)));
connect(control, SIGNAL(volumeChanged(int)),
this, SIGNAL(volumeChanged(int)));
connect(control, SIGNAL(mutedChanged(bool)),
this, SIGNAL(mutedChanged(bool)));
connect(control, SIGNAL(error(QRadioTuner::Error)),
this, SIGNAL(error(QRadioTuner::Error)));
connect(control, SIGNAL(stationFound(int, QString)),
this, SIGNAL(stationFound(int, QString)));
connect(control, SIGNAL(antennaConnectedChanged(bool)),
this, SIGNAL(antennaConnectedChanged(bool)));
}
FMRadioTunerControl::~FMRadioTunerControl()
{
}
bool FMRadioTunerControl::isAvailable() const
{
return control->isTunerAvailable();
}
QMultimedia::AvailabilityStatus FMRadioTunerControl::availability() const
{
return control->tunerAvailability();
}
QRadioTuner::State FMRadioTunerControl::state() const
{
return control->tunerState();
}
QRadioTuner::Band FMRadioTunerControl::band() const
{
return control->band();
}
void FMRadioTunerControl::setBand(QRadioTuner::Band b)
{
control->setBand(b);
}
bool FMRadioTunerControl::isBandSupported(QRadioTuner::Band b) const
{
return control->isBandSupported(b);
}
int FMRadioTunerControl::frequency() const
{
return control->frequency();
}
int FMRadioTunerControl::frequencyStep(QRadioTuner::Band b) const
{
int step = 0;
if (b == QRadioTuner::FM)
step = 100000; // 100kHz steps
else if (b == QRadioTuner::LW)
step = 1000; // 1kHz steps
else if (b == QRadioTuner::AM)
step = 1000; // 1kHz steps
else if (b == QRadioTuner::SW)
step = 500; // 500Hz steps
return step;
}
QPair<int,int> FMRadioTunerControl::frequencyRange(QRadioTuner::Band b) const
{
if (b == QRadioTuner::AM)
return qMakePair<int,int>(520000,1710000);
else if (b == QRadioTuner::FM)
return qMakePair<int,int>(87500000,108000000);
else if (b == QRadioTuner::SW)
return qMakePair<int,int>(1711111,30000000);
else if (b == QRadioTuner::LW)
return qMakePair<int,int>(148500,283500);
return qMakePair<int,int>(0,0);
}
void FMRadioTunerControl::setFrequency(int frequency)
{
control->setFrequency(frequency);
}
bool FMRadioTunerControl::isStereo() const
{
return control->isStereo();
}
QRadioTuner::StereoMode FMRadioTunerControl::stereoMode() const
{
return control->stereoMode();
}
void FMRadioTunerControl::setStereoMode(QRadioTuner::StereoMode mode)
{
control->setStereoMode(mode);
}
int FMRadioTunerControl::signalStrength() const
{
return control->signalStrength();
}
int FMRadioTunerControl::volume() const
{
return 0;
}
void FMRadioTunerControl::setVolume(int)
{
}
bool FMRadioTunerControl::isMuted() const
{
return control->isMuted();
}
void FMRadioTunerControl::setMuted(bool muted)
{
control->setMuted(muted);
}
bool FMRadioTunerControl::isSearching() const
{
return control->isSearching();
}
bool FMRadioTunerControl::isAntennaConnected() const
{
return true;
}
void FMRadioTunerControl::searchForward()
{
control->searchForward();
}
void FMRadioTunerControl::searchBackward()
{
control->searchBackward();
}
void FMRadioTunerControl::searchAllStations(QRadioTuner::SearchMode searchMode)
{
control->searchAllStations(searchMode);
}
void FMRadioTunerControl::cancelSearch()
{
control->cancelSearch();
}
void FMRadioTunerControl::start()
{
control->start();
}
void FMRadioTunerControl::stop()
{
control->stop();
}
QRadioTuner::Error FMRadioTunerControl::error() const
{
return control->tunerError();
}
QString FMRadioTunerControl::errorString() const
{
return control->tunerErrorString();
}
QT_END_NAMESPACE