author | Pat Downey <patd@symbian.org> |
Wed, 23 Jun 2010 17:20:24 +0100 | |
changeset 29 | 29ba091146f4 |
parent 28 | 075425b8d9a4 |
child 32 | 189d20c34778 |
permissions | -rw-r--r-- |
24 | 1 |
/* |
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// System includes |
|
19 |
#include <AudioOutput.h> |
|
20 |
#include <eikdef.h> |
|
21 |
#include <coemain.h> |
|
22 |
#include <badesca.h> |
|
23 |
#include <tzlocalizer.h> |
|
24 |
||
25 |
// User includes |
|
26 |
#include "cradioenginelogger.h" |
|
27 |
#include "radiointernalcrkeys.h" |
|
28 |
#include "cradioaudiorouter.h" |
|
29 |
#include "cradioengineimp.h" |
|
30 |
#include "mradioengineobserver.h" |
|
31 |
#include "cradioregion.h" |
|
32 |
#include "cradiosettings.h" |
|
33 |
#include "mradioenginesettings.h" |
|
34 |
#include "mradiosettingssetter.h" |
|
35 |
#include "cradiordsreceiver.h" |
|
36 |
#include "cradiosystemeventcollector.h" |
|
37 |
#include "cradionetworkinfolistener.h" |
|
38 |
#include "radioengine.hrh" |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
39 |
#include "cradioenginelogger.h" |
24 | 40 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
41 |
// This has to be the last include. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
42 |
#ifdef STUB_CONSTELLATION |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
43 |
# include <RadioStubManager.h> |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
44 |
#endif //STUB_CONSTELLATION |
24 | 45 |
|
46 |
// Constants |
|
47 |
||
48 |
/** The limit of volume steps that must not be divided */ |
|
49 |
const TInt KRadioVolumeStepsDividinglimit = 20; |
|
50 |
/** If CMMTunerUtility has 200 volume steps, AknVolume control has 20 steps */ |
|
51 |
const TInt KRadioVolumeStepsDivider = 500; |
|
52 |
/** amount of volume steps used previously */ |
|
53 |
#if defined __WINS__ |
|
54 |
const TInt KRadioVolumeStepsOld = 10; |
|
55 |
#endif // defined __WINS__ |
|
56 |
||
57 |
/** KRadioRadioSwitchDelay value must not be too small, otherwise problems with |
|
58 |
radioserver will occur, when swithing between valid and invalid presets */ |
|
59 |
const TInt KRadioRadioSwitchDelay = 300; // In milliseconds |
|
60 |
||
61 |
const TInt KRadioThousand = 1000; |
|
62 |
const TInt KRadioMillion = KRadioThousand * KRadioThousand; |
|
63 |
||
64 |
// Country order from timezones.rss. Default = 0, Japan = 1, America = 2. |
|
65 |
const TUint KCityGroupRegions[] = |
|
66 |
{0,0,0,0,0,0,2,0,0,0,0,2,0,2,0,2,0,2,0,2,2,0,2,0,0,2,2,2,0,2,0,0, //32 |
|
67 |
0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0, //64 |
|
68 |
0,0,0,0,0,2,0,0,0,2,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //96 |
|
69 |
0,0,0,2,0,0,0,0,2,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //128 |
|
70 |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //160 |
|
71 |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0, //192 |
|
72 |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0, //224 |
|
73 |
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
|
74 |
||
75 |
||
76 |
||
77 |
// ================= MEMBER FUNCTIONS ======================= |
|
78 |
||
79 |
// --------------------------------------------------------------------------- |
|
80 |
// |
|
81 |
// --------------------------------------------------------------------------- |
|
82 |
// |
|
83 |
CRadioEngineImp::CRadioEngineImp( CRadioAudioRouter* aAudioRouter ) |
|
84 |
: CRadioEngine( aAudioRouter ) |
|
85 |
, iAntennaAttached( ETrue ) |
|
86 |
, iFreqEventReason( RadioEngine::ERadioFrequencyEventReasonUnknown ) |
|
87 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
88 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 89 |
} |
90 |
||
91 |
// --------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
// --------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
void CRadioEngineImp::ConstructL() |
|
96 |
{ |
|
97 |
LOG_METHOD_AUTO; |
|
98 |
||
99 |
if ( !iAudioRouter || !iSystemEventCollector || !iSettings ) |
|
100 |
{ |
|
101 |
User::Leave( KErrNotReady ); |
|
102 |
} |
|
103 |
||
104 |
iSystemEventCollector->AddObserverL( this ); |
|
105 |
||
106 |
// Initial default values to be over by init |
|
107 |
User::LeaveIfError( iSettings->RadioSetter().SetPowerOn( EFalse ) ); |
|
108 |
||
109 |
// The output source needs to be in headset when starting the radio. |
|
110 |
// But if the headset is not connected, audio cannot be heard if it is routed |
|
111 |
// to headset |
|
112 |
RadioEngine::TRadioAudioRoute route = iSystemEventCollector->IsHeadsetConnectedL() ? |
|
113 |
RadioEngine::ERadioHeadset : RadioEngine::ERadioSpeaker; |
|
114 |
User::LeaveIfError( iSettings->RadioSetter().SetAudioRoute( route ) ); |
|
115 |
||
116 |
iRdsReceiver = CRadioRdsReceiver::NewL( iSettings->EngineSettings() ); |
|
117 |
iNetworkInfoListener = CRadioNetworkInfoListener::NewL( iSettings->RadioSetter(), NULL ); |
|
118 |
||
119 |
iRdsReceiver->AddObserverL( this ); |
|
120 |
||
121 |
// Create timer that is used when polling for radio restart. |
|
122 |
iRadioTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
|
123 |
} |
|
124 |
||
125 |
// --------------------------------------------------------------------------- |
|
126 |
// |
|
127 |
// --------------------------------------------------------------------------- |
|
128 |
// |
|
129 |
CRadioEngineImp::~CRadioEngineImp() |
|
130 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
131 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 132 |
|
133 |
delete iNetworkInfoListener; |
|
134 |
||
135 |
PowerOff(); |
|
136 |
||
137 |
delete iRadioTimer; |
|
138 |
||
139 |
DeleteAudioOutput(); |
|
140 |
||
141 |
if ( iTunerUtility ) |
|
142 |
{ |
|
143 |
iTunerUtility->Close(); |
|
144 |
} |
|
145 |
||
146 |
if ( iPlayerUtility ) |
|
147 |
{ |
|
148 |
iPlayerUtility->Close(); |
|
149 |
} |
|
150 |
||
151 |
if ( iRdsReceiver ) |
|
152 |
{ |
|
153 |
iRdsReceiver->RemoveObserver( this ); |
|
154 |
} |
|
155 |
||
156 |
delete iRdsReceiver; |
|
157 |
delete iRadioUtility; |
|
158 |
||
159 |
iObservers.Close(); |
|
160 |
||
161 |
if ( iSystemEventCollector ) |
|
162 |
{ |
|
163 |
iSystemEventCollector->RemoveObserver( this ); |
|
164 |
} |
|
165 |
delete iSystemEventCollector; |
|
166 |
||
167 |
if ( iSettings ) |
|
168 |
{ |
|
169 |
iSettings->RadioSetter().SetObserver( NULL ); |
|
170 |
} |
|
171 |
delete iSettings; |
|
172 |
||
173 |
} |
|
174 |
||
175 |
// --------------------------------------------------------------------------- |
|
176 |
// |
|
177 |
// --------------------------------------------------------------------------- |
|
178 |
// |
|
179 |
void CRadioEngineImp::SetSystemEventCollector( CRadioSystemEventCollector* aCollector ) |
|
180 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
181 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 182 |
iSystemEventCollector = aCollector; |
183 |
} |
|
184 |
||
185 |
// --------------------------------------------------------------------------- |
|
186 |
// |
|
187 |
// --------------------------------------------------------------------------- |
|
188 |
// |
|
189 |
void CRadioEngineImp::SetRadioSettings( CRadioSettings* aSettings ) |
|
190 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
191 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 192 |
iSettings = aSettings; |
193 |
iSettings->RadioSetter().SetObserver( this ); |
|
194 |
} |
|
195 |
||
196 |
// --------------------------------------------------------------------------- |
|
197 |
// |
|
198 |
// --------------------------------------------------------------------------- |
|
199 |
// |
|
200 |
CRadioAudioRouter& CRadioEngineImp::AudioRouter() const |
|
201 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
202 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 203 |
return *iAudioRouter; |
204 |
} |
|
205 |
||
206 |
// --------------------------------------------------------------------------- |
|
207 |
// |
|
208 |
// --------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
CRadioSystemEventCollector& CRadioEngineImp::SystemEventCollector() const |
|
211 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
212 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 213 |
return *iSystemEventCollector; |
214 |
} |
|
215 |
||
216 |
// --------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
// --------------------------------------------------------------------------- |
|
219 |
// |
|
220 |
CRadioSettings& CRadioEngineImp::Settings() const |
|
221 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
222 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 223 |
return *iSettings; |
224 |
} |
|
225 |
||
226 |
// --------------------------------------------------------------------------- |
|
227 |
// Determines radio region |
|
228 |
// --------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
TRadioRegion CRadioEngineImp::DetermineRegion() |
|
231 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
232 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 233 |
TRadioRegion region = ERadioRegionNone; |
234 |
||
235 |
MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
|
236 |
if ( iSystemEventCollector->IsMobileNetworkCoverage() ) |
|
237 |
{ |
|
238 |
region = RegionFromMobileNetwork(); |
|
239 |
} |
|
240 |
else |
|
241 |
{ |
|
242 |
region = RegionFromTimezone(); |
|
243 |
} |
|
244 |
||
245 |
if ( !iSettings->IsRegionAllowed( region ) ) |
|
246 |
{ |
|
247 |
region = ERadioRegionNone; |
|
248 |
} |
|
249 |
||
250 |
// Region not found, try to use the previously set region |
|
251 |
if ( region == ERadioRegionNone && engineSettings.RegionId() != ERadioRegionNone ) |
|
252 |
{ |
|
253 |
region = engineSettings.RegionId(); |
|
254 |
} |
|
255 |
||
256 |
// All regions have been searched and no direct match found, use default one |
|
257 |
if ( region == ERadioRegionNone ) |
|
258 |
{ |
|
259 |
region = engineSettings.DefaultRegion(); |
|
260 |
} |
|
261 |
||
262 |
return region; |
|
263 |
} |
|
264 |
||
265 |
// --------------------------------------------------------------------------- |
|
266 |
// Initializes / reinitializes the radio. If this is not called |
|
267 |
// the radio is not functional |
|
268 |
// --------------------------------------------------------------------------- |
|
269 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
270 |
void CRadioEngineImp::InitRadioL( TInt aRegionId ) |
24 | 271 |
{ |
272 |
LOG_METHOD_AUTO; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
273 |
LOG_FORMAT( "Region: %d", aRegionId ); |
24 | 274 |
|
275 |
iRadioInitializationState = ERadioNotInitialized; |
|
276 |
||
277 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonUnknown; |
|
278 |
if ( iSettings->EngineSettings().RegionId() != aRegionId ) |
|
279 |
{ |
|
280 |
// Change only when necessary as it changes also the default tuned frequency |
|
281 |
User::LeaveIfError( iSettings->RadioSetter().SetRegionId( aRegionId ) ); |
|
282 |
} |
|
283 |
||
284 |
if ( !iRadioUtility ) |
|
285 |
{ |
|
286 |
iRadioUtility = CRadioUtility::NewL( ETrue ); |
|
287 |
} |
|
288 |
||
289 |
if ( !iPlayerUtility ) |
|
290 |
{ |
|
291 |
iPlayerUtility = &iRadioUtility->RadioPlayerUtilityL( *this ); |
|
292 |
SetAudioOutput( CAudioOutput::NewL( *iPlayerUtility ) ); |
|
293 |
} |
|
294 |
||
295 |
if ( !iTunerUtility ) |
|
296 |
{ |
|
297 |
iTunerUtility = &iRadioUtility->RadioFmTunerUtilityL( *this ); |
|
298 |
} |
|
299 |
||
300 |
// Utilities have been created now |
|
301 |
iRadioInitializationState = ERadioUtilitiesConstructed; |
|
302 |
||
303 |
// Before first RequestTunerControl() call it is ok to enable offline mode without checking capabilities |
|
304 |
iTunerUtility->EnableTunerInOfflineMode( ETrue ); |
|
305 |
iTunerUtility->RequestTunerControl(); |
|
306 |
} |
|
307 |
||
308 |
// --------------------------------------------------------------------------- |
|
309 |
// |
|
310 |
// --------------------------------------------------------------------------- |
|
311 |
// |
|
312 |
TBool CRadioEngineImp::RadioInitialized() const |
|
313 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
314 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 315 |
return iRadioInitializationState == ERadioTunerControlGranted; |
316 |
} |
|
317 |
||
318 |
// --------------------------------------------------------------------------- |
|
319 |
// Sets the state for radio audio |
|
320 |
// --------------------------------------------------------------------------- |
|
321 |
// |
|
322 |
void CRadioEngineImp::EnableAudio( TBool aEnable, TBool aDelay ) |
|
323 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
324 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
325 |
LOG_FORMAT( "aEnable %d ", aEnable ); |
24 | 326 |
iRadioEnabled = aEnable; |
327 |
if ( aDelay ) |
|
328 |
{ |
|
329 |
SwitchPower( iRadioEnabled ); |
|
330 |
} |
|
331 |
else if ( aEnable ) |
|
332 |
{ |
|
333 |
if ( !RadioInitialized() && |
|
334 |
iRadioInitializationState == ERadioUtilitiesConstructed && |
|
335 |
iRadioEnabled && |
|
336 |
OkToPlay( iSettings->EngineSettings().TunedFrequency() ) ) |
|
337 |
{ |
|
338 |
iTunerUtility->RequestTunerControl(); |
|
339 |
} |
|
340 |
else |
|
341 |
{ |
|
342 |
PowerOn(); |
|
343 |
} |
|
344 |
} |
|
345 |
else |
|
346 |
{ |
|
347 |
PowerOff(); |
|
348 |
} |
|
349 |
} |
|
350 |
||
351 |
// --------------------------------------------------------------------------- |
|
352 |
// Gets the state for radio audio. |
|
353 |
// --------------------------------------------------------------------------- |
|
354 |
// |
|
355 |
TBool CRadioEngineImp::RadioAudioEnabled() const |
|
356 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
357 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 358 |
return iRadioEnabled; |
359 |
} |
|
360 |
||
361 |
// --------------------------------------------------------------------------- |
|
362 |
// Sets the state for audio overriding |
|
363 |
// --------------------------------------------------------------------------- |
|
364 |
// |
|
365 |
void CRadioEngineImp::SetAudioOverride( TBool aOverride ) |
|
366 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
367 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
368 |
LEVEL3( LOG_FORMAT( "aOverride %d ", aOverride ) ); |
24 | 369 |
iOverrideAudioResources = aOverride; |
370 |
} |
|
371 |
||
372 |
// --------------------------------------------------------------------------- |
|
373 |
// Adds an observer for the radio state changes notifications. |
|
374 |
// --------------------------------------------------------------------------- |
|
375 |
// |
|
376 |
void CRadioEngineImp::AddObserverL( MRadioEngineObserver* aObserver ) |
|
377 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
378 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 379 |
TInt index = iObservers.FindInAddressOrder( aObserver ); |
380 |
if ( index == KErrNotFound ) |
|
381 |
{ |
|
382 |
iObservers.InsertInAddressOrderL( aObserver ); |
|
383 |
} |
|
384 |
} |
|
385 |
||
386 |
// --------------------------------------------------------------------------- |
|
387 |
// Removes an observer from the list of obsevers |
|
388 |
// --------------------------------------------------------------------------- |
|
389 |
// |
|
390 |
void CRadioEngineImp::RemoveObserver( MRadioEngineObserver* aObserver ) |
|
391 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
392 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 393 |
TInt index = iObservers.FindInAddressOrder( aObserver ); |
394 |
||
395 |
if ( index >= 0 ) |
|
396 |
{ |
|
397 |
iObservers.Remove( index ); |
|
398 |
} |
|
399 |
} |
|
400 |
||
401 |
// --------------------------------------------------------------------------- |
|
402 |
// |
|
403 |
// --------------------------------------------------------------------------- |
|
404 |
// |
|
405 |
TFmRadioFrequencyRange CRadioEngineImp::TunerFrequencyRangeForRegionId( TInt aRegionId ) const |
|
406 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
407 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 408 |
TFmRadioFrequencyRange result = EFmRangeEuroAmerica; |
409 |
switch ( aRegionId ) |
|
410 |
{ |
|
411 |
case ERadioRegionDefault: |
|
412 |
{ |
|
413 |
result = EFmRangeEuroAmerica; |
|
414 |
break; |
|
415 |
} |
|
416 |
case ERadioRegionJapan: |
|
417 |
{ |
|
418 |
result = EFmRangeJapan; |
|
419 |
break; |
|
420 |
} |
|
421 |
case ERadioRegionAmerica: |
|
422 |
{ |
|
423 |
result = EFmRangeEuroAmerica; |
|
424 |
break; |
|
425 |
} |
|
426 |
default: |
|
427 |
break; |
|
428 |
} |
|
429 |
return result; |
|
430 |
} |
|
431 |
||
432 |
// --------------------------------------------------------------------------- |
|
433 |
// Sets radio mode ERadioStereo or ERadioMono |
|
434 |
// --------------------------------------------------------------------------- |
|
435 |
||
436 |
void CRadioEngineImp::SetAudioMode( TInt aAudioMode ) |
|
437 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
438 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
439 |
LOG_FORMAT( "aAudioMode: %d", aAudioMode ); |
24 | 440 |
TInt err = KErrNone; |
441 |
if ( !RadioInitialized() ) |
|
442 |
{ |
|
443 |
TInt err = iSettings->RadioSetter().SetOutputMode( aAudioMode ); |
|
444 |
NotifyRadioEvent( ERadioEventAudioMode, err ); |
|
445 |
} |
|
446 |
else |
|
447 |
{ |
|
448 |
err = iTunerUtility->ForceMonoReception( aAudioMode == RadioEngine::ERadioMono ); |
|
449 |
||
450 |
if ( err ) |
|
451 |
{ |
|
452 |
NotifyRadioEvent( ERadioEventAudioMode, err ); |
|
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
||
457 |
// --------------------------------------------------------------------------- |
|
458 |
// Switches power on/off after a delay |
|
459 |
// --------------------------------------------------------------------------- |
|
460 |
// |
|
461 |
void CRadioEngineImp::SwitchPower( TBool aPowerOn ) |
|
462 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
463 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
464 |
LOG_FORMAT( "aPowerOn %d", aPowerOn ); |
24 | 465 |
if ( RadioInitialized() ) |
466 |
{ |
|
467 |
if ( !aPowerOn || OkToPlay( iSettings->EngineSettings().TunedFrequency() ) ) |
|
468 |
{ |
|
469 |
iRadioTimer->Cancel(); |
|
470 |
if ( aPowerOn ) |
|
471 |
{ |
|
472 |
iRadioTimer->Start( TTimeIntervalMicroSeconds32( KRadioRadioSwitchDelay * KRadioThousand ), |
|
473 |
TTimeIntervalMicroSeconds32( 0 ), |
|
474 |
TCallBack( StaticPowerOnCallback, this ) ); |
|
475 |
} |
|
476 |
else |
|
477 |
{ |
|
478 |
iRadioTimer->Start( TTimeIntervalMicroSeconds32( KRadioRadioSwitchDelay * KRadioThousand ), |
|
479 |
TTimeIntervalMicroSeconds32( 0 ), |
|
480 |
TCallBack( StaticPowerOffCallback, this ) ); |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
else if ( aPowerOn && |
|
485 |
iRadioInitializationState == ERadioUtilitiesConstructed && |
|
486 |
iRadioEnabled && |
|
487 |
OkToPlay( iSettings->EngineSettings().TunedFrequency() ) ) |
|
488 |
{ |
|
489 |
iTunerUtility->RequestTunerControl(); |
|
490 |
} |
|
491 |
else |
|
492 |
{ |
|
493 |
LOG( "CRadioEngineImp::SwitchPower - Unhandled case" ); |
|
494 |
LOG_FORMAT( "PowerOn: %d, InitializationState: %d, Enabled: %d, Frequency: %d", |
|
495 |
aPowerOn, iRadioInitializationState, iRadioEnabled, iSettings->EngineSettings().TunedFrequency() ); |
|
496 |
} |
|
497 |
} |
|
498 |
||
499 |
// --------------------------------------------------------------------------- |
|
500 |
// Executes the power switch |
|
501 |
// --------------------------------------------------------------------------- |
|
502 |
// |
|
503 |
TInt CRadioEngineImp::StaticPowerOnCallback( TAny* aSelfPtr ) |
|
504 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
505 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 506 |
CRadioEngineImp* self = reinterpret_cast<CRadioEngineImp*>( aSelfPtr ); |
507 |
||
508 |
if ( self ) |
|
509 |
{ |
|
510 |
self->iRadioTimer->Cancel(); // prevents the further calls. |
|
511 |
||
512 |
if ( !self->iSettings->EngineSettings().IsPowerOn() ) |
|
513 |
{ |
|
514 |
self->PowerOn(); |
|
515 |
} |
|
516 |
} |
|
517 |
||
518 |
return KErrNone; |
|
519 |
} |
|
520 |
||
521 |
// --------------------------------------------------------------------------- |
|
522 |
// Executes the power switch |
|
523 |
// --------------------------------------------------------------------------- |
|
524 |
// |
|
525 |
TInt CRadioEngineImp::StaticPowerOffCallback( TAny* aSelfPtr ) |
|
526 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
527 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 528 |
CRadioEngineImp* self = reinterpret_cast<CRadioEngineImp*>( aSelfPtr ); |
529 |
||
530 |
if ( self ) |
|
531 |
{ |
|
532 |
self->iRadioTimer->Cancel(); // prevents the further calls. |
|
533 |
||
534 |
if ( self->iSettings->EngineSettings().IsPowerOn() ) |
|
535 |
{ |
|
536 |
self->PowerOff(); |
|
537 |
} |
|
538 |
} |
|
539 |
||
540 |
return KErrNone; |
|
541 |
} |
|
542 |
||
543 |
// --------------------------------------------------------------------------- |
|
544 |
// |
|
545 |
// --------------------------------------------------------------------------- |
|
546 |
// |
|
547 |
void CRadioEngineImp::PowerOn() |
|
548 |
{ |
|
549 |
LOG_METHOD_AUTO; |
|
550 |
||
551 |
if ( RadioInitialized() && |
|
552 |
iRadioEnabled && |
|
553 |
OkToPlay( iSettings->EngineSettings().TunedFrequency() ) ) |
|
554 |
{ |
|
555 |
SetAudioMode( iSettings->EngineSettings().OutputMode() ); |
|
556 |
iPlayerUtility->SetVolumeRamp( TTimeIntervalMicroSeconds( MAKE_TINT64( 0, KRadioMillion ) ) ); |
|
557 |
iPlayerUtility->SetVolume( TunerVolumeForUiVolume( iSettings->EngineSettings().Volume() ) ); |
|
558 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
559 |
iPlayerUtility->Mute( iSettings->EngineSettings().IsVolMuted() ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
560 |
iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
24 | 561 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
562 |
||
563 |
TRAP_IGNORE( iAudioRouter->SetAudioRouteL( |
|
564 |
RadioEngine::TRadioAudioRoute( iSettings->EngineSettings().AudioRoute() ) ) ) |
|
565 |
||
566 |
iPlayerUtility->Play(); |
|
567 |
} |
|
568 |
else |
|
569 |
{ |
|
570 |
HandlePowerEvent( EFalse, KErrGeneral ); |
|
571 |
} |
|
572 |
} |
|
573 |
||
574 |
// --------------------------------------------------------------------------- |
|
575 |
// Radio power off |
|
576 |
// --------------------------------------------------------------------------- |
|
577 |
// |
|
578 |
void CRadioEngineImp::PowerOff() |
|
579 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
580 |
LOG_METHOD_AUTO; |
24 | 581 |
|
582 |
if ( iSettings->EngineSettings().IsPowerOn() ) |
|
583 |
{ |
|
584 |
if ( RadioInitialized() ) |
|
585 |
{ |
|
586 |
iPlayerUtility->Stop(); |
|
587 |
} |
|
588 |
else // This shouldn't occur normally, just a recovery action |
|
589 |
{ |
|
590 |
HandlePowerEvent( EFalse, KErrNone ); |
|
591 |
} |
|
592 |
} |
|
593 |
} |
|
594 |
||
595 |
// --------------------------------------------------------------------------- |
|
596 |
// |
|
597 |
// --------------------------------------------------------------------------- |
|
598 |
// |
|
599 |
TBool CRadioEngineImp::OkToPlay( TUint32 aFrequency ) const |
|
600 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
601 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 602 |
TBool audioResourcesAvailable = iSystemEventCollector->IsAudioResourcesAvailable(); |
603 |
TBool okToPlay = iAntennaAttached && |
|
604 |
!iFmTransmitterActive && |
|
605 |
( audioResourcesAvailable || iOverrideAudioResources ) && |
|
606 |
#ifdef COMPILE_IN_IVALO |
|
607 |
IsFrequencyValid( aFrequency ) |
|
608 |
&& !iSystemEventCollector->IsCallActive(); |
|
609 |
#else |
|
610 |
IsFrequencyValid( aFrequency ); |
|
611 |
#endif //COMPILE_IN_IVALO |
|
612 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
613 |
LEVEL2( LOG_FORMAT( "returning okToPlay %d ", okToPlay ) ); |
24 | 614 |
return okToPlay; |
615 |
} |
|
616 |
||
617 |
// --------------------------------------------------------------------------- |
|
618 |
// |
|
619 |
// --------------------------------------------------------------------------- |
|
620 |
// |
|
621 |
TBool CRadioEngineImp::IsFrequencyValid( TUint32 aFrequency ) const |
|
622 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
623 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 624 |
TBool ret( EFalse ); |
625 |
if ( !aFrequency ) |
|
626 |
{ |
|
627 |
aFrequency = iSettings->EngineSettings().TunedFrequency(); |
|
628 |
} |
|
629 |
if ( aFrequency >= iSettings->EngineSettings().MinFrequency() && aFrequency <= iSettings->EngineSettings().MaxFrequency() ) |
|
630 |
{ |
|
631 |
ret = ETrue; |
|
632 |
} |
|
633 |
return ret; |
|
634 |
} |
|
635 |
||
636 |
// --------------------------------------------------------------------------- |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
637 |
// |
24 | 638 |
// --------------------------------------------------------------------------- |
639 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
640 |
void CRadioEngineImp::SetManualSeekMode( TBool aManualSeekActive ) |
24 | 641 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
642 |
iManualSeekMode = aManualSeekActive; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
643 |
if ( iManualSeekMode ) |
24 | 644 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
645 |
CancelSeek(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
646 |
iRdsReceiver->StopReceiver(); |
24 | 647 |
} |
648 |
else |
|
649 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
650 |
iRdsReceiver->StartReceiver(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
651 |
TInt frequency = 0; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
652 |
iTunerUtility->GetFrequency( frequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
653 |
HandleFrequencyEvent( frequency ); |
24 | 654 |
} |
655 |
} |
|
656 |
||
657 |
// --------------------------------------------------------------------------- |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
658 |
// |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
659 |
// --------------------------------------------------------------------------- |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
660 |
// |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
661 |
TBool CRadioEngineImp::IsInManualSeekMode() const |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
662 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
663 |
return iManualSeekMode; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
664 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
665 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
666 |
// --------------------------------------------------------------------------- |
24 | 667 |
// Radio tuning |
668 |
// --------------------------------------------------------------------------- |
|
669 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
670 |
void CRadioEngineImp::SetFrequency( TUint32 aFrequency, RadioEngine::TRadioFrequencyEventReason aReason ) |
24 | 671 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
672 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
673 |
LEVEL2( LOG_FORMAT( "freq: %u, Initialized: %d, Enabled: %d", |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
674 |
aFrequency, RadioInitialized(), iRadioEnabled ) ); |
24 | 675 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
676 |
iFreqEventReason = aReason; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
677 |
if ( iManualSeekMode ) |
24 | 678 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
679 |
iTunerUtility->SetFrequency( aFrequency ); |
24 | 680 |
} |
681 |
else |
|
682 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
683 |
iFrequencySetByRdsAf = EFalse; |
24 | 684 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
685 |
TInt frequency = 0; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
686 |
if ( iTunerUtility ) |
24 | 687 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
688 |
iTunerUtility->GetFrequency( frequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
689 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
690 |
CancelSeek(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
691 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
692 |
if ( aFrequency == frequency ) //radio has already the frequency to be set. |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
693 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
694 |
LOG( "CRadioEngineImp::SetFrequency: Already at the requested frequency" ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
695 |
HandleFrequencyEvent( aFrequency ); |
24 | 696 |
} |
697 |
else |
|
698 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
699 |
iRadioTimer->Cancel(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
700 |
if ( RadioInitialized() && iRadioEnabled && OkToPlay( aFrequency ) ) |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
701 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
702 |
LOG( "CRadioEngineImp::SetFrequency: Tuning to frequency" ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
703 |
iTunerUtility->SetFrequency( aFrequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
704 |
} |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
705 |
else |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
706 |
{ |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
707 |
HandleFrequencyEvent( aFrequency ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
708 |
} |
24 | 709 |
} |
710 |
} |
|
711 |
} |
|
712 |
||
713 |
// --------------------------------------------------------------------------- |
|
714 |
// Radio seek |
|
715 |
// --------------------------------------------------------------------------- |
|
716 |
// |
|
717 |
void CRadioEngineImp::Seek( RadioEngine::TRadioTuneDirection aDirection ) |
|
718 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
719 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
720 |
LOG_FORMAT( "aDirection: %d",aDirection ); |
24 | 721 |
|
722 |
iFrequencySetByRdsAf = EFalse; |
|
723 |
||
724 |
// Check if audio playing parameters ( other than frequency ) are OK |
|
725 |
if ( iRadioEnabled && |
|
726 |
OkToPlay( iSettings->EngineSettings().MinFrequency() ) && |
|
727 |
iSeekingState == RadioEngine::ERadioNotSeeking ) |
|
728 |
{ |
|
729 |
if ( aDirection == RadioEngine::ERadioDown ) |
|
730 |
{ |
|
731 |
iSeekingState = RadioEngine::ERadioSeekingDown; |
|
732 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonSeekDown; |
|
733 |
} |
|
734 |
else |
|
735 |
{ |
|
736 |
iSeekingState = RadioEngine::ERadioSeekingUp; |
|
737 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonSeekUp; |
|
738 |
} |
|
739 |
||
740 |
NotifyRadioEvent( ERadioEventSeeking ); |
|
741 |
||
742 |
if ( IsFrequencyValid() ) |
|
743 |
{ |
|
744 |
if ( iSettings->EngineSettings().IsPowerOn() ) |
|
745 |
{ |
|
746 |
iTunerUtility->StationSeek( aDirection == RadioEngine::ERadioUp ? ETrue : EFalse ); |
|
747 |
} |
|
748 |
else |
|
749 |
{ |
|
750 |
// Try to switch power on ( reinitialization ) |
|
751 |
SwitchPower( ETrue ); |
|
752 |
} |
|
753 |
} |
|
754 |
else |
|
755 |
{ |
|
756 |
// Tune first to valid frequency, start seeking after radio power is on |
|
757 |
SetFrequency( iSettings->EngineSettings().MinFrequency(), RadioEngine::ERadioFrequencyEventReasonImplicit ); |
|
758 |
} |
|
759 |
} |
|
760 |
else |
|
761 |
{ |
|
762 |
NotifyRadioEvent( ERadioEventSeeking, KErrGeneral ); |
|
763 |
} |
|
764 |
} |
|
765 |
||
766 |
// --------------------------------------------------------------------------- |
|
767 |
// Cancels seek up/down request |
|
768 |
// --------------------------------------------------------------------------- |
|
769 |
// |
|
770 |
void CRadioEngineImp::CancelSeek() |
|
771 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
772 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
773 |
LOG_FORMAT( "seeking state was:%d", iSeekingState ); |
24 | 774 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
775 |
if ( iSeekingState != RadioEngine::ERadioNotSeeking ) |
24 | 776 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
777 |
iSeekingState = RadioEngine::ERadioNotSeeking; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
778 |
iTunerUtility->CancelStationSeek(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
779 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
780 |
NotifyRadioEvent( ERadioEventSeeking, KErrCancel ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
781 |
NotifyRadioEvent( ERadioEventFrequency, KErrNone ); // Notify the observers even if the frequency remains the same. |
24 | 782 |
} |
783 |
} |
|
784 |
||
785 |
// --------------------------------------------------------------------------- |
|
786 |
// |
|
787 |
// --------------------------------------------------------------------------- |
|
788 |
// |
|
789 |
RadioEngine::TRadioSeeking CRadioEngineImp::Seeking() const |
|
790 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
791 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 792 |
return iSeekingState; |
793 |
} |
|
794 |
||
795 |
// --------------------------------------------------------------------------- |
|
796 |
// Sets volume level up/down one step. |
|
797 |
// --------------------------------------------------------------------------- |
|
798 |
// |
|
799 |
void CRadioEngineImp::AdjustVolume( RadioEngine::TRadioVolumeSetDirection aDirection ) |
|
800 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
801 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
802 |
LOG_FORMAT( "aDirection: %d ", aDirection ); |
24 | 803 |
|
804 |
if ( iSettings->EngineSettings().IsPowerOn() ) |
|
805 |
{ |
|
806 |
TInt volume = iSettings->EngineSettings().Volume(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
807 |
LOG_FORMAT( "volume = ( %d )", volume ); |
24 | 808 |
|
809 |
if ( aDirection == RadioEngine::ERadioDecVolume ) |
|
810 |
{ |
|
811 |
TInt min = iSettings->EngineSettings().DefaultMinVolumeLevel(); |
|
812 |
if ( --volume < min ) |
|
813 |
{ |
|
814 |
volume = min; |
|
815 |
} |
|
816 |
} |
|
817 |
else if ( aDirection == RadioEngine::ERadioIncVolume ) |
|
818 |
{ |
|
819 |
TInt max = MaxVolumeLevel(); |
|
820 |
||
821 |
if ( ++volume > max ) |
|
822 |
{ |
|
823 |
volume = max; |
|
824 |
} |
|
825 |
} |
|
826 |
else |
|
827 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
828 |
LOG( "Unhandled case" ); |
24 | 829 |
} |
830 |
SetVolume( volume ); |
|
831 |
} |
|
832 |
} |
|
833 |
||
834 |
// --------------------------------------------------------------------------- |
|
835 |
// Sets audio volume level |
|
836 |
// --------------------------------------------------------------------------- |
|
837 |
// |
|
838 |
void CRadioEngineImp::SetVolume( TInt aVolume ) |
|
839 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
840 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
841 |
LOG_FORMAT( "aVolume: %d", aVolume ); |
24 | 842 |
|
843 |
if ( iSettings->EngineSettings().IsPowerOn() && RadioInitialized() ) |
|
844 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
845 |
LOG( "Setting volume to player utility" ); |
24 | 846 |
|
847 |
if ( aVolume == 0 ) |
|
848 |
{ |
|
849 |
SetVolumeMuted( ETrue ); |
|
850 |
} |
|
851 |
else |
|
852 |
{ |
|
853 |
if ( iSettings->EngineSettings().IsVolMuted() ) |
|
854 |
{ |
|
855 |
SetVolumeMuted( EFalse ); |
|
856 |
} |
|
857 |
else if ( iPlayerUtility->SetVolume( TunerVolumeForUiVolume( aVolume ) ) == KErrNone ) |
|
858 |
{ |
|
859 |
iSettings->RadioSetter().SetVolume( aVolume ); |
|
860 |
NotifyRadioEvent( ERadioEventVolume, KErrNone ); |
|
861 |
} |
|
862 |
} |
|
863 |
} |
|
864 |
} |
|
865 |
||
866 |
// --------------------------------------------------------------------------- |
|
867 |
// Set radio audio muted/unmuted |
|
868 |
// --------------------------------------------------------------------------- |
|
869 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
870 |
void CRadioEngineImp::SetVolumeMuted( TBool aMuteState, TBool aUpdateSettings ) |
24 | 871 |
{ |
872 |
LOG_METHOD_AUTO; |
|
873 |
LOG_FORMAT( "MuteState = %d", aMuteState ); |
|
874 |
||
875 |
if ( iSettings->EngineSettings().IsPowerOn() ) |
|
876 |
{ |
|
877 |
TInt err = KErrNone; |
|
878 |
if ( RadioInitialized() ) |
|
879 |
{ |
|
880 |
err = iPlayerUtility->Mute( aMuteState ); |
|
881 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
882 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
883 |
if ( aUpdateSettings ) |
24 | 884 |
{ |
885 |
err = iSettings->RadioSetter().SetVolMuted( aMuteState ); |
|
886 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
887 |
NotifyRadioEvent( ERadioEventMute, err ); |
24 | 888 |
} |
889 |
} |
|
890 |
||
891 |
// --------------------------------------------------------------------------- |
|
892 |
// |
|
893 |
// --------------------------------------------------------------------------- |
|
894 |
// |
|
895 |
TBool CRadioEngineImp::IsAntennaAttached() |
|
896 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
897 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
898 |
LEVEL3( LOG_FORMAT( "returning iAntennaAttached: %d", iAntennaAttached ) ); |
24 | 899 |
return iAntennaAttached; |
900 |
} |
|
901 |
||
902 |
// --------------------------------------------------------------------------- |
|
903 |
// |
|
904 |
// --------------------------------------------------------------------------- |
|
905 |
// |
|
906 |
TBool CRadioEngineImp::IsFmTransmitterActive() const |
|
907 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
908 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
909 |
LEVEL3( LOG_FORMAT( "returning iFmTransmitterActive: %d", iFmTransmitterActive ) ); |
24 | 910 |
return iFmTransmitterActive; |
911 |
} |
|
912 |
||
913 |
// --------------------------------------------------------------------------- |
|
914 |
// This function is usable only in WINS emulator. |
|
915 |
// --------------------------------------------------------------------------- |
|
916 |
// |
|
917 |
void CRadioEngineImp::SetAntennaAttached( TBool aAntennaAttached ) |
|
918 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
919 |
LOG_METHOD_AUTO; |
24 | 920 |
#ifdef __WINS__ |
921 |
MrftoAntennaStatusChange( aAntennaAttached ); |
|
922 |
#endif |
|
923 |
} |
|
924 |
||
925 |
// --------------------------------------------------------------------------- |
|
926 |
// If CRadioPlayerUtility has 10 steps, CAknVolumeControl has also 10 steps and also |
|
927 |
// the maximum volume level of Visual radio is 10. Otherwise CRadioPlayerUtility has |
|
928 |
// 200 steps, and CAknVolumeControl has 20 steps, so maximum volume level of Visual radio |
|
929 |
// is 20. |
|
930 |
// --------------------------------------------------------------------------- |
|
931 |
// |
|
932 |
TInt CRadioEngineImp::MaxVolumeLevel() const |
|
933 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
934 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 935 |
TInt maxLevel = 0; |
936 |
||
937 |
#if defined __WINS__ |
|
938 |
maxLevel = KRadioVolumeStepsOld; |
|
939 |
#else |
|
940 |
if ( RadioInitialized() ) |
|
941 |
{ |
|
942 |
iPlayerUtility->GetMaxVolume( maxLevel ); |
|
943 |
} |
|
944 |
#endif //defined __WINS__ |
|
945 |
||
946 |
if ( maxLevel > KRadioVolumeStepsDividinglimit ) |
|
947 |
{ |
|
948 |
maxLevel = maxLevel / KRadioVolumeStepsDivider; |
|
949 |
} |
|
950 |
||
951 |
return maxLevel; |
|
952 |
} |
|
953 |
||
954 |
// --------------------------------------------------------------------------- |
|
955 |
// |
|
956 |
// --------------------------------------------------------------------------- |
|
957 |
// |
|
958 |
TBool CRadioEngineImp::FrequencySetByRdsAf() const |
|
959 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
960 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 961 |
return iFrequencySetByRdsAf; |
962 |
} |
|
963 |
||
964 |
// --------------------------------------------------------------------------- |
|
965 |
// |
|
966 |
// --------------------------------------------------------------------------- |
|
967 |
// |
|
968 |
MRadioRdsReceiver& CRadioEngineImp::RdsReceiver() |
|
969 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
970 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 971 |
return *iRdsReceiver; |
972 |
} |
|
973 |
||
974 |
// --------------------------------------------------------------------------- |
|
975 |
// |
|
976 |
// --------------------------------------------------------------------------- |
|
977 |
// |
|
978 |
TInt CRadioEngineImp::TunerVolumeForUiVolume( TInt aUiVolume ) |
|
979 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
980 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 981 |
TInt vol = aUiVolume * KRadioVolumeStepsDivider; |
982 |
||
983 |
return vol; |
|
984 |
} |
|
985 |
||
986 |
// --------------------------------------------------------------------------- |
|
987 |
// |
|
988 |
// --------------------------------------------------------------------------- |
|
989 |
// |
|
990 |
void CRadioEngineImp::NotifyRadioEvent( TInt aRadioEvent, TInt aErrorCode ) |
|
991 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
992 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 993 |
TRAP_IGNORE( DoNotifyRadioEventL( aRadioEvent, aErrorCode ) ) |
994 |
} |
|
995 |
||
996 |
// --------------------------------------------------------------------------- |
|
997 |
// Notifies all the registered observers of radio events |
|
998 |
// by sending notifications to observers. |
|
999 |
// --------------------------------------------------------------------------- |
|
1000 |
// |
|
1001 |
void CRadioEngineImp::DoNotifyRadioEventL( TInt aRadioEvent, TInt aErrorCode ) |
|
1002 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1003 |
LOG_METHOD_AUTO; |
24 | 1004 |
TInt count = iObservers.Count(); |
1005 |
||
1006 |
for ( TInt i = 0; i<count; i++) |
|
1007 |
{ |
|
1008 |
MRadioEngineObserver * observer = iObservers[i]; |
|
1009 |
||
1010 |
switch ( aRadioEvent ) |
|
1011 |
{ |
|
1012 |
case ERadioEventPower: |
|
1013 |
{ |
|
1014 |
observer->PowerEventL( iSettings->EngineSettings().IsPowerOn(), aErrorCode ); |
|
1015 |
break; |
|
1016 |
} |
|
1017 |
case ERadioEventFrequency: |
|
1018 |
{ |
|
1019 |
observer->FrequencyEventL( iSettings->EngineSettings().TunedFrequency(), |
|
1020 |
iFreqEventReason, aErrorCode ); |
|
1021 |
break; |
|
1022 |
} |
|
1023 |
case ERadioEventVolume: |
|
1024 |
{ |
|
1025 |
observer->VolumeEventL( iSettings->EngineSettings().Volume(), aErrorCode ); |
|
1026 |
break; |
|
1027 |
} |
|
1028 |
case ERadioEventMute: |
|
1029 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1030 |
observer->MuteEventL( iSettings->EngineSettings().IsVolMuted(), aErrorCode ); |
24 | 1031 |
break; |
1032 |
} |
|
1033 |
case ERadioEventAudioMode: |
|
1034 |
{ |
|
1035 |
observer->AudioModeEventL( iSettings->EngineSettings().OutputMode(), aErrorCode ); |
|
1036 |
break; |
|
1037 |
} |
|
1038 |
case ERadioEventAntenna: |
|
1039 |
{ |
|
1040 |
observer->AntennaEventL( iAntennaAttached, aErrorCode ); |
|
1041 |
break; |
|
1042 |
} |
|
1043 |
case ERadioEventAudioRouting: |
|
1044 |
{ |
|
1045 |
observer->AudioRoutingEventL( iSettings->EngineSettings().AudioRoute(), aErrorCode ); |
|
1046 |
break; |
|
1047 |
} |
|
1048 |
case ERadioEventSeeking: |
|
1049 |
{ |
|
1050 |
observer->SeekingEventL( iSeekingState, aErrorCode ); |
|
1051 |
break; |
|
1052 |
} |
|
1053 |
case ERadioEventRegion: |
|
1054 |
{ |
|
1055 |
observer->RegionEventL( iSettings->EngineSettings().RegionId(), aErrorCode ); |
|
1056 |
break; |
|
1057 |
} |
|
1058 |
case ERadioEventFmTransmitter: |
|
1059 |
{ |
|
1060 |
observer->FmTransmitterEventL( iFmTransmitterActive ); |
|
1061 |
break; |
|
1062 |
} |
|
1063 |
default: |
|
1064 |
{ |
|
1065 |
break; |
|
1066 |
} |
|
1067 |
} |
|
1068 |
} |
|
1069 |
} |
|
1070 |
||
1071 |
// --------------------------------------------------------------------------- |
|
1072 |
// Handles some system events |
|
1073 |
// --------------------------------------------------------------------------- |
|
1074 |
// |
|
1075 |
void CRadioEngineImp::HandleSystemEventL( TRadioSystemEventType aEventType ) |
|
1076 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1077 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1078 |
LOG_FORMAT( "aEventType = %d", aEventType ); |
24 | 1079 |
|
1080 |
switch ( aEventType ) |
|
1081 |
{ |
|
1082 |
case ERadioAudioResourcesAvailable: |
|
1083 |
{ |
|
1084 |
LOG( "CRadioEngineImp::HandleSystemEventL, Audio resources available" ); |
|
1085 |
SwitchPower( ETrue ); |
|
1086 |
} |
|
1087 |
break; |
|
1088 |
||
1089 |
case ERadioAudioAutoResumeForbidden: |
|
1090 |
{ |
|
1091 |
EnableAudio( EFalse ); |
|
1092 |
} |
|
1093 |
break; |
|
1094 |
||
1095 |
case ERadioAudioRouteHeadset: |
|
1096 |
{ |
|
1097 |
HandleAudioRoutingEvent( RadioEngine::ERadioHeadset ); |
|
1098 |
} |
|
1099 |
break; |
|
1100 |
||
1101 |
case ERadioAudioRouteSpeaker: |
|
1102 |
{ |
|
1103 |
HandleAudioRoutingEvent( RadioEngine::ERadioSpeaker ); |
|
1104 |
} |
|
1105 |
break; |
|
1106 |
||
1107 |
case ERadioCallActivated: |
|
1108 |
{ |
|
1109 |
CancelSeek(); |
|
1110 |
} |
|
1111 |
break; |
|
1112 |
||
1113 |
case ERadioCallDeactivated: |
|
1114 |
{ |
|
1115 |
SwitchPower( ETrue ); |
|
1116 |
} |
|
1117 |
break; |
|
1118 |
||
1119 |
case ERadioHeadsetConnected: |
|
1120 |
{ |
|
1121 |
// Explicitly set the audio routing to headset. Because system |
|
1122 |
// forces the routing to headset anyway, and without our knowledge. |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1123 |
MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1124 |
setter.SetAudioRoute( RadioEngine::ERadioHeadset ); |
24 | 1125 |
iAudioRouter->SetAudioRouteL( RadioEngine::ERadioHeadset ); |
1126 |
} |
|
1127 |
break; |
|
1128 |
||
1129 |
case ERadioHeadsetDisconnected: |
|
1130 |
{ |
|
1131 |
// Explicitly set the audio routing to speaker. Because system |
|
1132 |
// forces the routing to speaker anyway, if radio stays on. |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1133 |
MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1134 |
setter.SetAudioRoute( RadioEngine::ERadioSpeaker ); |
24 | 1135 |
iAudioRouter->SetAudioRouteL( RadioEngine::ERadioSpeaker ); |
1136 |
} |
|
1137 |
break; |
|
1138 |
default: |
|
1139 |
{ |
|
1140 |
break; |
|
1141 |
} |
|
1142 |
} |
|
1143 |
} |
|
1144 |
||
1145 |
// --------------------------------------------------------------------------- |
|
1146 |
// |
|
1147 |
// --------------------------------------------------------------------------- |
|
1148 |
// |
|
1149 |
void CRadioEngineImp::MrftoRequestTunerControlComplete( TInt aError ) |
|
1150 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1151 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1152 |
LOG_FORMAT( "aError: %d", aError ); |
24 | 1153 |
|
1154 |
if ( aError == KErrNone || aError == KErrAlreadyExists ) // Tuner activated now or was already active |
|
1155 |
{ |
|
1156 |
iRadioInitializationState = ERadioTunerControlGranted; |
|
1157 |
||
1158 |
TFmTunerCapabilities tunerCaps; |
|
1159 |
tunerCaps.iTunerBands = 0; |
|
1160 |
tunerCaps.iTunerFunctions = 0; |
|
1161 |
tunerCaps.iAdditionalFunctions1 = 0; |
|
1162 |
tunerCaps.iAdditionalFunctions2 = 0; |
|
1163 |
iTunerUtility->GetCapabilities( tunerCaps ); |
|
1164 |
||
1165 |
#ifdef LOGGING_ENABLED |
|
1166 |
TBuf<50> tunerCapsBuf; |
|
1167 |
if ( tunerCaps.ETunerAvailableInOfflineMode ) |
|
1168 |
{ |
|
1169 |
tunerCapsBuf.Append( _L("OfflineMode ") ); |
|
1170 |
} |
|
1171 |
if ( tunerCaps.ETunerRdsSupport ) |
|
1172 |
{ |
|
1173 |
tunerCapsBuf.Append( _L("RDS ") ); |
|
1174 |
} |
|
1175 |
if ( tunerCaps.ETunerDualTunerSupport ) |
|
1176 |
{ |
|
1177 |
tunerCapsBuf.Append( _L("DualTuner ") ); |
|
1178 |
} |
|
1179 |
LOG_FORMAT( "Radio tuner capabilities: %S", &tunerCapsBuf ); |
|
1180 |
||
1181 |
#endif // LOGGING_ENABLED |
|
1182 |
||
1183 |
TBool offlineAvailable( tunerCaps.iTunerFunctions & |
|
1184 |
TFmTunerCapabilities::ETunerAvailableInOfflineMode ); |
|
1185 |
iTunerUtility->EnableTunerInOfflineMode( offlineAvailable ); |
|
1186 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1187 |
if ( tunerCaps.iTunerFunctions & TFmTunerCapabilities::ETunerRdsSupport ) |
24 | 1188 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1189 |
TRAP_IGNORE( iRdsReceiver->InitL( *iRadioUtility ) ) |
24 | 1190 |
} |
1191 |
||
1192 |
iTunerUtility->SetFrequencyRange( TunerFrequencyRangeForRegionId( |
|
1193 |
iSettings->EngineSettings().RegionId() ) ); |
|
1194 |
// To prevent false frequency changes |
|
1195 |
iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
|
1196 |
SwitchPower( ETrue ); |
|
1197 |
} |
|
1198 |
} |
|
1199 |
||
1200 |
// --------------------------------------------------------------------------- |
|
1201 |
// |
|
1202 |
// --------------------------------------------------------------------------- |
|
1203 |
// |
|
1204 |
void CRadioEngineImp::MrftoSetFrequencyRangeComplete( TInt aError ) |
|
1205 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1206 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1207 |
LEVEL3( LOG_FORMAT( "aError: %d", aError ) ); |
24 | 1208 |
if ( aError ) |
1209 |
{ |
|
1210 |
NotifyRadioEvent( ERadioEventRegion, aError ); |
|
1211 |
} |
|
1212 |
} |
|
1213 |
||
1214 |
// --------------------------------------------------------------------------- |
|
1215 |
// |
|
1216 |
// --------------------------------------------------------------------------- |
|
1217 |
// |
|
1218 |
void CRadioEngineImp::MrftoSetFrequencyComplete( TInt aError ) |
|
1219 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1220 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1221 |
LOG_FORMAT( "aError: %d", aError ); |
24 | 1222 |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1223 |
if ( aError && !iManualSeekMode ) |
24 | 1224 |
{ |
1225 |
if ( aError == KErrNotReady ) |
|
1226 |
{ |
|
1227 |
iRadioInitializationState = ERadioUtilitiesConstructed; |
|
1228 |
} |
|
1229 |
HandleFrequencyEvent( iSettings->EngineSettings().TunedFrequency(), aError ); |
|
1230 |
} |
|
1231 |
} |
|
1232 |
||
1233 |
// --------------------------------------------------------------------------- |
|
1234 |
// |
|
1235 |
// --------------------------------------------------------------------------- |
|
1236 |
// |
|
1237 |
void CRadioEngineImp::MrftoStationSeekComplete( TInt aError, TInt aFrequency ) |
|
1238 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1239 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1240 |
LOG_FORMAT( "aError = %d, aFrequency = %d", aError, aFrequency ); |
24 | 1241 |
// Seeking has ended, error code tells if it was successful |
1242 |
||
1243 |
if ( aError == KFmRadioErrAntennaNotConnected ) |
|
1244 |
{ |
|
1245 |
iAntennaAttached = EFalse; |
|
1246 |
} |
|
1247 |
else if ( aError == KErrNotReady ) |
|
1248 |
{ |
|
1249 |
iRadioInitializationState = ERadioUtilitiesConstructed; |
|
1250 |
} |
|
1251 |
||
1252 |
iSeekingState = RadioEngine::ERadioNotSeeking; |
|
1253 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1254 |
if ( aFrequency == 0 ) { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1255 |
NotifyRadioEvent( ERadioEventFrequency, aError ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1256 |
} |
24 | 1257 |
|
1258 |
// if ( aError != KErrNone ) |
|
1259 |
// { |
|
1260 |
// iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
|
1261 |
// NotifyRadioEvent( ERadioEventFrequency, KErrNone ); // Frequency change is not otherwise notified when seeking fails. |
|
1262 |
// } |
|
1263 |
// else |
|
1264 |
// { |
|
1265 |
// // sometimes frequency change is not reported even if seeking succeeds |
|
1266 |
// if ( !iFrequencySetByRdsAf ) |
|
1267 |
// { |
|
1268 |
// NotifyRadioEvent( ERadioEventFrequency, KErrNone ); |
|
1269 |
// } |
|
1270 |
// } |
|
1271 |
} |
|
1272 |
||
1273 |
// --------------------------------------------------------------------------- |
|
1274 |
// |
|
1275 |
// --------------------------------------------------------------------------- |
|
1276 |
// |
|
1277 |
void CRadioEngineImp::MrftoFmTransmitterStatusChange( TBool aActive ) |
|
1278 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1279 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1280 |
LOG_FORMAT( "aActive: %d", aActive ); |
24 | 1281 |
iFmTransmitterActive = aActive; |
1282 |
||
1283 |
if ( !iFmTransmitterActive ) |
|
1284 |
{ |
|
1285 |
SwitchPower( ETrue ); |
|
1286 |
} |
|
1287 |
||
1288 |
NotifyRadioEvent( ERadioEventFmTransmitter ); |
|
1289 |
} |
|
1290 |
||
1291 |
// --------------------------------------------------------------------------- |
|
1292 |
// |
|
1293 |
// --------------------------------------------------------------------------- |
|
1294 |
// |
|
1295 |
void CRadioEngineImp::MrftoAntennaStatusChange( TBool aAttached ) |
|
1296 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1297 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1298 |
LOG_FORMAT( "aAttached: %d", aAttached ); |
24 | 1299 |
iAntennaAttached = aAttached; |
1300 |
if ( iAntennaAttached ) |
|
1301 |
{ |
|
1302 |
SwitchPower( ETrue ); |
|
1303 |
NotifyRadioEvent( ERadioEventAntenna ); |
|
1304 |
} |
|
1305 |
else |
|
1306 |
{ |
|
1307 |
NotifyRadioEvent( ERadioEventAntenna, KErrDisconnected ); |
|
1308 |
} |
|
1309 |
} |
|
1310 |
||
1311 |
// --------------------------------------------------------------------------- |
|
1312 |
// |
|
1313 |
// --------------------------------------------------------------------------- |
|
1314 |
||
1315 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1316 |
void CRadioEngineImp::MrftoOfflineModeStatusChange( TBool DEBUGVAR3( aOfflineMode ) ) |
24 | 1317 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1318 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1319 |
LEVEL3( LOG_FORMAT( "aOfflineMode: %d", aOfflineMode ) ); |
24 | 1320 |
} |
1321 |
||
1322 |
// --------------------------------------------------------------------------- |
|
1323 |
// |
|
1324 |
// --------------------------------------------------------------------------- |
|
1325 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1326 |
void CRadioEngineImp::MrftoFrequencyRangeChange( TFmRadioFrequencyRange DEBUGVAR3( aBand ) ) |
24 | 1327 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1328 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1329 |
LEVEL3( LOG_FORMAT( "aBand: %d", aBand ) ); |
24 | 1330 |
if ( RadioInitialized() ) |
1331 |
{ |
|
1332 |
iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
|
1333 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
|
1334 |
} |
|
1335 |
NotifyRadioEvent( ERadioEventRegion ); |
|
1336 |
} |
|
1337 |
||
1338 |
// --------------------------------------------------------------------------- |
|
1339 |
// |
|
1340 |
// --------------------------------------------------------------------------- |
|
1341 |
// |
|
1342 |
void CRadioEngineImp::MrftoFrequencyChange( TInt aNewFrequency ) |
|
1343 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1344 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1345 |
LEVEL3( LOG_FORMAT( "aNewFrequency = %u", aNewFrequency ) ); |
24 | 1346 |
|
1347 |
// There may be frequency changed events when radio is not initialized ( because |
|
1348 |
// of SetFrequency or Seek returns with KErrNotReady ). |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1349 |
if ( !iManualSeekMode && RadioInitialized() ) |
24 | 1350 |
{ |
1351 |
HandleFrequencyEvent( aNewFrequency ); |
|
1352 |
} |
|
1353 |
} |
|
1354 |
||
1355 |
// --------------------------------------------------------------------------- |
|
1356 |
// |
|
1357 |
// --------------------------------------------------------------------------- |
|
1358 |
// |
|
1359 |
void CRadioEngineImp::MrftoForcedMonoChange( TBool aForcedMono ) |
|
1360 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1361 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1362 |
LEVEL3( LOG_FORMAT( "aForcedMono = %d", aForcedMono ) ); |
24 | 1363 |
|
1364 |
iSettings->RadioSetter().SetOutputMode( aForcedMono ? RadioEngine::ERadioMono : RadioEngine::ERadioStereo ); |
|
1365 |
NotifyRadioEvent( ERadioEventAudioMode ); |
|
1366 |
} |
|
1367 |
||
1368 |
// --------------------------------------------------------------------------- |
|
1369 |
// |
|
1370 |
// --------------------------------------------------------------------------- |
|
1371 |
// |
|
1372 |
void CRadioEngineImp::MrftoSquelchChange( TBool /*aSquelch*/ ) |
|
1373 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1374 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1375 |
} |
1376 |
||
1377 |
// --------------------------------------------------------------------------- |
|
1378 |
// |
|
1379 |
// --------------------------------------------------------------------------- |
|
1380 |
// |
|
1381 |
void CRadioEngineImp::MrpoStateChange( TPlayerState aState, TInt aError ) |
|
1382 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1383 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1384 |
LEVEL3( LOG_FORMAT( "aState = %d, aError = %d", aState, aError ) ); |
24 | 1385 |
|
1386 |
if ( aError == KFmRadioErrAntennaNotConnected ) |
|
1387 |
{ |
|
1388 |
iAntennaAttached = EFalse; |
|
1389 |
} |
|
1390 |
HandlePowerEvent( aState == ERadioPlayerPlaying, aError ); |
|
1391 |
} |
|
1392 |
||
1393 |
// --------------------------------------------------------------------------- |
|
1394 |
// |
|
1395 |
// --------------------------------------------------------------------------- |
|
1396 |
// |
|
1397 |
void CRadioEngineImp::MrpoVolumeChange( TInt aVolume ) |
|
1398 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1399 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1400 |
aVolume = aVolume / KRadioVolumeStepsDivider; |
24 | 1401 |
if ( aVolume != iSettings->EngineSettings().Volume() ) |
1402 |
{ |
|
1403 |
iSettings->RadioSetter().SetVolume( aVolume ); |
|
1404 |
NotifyRadioEvent( ERadioEventVolume ); |
|
1405 |
} |
|
1406 |
} |
|
1407 |
||
1408 |
// --------------------------------------------------------------------------- |
|
1409 |
// |
|
1410 |
// --------------------------------------------------------------------------- |
|
1411 |
// |
|
1412 |
void CRadioEngineImp::MrpoMuteChange( TBool aMute ) |
|
1413 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1414 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1415 |
TBool muted = iSettings->EngineSettings().IsVolMuted(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1416 |
if ( !aMute != !muted ) |
24 | 1417 |
{ |
1418 |
iSettings->RadioSetter().SetVolMuted( aMute ); |
|
1419 |
NotifyRadioEvent( ERadioEventMute ); |
|
1420 |
} |
|
1421 |
} |
|
1422 |
||
1423 |
// --------------------------------------------------------------------------- |
|
1424 |
// |
|
1425 |
// --------------------------------------------------------------------------- |
|
1426 |
// |
|
1427 |
void CRadioEngineImp::MrpoBalanceChange( TInt /*aLeftPercentage*/, TInt /*aRightPercentage*/ ) |
|
1428 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1429 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1430 |
} |
1431 |
||
1432 |
// --------------------------------------------------------------------------- |
|
1433 |
// |
|
1434 |
// --------------------------------------------------------------------------- |
|
1435 |
// |
|
1436 |
void CRadioEngineImp::RdsAfSearchSettingChangedL( TBool aEnabled ) |
|
1437 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1438 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1439 |
LEVEL3( LOG_FORMAT( "aEnabled: %d", aEnabled ) ); |
24 | 1440 |
iRdsReceiver->SetAutomaticSwitchingL( aEnabled ); |
1441 |
} |
|
1442 |
||
1443 |
// --------------------------------------------------------------------------- |
|
1444 |
// |
|
1445 |
// --------------------------------------------------------------------------- |
|
1446 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1447 |
//TODO: Check if this can be removed. Radio doesn't currently support changing regions on the fly |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1448 |
void CRadioEngineImp::RegionSettingChangedL( TInt DEBUGVAR3( aRegion ) ) |
24 | 1449 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1450 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1451 |
LEVEL3( LOG_FORMAT( "aRegion: %d", aRegion ) ); |
24 | 1452 |
|
1453 |
if ( RadioInitialized() ) |
|
1454 |
{ |
|
1455 |
iTunerUtility->SetFrequencyRange( TunerFrequencyRangeForRegionId( iSettings->EngineSettings().RegionId() ) ); |
|
1456 |
iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
|
1457 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
|
1458 |
} |
|
1459 |
} |
|
1460 |
||
1461 |
// --------------------------------------------------------------------------- |
|
1462 |
// |
|
1463 |
// --------------------------------------------------------------------------- |
|
1464 |
// |
|
1465 |
void CRadioEngineImp::RdsAfSearchBegin() |
|
1466 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1467 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1468 |
iFrequencySetByRdsAf = ETrue; |
1469 |
} |
|
1470 |
||
1471 |
// --------------------------------------------------------------------------- |
|
1472 |
// |
|
1473 |
// --------------------------------------------------------------------------- |
|
1474 |
// |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1475 |
void CRadioEngineImp::RdsAfSearchEnd( TUint32 DEBUGVAR3( aFrequency ), TInt aError ) |
24 | 1476 |
{ |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1477 |
LEVEL3( LOG_METHOD_AUTO ); |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1478 |
LEVEL3( LOG_FORMAT( "aFrequency: %d, aError: %d )", aFrequency, aError ) ); |
24 | 1479 |
if ( aError != KErrNone ) |
1480 |
{ |
|
1481 |
iFrequencySetByRdsAf = EFalse; |
|
1482 |
} |
|
1483 |
} |
|
1484 |
||
1485 |
// --------------------------------------------------------------------------- |
|
1486 |
// Tries to figure the region out based on current mobile network id |
|
1487 |
// --------------------------------------------------------------------------- |
|
1488 |
// |
|
1489 |
TRadioRegion CRadioEngineImp::RegionFromMobileNetwork() const |
|
1490 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1491 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1492 |
TRadioRegion region = ERadioRegionNone; |
1493 |
||
1494 |
// Choose the frequency range according to country code |
|
1495 |
MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1496 |
TPtrC countryCode = engineSettings.CountryCode(); |
24 | 1497 |
const TInt regionCount = engineSettings.CountRegions(); |
1498 |
TBool matchFound = EFalse; |
|
1499 |
for ( TInt i = 0; i < regionCount && !matchFound; ++i ) |
|
1500 |
{ |
|
1501 |
const RRadioCountryCodeArray& regionCountryCodes = |
|
1502 |
engineSettings.Region( i ).CountryCodes(); |
|
1503 |
||
1504 |
const TInt countryCodeCount = regionCountryCodes.Count(); |
|
1505 |
for ( TInt j = 0; j < countryCodeCount && !matchFound; ++j ) |
|
1506 |
{ |
|
1507 |
if ( countryCode == *regionCountryCodes[j] ) |
|
1508 |
{ |
|
1509 |
// We have a match |
|
1510 |
matchFound = ETrue; |
|
1511 |
region = engineSettings.Region( i ).Id(); |
|
1512 |
} |
|
1513 |
} |
|
1514 |
} |
|
1515 |
||
1516 |
return region; |
|
1517 |
} |
|
1518 |
||
1519 |
// --------------------------------------------------------------------------- |
|
1520 |
// Tries to figure the region out based on timezone selection |
|
1521 |
// --------------------------------------------------------------------------- |
|
1522 |
// |
|
1523 |
TRadioRegion CRadioEngineImp::RegionFromTimezone() const |
|
1524 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1525 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1526 |
TRadioRegion region = ERadioRegionNone; |
1527 |
TRAP_IGNORE( region = DoRegionFromTimezoneL() ); |
|
1528 |
return region; |
|
1529 |
} |
|
1530 |
||
1531 |
// --------------------------------------------------------------------------- |
|
1532 |
// Performs the timezone-based check |
|
1533 |
// --------------------------------------------------------------------------- |
|
1534 |
// |
|
1535 |
TRadioRegion CRadioEngineImp::DoRegionFromTimezoneL() const |
|
1536 |
{ |
|
1537 |
LOG_METHOD_AUTO; |
|
1538 |
CTzLocalizer* timezoneLocalizer = CTzLocalizer::NewL(); |
|
1539 |
CleanupStack::PushL( timezoneLocalizer ); |
|
1540 |
||
1541 |
CTzLocalizedCityGroupArray* cityGroups = timezoneLocalizer->GetAllCityGroupsL( |
|
1542 |
CTzLocalizer::ETzAlphaNameAscending ); |
|
1543 |
CleanupStack::PushL( cityGroups ); |
|
1544 |
||
1545 |
// We get the ownership so we must delete |
|
1546 |
CTzLocalizedCity* city = timezoneLocalizer->GetFrequentlyUsedZoneCityL( CTzLocalizedTimeZone::ECurrentZone ); |
|
1547 |
const TUint8 cityId = city->GroupId(); |
|
1548 |
delete city; |
|
1549 |
city = NULL; |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1550 |
LOG_FORMAT( "group id: %d", cityId ); |
24 | 1551 |
|
1552 |
TRadioRegion region = ERadioRegionNone; |
|
1553 |
const TInt cityGroupCount = cityGroups->Count(); |
|
1554 |
TBool found = EFalse; |
|
1555 |
for ( TInt i = 0; i < cityGroupCount && !found; ++i ) |
|
1556 |
{ |
|
1557 |
if ( cityId == cityGroups->At( i ).Id() ) |
|
1558 |
{ |
|
1559 |
region = static_cast<TRadioRegion>( KCityGroupRegions[ cityId - 1 ] ); |
|
1560 |
found = ETrue; |
|
1561 |
} |
|
1562 |
} |
|
1563 |
||
1564 |
CleanupStack::PopAndDestroy( cityGroups ); |
|
1565 |
CleanupStack::PopAndDestroy( timezoneLocalizer ); |
|
1566 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1567 |
LOG_ASSERT( found, LOG_FORMAT( "City not found: %d", cityId ) ); |
24 | 1568 |
|
1569 |
return region; |
|
1570 |
} |
|
1571 |
||
1572 |
// --------------------------------------------------------------------------- |
|
1573 |
// |
|
1574 |
// --------------------------------------------------------------------------- |
|
1575 |
// |
|
1576 |
void CRadioEngineImp::HandleAudioRoutingEvent( RadioEngine::TRadioAudioRoute aDestination ) |
|
1577 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1578 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1579 |
LOG_FORMAT( "aDestination: %d", aDestination ); |
24 | 1580 |
|
1581 |
// Make modifications to volume ONLY if new audio source state |
|
1582 |
// differs from settings. If they don't differ, this state |
|
1583 |
// change is a part of the radio initialization. |
|
1584 |
MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
|
1585 |
if ( aDestination != iSettings->EngineSettings().AudioRoute() ) |
|
1586 |
{ |
|
1587 |
setter.SetAudioRoute( aDestination ); |
|
1588 |
||
1589 |
// If audio muted, change it to minimum volume |
|
1590 |
MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
|
1591 |
TInt vol = engineSettings.IsVolMuted() ? engineSettings.DefaultMinVolumeLevel() |
|
1592 |
: engineSettings.Volume(); |
|
1593 |
||
1594 |
if ( RadioInitialized() ) |
|
1595 |
{ |
|
1596 |
TInt err = iPlayerUtility->Mute( EFalse ); |
|
1597 |
if ( !err ) |
|
1598 |
{ |
|
1599 |
setter.SetVolMuted( EFalse ); |
|
1600 |
err = iPlayerUtility->SetVolume( TunerVolumeForUiVolume( vol )); |
|
1601 |
||
1602 |
if ( !err ) |
|
1603 |
{ |
|
1604 |
setter.SetVolume( vol ); |
|
1605 |
} |
|
1606 |
} |
|
1607 |
} |
|
1608 |
else |
|
1609 |
{ |
|
1610 |
setter.SetVolMuted( EFalse ); |
|
1611 |
setter.SetVolume( vol ); |
|
1612 |
} |
|
1613 |
NotifyRadioEvent( ERadioEventAudioRouting ); |
|
1614 |
} |
|
1615 |
} |
|
1616 |
||
1617 |
// --------------------------------------------------------------------------- |
|
1618 |
// |
|
1619 |
// --------------------------------------------------------------------------- |
|
1620 |
// |
|
1621 |
void CRadioEngineImp::HandlePowerEvent( TBool aPowerOn, TInt aErrorCode ) |
|
1622 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1623 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1624 |
LOG_FORMAT( "aPowerOn: %d, aErrorCode: %d )", aPowerOn, aErrorCode ); |
24 | 1625 |
|
1626 |
const TBool powerState = iSettings->EngineSettings().IsPowerOn(); |
|
1627 |
if ( !powerState != !aPowerOn ) |
|
1628 |
{ |
|
1629 |
iSettings->RadioSetter().SetPowerOn( aPowerOn ); |
|
1630 |
||
1631 |
if ( aPowerOn ) |
|
1632 |
{ |
|
1633 |
iRdsReceiver->StartReceiver(); |
|
1634 |
} |
|
1635 |
else |
|
1636 |
{ |
|
1637 |
iRdsReceiver->StopReceiver(); |
|
1638 |
} |
|
1639 |
} |
|
1640 |
||
1641 |
if ( !iSettings->EngineSettings().IsPowerOn() ) |
|
1642 |
{ |
|
1643 |
CancelSeek(); |
|
1644 |
} |
|
1645 |
||
1646 |
// If we are seeking, power event starts seeking |
|
1647 |
if ( iSeekingState != RadioEngine::ERadioNotSeeking && iSettings->EngineSettings().IsPowerOn() ) |
|
1648 |
{ |
|
1649 |
// Reset seeking state to enable seeking start |
|
1650 |
RadioEngine::TRadioSeeking oldSeeking = iSeekingState; |
|
1651 |
iSeekingState = RadioEngine::ERadioNotSeeking; |
|
1652 |
Seek( oldSeeking == RadioEngine::ERadioSeekingUp ? RadioEngine::ERadioUp : RadioEngine::ERadioDown ); |
|
1653 |
} |
|
1654 |
||
1655 |
if ( !powerState != !aPowerOn ) |
|
1656 |
{ |
|
1657 |
NotifyRadioEvent( ERadioEventPower, aErrorCode ); |
|
1658 |
} |
|
1659 |
} |
|
1660 |
||
1661 |
// --------------------------------------------------------------------------- |
|
1662 |
// |
|
1663 |
// --------------------------------------------------------------------------- |
|
1664 |
// |
|
1665 |
void CRadioEngineImp::HandleFrequencyEvent( TUint32 aFrequency, TInt aErrorCode ) |
|
1666 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1667 |
LOG_METHOD_AUTO; |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1668 |
LOG_FORMAT( "aFrequency: %d, aErrorCode: %d )", aFrequency, aErrorCode ); |
24 | 1669 |
|
1670 |
if ( iSettings->EngineSettings().TunedFrequency() != aFrequency ) |
|
1671 |
{ |
|
1672 |
if ( iSettings->EngineSettings().IsPowerOn() ) |
|
1673 |
{ |
|
1674 |
if ( !OkToPlay( aFrequency ) ) |
|
1675 |
{ |
|
1676 |
// Radio is going to be powered off, stop rds receiver immediately because |
|
1677 |
// some rds data from previous channel might come before power off event. |
|
1678 |
iRdsReceiver->StopReceiver(); |
|
1679 |
} |
|
1680 |
else |
|
1681 |
{ |
|
1682 |
// Normal frequency change, make sure that rds receiver is started |
|
1683 |
iRdsReceiver->StartReceiver(); |
|
1684 |
} |
|
1685 |
} |
|
1686 |
if ( !iFrequencySetByRdsAf ) |
|
1687 |
{ |
|
1688 |
iRdsReceiver->ClearRdsInformation(); |
|
1689 |
} |
|
1690 |
} |
|
1691 |
else if ( iFrequencySetByRdsAf ) |
|
1692 |
{ |
|
1693 |
// frequency didn't change, so AF search didn't complete successfully |
|
1694 |
iFrequencySetByRdsAf = EFalse; |
|
1695 |
} |
|
1696 |
||
1697 |
iSettings->RadioSetter().SetTunedFrequency( aFrequency ); |
|
1698 |
||
1699 |
NotifyRadioEvent( ERadioEventFrequency, aErrorCode ); |
|
1700 |
iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonUnknown; |
|
1701 |
||
1702 |
if ( aErrorCode == KErrNone ) |
|
1703 |
{ |
|
1704 |
SwitchPower( iRadioEnabled && OkToPlay( aFrequency ) ); |
|
1705 |
} |
|
1706 |
} |
|
1707 |
||
1708 |
// --------------------------------------------------------------------------- |
|
1709 |
// Routing is not possible when headset is not available, power is off or |
|
1710 |
// audio routing is not supported. |
|
1711 |
// --------------------------------------------------------------------------- |
|
1712 |
// |
|
1713 |
TBool CRadioEngineImp::IsAudioRoutingPossible() const |
|
1714 |
{ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
1715 |
LEVEL3( LOG_METHOD_AUTO ); |
24 | 1716 |
TBool headsetConnected = EFalse; |
1717 |
TRAP_IGNORE( ( headsetConnected = iSystemEventCollector->IsHeadsetConnectedL() ) ) |
|
1718 |
||
1719 |
TBool powerOn = iSettings->EngineSettings().IsPowerOn(); |
|
1720 |
||
1721 |
TBool isAudioRoutingPossible = EFalse; |
|
1722 |
if ( headsetConnected && powerOn && AudioRoutingSupported() ) |
|
1723 |
{ |
|
1724 |
isAudioRoutingPossible = ETrue; |
|
1725 |
} |
|
1726 |
||
1727 |
return isAudioRoutingPossible; |
|
1728 |
} |
|
1729 |