1 /* |
|
2 * Copyright (c) 2005-2007 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: This class provides GlobalManager functionality. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 |
|
22 #include "cammsglobalmanager.h" |
|
23 #include "cammsmodulecontainer.h" |
|
24 #include "cammssoundsource3d.h" |
|
25 #include "cammseffectmodule.h" |
|
26 |
|
27 // Audio 3d includes. |
|
28 #include "cammsdopplercontrolgroup.h" |
|
29 #include "cammslocationcontrolgroup.h" |
|
30 |
|
31 // Global manager |
|
32 #include "cammsreverbcontrolgroup.h" |
|
33 #include "cammsequalizercontrolgroup.h" |
|
34 #include "cammsvolumecontrolgroup.h" |
|
35 #include "cammspancontrolgroup.h" |
|
36 #include "cammscommitcontrolgroup.h" |
|
37 #include "cammsorientationcontrolgroup.h" |
|
38 |
|
39 #include "cammsplayerbuildergroup.h" |
|
40 #include "cammsaudioplayerbuilder.h" |
|
41 #include "cammsvolumecontrolbuilder.h" |
|
42 #include "ammsconstants.h" |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CAMMSGlobalManager::NewLC |
|
48 // Two-phased constructor. |
|
49 // ----------------------------------------------------------------------------- |
|
50 CAMMSGlobalManager* CAMMSGlobalManager::NewLC() |
|
51 { |
|
52 CAMMSGlobalManager* self = new(ELeave) CAMMSGlobalManager; |
|
53 |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 // Destructor |
|
61 CAMMSGlobalManager::~CAMMSGlobalManager() |
|
62 { |
|
63 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::~CAMMSGlobalManager"); |
|
64 delete iSpectator; |
|
65 delete iEffectModules; |
|
66 delete iSoundSource3Ds; |
|
67 delete iPlayerBuilder; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CAMMSGlobalManager::AddPlayerNotifyL |
|
72 // Adds new player |
|
73 // (other items were commented in a header). |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CAMMSGlobalManager::AddPlayerNotifyL(CMMAPlayer* aPlayer) |
|
77 { |
|
78 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::AddPlayerNotifyL player type %S", |
|
79 aPlayer->Type().Ptr()); |
|
80 |
|
81 // Add amms controls to player. |
|
82 iPlayerBuilder->PreparePlayerL(aPlayer); |
|
83 |
|
84 // AddPlayerNoStateCheckL is used to add players to global manager and |
|
85 // global controls because mma player may be started or prefetched before |
|
86 // amms global manager is created. |
|
87 |
|
88 // Add player to global manager. All global control groups will be informed. |
|
89 AddPlayerNoStateCheckL(aPlayer); |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CAMMSGlobalManager::RemovePlayerNotify |
|
94 // Removes player |
|
95 // (other items were commented in a header). |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CAMMSGlobalManager::RemovePlayerNotify(CMMAPlayer* aPlayer) |
|
99 { |
|
100 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::RemovePlayerNotify player type %S", |
|
101 aPlayer->Type().Ptr()); |
|
102 |
|
103 // RemovePlayer can return only KErrNotFound or KErrNone, and in this case |
|
104 // we do not need to handle KErrNotFound |
|
105 RemovePlayerNoStateCheck(aPlayer); |
|
106 |
|
107 // Removing player from other modules |
|
108 iEffectModules->RemovePlayer(aPlayer); |
|
109 iSoundSource3Ds->RemovePlayer(aPlayer); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CAMMSGlobalManager::InitL |
|
114 // Initializes GlobalManager. |
|
115 // (other items were commented in a header). |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CAMMSGlobalManager::InitL(RPointerArray< CMMAPlayer >& aPlayers) |
|
119 { |
|
120 TInt playerCount = aPlayers.Count(); |
|
121 |
|
122 // Add all players to the global controls and to the spectator. |
|
123 for (TInt i = 0; i < playerCount; i++) |
|
124 { |
|
125 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::InitL adding controls to %S", |
|
126 aPlayers[ i ]->Type().Ptr()); |
|
127 AddPlayerNotifyL(aPlayers[ i ]); |
|
128 } |
|
129 } |
|
130 |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CAMMSGlobalManager::CreateSoundSource3DL |
|
134 // Creates a new sound source 3D module. |
|
135 // (other items were commented in a header). |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 CAMMSModule* CAMMSGlobalManager::CreateSoundSource3DL() |
|
139 { |
|
140 // InitL must have been called before call to this methdod. |
|
141 __ASSERT_DEBUG(iSpectator, User::Invariant()); |
|
142 |
|
143 CAMMSSoundSource3D* soundSource3D = |
|
144 CAMMSSoundSource3D::NewLC(iSpectator, this); |
|
145 |
|
146 iSoundSource3Ds->AppendL(soundSource3D); |
|
147 |
|
148 CleanupStack::Pop(soundSource3D); |
|
149 |
|
150 return soundSource3D; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CAMMSGlobalManager::CreateEffectModuleL |
|
155 // Creates a new effect module. |
|
156 // (other items were commented in a header). |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 CAMMSModule* CAMMSGlobalManager::CreateEffectModuleL() |
|
160 { |
|
161 CAMMSEffectModule* module = CAMMSEffectModule::NewLC(this); |
|
162 |
|
163 iEffectModules->AppendL(module); |
|
164 |
|
165 CleanupStack::Pop(module); |
|
166 |
|
167 return module; |
|
168 } |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CAMMSGlobalManager::Spectator |
|
172 // Returns the spectator. |
|
173 // (other items were commented in a header). |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 CAMMSModule* CAMMSGlobalManager::Spectator() |
|
177 { |
|
178 return iSpectator; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CAMMSGlobalManager::DisposeModule |
|
183 // Disposes module. |
|
184 // (other items were commented in a header). |
|
185 // ----------------------------------------------------------------------------- |
|
186 void CAMMSGlobalManager::DisposeModule(CAMMSModule* aModule) |
|
187 { |
|
188 // Remove the module from the module containers. |
|
189 iSoundSource3Ds->RemoveModule(aModule); |
|
190 iEffectModules->RemoveModule(aModule); |
|
191 |
|
192 // Delete the module itself. |
|
193 delete aModule; |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CAMMSGlobalManager::PlayerAddingAllowed |
|
198 // Checks whether the given player can be added to a module. |
|
199 // (other items were commented in a header). |
|
200 // ----------------------------------------------------------------------------- |
|
201 TInt CAMMSGlobalManager::PlayerAddingAllowed(CMMAPlayer* aPlayer) |
|
202 { |
|
203 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::PlayerAddingAllowed %d +", |
|
204 (TInt)aPlayer); |
|
205 |
|
206 TInt result = KErrNone; |
|
207 |
|
208 // Check whether the player can be added according to SoundSource3Ds. |
|
209 TInt modules = iSoundSource3Ds->Count(); |
|
210 |
|
211 for (TInt i = 0; (result == KErrNone) && (i < modules); i++) |
|
212 { |
|
213 CAMMSModule* module = iSoundSource3Ds->At(i); |
|
214 |
|
215 result = PlayerAddingAllowed(aPlayer, module); |
|
216 } |
|
217 |
|
218 |
|
219 // Check whether the player can be added according to EffectModules. |
|
220 modules = iEffectModules->Count(); |
|
221 |
|
222 for (TInt i = 0; (result == KErrNone) && (i < modules); i++) |
|
223 { |
|
224 CAMMSModule* module = iEffectModules->At(i); |
|
225 |
|
226 result = PlayerAddingAllowed(aPlayer, module); |
|
227 } |
|
228 |
|
229 |
|
230 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::PlayerAddingAllowed %d -", result); |
|
231 |
|
232 return result; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CAMMSGlobalManager::CAMMSGlobalManager |
|
237 // C++ default constructor can NOT contain any code, that |
|
238 // might leave. |
|
239 // ----------------------------------------------------------------------------- |
|
240 CAMMSGlobalManager::CAMMSGlobalManager() |
|
241 { |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CAMMSGlobalManager::ConstructL |
|
246 // Symbian 2nd phase constructor can leave. |
|
247 // ----------------------------------------------------------------------------- |
|
248 void CAMMSGlobalManager::ConstructL() |
|
249 { |
|
250 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::ConstructL +"); |
|
251 |
|
252 CAMMSModule::ConstructL(); |
|
253 |
|
254 iSoundSource3Ds = new(ELeave) CAMMSModuleContainer(); |
|
255 iEffectModules = new(ELeave) CAMMSModuleContainer(); |
|
256 iPlayerBuilder = CAMMSPlayerBuilderGroup::NewL(); |
|
257 iPlayerBuilder->AddBuilderAndPopL(CAMMSAudioPlayerBuilder::NewLC()); |
|
258 iPlayerBuilder->AddBuilderAndPopL(CAMMSVolumeControlBuilder::NewLC()); |
|
259 |
|
260 // Add control groups to global manager |
|
261 AddControlGroupAndPopL(CAMMSReverbControlGroup::NewLC()); |
|
262 AddControlGroupAndPopL(CAMMSEqualizerControlGroup::NewLC()); |
|
263 AddControlGroupAndPopL(CAMMSVolumeControlGroup::NewLC( |
|
264 KAMMSGlobalVolume)); |
|
265 |
|
266 #ifndef __WINS__ |
|
267 // PanControl is not supported in WINSCW builds. |
|
268 // This is because of limited pan support in DirectX. |
|
269 AddControlGroupAndPopL(CAMMSPanControlGroup::NewLC()); |
|
270 #endif // __WINS__ |
|
271 |
|
272 // Create spectator and add controls. |
|
273 iSpectator = CAMMSModule::NewL(); |
|
274 iSpectator->AddControlGroupAndPopL(CAMMSLocationControlGroup::NewLC( |
|
275 EAMMSSpectatorControl)); |
|
276 iSpectator->AddControlGroupAndPopL(CAMMSOrientationControlGroup::NewLC()); |
|
277 iSpectator->AddControlGroupAndPopL(CAMMSDopplerControlGroup::NewLC( |
|
278 EAMMSSpectatorControl)); |
|
279 |
|
280 // Add Commit control group to global manager, and pass required references |
|
281 AddControlGroupAndPopL(CAMMSCommitControlGroup::NewLC( |
|
282 *iSpectator, |
|
283 *iSoundSource3Ds)); |
|
284 |
|
285 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::ConstructL -"); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CAMMSGlobalManager::PlayerAddingAllowed |
|
290 // Checks whether the given player can be added to a module. |
|
291 // (other items were commented in a header). |
|
292 // ----------------------------------------------------------------------------- |
|
293 TInt CAMMSGlobalManager::PlayerAddingAllowed(CMMAPlayer* aPlayer, |
|
294 CAMMSModule* aModule) |
|
295 { |
|
296 LOG2( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::PlayerAddingAllowed %d %d +", |
|
297 (TInt)aPlayer, (TInt)aModule); |
|
298 |
|
299 TBool playerExists = aModule->HasPlayer(aPlayer); |
|
300 |
|
301 TInt result = (playerExists ? KAMMSPlayerAlreadyInModuleError : KErrNone); |
|
302 |
|
303 // WINSCW build does not support audio mixing. |
|
304 // Thus, check in WINSCW build that there is not any non-closed player |
|
305 // in the module. If there is any non-closed player in the module, |
|
306 // adding a new player is not allowed to ANY module. |
|
307 // However, allow a player to be in CLOSED state, because it cannot be started |
|
308 // anymore and cannot thus reserve any resources anymore. |
|
309 |
|
310 #ifdef __WINS__ |
|
311 |
|
312 if (result == KErrNone) |
|
313 { |
|
314 TInt players = aModule->PlayerCount(CMMAPlayer::EUnrealized, |
|
315 CMMAPlayer::EStarted); |
|
316 |
|
317 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::PlayerAddingAllowed players=%d", |
|
318 players); |
|
319 |
|
320 result = (players == 0 ? KErrNone : KAMMSMixingNotSupported); |
|
321 } |
|
322 |
|
323 #endif // __WINS__ |
|
324 |
|
325 |
|
326 LOG1( EJavaAMMS, EInfo, "AMMS::CAMMSGlobalManager::PlayerAddingAllowed %d -", result); |
|
327 |
|
328 return result; |
|
329 } |
|
330 |
|
331 |
|
332 // End of File |
|