22 #include <badesca.h> |
22 #include <badesca.h> |
23 #include <tzlocalizer.h> |
23 #include <tzlocalizer.h> |
24 |
24 |
25 // User includes |
25 // User includes |
26 #include "cradioenginelogger.h" |
26 #include "cradioenginelogger.h" |
27 #include "radiointernalpskeys.h" |
|
28 #include "radiointernalcrkeys.h" |
27 #include "radiointernalcrkeys.h" |
29 #include "cradioaudiorouter.h" |
28 #include "cradioaudiorouter.h" |
30 #include "cradiopubsub.h" |
|
31 #include "cradioengineimp.h" |
29 #include "cradioengineimp.h" |
32 #include "mradioengineobserver.h" |
30 #include "mradioengineobserver.h" |
33 #include "mradioscanobserver.h" |
|
34 #include "cradioregion.h" |
31 #include "cradioregion.h" |
35 #include "cradiosettings.h" |
32 #include "cradiosettings.h" |
36 #include "mradioenginesettings.h" |
33 #include "mradioenginesettings.h" |
37 #include "mradiosettingssetter.h" |
34 #include "mradiosettingssetter.h" |
38 #include "cradiorepositorymanager.h" |
|
39 #include "cradiordsreceiver.h" |
35 #include "cradiordsreceiver.h" |
40 #include "cradiosystemeventcollector.h" |
36 #include "cradiosystemeventcollector.h" |
41 #include "cradionetworkinfolistener.h" |
37 #include "cradionetworkinfolistener.h" |
42 #include "radioengine.hrh" |
38 #include "radioengine.hrh" |
43 |
39 #include "cradioenginelogger.h" |
44 #include "../../group/buildflags.hrh" |
40 |
45 #ifdef __FEATURE_RDS_SIMULATOR |
41 // This has to be the last include. |
46 # include "t_cradiordsreceiversimulator.h" |
42 #ifdef STUB_CONSTELLATION |
47 #endif |
43 # include <RadioStubManager.h> |
|
44 #endif //STUB_CONSTELLATION |
48 |
45 |
49 // Constants |
46 // Constants |
50 |
47 |
51 /** The limit of volume steps that must not be divided */ |
48 /** The limit of volume steps that must not be divided */ |
52 const TInt KRadioVolumeStepsDividinglimit = 20; |
49 const TInt KRadioVolumeStepsDividinglimit = 20; |
169 { |
162 { |
170 iSystemEventCollector->RemoveObserver( this ); |
163 iSystemEventCollector->RemoveObserver( this ); |
171 } |
164 } |
172 delete iSystemEventCollector; |
165 delete iSystemEventCollector; |
173 |
166 |
174 delete iPubSub; |
|
175 |
|
176 if ( iSettings ) |
167 if ( iSettings ) |
177 { |
168 { |
178 iSettings->RadioSetter().SetObserver( NULL ); |
169 iSettings->RadioSetter().SetObserver( NULL ); |
179 } |
170 } |
180 delete iSettings; |
171 delete iSettings; |
181 |
172 |
182 LOG( "CRadioEngineImp::~CRadioEngineImp -- End" ); |
|
183 } |
173 } |
184 |
174 |
185 // --------------------------------------------------------------------------- |
175 // --------------------------------------------------------------------------- |
186 // |
176 // |
187 // --------------------------------------------------------------------------- |
177 // --------------------------------------------------------------------------- |
188 // |
178 // |
189 void CRadioEngineImp::SetSystemEventCollector( CRadioSystemEventCollector* aCollector ) |
179 void CRadioEngineImp::SetSystemEventCollector( CRadioSystemEventCollector* aCollector ) |
190 { |
180 { |
|
181 LEVEL3( LOG_METHOD_AUTO ); |
191 iSystemEventCollector = aCollector; |
182 iSystemEventCollector = aCollector; |
192 } |
183 } |
193 |
184 |
194 // --------------------------------------------------------------------------- |
185 // --------------------------------------------------------------------------- |
195 // |
186 // |
196 // --------------------------------------------------------------------------- |
187 // --------------------------------------------------------------------------- |
197 // |
188 // |
198 void CRadioEngineImp::SetRadioSettings( CRadioSettings* aSettings ) |
189 void CRadioEngineImp::SetRadioSettings( CRadioSettings* aSettings ) |
199 { |
190 { |
|
191 LEVEL3( LOG_METHOD_AUTO ); |
200 iSettings = aSettings; |
192 iSettings = aSettings; |
201 iSettings->RadioSetter().SetObserver( this ); |
193 iSettings->RadioSetter().SetObserver( this ); |
202 } |
194 } |
203 |
195 |
204 // --------------------------------------------------------------------------- |
196 // --------------------------------------------------------------------------- |
205 // |
197 // |
206 // --------------------------------------------------------------------------- |
198 // --------------------------------------------------------------------------- |
207 // |
199 // |
208 void CRadioEngineImp::SetRadioPubSub( CRadioPubSub* aPubSub ) |
|
209 { |
|
210 iPubSub = aPubSub; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 CRadioAudioRouter& CRadioEngineImp::AudioRouter() const |
200 CRadioAudioRouter& CRadioEngineImp::AudioRouter() const |
218 { |
201 { |
|
202 LEVEL3( LOG_METHOD_AUTO ); |
219 return *iAudioRouter; |
203 return *iAudioRouter; |
220 } |
204 } |
221 |
205 |
222 // --------------------------------------------------------------------------- |
206 // --------------------------------------------------------------------------- |
223 // |
207 // |
224 // --------------------------------------------------------------------------- |
208 // --------------------------------------------------------------------------- |
225 // |
209 // |
226 CRadioSystemEventCollector& CRadioEngineImp::SystemEventCollector() const |
210 CRadioSystemEventCollector& CRadioEngineImp::SystemEventCollector() const |
227 { |
211 { |
|
212 LEVEL3( LOG_METHOD_AUTO ); |
228 return *iSystemEventCollector; |
213 return *iSystemEventCollector; |
229 } |
214 } |
230 |
215 |
231 // --------------------------------------------------------------------------- |
216 // --------------------------------------------------------------------------- |
232 // |
217 // |
233 // --------------------------------------------------------------------------- |
218 // --------------------------------------------------------------------------- |
234 // |
219 // |
235 CRadioSettings& CRadioEngineImp::Settings() const |
220 CRadioSettings& CRadioEngineImp::Settings() const |
236 { |
221 { |
|
222 LEVEL3( LOG_METHOD_AUTO ); |
237 return *iSettings; |
223 return *iSettings; |
238 } |
224 } |
239 |
225 |
240 // --------------------------------------------------------------------------- |
226 // --------------------------------------------------------------------------- |
241 // |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 CRadioPubSub* CRadioEngineImp::PubSub() const |
|
245 { |
|
246 return iPubSub; |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // Determines radio region |
227 // Determines radio region |
251 // --------------------------------------------------------------------------- |
228 // --------------------------------------------------------------------------- |
252 // |
229 // |
253 TRadioRegion CRadioEngineImp::DetermineRegion() |
230 TRadioRegion CRadioEngineImp::DetermineRegion() |
254 { |
231 { |
|
232 LEVEL3( LOG_METHOD_AUTO ); |
255 TRadioRegion region = ERadioRegionNone; |
233 TRadioRegion region = ERadioRegionNone; |
256 |
234 |
257 MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
235 MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
258 if ( iSystemEventCollector->IsMobileNetworkCoverage() ) |
236 if ( iSystemEventCollector->IsMobileNetworkCoverage() ) |
259 { |
237 { |
287 // --------------------------------------------------------------------------- |
265 // --------------------------------------------------------------------------- |
288 // Initializes / reinitializes the radio. If this is not called |
266 // Initializes / reinitializes the radio. If this is not called |
289 // the radio is not functional |
267 // the radio is not functional |
290 // --------------------------------------------------------------------------- |
268 // --------------------------------------------------------------------------- |
291 // |
269 // |
292 void CRadioEngineImp::InitRadioL( TInt aRegionId, CRadioPubSub* aPubSub ) |
270 void CRadioEngineImp::InitRadioL( TInt aRegionId ) |
293 { |
271 { |
294 LOG_METHOD_AUTO; |
272 LOG_METHOD_AUTO; |
295 LOG_FORMAT( "CRadioEngineImp::InitRadioL: Region: %d", aRegionId ); |
273 LOG_FORMAT( "Region: %d", aRegionId ); |
296 |
274 |
297 iRadioInitializationState = ERadioNotInitialized; |
275 iRadioInitializationState = ERadioNotInitialized; |
298 |
|
299 iPubSub = aPubSub; |
|
300 |
276 |
301 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonUnknown; |
277 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonUnknown; |
302 if ( iSettings->EngineSettings().RegionId() != aRegionId ) |
278 if ( iSettings->EngineSettings().RegionId() != aRegionId ) |
303 { |
279 { |
304 // Change only when necessary as it changes also the default tuned frequency |
280 // Change only when necessary as it changes also the default tuned frequency |
333 // |
309 // |
334 // --------------------------------------------------------------------------- |
310 // --------------------------------------------------------------------------- |
335 // |
311 // |
336 TBool CRadioEngineImp::RadioInitialized() const |
312 TBool CRadioEngineImp::RadioInitialized() const |
337 { |
313 { |
|
314 LEVEL3( LOG_METHOD_AUTO ); |
338 return iRadioInitializationState == ERadioTunerControlGranted; |
315 return iRadioInitializationState == ERadioTunerControlGranted; |
339 } |
316 } |
340 |
317 |
341 // --------------------------------------------------------------------------- |
318 // --------------------------------------------------------------------------- |
342 // Sets the state for radio audio |
319 // Sets the state for radio audio |
343 // --------------------------------------------------------------------------- |
320 // --------------------------------------------------------------------------- |
344 // |
321 // |
345 void CRadioEngineImp::EnableAudio( TBool aEnable, TBool aDelay ) |
322 void CRadioEngineImp::EnableAudio( TBool aEnable, TBool aDelay ) |
346 { |
323 { |
347 LOG_FORMAT( "CRadioEngineImp::EnableAudio( %d )", aEnable ); |
324 LOG_METHOD_AUTO; |
|
325 LOG_FORMAT( "aEnable %d ", aEnable ); |
348 iRadioEnabled = aEnable; |
326 iRadioEnabled = aEnable; |
349 if ( aDelay ) |
327 if ( aDelay ) |
350 { |
328 { |
351 SwitchPower( iRadioEnabled ); |
329 SwitchPower( iRadioEnabled ); |
352 } |
330 } |
374 // Gets the state for radio audio. |
352 // Gets the state for radio audio. |
375 // --------------------------------------------------------------------------- |
353 // --------------------------------------------------------------------------- |
376 // |
354 // |
377 TBool CRadioEngineImp::RadioAudioEnabled() const |
355 TBool CRadioEngineImp::RadioAudioEnabled() const |
378 { |
356 { |
|
357 LEVEL3( LOG_METHOD_AUTO ); |
379 return iRadioEnabled; |
358 return iRadioEnabled; |
380 } |
359 } |
381 |
360 |
382 // --------------------------------------------------------------------------- |
361 // --------------------------------------------------------------------------- |
383 // Sets the state for audio overriding |
362 // Sets the state for audio overriding |
384 // --------------------------------------------------------------------------- |
363 // --------------------------------------------------------------------------- |
385 // |
364 // |
386 void CRadioEngineImp::SetAudioOverride( TBool aOverride ) |
365 void CRadioEngineImp::SetAudioOverride( TBool aOverride ) |
387 { |
366 { |
388 LOG_FORMAT( "CRadioEngineImp::SetAudioOverride( %d )", aOverride ); |
367 LEVEL3( LOG_METHOD_AUTO ); |
|
368 LEVEL3( LOG_FORMAT( "aOverride %d ", aOverride ) ); |
389 iOverrideAudioResources = aOverride; |
369 iOverrideAudioResources = aOverride; |
390 } |
370 } |
391 |
371 |
392 // --------------------------------------------------------------------------- |
372 // --------------------------------------------------------------------------- |
393 // Adds an observer for the radio state changes notifications. |
373 // Adds an observer for the radio state changes notifications. |
394 // --------------------------------------------------------------------------- |
374 // --------------------------------------------------------------------------- |
395 // |
375 // |
396 void CRadioEngineImp::AddObserverL( MRadioEngineObserver* aObserver ) |
376 void CRadioEngineImp::AddObserverL( MRadioEngineObserver* aObserver ) |
397 { |
377 { |
398 LOG( "CRadioEngineImp::AddObserver" ); |
378 LEVEL3( LOG_METHOD_AUTO ); |
399 TInt index = iObservers.FindInAddressOrder( aObserver ); |
379 TInt index = iObservers.FindInAddressOrder( aObserver ); |
400 if ( index == KErrNotFound ) |
380 if ( index == KErrNotFound ) |
401 { |
381 { |
402 iObservers.InsertInAddressOrderL( aObserver ); |
382 iObservers.InsertInAddressOrderL( aObserver ); |
403 } |
383 } |
571 { |
554 { |
572 SetAudioMode( iSettings->EngineSettings().OutputMode() ); |
555 SetAudioMode( iSettings->EngineSettings().OutputMode() ); |
573 iPlayerUtility->SetVolumeRamp( TTimeIntervalMicroSeconds( MAKE_TINT64( 0, KRadioMillion ) ) ); |
556 iPlayerUtility->SetVolumeRamp( TTimeIntervalMicroSeconds( MAKE_TINT64( 0, KRadioMillion ) ) ); |
574 iPlayerUtility->SetVolume( TunerVolumeForUiVolume( iSettings->EngineSettings().Volume() ) ); |
557 iPlayerUtility->SetVolume( TunerVolumeForUiVolume( iSettings->EngineSettings().Volume() ) ); |
575 |
558 |
576 // If we are about to start scanning, mute the radio and set minimum frequency |
559 iPlayerUtility->Mute( iSettings->EngineSettings().IsVolMuted() ); |
577 if ( iScanObserver ) |
560 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
578 { |
|
579 iPlayerUtility->Mute( ETrue ); |
|
580 iTunerUtility->SetFrequency( iSettings->EngineSettings().MinFrequency() ); |
|
581 } |
|
582 else |
|
583 { |
|
584 iPlayerUtility->Mute( iSettings->EngineSettings().IsVolMuted() ); |
|
585 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
|
586 } |
|
587 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
561 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
588 |
562 |
589 TRAP_IGNORE( iAudioRouter->SetAudioRouteL( |
563 TRAP_IGNORE( iAudioRouter->SetAudioRouteL( |
590 RadioEngine::TRadioAudioRoute( iSettings->EngineSettings().AudioRoute() ) ) ) |
564 RadioEngine::TRadioAudioRoute( iSettings->EngineSettings().AudioRoute() ) ) ) |
591 |
565 |
656 } |
632 } |
657 return ret; |
633 return ret; |
658 } |
634 } |
659 |
635 |
660 // --------------------------------------------------------------------------- |
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 // --------------------------------------------------------------------------- |
|
639 // |
|
640 void CRadioEngineImp::SetManualSeekMode( TBool aManualSeekActive ) |
|
641 { |
|
642 iManualSeekMode = aManualSeekActive; |
|
643 if ( iManualSeekMode ) |
|
644 { |
|
645 CancelSeek(); |
|
646 iRdsReceiver->StopReceiver(); |
|
647 } |
|
648 else |
|
649 { |
|
650 iRdsReceiver->StartReceiver(); |
|
651 TInt frequency = 0; |
|
652 iTunerUtility->GetFrequency( frequency ); |
|
653 HandleFrequencyEvent( frequency ); |
|
654 } |
|
655 } |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // |
|
659 // --------------------------------------------------------------------------- |
|
660 // |
|
661 TBool CRadioEngineImp::IsInManualSeekMode() const |
|
662 { |
|
663 return iManualSeekMode; |
|
664 } |
|
665 |
|
666 // --------------------------------------------------------------------------- |
661 // Radio tuning |
667 // Radio tuning |
662 // --------------------------------------------------------------------------- |
668 // --------------------------------------------------------------------------- |
663 // |
669 // |
664 void CRadioEngineImp::SetFrequency( TUint32 aFrequency, RadioEngine::TRadioFrequencyEventReason aReason ) |
670 void CRadioEngineImp::SetFrequency( TUint32 aFrequency, RadioEngine::TRadioFrequencyEventReason aReason ) |
665 { |
671 { |
666 LOG_METHOD_AUTO; |
672 LEVEL3( LOG_METHOD_AUTO ); |
667 LOG_FORMAT( "CRadioEngineImp::SetFrequency, freq: %u, Initialized: %d, Enabled: %d", |
673 LEVEL2( LOG_FORMAT( "freq: %u, Initialized: %d, Enabled: %d", |
668 aFrequency, RadioInitialized(), iRadioEnabled ); |
674 aFrequency, RadioInitialized(), iRadioEnabled ) ); |
669 |
675 |
670 iFrequencySetByRdsAf = EFalse; |
|
671 iFreqEventReason = aReason; |
676 iFreqEventReason = aReason; |
672 |
677 if ( iManualSeekMode ) |
673 TInt frequency = 0; |
678 { |
674 if ( iTunerUtility ) |
679 iTunerUtility->SetFrequency( aFrequency ); |
675 { |
|
676 iTunerUtility->GetFrequency( frequency ); |
|
677 } |
|
678 CancelSeek(); |
|
679 |
|
680 if ( aFrequency == frequency ) //radio has already the frequency to be set. |
|
681 { |
|
682 LOG( "CRadioEngineImp::SetFrequency: Already at the requested frequency" ); |
|
683 HandleFrequencyEvent( aFrequency ); |
|
684 } |
680 } |
685 else |
681 else |
686 { |
682 { |
687 iRadioTimer->Cancel(); |
683 iFrequencySetByRdsAf = EFalse; |
688 if ( RadioInitialized() && iRadioEnabled && OkToPlay( aFrequency ) ) |
684 |
689 { |
685 TInt frequency = 0; |
690 LOG( "CRadioEngineImp::SetFrequency: Tuning to frequency" ); |
686 if ( iTunerUtility ) |
691 iTunerUtility->SetFrequency( aFrequency ); |
687 { |
|
688 iTunerUtility->GetFrequency( frequency ); |
|
689 } |
|
690 CancelSeek(); |
|
691 |
|
692 if ( aFrequency == frequency ) //radio has already the frequency to be set. |
|
693 { |
|
694 LOG( "CRadioEngineImp::SetFrequency: Already at the requested frequency" ); |
|
695 HandleFrequencyEvent( aFrequency ); |
692 } |
696 } |
693 else |
697 else |
694 { |
698 { |
695 HandleFrequencyEvent( aFrequency ); |
699 iRadioTimer->Cancel(); |
696 } |
700 if ( RadioInitialized() && iRadioEnabled && OkToPlay( aFrequency ) ) |
697 } |
701 { |
698 } |
702 LOG( "CRadioEngineImp::SetFrequency: Tuning to frequency" ); |
699 |
703 iTunerUtility->SetFrequency( aFrequency ); |
700 // --------------------------------------------------------------------------- |
704 } |
701 // Radio tuning |
705 else |
702 // --------------------------------------------------------------------------- |
706 { |
703 // |
707 HandleFrequencyEvent( aFrequency ); |
704 void CRadioEngineImp::SetFrequencyFast( TUint32 aFrequency, |
708 } |
705 RadioEngine::TRadioFrequencyEventReason /*aReason*/ ) |
709 } |
706 { |
710 } |
707 if ( iSeekingState != RadioEngine::ERadioNotSeeking ) |
|
708 { |
|
709 iSeekingState = RadioEngine::ERadioNotSeeking; |
|
710 iTunerUtility->CancelStationSeek(); |
|
711 } |
|
712 iTunerUtility->SetFrequency( aFrequency ); |
|
713 iSettings->RadioSetter().SetTunedFrequency( aFrequency ); |
|
714 } |
|
715 |
|
716 // --------------------------------------------------------------------------- |
|
717 // Frequency stepping |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 void CRadioEngineImp::StepToFrequency( RadioEngine::TRadioTuneDirection aDirection ) |
|
721 { |
|
722 LOG( "CRadioEngineImp::StepToFrequency" ); |
|
723 |
|
724 TUint32 freq = iSettings->EngineSettings().TunedFrequency(); |
|
725 RadioEngine::TRadioFrequencyEventReason reason( RadioEngine::ERadioFrequencyEventReasonUnknown ); |
|
726 if ( aDirection == RadioEngine::ERadioUp ) |
|
727 { |
|
728 freq = freq + iSettings->EngineSettings().FrequencyStepSize(); |
|
729 reason = RadioEngine::ERadioFrequencyEventReasonUp; |
|
730 } |
|
731 else |
|
732 { |
|
733 freq = freq - iSettings->EngineSettings().FrequencyStepSize(); |
|
734 reason = RadioEngine::ERadioFrequencyEventReasonDown; |
|
735 } |
|
736 |
|
737 // Check overflow or underflow |
|
738 if ( IsFrequencyValid( freq ) ) |
|
739 { |
|
740 if ( aDirection == RadioEngine::ERadioUp ) |
|
741 { |
|
742 freq = iSettings->EngineSettings().MinFrequency(); |
|
743 } |
|
744 else |
|
745 { |
|
746 freq = iSettings->EngineSettings().MaxFrequency(); |
|
747 } |
|
748 } |
|
749 SetFrequency( freq, reason ); |
|
750 } |
711 } |
751 |
712 |
752 // --------------------------------------------------------------------------- |
713 // --------------------------------------------------------------------------- |
753 // Radio seek |
714 // Radio seek |
754 // --------------------------------------------------------------------------- |
715 // --------------------------------------------------------------------------- |
755 // |
716 // |
756 void CRadioEngineImp::Seek( RadioEngine::TRadioTuneDirection aDirection ) |
717 void CRadioEngineImp::Seek( RadioEngine::TRadioTuneDirection aDirection ) |
757 { |
718 { |
758 LOG_FORMAT( "CRadioEngineImp::Seek-- Start direction:%d",aDirection ); |
719 LOG_METHOD_AUTO; |
|
720 LOG_FORMAT( "aDirection: %d",aDirection ); |
759 |
721 |
760 iFrequencySetByRdsAf = EFalse; |
722 iFrequencySetByRdsAf = EFalse; |
761 |
723 |
762 // Check if audio playing parameters ( other than frequency ) are OK |
724 // Check if audio playing parameters ( other than frequency ) are OK |
763 if ( iRadioEnabled && |
725 if ( iRadioEnabled && |
796 } |
758 } |
797 } |
759 } |
798 else |
760 else |
799 { |
761 { |
800 NotifyRadioEvent( ERadioEventSeeking, KErrGeneral ); |
762 NotifyRadioEvent( ERadioEventSeeking, KErrGeneral ); |
801 StopScan( KErrGeneral ); |
|
802 } |
763 } |
803 } |
764 } |
804 |
765 |
805 // --------------------------------------------------------------------------- |
766 // --------------------------------------------------------------------------- |
806 // Cancels seek up/down request |
767 // Cancels seek up/down request |
807 // --------------------------------------------------------------------------- |
768 // --------------------------------------------------------------------------- |
808 // |
769 // |
809 void CRadioEngineImp::CancelSeek() |
770 void CRadioEngineImp::CancelSeek() |
810 { |
771 { |
811 LOG_FORMAT( "CRadioEngineImp::CancelSeek -- seeking state was:%d", iSeekingState ); |
772 LOG_METHOD_AUTO; |
812 |
773 LOG_FORMAT( "seeking state was:%d", iSeekingState ); |
813 if ( !iScanObserver ) |
774 |
814 { |
775 if ( iSeekingState != RadioEngine::ERadioNotSeeking ) |
815 if ( iSeekingState != RadioEngine::ERadioNotSeeking ) |
776 { |
816 { |
777 iSeekingState = RadioEngine::ERadioNotSeeking; |
817 iSeekingState = RadioEngine::ERadioNotSeeking; |
778 iTunerUtility->CancelStationSeek(); |
818 iTunerUtility->CancelStationSeek(); |
779 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
819 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
780 NotifyRadioEvent( ERadioEventSeeking, KErrCancel ); |
820 NotifyRadioEvent( ERadioEventSeeking, KErrCancel ); |
781 NotifyRadioEvent( ERadioEventFrequency, KErrNone ); // Notify the observers even if the frequency remains the same. |
821 NotifyRadioEvent( ERadioEventFrequency, KErrNone ); // Notify the observers even if the frequency remains the same. |
|
822 } |
|
823 } |
|
824 else |
|
825 { |
|
826 StopScan( KErrCancel ); |
|
827 } |
782 } |
828 } |
783 } |
829 |
784 |
830 // --------------------------------------------------------------------------- |
785 // --------------------------------------------------------------------------- |
831 // |
786 // |
832 // --------------------------------------------------------------------------- |
787 // --------------------------------------------------------------------------- |
833 // |
788 // |
834 RadioEngine::TRadioSeeking CRadioEngineImp::Seeking() const |
789 RadioEngine::TRadioSeeking CRadioEngineImp::Seeking() const |
835 { |
790 { |
|
791 LEVEL3( LOG_METHOD_AUTO ); |
836 return iSeekingState; |
792 return iSeekingState; |
837 } |
793 } |
838 |
794 |
839 // --------------------------------------------------------------------------- |
795 // --------------------------------------------------------------------------- |
840 // Starts scanning all available stations from the minimum frequency |
|
841 // --------------------------------------------------------------------------- |
|
842 // |
|
843 void CRadioEngineImp::StartScan( MRadioScanObserver& aObserver ) |
|
844 { |
|
845 LOG( "CRadioEngineImp::StartScan" ); |
|
846 |
|
847 const TUint32 minFrequency = iSettings->EngineSettings().MinFrequency(); |
|
848 if ( !iScanObserver && iRadioEnabled && RadioInitialized() && OkToPlay( minFrequency ) ) |
|
849 { |
|
850 CancelSeek(); |
|
851 iScanObserver = &aObserver; |
|
852 iPreviousMuteState = iSettings->EngineSettings().IsVolMuted(); |
|
853 iPreviousScannedFrequency = 0; |
|
854 iPlayerUtility->Mute( ETrue ); |
|
855 iTunerUtility->SetFrequency( minFrequency ); |
|
856 Seek( RadioEngine::ERadioUp ); |
|
857 } |
|
858 else |
|
859 { |
|
860 TInt error = iScanObserver ? KErrAlreadyExists : KErrNotReady; |
|
861 TRAP_IGNORE( aObserver.ScanCompletedEventL( error ) ) |
|
862 } |
|
863 } |
|
864 |
|
865 // --------------------------------------------------------------------------- |
|
866 // Stops any scans currently in progress. |
|
867 // --------------------------------------------------------------------------- |
|
868 // |
|
869 void CRadioEngineImp::StopScan( TInt aError ) |
|
870 { |
|
871 LOG_FORMAT( "CRadioEngineImp::StopScan, error: %d", aError ); |
|
872 if ( iScanObserver ) |
|
873 { |
|
874 if ( iSeekingState != RadioEngine::ERadioNotSeeking ) |
|
875 { |
|
876 iSeekingState = RadioEngine::ERadioNotSeeking; |
|
877 if ( RadioInitialized() ) |
|
878 { |
|
879 iTunerUtility->CancelStationSeek(); |
|
880 } |
|
881 } |
|
882 |
|
883 iPreviousScannedFrequency = 0; |
|
884 MRadioScanObserver& observer = *iScanObserver; |
|
885 iScanObserver = NULL; |
|
886 NotifyRadioScanEvent( ERadioEventScanCompleted, observer, aError ); |
|
887 |
|
888 if ( !OkToPlay( iSettings->EngineSettings().MinFrequency() ) ) |
|
889 { |
|
890 // Try to reset the frequency as sometimes extra frequency event occurs after seeking |
|
891 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
|
892 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
|
893 } |
|
894 |
|
895 if ( iPlayerUtility && OkToPlay( iSettings->EngineSettings().TunedFrequency() ) ) |
|
896 { |
|
897 iPlayerUtility->Mute( iPreviousMuteState ); |
|
898 } |
|
899 } |
|
900 } |
|
901 |
|
902 // --------------------------------------------------------------------------- |
|
903 // Sets volume level up/down one step. |
796 // Sets volume level up/down one step. |
904 // --------------------------------------------------------------------------- |
797 // --------------------------------------------------------------------------- |
905 // |
798 // |
906 void CRadioEngineImp::AdjustVolume( RadioEngine::TRadioVolumeSetDirection aDirection ) |
799 void CRadioEngineImp::AdjustVolume( RadioEngine::TRadioVolumeSetDirection aDirection ) |
907 { |
800 { |
908 LOG_FORMAT( "CRadioEngineImp::AdjustVolume( %d )", aDirection ); |
801 LOG_METHOD_AUTO; |
|
802 LOG_FORMAT( "aDirection: %d ", aDirection ); |
909 |
803 |
910 if ( iSettings->EngineSettings().IsPowerOn() ) |
804 if ( iSettings->EngineSettings().IsPowerOn() ) |
911 { |
805 { |
912 TInt volume = iSettings->EngineSettings().Volume(); |
806 TInt volume = iSettings->EngineSettings().Volume(); |
913 LOG_FORMAT( "CRadioEngineImp::AdjustVolume volume = ( %d )", volume ); |
807 LOG_FORMAT( "volume = ( %d )", volume ); |
914 |
808 |
915 if ( aDirection == RadioEngine::ERadioDecVolume ) |
809 if ( aDirection == RadioEngine::ERadioDecVolume ) |
916 { |
810 { |
917 TInt min = iSettings->EngineSettings().DefaultMinVolumeLevel(); |
811 TInt min = iSettings->EngineSettings().DefaultMinVolumeLevel(); |
918 if ( --volume < min ) |
812 if ( --volume < min ) |
970 |
865 |
971 // --------------------------------------------------------------------------- |
866 // --------------------------------------------------------------------------- |
972 // Set radio audio muted/unmuted |
867 // Set radio audio muted/unmuted |
973 // --------------------------------------------------------------------------- |
868 // --------------------------------------------------------------------------- |
974 // |
869 // |
975 void CRadioEngineImp::SetVolumeMuted( TBool aMuteState ) |
870 void CRadioEngineImp::SetVolumeMuted( TBool aMuteState, TBool aUpdateSettings ) |
976 { |
871 { |
977 LOG_METHOD_AUTO; |
872 LOG_METHOD_AUTO; |
978 LOG_FORMAT( "MuteState = %d", aMuteState ); |
873 LOG_FORMAT( "MuteState = %d", aMuteState ); |
979 |
874 |
980 if ( iSettings->EngineSettings().IsPowerOn() ) |
875 if ( iSettings->EngineSettings().IsPowerOn() ) |
981 { |
876 { |
982 TInt err = KErrNone; |
877 TInt err = KErrNone; |
983 if ( RadioInitialized() ) |
878 if ( RadioInitialized() ) |
984 { |
879 { |
985 err = iPlayerUtility->Mute( aMuteState ); |
880 err = iPlayerUtility->Mute( aMuteState ); |
986 iSettings->RadioSetter().SetVolMuted( aMuteState ); |
881 } |
987 NotifyRadioEvent( ERadioEventMute, err ); |
882 |
988 } |
883 if ( aUpdateSettings ) |
989 else |
|
990 { |
884 { |
991 err = iSettings->RadioSetter().SetVolMuted( aMuteState ); |
885 err = iSettings->RadioSetter().SetVolMuted( aMuteState ); |
992 NotifyRadioEvent( ERadioEventMute, err ); |
886 } |
993 } |
887 NotifyRadioEvent( ERadioEventMute, err ); |
994 } |
888 } |
995 } |
889 } |
996 |
890 |
997 // --------------------------------------------------------------------------- |
891 // --------------------------------------------------------------------------- |
998 // |
892 // |
999 // --------------------------------------------------------------------------- |
893 // --------------------------------------------------------------------------- |
1000 // |
894 // |
1001 TBool CRadioEngineImp::IsAntennaAttached() |
895 TBool CRadioEngineImp::IsAntennaAttached() |
1002 { |
896 { |
1003 LOG_FORMAT( "CRadioEngineImp::IsAntennaAttached, returning %d", iAntennaAttached ); |
897 LEVEL3( LOG_METHOD_AUTO ); |
|
898 LEVEL3( LOG_FORMAT( "returning iAntennaAttached: %d", iAntennaAttached ) ); |
1004 return iAntennaAttached; |
899 return iAntennaAttached; |
1005 } |
900 } |
1006 |
901 |
1007 // --------------------------------------------------------------------------- |
902 // --------------------------------------------------------------------------- |
1008 // |
903 // |
1009 // --------------------------------------------------------------------------- |
904 // --------------------------------------------------------------------------- |
1010 // |
905 // |
1011 TBool CRadioEngineImp::IsFmTransmitterActive() const |
906 TBool CRadioEngineImp::IsFmTransmitterActive() const |
1012 { |
907 { |
1013 LOG_FORMAT( "CRadioEngineImp::IsFmTransmitterActive, returning %d", iFmTransmitterActive ); |
908 LEVEL3( LOG_METHOD_AUTO ); |
|
909 LEVEL3( LOG_FORMAT( "returning iFmTransmitterActive: %d", iFmTransmitterActive ) ); |
1014 return iFmTransmitterActive; |
910 return iFmTransmitterActive; |
1015 } |
911 } |
1016 |
912 |
1017 // --------------------------------------------------------------------------- |
913 // --------------------------------------------------------------------------- |
1018 // This function is usable only in WINS emulator. |
914 // This function is usable only in WINS emulator. |
1019 // --------------------------------------------------------------------------- |
915 // --------------------------------------------------------------------------- |
1020 // |
916 // |
1021 void CRadioEngineImp::SetAntennaAttached( TBool aAntennaAttached ) |
917 void CRadioEngineImp::SetAntennaAttached( TBool aAntennaAttached ) |
1022 { |
918 { |
|
919 LOG_METHOD_AUTO; |
1023 #ifdef __WINS__ |
920 #ifdef __WINS__ |
1024 MrftoAntennaStatusChange( aAntennaAttached ); |
921 MrftoAntennaStatusChange( aAntennaAttached ); |
1025 #endif |
922 #endif |
1026 } |
923 } |
1027 |
924 |
1057 // |
955 // |
1058 // --------------------------------------------------------------------------- |
956 // --------------------------------------------------------------------------- |
1059 // |
957 // |
1060 TBool CRadioEngineImp::FrequencySetByRdsAf() const |
958 TBool CRadioEngineImp::FrequencySetByRdsAf() const |
1061 { |
959 { |
|
960 LEVEL3( LOG_METHOD_AUTO ); |
1062 return iFrequencySetByRdsAf; |
961 return iFrequencySetByRdsAf; |
1063 } |
962 } |
1064 |
963 |
1065 // --------------------------------------------------------------------------- |
964 // --------------------------------------------------------------------------- |
1066 // |
965 // |
1067 // --------------------------------------------------------------------------- |
966 // --------------------------------------------------------------------------- |
1068 // |
967 // |
1069 MRadioRdsReceiver& CRadioEngineImp::RdsReceiver() |
968 MRadioRdsReceiver& CRadioEngineImp::RdsReceiver() |
1070 { |
969 { |
|
970 LEVEL3( LOG_METHOD_AUTO ); |
1071 return *iRdsReceiver; |
971 return *iRdsReceiver; |
1072 } |
972 } |
1073 |
973 |
1074 // --------------------------------------------------------------------------- |
974 // --------------------------------------------------------------------------- |
1075 // |
975 // |
1076 // --------------------------------------------------------------------------- |
976 // --------------------------------------------------------------------------- |
1077 // |
977 // |
1078 TInt CRadioEngineImp::TunerVolumeForUiVolume( TInt aUiVolume ) |
978 TInt CRadioEngineImp::TunerVolumeForUiVolume( TInt aUiVolume ) |
1079 { |
979 { |
|
980 LEVEL3( LOG_METHOD_AUTO ); |
1080 TInt vol = aUiVolume * KRadioVolumeStepsDivider; |
981 TInt vol = aUiVolume * KRadioVolumeStepsDivider; |
1081 |
982 |
1082 return vol; |
983 return vol; |
1083 } |
984 } |
1084 |
985 |
1086 // |
987 // |
1087 // --------------------------------------------------------------------------- |
988 // --------------------------------------------------------------------------- |
1088 // |
989 // |
1089 void CRadioEngineImp::NotifyRadioEvent( TInt aRadioEvent, TInt aErrorCode ) |
990 void CRadioEngineImp::NotifyRadioEvent( TInt aRadioEvent, TInt aErrorCode ) |
1090 { |
991 { |
|
992 LEVEL3( LOG_METHOD_AUTO ); |
1091 TRAP_IGNORE( DoNotifyRadioEventL( aRadioEvent, aErrorCode ) ) |
993 TRAP_IGNORE( DoNotifyRadioEventL( aRadioEvent, aErrorCode ) ) |
1092 } |
994 } |
1093 |
995 |
1094 // --------------------------------------------------------------------------- |
996 // --------------------------------------------------------------------------- |
1095 // Notifies all the registered observers of radio events |
997 // Notifies all the registered observers of radio events |
1096 // by sending notifications to observers. |
998 // by sending notifications to observers. |
1097 // --------------------------------------------------------------------------- |
999 // --------------------------------------------------------------------------- |
1098 // |
1000 // |
1099 void CRadioEngineImp::DoNotifyRadioEventL( TInt aRadioEvent, TInt aErrorCode ) |
1001 void CRadioEngineImp::DoNotifyRadioEventL( TInt aRadioEvent, TInt aErrorCode ) |
1100 { |
1002 { |
|
1003 LOG_METHOD_AUTO; |
1101 TInt count = iObservers.Count(); |
1004 TInt count = iObservers.Count(); |
1102 |
1005 |
1103 for ( TInt i = 0; i<count; i++) |
1006 for ( TInt i = 0; i<count; i++) |
1104 { |
1007 { |
1105 MRadioEngineObserver * observer = iObservers[i]; |
1008 MRadioEngineObserver * observer = iObservers[i]; |
1167 } |
1067 } |
1168 } |
1068 } |
1169 } |
1069 } |
1170 |
1070 |
1171 // --------------------------------------------------------------------------- |
1071 // --------------------------------------------------------------------------- |
1172 // Notifies the observer of a radio scan event. |
|
1173 // --------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CRadioEngineImp::NotifyRadioScanEvent( TRadioScanEvent aEvent, |
|
1176 MRadioScanObserver& aObserver, |
|
1177 TInt aError ) |
|
1178 { |
|
1179 TRAP_IGNORE( DoNotifyRadioScanEventL( aEvent, aObserver, aError ) ) |
|
1180 } |
|
1181 |
|
1182 // --------------------------------------------------------------------------- |
|
1183 // Notifies the observer of a radio scan event. |
|
1184 // --------------------------------------------------------------------------- |
|
1185 // |
|
1186 void CRadioEngineImp::DoNotifyRadioScanEventL( TRadioScanEvent aEvent, |
|
1187 MRadioScanObserver& aObserver, |
|
1188 TInt aError ) |
|
1189 { |
|
1190 LOG_FORMAT( "CRadioEngineImp::DoNotifyRadioScanEventL, aEvent: %d, aError: %d", aEvent, aError ); |
|
1191 |
|
1192 if ( aEvent == ERadioEventFrequencyScanned ) |
|
1193 { |
|
1194 if ( aError == KErrNone ) |
|
1195 { |
|
1196 aObserver.ScanFrequencyEventL( iPreviousScannedFrequency ); |
|
1197 } |
|
1198 } |
|
1199 else if ( aEvent == ERadioEventScanCompleted ) |
|
1200 { |
|
1201 // KFmRadioErrTuning error means that no channels can be found anymore |
|
1202 if ( aError == KFmRadioErrTuning ) |
|
1203 { |
|
1204 aError = KErrNotFound; |
|
1205 } |
|
1206 |
|
1207 aObserver.ScanCompletedEventL( aError ); |
|
1208 } |
|
1209 } |
|
1210 |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // Handles some system events |
1072 // Handles some system events |
1213 // --------------------------------------------------------------------------- |
1073 // --------------------------------------------------------------------------- |
1214 // |
1074 // |
1215 void CRadioEngineImp::HandleSystemEventL( TRadioSystemEventType aEventType ) |
1075 void CRadioEngineImp::HandleSystemEventL( TRadioSystemEventType aEventType ) |
1216 { |
1076 { |
1217 LOG_FORMAT( "CRadioEngineImp::HandleSystemEventL, aEventType = %d", aEventType ); |
1077 LOG_METHOD_AUTO; |
|
1078 LOG_FORMAT( "aEventType = %d", aEventType ); |
1218 |
1079 |
1219 switch ( aEventType ) |
1080 switch ( aEventType ) |
1220 { |
1081 { |
1221 case ERadioAudioResourcesAvailable: |
1082 case ERadioAudioResourcesAvailable: |
1222 { |
1083 { |
1258 |
1118 |
1259 case ERadioHeadsetConnected: |
1119 case ERadioHeadsetConnected: |
1260 { |
1120 { |
1261 // Explicitly set the audio routing to headset. Because system |
1121 // Explicitly set the audio routing to headset. Because system |
1262 // forces the routing to headset anyway, and without our knowledge. |
1122 // forces the routing to headset anyway, and without our knowledge. |
|
1123 MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
|
1124 setter.SetAudioRoute( RadioEngine::ERadioHeadset ); |
1263 iAudioRouter->SetAudioRouteL( RadioEngine::ERadioHeadset ); |
1125 iAudioRouter->SetAudioRouteL( RadioEngine::ERadioHeadset ); |
1264 } |
1126 } |
1265 break; |
1127 break; |
1266 |
1128 |
1267 case ERadioHeadsetDisconnected: |
1129 case ERadioHeadsetDisconnected: |
1268 { |
1130 { |
1269 // Explicitly set the audio routing to speaker. Because system |
1131 // Explicitly set the audio routing to speaker. Because system |
1270 // forces the routing to speaker anyway, if radio stays on. |
1132 // forces the routing to speaker anyway, if radio stays on. |
|
1133 MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
|
1134 setter.SetAudioRoute( RadioEngine::ERadioSpeaker ); |
1271 iAudioRouter->SetAudioRouteL( RadioEngine::ERadioSpeaker ); |
1135 iAudioRouter->SetAudioRouteL( RadioEngine::ERadioSpeaker ); |
1272 } |
1136 } |
1273 break; |
1137 break; |
1274 default: |
1138 default: |
1275 { |
1139 { |
1400 // if ( !iFrequencySetByRdsAf ) |
1266 // if ( !iFrequencySetByRdsAf ) |
1401 // { |
1267 // { |
1402 // NotifyRadioEvent( ERadioEventFrequency, KErrNone ); |
1268 // NotifyRadioEvent( ERadioEventFrequency, KErrNone ); |
1403 // } |
1269 // } |
1404 // } |
1270 // } |
1405 |
|
1406 if ( iScanObserver ) |
|
1407 { |
|
1408 if ( aError != KErrNone ) |
|
1409 { |
|
1410 StopScan( aError ); |
|
1411 } |
|
1412 else |
|
1413 { |
|
1414 if ( aFrequency > iSettings->EngineSettings().MinFrequency() && aFrequency > iPreviousScannedFrequency ) |
|
1415 { |
|
1416 iPreviousScannedFrequency = aFrequency; |
|
1417 NotifyRadioScanEvent( ERadioEventFrequencyScanned, *iScanObserver, KErrNone ); |
|
1418 Seek( RadioEngine::ERadioUp ); // Continue scanning. |
|
1419 } |
|
1420 else |
|
1421 { |
|
1422 if ( aFrequency == iSettings->EngineSettings().MinFrequency() ) |
|
1423 { |
|
1424 iPreviousScannedFrequency = aFrequency; |
|
1425 NotifyRadioScanEvent( ERadioEventFrequencyScanned, *iScanObserver, KErrNone ); |
|
1426 } |
|
1427 StopScan( aError ); |
|
1428 } |
|
1429 } |
|
1430 } |
|
1431 } |
1271 } |
1432 |
1272 |
1433 // --------------------------------------------------------------------------- |
1273 // --------------------------------------------------------------------------- |
1434 // |
1274 // |
1435 // --------------------------------------------------------------------------- |
1275 // --------------------------------------------------------------------------- |
1436 // |
1276 // |
1437 void CRadioEngineImp::MrftoFmTransmitterStatusChange( TBool aActive ) |
1277 void CRadioEngineImp::MrftoFmTransmitterStatusChange( TBool aActive ) |
1438 { |
1278 { |
1439 LOG_FORMAT( "CRadioEngineImp::MrftoFmTransmitterStatusChange( %d )", aActive ); |
1279 LOG_METHOD_AUTO; |
|
1280 LOG_FORMAT( "aActive: %d", aActive ); |
1440 iFmTransmitterActive = aActive; |
1281 iFmTransmitterActive = aActive; |
1441 |
1282 |
1442 if ( !iFmTransmitterActive ) |
1283 if ( !iFmTransmitterActive ) |
1443 { |
1284 { |
1444 SwitchPower( ETrue ); |
1285 SwitchPower( ETrue ); |
1451 // |
1292 // |
1452 // --------------------------------------------------------------------------- |
1293 // --------------------------------------------------------------------------- |
1453 // |
1294 // |
1454 void CRadioEngineImp::MrftoAntennaStatusChange( TBool aAttached ) |
1295 void CRadioEngineImp::MrftoAntennaStatusChange( TBool aAttached ) |
1455 { |
1296 { |
1456 LOG_FORMAT( "CRadioEngineImp::MrftoAntennaStatusChange( %d )", aAttached ); |
1297 LOG_METHOD_AUTO; |
|
1298 LOG_FORMAT( "aAttached: %d", aAttached ); |
1457 iAntennaAttached = aAttached; |
1299 iAntennaAttached = aAttached; |
1458 if ( iAntennaAttached ) |
1300 if ( iAntennaAttached ) |
1459 { |
1301 { |
1460 SwitchPower( ETrue ); |
1302 SwitchPower( ETrue ); |
1461 NotifyRadioEvent( ERadioEventAntenna ); |
1303 NotifyRadioEvent( ERadioEventAntenna ); |
1462 iPubSub->PublishAntennaState( ERadioPSRadioAntennaAttached ); |
|
1463 } |
1304 } |
1464 else |
1305 else |
1465 { |
1306 { |
1466 NotifyRadioEvent( ERadioEventAntenna, KErrDisconnected ); |
1307 NotifyRadioEvent( ERadioEventAntenna, KErrDisconnected ); |
1467 iPubSub->PublishAntennaState( ERadioPSRadioAntennaDetached ); |
1308 } |
1468 } |
1309 } |
1469 } |
1310 |
1470 |
1311 // --------------------------------------------------------------------------- |
1471 // --------------------------------------------------------------------------- |
1312 // |
1472 // |
1313 // --------------------------------------------------------------------------- |
1473 // --------------------------------------------------------------------------- |
1314 |
1474 |
1315 // |
1475 // |
1316 void CRadioEngineImp::MrftoOfflineModeStatusChange( TBool DEBUGVAR3( aOfflineMode ) ) |
1476 void CRadioEngineImp::MrftoOfflineModeStatusChange( TBool DEBUGVAR( aOfflineMode ) ) |
1317 { |
1477 { |
1318 LEVEL3( LOG_METHOD_AUTO ); |
1478 LOG_FORMAT( "CRadioEngineImp::MrftoOfflineModeStatusChange( %d )", aOfflineMode ); |
1319 LEVEL3( LOG_FORMAT( "aOfflineMode: %d", aOfflineMode ) ); |
1479 } |
1320 } |
1480 |
1321 |
1481 // --------------------------------------------------------------------------- |
1322 // --------------------------------------------------------------------------- |
1482 // |
1323 // |
1483 // --------------------------------------------------------------------------- |
1324 // --------------------------------------------------------------------------- |
1484 // |
1325 // |
1485 void CRadioEngineImp::MrftoFrequencyRangeChange( TFmRadioFrequencyRange DEBUGVAR( aBand ) ) |
1326 void CRadioEngineImp::MrftoFrequencyRangeChange( TFmRadioFrequencyRange DEBUGVAR3( aBand ) ) |
1486 { |
1327 { |
1487 LOG_FORMAT( "CRadioEngineImp::MrftoFrequencyRangeChange( %d )", aBand ); |
1328 LEVEL3( LOG_METHOD_AUTO ); |
|
1329 LEVEL3( LOG_FORMAT( "aBand: %d", aBand ) ); |
1488 if ( RadioInitialized() ) |
1330 if ( RadioInitialized() ) |
1489 { |
1331 { |
1490 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
1332 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
1491 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
1333 iFreqEventReason = RadioEngine::ERadioFrequencyEventReasonImplicit; |
1492 } |
1334 } |
1497 // |
1339 // |
1498 // --------------------------------------------------------------------------- |
1340 // --------------------------------------------------------------------------- |
1499 // |
1341 // |
1500 void CRadioEngineImp::MrftoFrequencyChange( TInt aNewFrequency ) |
1342 void CRadioEngineImp::MrftoFrequencyChange( TInt aNewFrequency ) |
1501 { |
1343 { |
1502 LOG_FORMAT( "CRadioEngineImp::MrftoFrequencyChange aNewFrequency = %u", aNewFrequency ); |
1344 LEVEL3( LOG_METHOD_AUTO ); |
|
1345 LEVEL3( LOG_FORMAT( "aNewFrequency = %u", aNewFrequency ) ); |
1503 |
1346 |
1504 // There may be frequency changed events when radio is not initialized ( because |
1347 // There may be frequency changed events when radio is not initialized ( because |
1505 // of SetFrequency or Seek returns with KErrNotReady ). |
1348 // of SetFrequency or Seek returns with KErrNotReady ). |
1506 if ( RadioInitialized() ) |
1349 if ( !iManualSeekMode && RadioInitialized() ) |
1507 { |
1350 { |
1508 |
|
1509 HandleFrequencyEvent( aNewFrequency ); |
1351 HandleFrequencyEvent( aNewFrequency ); |
1510 } |
1352 } |
1511 } |
1353 } |
1512 |
1354 |
1513 // --------------------------------------------------------------------------- |
1355 // --------------------------------------------------------------------------- |
1514 // |
1356 // |
1515 // --------------------------------------------------------------------------- |
1357 // --------------------------------------------------------------------------- |
1516 // |
1358 // |
1517 void CRadioEngineImp::MrftoForcedMonoChange( TBool aForcedMono ) |
1359 void CRadioEngineImp::MrftoForcedMonoChange( TBool aForcedMono ) |
1518 { |
1360 { |
1519 LOG_FORMAT( "CRadioEngineImp::MrftoForcedMonoChange -- aForcedMono = %d", aForcedMono ); |
1361 LEVEL3( LOG_METHOD_AUTO ); |
|
1362 LEVEL3( LOG_FORMAT( "aForcedMono = %d", aForcedMono ) ); |
1520 |
1363 |
1521 iSettings->RadioSetter().SetOutputMode( aForcedMono ? RadioEngine::ERadioMono : RadioEngine::ERadioStereo ); |
1364 iSettings->RadioSetter().SetOutputMode( aForcedMono ? RadioEngine::ERadioMono : RadioEngine::ERadioStereo ); |
1522 NotifyRadioEvent( ERadioEventAudioMode ); |
1365 NotifyRadioEvent( ERadioEventAudioMode ); |
1523 } |
1366 } |
1524 |
1367 |
1526 // |
1369 // |
1527 // --------------------------------------------------------------------------- |
1370 // --------------------------------------------------------------------------- |
1528 // |
1371 // |
1529 void CRadioEngineImp::MrftoSquelchChange( TBool /*aSquelch*/ ) |
1372 void CRadioEngineImp::MrftoSquelchChange( TBool /*aSquelch*/ ) |
1530 { |
1373 { |
|
1374 LEVEL3( LOG_METHOD_AUTO ); |
1531 } |
1375 } |
1532 |
1376 |
1533 // --------------------------------------------------------------------------- |
1377 // --------------------------------------------------------------------------- |
1534 // |
1378 // |
1535 // --------------------------------------------------------------------------- |
1379 // --------------------------------------------------------------------------- |
1536 // |
1380 // |
1537 void CRadioEngineImp::MrpoStateChange( TPlayerState aState, TInt aError ) |
1381 void CRadioEngineImp::MrpoStateChange( TPlayerState aState, TInt aError ) |
1538 { |
1382 { |
1539 LOG_FORMAT( "CRadioEngineImp::MrpoStateChange() -- aState = %d, aError = %d", aState, aError ); |
1383 LEVEL3( LOG_METHOD_AUTO ); |
|
1384 LEVEL3( LOG_FORMAT( "aState = %d, aError = %d", aState, aError ) ); |
1540 |
1385 |
1541 if ( aError == KFmRadioErrAntennaNotConnected ) |
1386 if ( aError == KFmRadioErrAntennaNotConnected ) |
1542 { |
1387 { |
1543 iAntennaAttached = EFalse; |
1388 iAntennaAttached = EFalse; |
1544 } |
1389 } |
1578 // |
1424 // |
1579 // --------------------------------------------------------------------------- |
1425 // --------------------------------------------------------------------------- |
1580 // |
1426 // |
1581 void CRadioEngineImp::MrpoBalanceChange( TInt /*aLeftPercentage*/, TInt /*aRightPercentage*/ ) |
1427 void CRadioEngineImp::MrpoBalanceChange( TInt /*aLeftPercentage*/, TInt /*aRightPercentage*/ ) |
1582 { |
1428 { |
|
1429 LEVEL3( LOG_METHOD_AUTO ); |
1583 } |
1430 } |
1584 |
1431 |
1585 // --------------------------------------------------------------------------- |
1432 // --------------------------------------------------------------------------- |
1586 // |
1433 // |
1587 // --------------------------------------------------------------------------- |
1434 // --------------------------------------------------------------------------- |
1588 // |
1435 // |
1589 void CRadioEngineImp::RdsAfSearchSettingChangedL( TBool aEnabled ) |
1436 void CRadioEngineImp::RdsAfSearchSettingChangedL( TBool aEnabled ) |
1590 { |
1437 { |
1591 LOG_FORMAT( "CRadioEngineImp::RdsAfSearchSettingChangedL( %d )", aEnabled ); |
1438 LEVEL3( LOG_METHOD_AUTO ); |
|
1439 LEVEL3( LOG_FORMAT( "aEnabled: %d", aEnabled ) ); |
1592 iRdsReceiver->SetAutomaticSwitchingL( aEnabled ); |
1440 iRdsReceiver->SetAutomaticSwitchingL( aEnabled ); |
1593 } |
1441 } |
1594 |
1442 |
1595 // --------------------------------------------------------------------------- |
1443 // --------------------------------------------------------------------------- |
1596 // |
1444 // |
1597 // --------------------------------------------------------------------------- |
1445 // --------------------------------------------------------------------------- |
1598 // |
1446 // |
1599 void CRadioEngineImp::RegionSettingChangedL( TInt DEBUGVAR( aRegion ) ) |
1447 //TODO: Check if this can be removed. Radio doesn't currently support changing regions on the fly |
1600 { |
1448 void CRadioEngineImp::RegionSettingChangedL( TInt DEBUGVAR3( aRegion ) ) |
1601 LOG_FORMAT( "CRadioEngineImp::RegionSettingChangedL( %d )", aRegion ); |
1449 { |
|
1450 LEVEL3( LOG_METHOD_AUTO ); |
|
1451 LEVEL3( LOG_FORMAT( "aRegion: %d", aRegion ) ); |
1602 |
1452 |
1603 if ( RadioInitialized() ) |
1453 if ( RadioInitialized() ) |
1604 { |
1454 { |
1605 iTunerUtility->SetFrequencyRange( TunerFrequencyRangeForRegionId( iSettings->EngineSettings().RegionId() ) ); |
1455 iTunerUtility->SetFrequencyRange( TunerFrequencyRangeForRegionId( iSettings->EngineSettings().RegionId() ) ); |
1606 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
1456 iTunerUtility->SetFrequency( iSettings->EngineSettings().TunedFrequency() ); |
1612 // |
1462 // |
1613 // --------------------------------------------------------------------------- |
1463 // --------------------------------------------------------------------------- |
1614 // |
1464 // |
1615 void CRadioEngineImp::RdsAfSearchBegin() |
1465 void CRadioEngineImp::RdsAfSearchBegin() |
1616 { |
1466 { |
1617 LOG( "CRadioEngineImp::RdsAfSearchBegin()" ); |
1467 LEVEL3( LOG_METHOD_AUTO ); |
1618 iFrequencySetByRdsAf = ETrue; |
1468 iFrequencySetByRdsAf = ETrue; |
1619 } |
1469 } |
1620 |
1470 |
1621 // --------------------------------------------------------------------------- |
1471 // --------------------------------------------------------------------------- |
1622 // |
1472 // |
1623 // --------------------------------------------------------------------------- |
1473 // --------------------------------------------------------------------------- |
1624 // |
1474 // |
1625 void CRadioEngineImp::RdsAfSearchEnd( TUint32 DEBUGVAR( aFrequency ), TInt aError ) |
1475 void CRadioEngineImp::RdsAfSearchEnd( TUint32 DEBUGVAR3( aFrequency ), TInt aError ) |
1626 { |
1476 { |
1627 LOG_FORMAT( "CRadioEngineImp::RdsAfSearchEnd( %d, %d )", aFrequency, aError ); |
1477 LEVEL3( LOG_METHOD_AUTO ); |
|
1478 LEVEL3( LOG_FORMAT( "aFrequency: %d, aError: %d )", aFrequency, aError ) ); |
1628 if ( aError != KErrNone ) |
1479 if ( aError != KErrNone ) |
1629 { |
1480 { |
1630 iFrequencySetByRdsAf = EFalse; |
1481 iFrequencySetByRdsAf = EFalse; |
1631 } |
1482 } |
1632 } |
1483 } |
1635 // Tries to figure the region out based on current mobile network id |
1486 // Tries to figure the region out based on current mobile network id |
1636 // --------------------------------------------------------------------------- |
1487 // --------------------------------------------------------------------------- |
1637 // |
1488 // |
1638 TRadioRegion CRadioEngineImp::RegionFromMobileNetwork() const |
1489 TRadioRegion CRadioEngineImp::RegionFromMobileNetwork() const |
1639 { |
1490 { |
|
1491 LEVEL3( LOG_METHOD_AUTO ); |
1640 TRadioRegion region = ERadioRegionNone; |
1492 TRadioRegion region = ERadioRegionNone; |
1641 |
1493 |
1642 // Choose the frequency range according to country code |
1494 // Choose the frequency range according to country code |
1643 MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
1495 MRadioEngineSettings& engineSettings = iSettings->EngineSettings(); |
1644 const TDesC& countryCode = engineSettings.CountryCode(); |
1496 TPtrC countryCode = engineSettings.CountryCode(); |
1645 const TInt regionCount = engineSettings.CountRegions(); |
1497 const TInt regionCount = engineSettings.CountRegions(); |
1646 TBool matchFound = EFalse; |
1498 TBool matchFound = EFalse; |
1647 for ( TInt i = 0; i < regionCount && !matchFound; ++i ) |
1499 for ( TInt i = 0; i < regionCount && !matchFound; ++i ) |
1648 { |
1500 { |
1649 const RRadioCountryCodeArray& regionCountryCodes = |
1501 const RRadioCountryCodeArray& regionCountryCodes = |
1709 } |
1562 } |
1710 |
1563 |
1711 CleanupStack::PopAndDestroy( cityGroups ); |
1564 CleanupStack::PopAndDestroy( cityGroups ); |
1712 CleanupStack::PopAndDestroy( timezoneLocalizer ); |
1565 CleanupStack::PopAndDestroy( timezoneLocalizer ); |
1713 |
1566 |
1714 LOG_ASSERT( found, LOG_FORMAT( "CRadioEngine::DoMapCurrentTimeZoneToRegionL. City not found: %d", cityId ) ); |
1567 LOG_ASSERT( found, LOG_FORMAT( "City not found: %d", cityId ) ); |
1715 |
1568 |
1716 return region; |
1569 return region; |
1717 } |
1570 } |
1718 |
1571 |
1719 // --------------------------------------------------------------------------- |
1572 // --------------------------------------------------------------------------- |
1720 // |
1573 // |
1721 // --------------------------------------------------------------------------- |
1574 // --------------------------------------------------------------------------- |
1722 // |
1575 // |
1723 void CRadioEngineImp::HandleAudioRoutingEvent( RadioEngine::TRadioAudioRoute aDestination ) |
1576 void CRadioEngineImp::HandleAudioRoutingEvent( RadioEngine::TRadioAudioRoute aDestination ) |
1724 { |
1577 { |
1725 LOG_FORMAT( "CRadioEngineImp::HandleAudioRoutingL( %d )", aDestination ); |
1578 LOG_METHOD_AUTO; |
|
1579 LOG_FORMAT( "aDestination: %d", aDestination ); |
1726 |
1580 |
1727 // Make modifications to volume ONLY if new audio source state |
1581 // Make modifications to volume ONLY if new audio source state |
1728 // differs from settings. If they don't differ, this state |
1582 // differs from settings. If they don't differ, this state |
1729 // change is a part of the radio initialization. |
1583 // change is a part of the radio initialization. |
1730 MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
1584 MRadioSettingsSetter& setter = iSettings->RadioSetter(); |
1783 } |
1638 } |
1784 } |
1639 } |
1785 |
1640 |
1786 if ( !iSettings->EngineSettings().IsPowerOn() ) |
1641 if ( !iSettings->EngineSettings().IsPowerOn() ) |
1787 { |
1642 { |
1788 StopScan( aErrorCode ); |
|
1789 CancelSeek(); |
1643 CancelSeek(); |
1790 } |
1644 } |
1791 |
1645 |
1792 // If we are seeking, power event starts seeking |
1646 // If we are seeking, power event starts seeking |
1793 if ( iSeekingState != RadioEngine::ERadioNotSeeking && iSettings->EngineSettings().IsPowerOn() ) |
1647 if ( iSeekingState != RadioEngine::ERadioNotSeeking && iSettings->EngineSettings().IsPowerOn() ) |
1794 { |
1648 { |
1795 // Reset seeking state to enable seeking start |
1649 // Reset seeking state to enable seeking start |
|
1650 LOG( "PowerOn event in seekingstate. Restart seeking" ); |
1796 RadioEngine::TRadioSeeking oldSeeking = iSeekingState; |
1651 RadioEngine::TRadioSeeking oldSeeking = iSeekingState; |
1797 iSeekingState = RadioEngine::ERadioNotSeeking; |
1652 iSeekingState = RadioEngine::ERadioNotSeeking; |
1798 Seek( oldSeeking == RadioEngine::ERadioSeekingUp ? RadioEngine::ERadioUp : RadioEngine::ERadioDown ); |
1653 Seek( oldSeeking == RadioEngine::ERadioSeekingUp ? RadioEngine::ERadioUp : RadioEngine::ERadioDown ); |
1799 } |
1654 } |
1800 |
1655 |
1801 if ( !powerState != !aPowerOn ) |
1656 if ( !powerState != !aPowerOn || aErrorCode ) |
1802 { |
1657 { |
1803 NotifyRadioEvent( ERadioEventPower, aErrorCode ); |
1658 NotifyRadioEvent( ERadioEventPower, aErrorCode ); |
1804 } |
1659 } |
1805 } |
1660 } |
1806 |
1661 |