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