|
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 // User includes |
|
19 #include "cradioenginelogger.h" |
|
20 #include "cradioaudiorouter.h" |
|
21 #include "mradioaudioroutingobserver.h" |
|
22 #include "cradioroutableaudio.h" |
|
23 #include "radioengineutils.h" |
|
24 |
|
25 |
|
26 const TInt KVisualRadioInitialRoutableAudioArraySize( 2 ); |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CRadioAudioRouter::CRadioAudioRouter( MRadioAudioRoutingObserver& aAudioRoutingObserver ) |
|
33 : iAudioRoutingObserver( aAudioRoutingObserver ) |
|
34 { |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CRadioAudioRouter* CRadioAudioRouter::NewL( MRadioAudioRoutingObserver& aAudioRoutingObserver ) |
|
42 { |
|
43 CRadioAudioRouter* self = new( ELeave ) CRadioAudioRouter( aAudioRoutingObserver ); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C CRadioAudioRouter::~CRadioAudioRouter() |
|
55 { |
|
56 iRoutableAudios.Close(); |
|
57 RadioEngineUtils::Release(); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CRadioAudioRouter::ConstructL() |
|
65 { |
|
66 RadioEngineUtils::InitializeL(); |
|
67 iRoutableAudios = RArray<CRadioRoutableAudio*>( KVisualRadioInitialRoutableAudioArraySize ); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Sets audio route |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 EXPORT_C void CRadioAudioRouter::SetAudioRouteL( RadioEngine::TRadioAudioRoute aAudioRoute ) |
|
75 { |
|
76 LOG_FORMAT( "CRadioAudioRouter::SetAudioRouteL: Route: %d", aAudioRoute ); |
|
77 |
|
78 for ( TInt i = 0 ; i < iRoutableAudios.Count(); i++ ) |
|
79 { |
|
80 iRoutableAudios[i]->SetAudioRouteL( aAudioRoute ); |
|
81 } |
|
82 iAudioRoutingObserver.AudioRouteChangedL( aAudioRoute ); |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 EXPORT_C void CRadioAudioRouter::RegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio ) |
|
90 { |
|
91 LOG( "CRadioAudioRouter::RegisterRoutableAudio" ); |
|
92 iRoutableAudios.Append( aRoutableAudio ); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C void CRadioAudioRouter::UnRegisterRoutableAudio( CRadioRoutableAudio* aRoutableAudio ) |
|
100 { |
|
101 LOG( "CRadioAudioRouter::UnRegisterRoutableAudio" ); |
|
102 |
|
103 TInt objectIndex = iRoutableAudios.Find( aRoutableAudio ); |
|
104 |
|
105 __ASSERT_DEBUG( objectIndex != KErrNotFound, User::Panic( _L("VisualRadio" ), KErrAbort ) ); |
|
106 |
|
107 if ( objectIndex != KErrNotFound ) |
|
108 { |
|
109 iRoutableAudios.Remove( objectIndex ); |
|
110 } |
|
111 } |
|
112 |