sl@0
|
1 |
//audiocontext.cpp
|
sl@0
|
2 |
|
sl@0
|
3 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
4 |
// All rights reserved.
|
sl@0
|
5 |
// This component and the accompanying materials are made available
|
sl@0
|
6 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
7 |
// which accompanies this distribution, and is available
|
sl@0
|
8 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
9 |
//
|
sl@0
|
10 |
// Initial Contributors:
|
sl@0
|
11 |
// Nokia Corporation - initial contribution.
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Contributors:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
// Description:
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <a3f/maudiostream.h>
|
sl@0
|
21 |
#include <a3f/maudiocodec.h>
|
sl@0
|
22 |
#include <a3f/maudiogaincontrol.h>
|
sl@0
|
23 |
#include <a3f/a3fbase.h>
|
sl@0
|
24 |
|
sl@0
|
25 |
#include "audiocontext.h"
|
sl@0
|
26 |
#include "audioprocessingunit.h"
|
sl@0
|
27 |
#include "logicalaudiostream.h"
|
sl@0
|
28 |
#include "audiostreammanager.h"
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
// ---------------------------------------------------------------------------
|
sl@0
|
32 |
// Default constructor
|
sl@0
|
33 |
// ---------------------------------------------------------------------------
|
sl@0
|
34 |
//
|
sl@0
|
35 |
CAudioContext::CAudioContext()
|
sl@0
|
36 |
{
|
sl@0
|
37 |
TRACE_CREATE();
|
sl@0
|
38 |
DP_CONTEXT(CAudioContext::CAudioContext *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
39 |
DP_IN();
|
sl@0
|
40 |
iInCommit = EFalse;
|
sl@0
|
41 |
DP_OUT();
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
// ---------------------------------------------------------------------------
|
sl@0
|
45 |
// Symbian 2nd phase constructor
|
sl@0
|
46 |
// ---------------------------------------------------------------------------
|
sl@0
|
47 |
void CAudioContext::ConstructL()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
DP_CONTEXT(CAudioContext::ConstructL *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
50 |
DP_IN();
|
sl@0
|
51 |
|
sl@0
|
52 |
// Setup Multimedia Resource Control
|
sl@0
|
53 |
User::LeaveIfError(iMMRC.Open(*this));
|
sl@0
|
54 |
User::LeaveIfError(iCriticalSection.CreateLocal());
|
sl@0
|
55 |
DP_OUT();
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
// ---------------------------------------------------------------------------
|
sl@0
|
59 |
// Symbian constructor
|
sl@0
|
60 |
// ---------------------------------------------------------------------------
|
sl@0
|
61 |
EXPORT_C CAudioContext* CAudioContext::NewL()
|
sl@0
|
62 |
{
|
sl@0
|
63 |
DP_STATIC_CONTEXT(CAudioContext::NewL *CD0*, CtxDevSound, DPLOCAL);
|
sl@0
|
64 |
DP_IN();
|
sl@0
|
65 |
CAudioContext* self = new(ELeave)CAudioContext();
|
sl@0
|
66 |
CleanupStack::PushL(self);
|
sl@0
|
67 |
self->ConstructL();
|
sl@0
|
68 |
CleanupStack::Pop(self);
|
sl@0
|
69 |
DP0_RET(self, "0x%x");
|
sl@0
|
70 |
}
|
sl@0
|
71 |
|
sl@0
|
72 |
// ---------------------------------------------------------------------------
|
sl@0
|
73 |
// Destructor
|
sl@0
|
74 |
// ---------------------------------------------------------------------------
|
sl@0
|
75 |
//
|
sl@0
|
76 |
EXPORT_C CAudioContext::~CAudioContext()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
DP_CONTEXT(CAudioContext::~CAudioContext *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
79 |
DP_IN();
|
sl@0
|
80 |
iMMRC.Close();
|
sl@0
|
81 |
iAudioContextObservers.Close();
|
sl@0
|
82 |
iAudioProcessingUnits.Close();
|
sl@0
|
83 |
if (iActualChain)
|
sl@0
|
84 |
{
|
sl@0
|
85 |
iActualChain->Release();
|
sl@0
|
86 |
};
|
sl@0
|
87 |
iCriticalSection.Close();
|
sl@0
|
88 |
DP_OUT();
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
// ---------------------------------------------------------------------------
|
sl@0
|
92 |
// From class MAudioContext
|
sl@0
|
93 |
// CAudioContext::SetClientSettings
|
sl@0
|
94 |
// ---------------------------------------------------------------------------
|
sl@0
|
95 |
//
|
sl@0
|
96 |
TInt CAudioContext::SetClientSettings(const TClientContextSettings& aSettings)
|
sl@0
|
97 |
{
|
sl@0
|
98 |
DP_CONTEXT(CAudioContext::SetClientSettings *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
99 |
DP_IN();
|
sl@0
|
100 |
TInt err(KErrNone);
|
sl@0
|
101 |
iClientSettings = aSettings;
|
sl@0
|
102 |
if( iContextId.Id() == 0 )
|
sl@0
|
103 |
{
|
sl@0
|
104 |
TUint64 id = iMMRC.LogOn(iClientSettings.iProcessId);
|
sl@0
|
105 |
TAudioContextId temp(id);
|
sl@0
|
106 |
iContextId = temp;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
else
|
sl@0
|
109 |
{
|
sl@0
|
110 |
err = KErrAlreadyExists;
|
sl@0
|
111 |
}
|
sl@0
|
112 |
DP0_RET(err, "%d");
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
// ---------------------------------------------------------------------------
|
sl@0
|
117 |
// From class MAudioContext
|
sl@0
|
118 |
// CAudioContext::GetContextId
|
sl@0
|
119 |
// ---------------------------------------------------------------------------
|
sl@0
|
120 |
//
|
sl@0
|
121 |
TAudioContextId CAudioContext::ContextId() const
|
sl@0
|
122 |
{
|
sl@0
|
123 |
DP_CONTEXT(CAudioContext::ContextId *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
124 |
DP_IN();
|
sl@0
|
125 |
DP_OUT();
|
sl@0
|
126 |
return iContextId;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
// ---------------------------------------------------------------------------
|
sl@0
|
130 |
// From class MAudioContext
|
sl@0
|
131 |
// CAudioContext::Commit
|
sl@0
|
132 |
// ---------------------------------------------------------------------------
|
sl@0
|
133 |
//
|
sl@0
|
134 |
TInt CAudioContext::Commit()
|
sl@0
|
135 |
{
|
sl@0
|
136 |
DP_CONTEXT(CAudioContext::Commit *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
137 |
DP_IN();
|
sl@0
|
138 |
TInt err(KErrNone);
|
sl@0
|
139 |
iInCommit = ETrue;
|
sl@0
|
140 |
|
sl@0
|
141 |
if (iClientSettings.iProcessId.Id() == 0)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
DP0_RET(KErrNotReady, "%d");
|
sl@0
|
144 |
}
|
sl@0
|
145 |
|
sl@0
|
146 |
err = iMMRC.SendResourceRequest(iActualChain, iDesiredChain, this);
|
sl@0
|
147 |
DP0_RET(err, "%d");
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
// ---------------------------------------------------------------------------
|
sl@0
|
151 |
// From class MAudioContext
|
sl@0
|
152 |
// CAudioContext::CreateAudioStream
|
sl@0
|
153 |
// ---------------------------------------------------------------------------
|
sl@0
|
154 |
//
|
sl@0
|
155 |
TInt CAudioContext::CreateAudioStream(MAudioStream *&aStream)
|
sl@0
|
156 |
{
|
sl@0
|
157 |
DP_CONTEXT(CAudioContext::CreateAudioStream *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
158 |
DP_IN();
|
sl@0
|
159 |
TInt err(KErrNone);
|
sl@0
|
160 |
|
sl@0
|
161 |
CAudioStreamManager* manager(NULL);
|
sl@0
|
162 |
|
sl@0
|
163 |
// Create desired logical chain
|
sl@0
|
164 |
TRAP(err, manager = CAudioStreamManager::NewL(KUidAudioStream));
|
sl@0
|
165 |
if(err == KErrNone)
|
sl@0
|
166 |
{
|
sl@0
|
167 |
aStream = static_cast<MAudioStream*>(manager);
|
sl@0
|
168 |
|
sl@0
|
169 |
// Use this as desired chain (this is the one that the client modify)
|
sl@0
|
170 |
CLogicalAudioStream* logicalAudioStream = static_cast<CLogicalAudioStream*>(aStream);
|
sl@0
|
171 |
iDesiredChain = static_cast<MLogicalChain*>(logicalAudioStream);
|
sl@0
|
172 |
logicalAudioStream->SetParentContext(*this);
|
sl@0
|
173 |
if (iActualChain)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
iActualChain->Release();
|
sl@0
|
176 |
iActualChain=NULL;
|
sl@0
|
177 |
}
|
sl@0
|
178 |
TRAP(err, iActualChain = iDesiredChain->CloneL());
|
sl@0
|
179 |
}
|
sl@0
|
180 |
DP0_RET(err, "%d");
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
// ---------------------------------------------------------------------------
|
sl@0
|
184 |
// From class MAudioContext
|
sl@0
|
185 |
// CAudioContext::DeleteAudioStream
|
sl@0
|
186 |
// ---------------------------------------------------------------------------
|
sl@0
|
187 |
//
|
sl@0
|
188 |
void CAudioContext::DeleteAudioStream(MAudioStream *&aStream)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
DP_CONTEXT(CAudioContext::DeleteAudioStream *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
191 |
DP_IN();
|
sl@0
|
192 |
CAudioStreamManager* manager = static_cast<CAudioStreamManager*>(aStream);
|
sl@0
|
193 |
delete manager;
|
sl@0
|
194 |
DP_OUT();
|
sl@0
|
195 |
}
|
sl@0
|
196 |
|
sl@0
|
197 |
// ---------------------------------------------------------------------------
|
sl@0
|
198 |
// From class MAudioContext
|
sl@0
|
199 |
// CAudioContext::CreateAudioProcessingUnit
|
sl@0
|
200 |
// ---------------------------------------------------------------------------
|
sl@0
|
201 |
//
|
sl@0
|
202 |
TInt CAudioContext::CreateAudioProcessingUnit(TUid aTypeId, MAudioProcessingUnit *&aProcessingUnit)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
DP_CONTEXT(CAudioContext::CreateAudioProcessingUnit *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
205 |
DP_IN();
|
sl@0
|
206 |
TInt err(KErrNone);
|
sl@0
|
207 |
TAudioComponentId unitInstance = GetAndSetInstanceID();
|
sl@0
|
208 |
|
sl@0
|
209 |
CAudioProcessingUnit* pUnit=NULL;
|
sl@0
|
210 |
TComponentParameters cParameters;
|
sl@0
|
211 |
cParameters.iTypeUid = aTypeId;
|
sl@0
|
212 |
cParameters.iInstanceId = unitInstance;
|
sl@0
|
213 |
cParameters.iContextId = iContextId;
|
sl@0
|
214 |
cParameters.iSettingsObserver = this;
|
sl@0
|
215 |
|
sl@0
|
216 |
TRAP(err, pUnit = CAudioProcessingUnit::NewL(cParameters));
|
sl@0
|
217 |
if (err==KErrNone)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
aProcessingUnit = static_cast<MAudioProcessingUnit*>(pUnit);
|
sl@0
|
220 |
err = iAudioProcessingUnits.Append(aProcessingUnit);
|
sl@0
|
221 |
if(err!=KErrNone)
|
sl@0
|
222 |
{
|
sl@0
|
223 |
delete pUnit;
|
sl@0
|
224 |
aProcessingUnit = NULL;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
}
|
sl@0
|
227 |
DP0_RET(err, "%d");
|
sl@0
|
228 |
}
|
sl@0
|
229 |
|
sl@0
|
230 |
// ---------------------------------------------------------------------------
|
sl@0
|
231 |
// From class MAudioContext
|
sl@0
|
232 |
// CAudioContext::DeleteAudioProcessingUnit
|
sl@0
|
233 |
// ---------------------------------------------------------------------------
|
sl@0
|
234 |
//
|
sl@0
|
235 |
void CAudioContext::DeleteAudioProcessingUnit(
|
sl@0
|
236 |
MAudioProcessingUnit *&aProcessingUnit)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
DP_CONTEXT(CAudioContext::DeleteAudioProcessingUnit *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
239 |
DP_IN();
|
sl@0
|
240 |
DP_OUT();
|
sl@0
|
241 |
CAudioProcessingUnit* cUnit = static_cast<CAudioProcessingUnit*>(aProcessingUnit);
|
sl@0
|
242 |
TAudioComponentId param = aProcessingUnit->InstanceId();
|
sl@0
|
243 |
TUint count= iAudioProcessingUnits.Count();
|
sl@0
|
244 |
|
sl@0
|
245 |
for ( TUint i(0); i < count; i++ )
|
sl@0
|
246 |
{
|
sl@0
|
247 |
// find and delete component
|
sl@0
|
248 |
if( iAudioProcessingUnits[i]->InstanceId() == param)
|
sl@0
|
249 |
{
|
sl@0
|
250 |
iAudioProcessingUnits.Remove(i);
|
sl@0
|
251 |
delete cUnit;
|
sl@0
|
252 |
break;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
}
|
sl@0
|
255 |
}
|
sl@0
|
256 |
|
sl@0
|
257 |
// ---------------------------------------------------------------------------
|
sl@0
|
258 |
// From class MAudioContext
|
sl@0
|
259 |
// CAudioContext::RegisterAudioContextObserver
|
sl@0
|
260 |
// ---------------------------------------------------------------------------
|
sl@0
|
261 |
//
|
sl@0
|
262 |
TInt CAudioContext::RegisterAudioContextObserver(
|
sl@0
|
263 |
MAudioContextObserver& aObserver)
|
sl@0
|
264 |
{
|
sl@0
|
265 |
DP_CONTEXT(CAudioContext::RegisterAudioContextObserver *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
266 |
DP_IN();
|
sl@0
|
267 |
TInt err = iAudioContextObservers.Find(&aObserver);
|
sl@0
|
268 |
if( err != KErrNotFound )
|
sl@0
|
269 |
{
|
sl@0
|
270 |
err = KErrAlreadyExists;
|
sl@0
|
271 |
}
|
sl@0
|
272 |
else
|
sl@0
|
273 |
{
|
sl@0
|
274 |
err = iAudioContextObservers.Append(&aObserver);
|
sl@0
|
275 |
}
|
sl@0
|
276 |
DP0_RET(err, "%d");
|
sl@0
|
277 |
}
|
sl@0
|
278 |
|
sl@0
|
279 |
// ---------------------------------------------------------------------------
|
sl@0
|
280 |
// From class MAudioContext
|
sl@0
|
281 |
// CAudioContext::UnregisterAudioContextObserver
|
sl@0
|
282 |
// ---------------------------------------------------------------------------
|
sl@0
|
283 |
//
|
sl@0
|
284 |
void CAudioContext::UnregisterAudioContextObserver(
|
sl@0
|
285 |
MAudioContextObserver& aObserver)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
DP_CONTEXT(CAudioContext::UnregisterAudioContextObserver *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
288 |
DP_IN();
|
sl@0
|
289 |
|
sl@0
|
290 |
TInt idxOrErr = iAudioContextObservers.Find(&aObserver);
|
sl@0
|
291 |
if( idxOrErr != KErrNotFound )
|
sl@0
|
292 |
{
|
sl@0
|
293 |
iAudioContextObservers.Remove(idxOrErr);
|
sl@0
|
294 |
}
|
sl@0
|
295 |
DP_OUT();
|
sl@0
|
296 |
}
|
sl@0
|
297 |
|
sl@0
|
298 |
// ---------------------------------------------------------------------------
|
sl@0
|
299 |
// From class MAudioContext
|
sl@0
|
300 |
// CAudioContext::Interface
|
sl@0
|
301 |
// ---------------------------------------------------------------------------
|
sl@0
|
302 |
//
|
sl@0
|
303 |
TAny* CAudioContext::Interface(TUid aType)
|
sl@0
|
304 |
{
|
sl@0
|
305 |
DP_CONTEXT(CAudioContext::Interface *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
306 |
DP_IN();
|
sl@0
|
307 |
TAny* interface = NULL;
|
sl@0
|
308 |
if(aType == KUIdAudioResourceNotification)
|
sl@0
|
309 |
{
|
sl@0
|
310 |
#ifndef SYMBIAN_DISABLE_ARN
|
sl@0
|
311 |
interface = static_cast<MA3FDevSoundAutoPauseResume*>(this);
|
sl@0
|
312 |
#else
|
sl@0
|
313 |
interface = NULL;
|
sl@0
|
314 |
#endif
|
sl@0
|
315 |
}
|
sl@0
|
316 |
else
|
sl@0
|
317 |
{
|
sl@0
|
318 |
interface = NULL;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
DP_OUT();
|
sl@0
|
321 |
return interface;
|
sl@0
|
322 |
}
|
sl@0
|
323 |
|
sl@0
|
324 |
|
sl@0
|
325 |
// ---------------------------------------------------------------------------
|
sl@0
|
326 |
// From class MAudioContext
|
sl@0
|
327 |
// CAudioContext::Reset
|
sl@0
|
328 |
// ---------------------------------------------------------------------------
|
sl@0
|
329 |
//
|
sl@0
|
330 |
TInt CAudioContext::Reset()
|
sl@0
|
331 |
{
|
sl@0
|
332 |
DP_CONTEXT(CAudioContext::Reset *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
333 |
DP_IN();
|
sl@0
|
334 |
TInt err = KErrNone;
|
sl@0
|
335 |
if (iInCommit)
|
sl@0
|
336 |
{
|
sl@0
|
337 |
err = KErrNotReady;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
iDesiredChain->ResetMessage();
|
sl@0
|
340 |
iDesiredChain->CopySettings(*iActualChain);
|
sl@0
|
341 |
DP0_RET(err, "%d");
|
sl@0
|
342 |
}
|
sl@0
|
343 |
|
sl@0
|
344 |
// ---------------------------------------------------------------------------
|
sl@0
|
345 |
// From class MMultimediaResourceControlObserver
|
sl@0
|
346 |
// CAudioContext::ReceiveResourceResponse
|
sl@0
|
347 |
// ---------------------------------------------------------------------------
|
sl@0
|
348 |
//
|
sl@0
|
349 |
void CAudioContext::ReceiveResourceResponse(MLogicalChain* aAppliedChain, TInt aError)
|
sl@0
|
350 |
{
|
sl@0
|
351 |
DP_CONTEXT(CAudioContext::ReceiveResourceResponse *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
352 |
DP_IN();
|
sl@0
|
353 |
|
sl@0
|
354 |
iCriticalSection.Wait();
|
sl@0
|
355 |
iMsgVersion++;
|
sl@0
|
356 |
iMMRC.ResetMessages();
|
sl@0
|
357 |
iCriticalSection.Signal();
|
sl@0
|
358 |
|
sl@0
|
359 |
if ( aError == KErrNone || iPreempted )
|
sl@0
|
360 |
{
|
sl@0
|
361 |
if ( iPreempted )
|
sl@0
|
362 |
{
|
sl@0
|
363 |
iPreempted = EFalse;
|
sl@0
|
364 |
}
|
sl@0
|
365 |
// Desired chain was commited succesfully
|
sl@0
|
366 |
TInt err;
|
sl@0
|
367 |
MLogicalChain* lc = NULL;
|
sl@0
|
368 |
TRAP(err, lc = aAppliedChain->CloneL());
|
sl@0
|
369 |
DP1(DLERR,"ECloneLeftWhenReceivingResourceResponse %d", err);
|
sl@0
|
370 |
__ASSERT_DEBUG(err == KErrNone, Panic(ECloneLeftWhenReceivingResourceResponse));
|
sl@0
|
371 |
if ( iActualChain )
|
sl@0
|
372 |
{
|
sl@0
|
373 |
iActualChain->Release();
|
sl@0
|
374 |
}
|
sl@0
|
375 |
iActualChain = lc;
|
sl@0
|
376 |
}
|
sl@0
|
377 |
else
|
sl@0
|
378 |
{
|
sl@0
|
379 |
iDesiredChain->CopySettings(*iActualChain);
|
sl@0
|
380 |
}
|
sl@0
|
381 |
iDesiredChain->ResetMessage();
|
sl@0
|
382 |
ContextEventSignal(KUidA3FContextUpdateComplete, aError);
|
sl@0
|
383 |
iInCommit = EFalse;
|
sl@0
|
384 |
DP_OUT();
|
sl@0
|
385 |
}
|
sl@0
|
386 |
|
sl@0
|
387 |
// ---------------------------------------------------------------------------
|
sl@0
|
388 |
// From class MMultimediaResourceControlObserver
|
sl@0
|
389 |
// CAudioContext::ReceiveResourceUpdate
|
sl@0
|
390 |
// ---------------------------------------------------------------------------
|
sl@0
|
391 |
//
|
sl@0
|
392 |
void CAudioContext::ReceiveResourceUpdate(MLogicalChain* /*aMessage*/, TInt aError)
|
sl@0
|
393 |
{
|
sl@0
|
394 |
DP_CONTEXT(CAudioContext::ReceiveResourceUpdate *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
395 |
DP_IN();
|
sl@0
|
396 |
ContextEventSignal(KUidA3FContextCommitUpdate, aError);
|
sl@0
|
397 |
DP_OUT();
|
sl@0
|
398 |
}
|
sl@0
|
399 |
|
sl@0
|
400 |
|
sl@0
|
401 |
// ---------------------------------------------------------------------------
|
sl@0
|
402 |
// From class MMultimediaResourceControlObserver
|
sl@0
|
403 |
// CAudioContext::ReceivePreemptionUpdate
|
sl@0
|
404 |
// ---------------------------------------------------------------------------
|
sl@0
|
405 |
//
|
sl@0
|
406 |
void CAudioContext::ReceivePreemptionUpdate(MLogicalChain* /*aMessage*/, TInt aError)
|
sl@0
|
407 |
{
|
sl@0
|
408 |
DP_CONTEXT(CAudioContext::ReceivePreemptionUpdate *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
409 |
DP_IN();
|
sl@0
|
410 |
iPreempted = ETrue;
|
sl@0
|
411 |
if(iInCommit)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
// Send only one callback
|
sl@0
|
414 |
ContextEventSignal(KUidA3FContextPreEmptedCommit, aError);
|
sl@0
|
415 |
}
|
sl@0
|
416 |
else
|
sl@0
|
417 |
{
|
sl@0
|
418 |
// Send two callbacks
|
sl@0
|
419 |
ContextEventSignal(KUidA3FContextPreEmption, aError);
|
sl@0
|
420 |
ContextEventSignal(KUidA3FContextPreEmptionUpdate, aError);
|
sl@0
|
421 |
}
|
sl@0
|
422 |
DP_OUT();
|
sl@0
|
423 |
}
|
sl@0
|
424 |
|
sl@0
|
425 |
|
sl@0
|
426 |
// ---------------------------------------------------------------------------
|
sl@0
|
427 |
// From class MLogicalSettingObserver
|
sl@0
|
428 |
// CAudioContext::ReceiveComponentSettingsChange
|
sl@0
|
429 |
// ---------------------------------------------------------------------------
|
sl@0
|
430 |
void CAudioContext::ReceiveComponentSettingsChange(TUid /*aId*/, TMMRCMessageType aMessageType)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
iDesiredChain->SetMessageType(aMessageType);
|
sl@0
|
433 |
}
|
sl@0
|
434 |
|
sl@0
|
435 |
// ---------------------------------------------------------------------------
|
sl@0
|
436 |
// Internals
|
sl@0
|
437 |
// CAudioContext::GetAndSetInstanceID
|
sl@0
|
438 |
// ---------------------------------------------------------------------------
|
sl@0
|
439 |
TAudioComponentId CAudioContext::GetAndSetInstanceID()
|
sl@0
|
440 |
{
|
sl@0
|
441 |
DP_CONTEXT(CAudioContext::GetAndSetInstanceID *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
442 |
DP_IN();
|
sl@0
|
443 |
TUint id(1); // start ID count from 1
|
sl@0
|
444 |
TAudioComponentId idComponent(1);
|
sl@0
|
445 |
TUint count = iAudioProcessingUnits.Count();
|
sl@0
|
446 |
if ( count < KMaxTUint )
|
sl@0
|
447 |
{
|
sl@0
|
448 |
id = ++count;
|
sl@0
|
449 |
}
|
sl@0
|
450 |
idComponent = id;
|
sl@0
|
451 |
DP_OUT();
|
sl@0
|
452 |
return idComponent;
|
sl@0
|
453 |
}
|
sl@0
|
454 |
|
sl@0
|
455 |
// ---------------------------------------------------------------------------
|
sl@0
|
456 |
// Internals
|
sl@0
|
457 |
// CAudioContext::ContextEventSignal
|
sl@0
|
458 |
// ---------------------------------------------------------------------------
|
sl@0
|
459 |
void CAudioContext::ContextEventSignal(TUid aEvent, TInt aError)
|
sl@0
|
460 |
{
|
sl@0
|
461 |
DP_CONTEXT(CAudioContext::ContextEventSignal *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
462 |
DP_IN();
|
sl@0
|
463 |
TUint count = iAudioContextObservers.Count();
|
sl@0
|
464 |
for ( TUint idx(0); idx < count; idx++ )
|
sl@0
|
465 |
{
|
sl@0
|
466 |
iAudioContextObservers[idx]->ContextEvent(aEvent, aError);
|
sl@0
|
467 |
}
|
sl@0
|
468 |
DP_OUT();
|
sl@0
|
469 |
}
|
sl@0
|
470 |
|
sl@0
|
471 |
// ---------------------------------------------------------------------------
|
sl@0
|
472 |
// CAudioContext::GetLogicalChain
|
sl@0
|
473 |
// ---------------------------------------------------------------------------
|
sl@0
|
474 |
EXPORT_C MLogicalChain* CAudioContext::GetLogicalChain(TInt aIndex)
|
sl@0
|
475 |
{
|
sl@0
|
476 |
DP_CONTEXT(CAudioContext::GetLogicalChain *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
477 |
DP_IN();
|
sl@0
|
478 |
MLogicalChain* logChain = NULL;
|
sl@0
|
479 |
if (aIndex == 0)
|
sl@0
|
480 |
{
|
sl@0
|
481 |
logChain = iDesiredChain;
|
sl@0
|
482 |
}
|
sl@0
|
483 |
else
|
sl@0
|
484 |
{
|
sl@0
|
485 |
logChain = iActualChain;
|
sl@0
|
486 |
}
|
sl@0
|
487 |
DP_OUT();
|
sl@0
|
488 |
return logChain;
|
sl@0
|
489 |
}
|
sl@0
|
490 |
|
sl@0
|
491 |
|
sl@0
|
492 |
// ---------------------------------------------------------------------------
|
sl@0
|
493 |
// CAudioContext::RegisterAsClient
|
sl@0
|
494 |
// ---------------------------------------------------------------------------
|
sl@0
|
495 |
TInt CAudioContext::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData, MA3FDevSoundAutoPauseResumeObserver* aObserverPtr)
|
sl@0
|
496 |
{
|
sl@0
|
497 |
DP_CONTEXT(CAudioContext::RegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
498 |
DP_IN();
|
sl@0
|
499 |
TInt err(KErrNone);
|
sl@0
|
500 |
iObserverPtr = aObserverPtr;
|
sl@0
|
501 |
err = iMMRC.RegisterAsClient(aEventType, aNotificationRegistrationData);
|
sl@0
|
502 |
DP0_RET(err, "%d");
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
// ---------------------------------------------------------------------------
|
sl@0
|
506 |
// CAudioContext::CancelRegisterAsClient
|
sl@0
|
507 |
// ---------------------------------------------------------------------------
|
sl@0
|
508 |
TInt CAudioContext::CancelRegisterAsClient(TUid aEventType)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
DP_CONTEXT(CAudioContext::CancelRegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
511 |
DP_IN();
|
sl@0
|
512 |
TInt err(KErrNone);
|
sl@0
|
513 |
err = iMMRC.CancelRegisterAsClient(aEventType);
|
sl@0
|
514 |
DP0_RET(err, "%d");
|
sl@0
|
515 |
}
|
sl@0
|
516 |
|
sl@0
|
517 |
// ---------------------------------------------------------------------------
|
sl@0
|
518 |
// CAudioContext::WillResumePlay
|
sl@0
|
519 |
// ---------------------------------------------------------------------------
|
sl@0
|
520 |
TInt CAudioContext::WillResumePlay()
|
sl@0
|
521 |
{
|
sl@0
|
522 |
DP_CONTEXT(CAudioContext::WillResumePlay *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
523 |
DP_IN();
|
sl@0
|
524 |
TInt err(KErrNone);
|
sl@0
|
525 |
err = iMMRC.WillResumePlay();
|
sl@0
|
526 |
DP0_RET(err, "%d");
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
// ---------------------------------------------------------------------------
|
sl@0
|
530 |
// From class MMultimediaResourceControlObserver
|
sl@0
|
531 |
// CAudioContext::CanResume
|
sl@0
|
532 |
// ---------------------------------------------------------------------------
|
sl@0
|
533 |
//
|
sl@0
|
534 |
void CAudioContext::CanResume()
|
sl@0
|
535 |
{
|
sl@0
|
536 |
DP_CONTEXT(CAudioContext::CanResume *CD1*, CtxDevSound, DPLOCAL);
|
sl@0
|
537 |
DP_IN();
|
sl@0
|
538 |
if(iObserverPtr)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
iObserverPtr->NotifyResume();
|
sl@0
|
541 |
}
|
sl@0
|
542 |
DP_OUT();
|
sl@0
|
543 |
}
|
sl@0
|
544 |
|
sl@0
|
545 |
void CAudioContext::Panic(TAudioContextPanicCodes aCode)
|
sl@0
|
546 |
{
|
sl@0
|
547 |
User::Panic(KAudioContextPanicCategory, aCode);
|
sl@0
|
548 |
}
|
sl@0
|
549 |
|
sl@0
|
550 |
EXPORT_C TInt CAudioContext::MsgVersion()
|
sl@0
|
551 |
{
|
sl@0
|
552 |
return iMsgVersion;
|
sl@0
|
553 |
}
|
sl@0
|
554 |
|
sl@0
|
555 |
EXPORT_C RCriticalSection& CAudioContext::CriticalSection()
|
sl@0
|
556 |
{
|
sl@0
|
557 |
return iCriticalSection;
|
sl@0
|
558 |
}
|
sl@0
|
559 |
// End of file
|