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