|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32mem.h> |
|
17 #include "mmfaudioclientserver.h" |
|
18 #include "mmfaudioserver.h" |
|
19 #include "mmfdevsoundserver.h" |
|
20 #include "mmfdevsoundsession.h" |
|
21 #include <mmf/plugin/mmfdevsoundcustominterface.hrh> |
|
22 #include <mm/mmpluginutils.h> |
|
23 #ifdef _DEBUG |
|
24 #include "e32debug.h" |
|
25 |
|
26 #define SYMBIAN_DEBPRN0(str) RDebug::Print(str, this) |
|
27 #define SYMBIAN_DEBPRN1(str, val1) RDebug::Print(str, this, val1) |
|
28 #define SYMBIAN_DEBPRN2(str, val1, val2) RDebug::Print(str, this, val1, val2) |
|
29 #define SYMBIAN_DEBPRN3(str, val1, val2, val3) RDebug::Print(str, this, val1, val2, val3) |
|
30 #else |
|
31 #define SYMBIAN_DEBPRN0(str) |
|
32 #define SYMBIAN_DEBPRN1(str, val1) |
|
33 #define SYMBIAN_DEBPRN2(str, val1, val2) |
|
34 #define SYMBIAN_DEBPRN3(str, val1, val2, val3) |
|
35 #endif //_DEBUG |
|
36 |
|
37 const TInt KMaxQueueRequest = 6; |
|
38 |
|
39 // MEMBER FUNCTIONS |
|
40 |
|
41 TMMFDevSoundRequest::TMMFDevSoundRequest() |
|
42 : iMessageCompleted(EFalse), |
|
43 iRequestType(EUndefinedType), |
|
44 iCallBackPF(KCallbackNone) |
|
45 { |
|
46 } |
|
47 |
|
48 TMMFDevSoundRequest::TMMFDevSoundRequest(TInt aIsCallBack) |
|
49 : iMessageCompleted(EFalse), |
|
50 iRequestType(ECallBackType), |
|
51 iCallBackPF(aIsCallBack) |
|
52 { |
|
53 } |
|
54 |
|
55 TMMFDevSoundRequest::TMMFDevSoundRequest(const TMMFDevSoundRequest& aRequest) |
|
56 : iMessageCompleted(EFalse), |
|
57 iMessage(aRequest.iMessage), |
|
58 iCallBackPF(aRequest.iCallBackPF) |
|
59 { |
|
60 iRequestType = ResolveType(); |
|
61 } |
|
62 |
|
63 TBool TMMFDevSoundRequest::operator==(const TMMFDevSoundRequest& aRequest) const |
|
64 { |
|
65 TBool retval = EFalse; |
|
66 if ( aRequest.Function() == Function() ) |
|
67 { |
|
68 retval = ETrue; |
|
69 } |
|
70 else |
|
71 { |
|
72 retval = EFalse; |
|
73 } |
|
74 return retval; |
|
75 } |
|
76 |
|
77 const RMmfIpcMessage& TMMFDevSoundRequest::Message() |
|
78 { |
|
79 return iMessage; |
|
80 } |
|
81 |
|
82 void TMMFDevSoundRequest::SetMessage(const RMmfIpcMessage& aMessage) |
|
83 { |
|
84 iMessageCompleted = EFalse; |
|
85 iMessage = aMessage; |
|
86 iRequestType = ResolveType(); |
|
87 } |
|
88 |
|
89 void TMMFDevSoundRequest::SetMessageCallback() |
|
90 { |
|
91 iMessageCompleted = EFalse; |
|
92 iRequestType = ECallBackType; |
|
93 } |
|
94 |
|
95 TInt TMMFDevSoundRequest::IsCallBack() const |
|
96 { |
|
97 return iCallBackPF; |
|
98 } |
|
99 |
|
100 TMMFDevSoundRequest::TA3FDevSoundRequestType TMMFDevSoundRequest::ResolveType() |
|
101 { |
|
102 TA3FDevSoundRequestType type = EUndefinedType; |
|
103 switch(iMessage.Function()) |
|
104 { |
|
105 case EMMFDevSoundProxyInitialize1: |
|
106 case EMMFDevSoundProxyInitialize2: |
|
107 case EMMFDevSoundProxyInitialize4: |
|
108 case EMMFDevSoundProxyPlayInit: |
|
109 case EMMFDevSoundProxyRecordInit: |
|
110 case EMMFDevSoundProxyPlayTone: |
|
111 case EMMFDevSoundProxyPlayDualTone: |
|
112 case EMMFDevSoundProxyPlayDTMFString: |
|
113 case EMMFDevSoundProxyPlayToneSequence: |
|
114 case EMMFDevSoundProxyPlayFixedSequence: |
|
115 type = EAction_PseudoAsynchronous; |
|
116 break; |
|
117 |
|
118 case EMMFDevSoundProxyStop: |
|
119 case EMMFDevSoundProxyPause: |
|
120 case EMMFDevSoundProxyClose: |
|
121 case EMMFDevSoundProxyCancelInitialize: |
|
122 case EMMFDevSoundProxyResume: |
|
123 case EMMFDevSoundProxyEmptyBuffers: |
|
124 type = EAction_Asynchronous; |
|
125 break; |
|
126 |
|
127 case EMMFDevSoundProxySetConfig: |
|
128 case EMMFDevSoundProxyPostOpen: // Although this is not a configure operation technically, it has same calling pattern. |
|
129 case EMMFDevSoundProxySetVolume: |
|
130 case EMMFDevSoundProxySetGain: |
|
131 case EMMFDevSoundProxySetPlayBalance: |
|
132 case EMMFDevSoundProxySetRecordBalance: |
|
133 case EMMFDevSoundProxySetVolumeRamp: |
|
134 case EMMFDevSoundProxySetPrioritySettings: |
|
135 type = EConfigure_Asynchronous; |
|
136 break; |
|
137 |
|
138 case EMMFDevSoundProxySetDTMFLengths: |
|
139 case EMMFDevSoundProxySetToneRepeats: |
|
140 type = EConfigure_Synchronous; |
|
141 break; |
|
142 case EMMFDevSoundProxyCapabilities: |
|
143 type = EQuery_Asynchronous; |
|
144 break; |
|
145 case EMMFDevSoundProxyMaxVolume: |
|
146 case EMMFDevSoundProxyMaxGain: |
|
147 case EMMFDevSoundProxyConfig: |
|
148 case EMMFDevSoundProxyVolume: |
|
149 case EMMFDevSoundProxyGain: |
|
150 case EMMFDevSoundProxyPlayBalance: |
|
151 case EMMFDevSoundProxyRecordBalance: |
|
152 case EMMFDevSoundProxyGetSupportedInputDataTypes: |
|
153 case EMMFDevSoundProxyGetSupportedOutputDataTypes: |
|
154 case EMMFDevSoundProxyFixedSequenceName: |
|
155 case EMMFDevSoundProxyFixedSequenceCount: |
|
156 case EMMFDevSoundProxySamplesRecorded: |
|
157 case EMMFDevSoundProxySamplesPlayed: |
|
158 case EMMFDevSoundProxyCopyFourCCArrayData: |
|
159 case EMMFDevSoundProxyGetTimePlayed: |
|
160 case EMMFDevSoundProxyIsResumeSupported: |
|
161 type = EQuery_Synchronous; |
|
162 break; |
|
163 |
|
164 case EMMFDevSoundProxyBTBFData: |
|
165 case EMMFDevSoundProxyBTBEData: |
|
166 case EMMFDevSoundProxyPlayData: |
|
167 case EMMFDevSoundProxyRecordData: |
|
168 type = EBufferExchangeRelated; |
|
169 break; |
|
170 |
|
171 // Custom Interfaces |
|
172 case EMMFDevSoundProxySyncCustomCommand: |
|
173 case EMMFDevSoundProxySyncCustomCommandResult: |
|
174 case EMMFDevSoundProxyAsyncCustomCommand: |
|
175 case EMMFDevSoundProxyAsyncCustomCommandResult: |
|
176 case EMMFDevSoundProxyCustomInterface: |
|
177 type = ECustomInterfacesRelated; |
|
178 break; |
|
179 case RMessage2::EDisConnect: |
|
180 type = ESessionEvents; |
|
181 break; |
|
182 default: |
|
183 break; |
|
184 } |
|
185 return type; |
|
186 } |
|
187 |
|
188 |
|
189 void TMMFDevSoundRequest::Complete(TInt aError) |
|
190 { |
|
191 if(!iMessageCompleted && iRequestType != EUndefinedType && iRequestType != ECallBackType) |
|
192 { |
|
193 iMessage.Complete(aError); |
|
194 iMessageCompleted = ETrue; |
|
195 iRequestType = EUndefinedType; |
|
196 } |
|
197 } |
|
198 |
|
199 TInt TMMFDevSoundRequest::Function() const |
|
200 { |
|
201 return iMessage.Function(); |
|
202 } |
|
203 |
|
204 TMMFDevSoundRequest::TA3FDevSoundRequestType TMMFDevSoundRequest::Type() const |
|
205 { |
|
206 return iRequestType; |
|
207 } |
|
208 |
|
209 |
|
210 // |
|
211 // CMMFDevSoundSession::CreateL |
|
212 // Creates a new object |
|
213 // |
|
214 void CMMFDevSoundSession::CreateL(const CMmfIpcServer& aServer) |
|
215 { |
|
216 CMmfIpcSession::CreateL(aServer); |
|
217 CMMFDevSoundServer& server = |
|
218 const_cast<CMMFDevSoundServer&>( |
|
219 static_cast<const CMMFDevSoundServer&>(aServer)); |
|
220 server.IncrementSessionId(); |
|
221 iDevSoundSessionId = server.DevSoundSessionId(); |
|
222 } |
|
223 |
|
224 // |
|
225 // NeedToQueue - mid-commit cycle or async queue start AO is active |
|
226 // |
|
227 TBool CMMFDevSoundSession::NeedToQueue() const |
|
228 { |
|
229 return iOperationCompletePending || iAsyncQueueStart->IsActive(); |
|
230 } |
|
231 |
|
232 // |
|
233 // CMMFDevSoundSession::ServiceL |
|
234 // (other items were commented in a header). |
|
235 // |
|
236 void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage) |
|
237 { |
|
238 SYMBIAN_DEBPRN2(_L("\nCMMFDevSoundSession[0x%x] NEW REQUEST %02x while pending=%d"), |
|
239 aMessage.Function(), NeedToQueue()); |
|
240 |
|
241 if(NeedToQueue()) |
|
242 { |
|
243 // if not possible to service now, then queue request |
|
244 EnqueueRequest(aMessage); |
|
245 } |
|
246 else |
|
247 { |
|
248 // If there is no oustanding operation service inmediately |
|
249 TRAPD(err, DoServiceRequestL(aMessage)); |
|
250 if (err) |
|
251 { |
|
252 aMessage.Complete(err); // repeat normal ServiceL() behaviour since we may keep going |
|
253 } |
|
254 if (!iOperationCompletePending && iQueuedRequests.Count() != 0) |
|
255 { |
|
256 //dequeue next |
|
257 DequeueRequest(); |
|
258 } |
|
259 } |
|
260 } |
|
261 |
|
262 // |
|
263 // CMMFDevSoundSession::DoServiceL |
|
264 // (other items were commented in a header). |
|
265 // |
|
266 void CMMFDevSoundSession::DoServiceRequestL(const RMmfIpcMessage& aMessage) |
|
267 { |
|
268 iRequestBeingServiced.SetMessage(aMessage); |
|
269 iAsyncQueueStart->Cancel(); // just in case. |
|
270 ResetNotifiedError(); |
|
271 |
|
272 if (aMessage.Function() == RMessage2::EDisConnect) |
|
273 { |
|
274 TBool complete = iAdapter->CloseDevSound(); |
|
275 if(!complete) |
|
276 { |
|
277 iRequestBeingServiced.SetMessage(aMessage); |
|
278 iOperationCompletePending = ETrue; |
|
279 ResetNotifiedError(); |
|
280 } |
|
281 else |
|
282 { |
|
283 // if we get here, iClosing wait will have been started and we'd be waiting |
|
284 iClosingWait->AsyncStop(); |
|
285 } |
|
286 return; |
|
287 } |
|
288 |
|
289 TMMFMessageDestinationPckg destinationPckg; |
|
290 User::LeaveIfError(MessageRead(aMessage, 0, destinationPckg)); |
|
291 SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - DestinationHandle [%d] InterfaceId [%d] "), destinationPckg().DestinationHandle(), destinationPckg().InterfaceId()); |
|
292 if ((destinationPckg().DestinationHandle() == KMMFObjectHandleDevSound) && |
|
293 (destinationPckg().InterfaceId() == KUidInterfaceMMFDevSound)) |
|
294 { |
|
295 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - Request [%d]"), aMessage.Function()); |
|
296 TBool complete = EFalse; |
|
297 switch(aMessage.Function()) |
|
298 { |
|
299 case EMMFDevSoundProxyPostOpen: |
|
300 complete = DoPostOpenL(aMessage); |
|
301 break; |
|
302 case EMMFDevSoundProxyInitialize1: |
|
303 complete = DoInitialize1L(aMessage); |
|
304 break; |
|
305 case EMMFDevSoundProxyInitialize2: |
|
306 complete = DoInitialize2L(aMessage); |
|
307 break; |
|
308 case EMMFDevSoundProxyInitialize4: |
|
309 complete = DoInitialize4L(aMessage); |
|
310 break; |
|
311 case EMMFDevSoundProxyCapabilities: |
|
312 complete = DoCapabilitiesL(aMessage); |
|
313 break; |
|
314 case EMMFDevSoundProxyConfig: |
|
315 complete = DoConfigL(aMessage); |
|
316 break; |
|
317 case EMMFDevSoundProxySetConfig: |
|
318 complete = DoSetConfigL(aMessage); |
|
319 break; |
|
320 case EMMFDevSoundProxyMaxVolume: |
|
321 complete = DoMaxVolumeL(aMessage); |
|
322 break; |
|
323 case EMMFDevSoundProxyVolume: |
|
324 complete = DoVolumeL(aMessage); |
|
325 break; |
|
326 case EMMFDevSoundProxySetVolume: |
|
327 complete = DoSetVolumeL(aMessage); |
|
328 break; |
|
329 case EMMFDevSoundProxyMaxGain: |
|
330 complete = DoMaxGainL(aMessage); |
|
331 break; |
|
332 case EMMFDevSoundProxyGain: |
|
333 complete = DoGainL(aMessage); |
|
334 break; |
|
335 case EMMFDevSoundProxySetGain: |
|
336 complete = DoSetGainL(aMessage); |
|
337 break; |
|
338 case EMMFDevSoundProxyPlayBalance: |
|
339 complete = DoGetPlayBalanceL(aMessage); |
|
340 break; |
|
341 case EMMFDevSoundProxySetPlayBalance: |
|
342 complete = DoSetPlayBalanceL(aMessage); |
|
343 break; |
|
344 case EMMFDevSoundProxyRecordBalance: |
|
345 complete = DoGetRecordBalanceL(aMessage); |
|
346 break; |
|
347 case EMMFDevSoundProxySetRecordBalance: |
|
348 complete = DoSetRecordBalanceL(aMessage); |
|
349 break; |
|
350 case EMMFDevSoundProxyBTBFData: |
|
351 complete = DoBufferToBeFilledDataL(aMessage); |
|
352 break; |
|
353 case EMMFDevSoundProxyBTBEData: |
|
354 complete = DoBufferToBeEmptiedDataL(aMessage); |
|
355 break; |
|
356 case EMMFDevSoundProxyPlayInit: |
|
357 complete = DoPlayInitL(aMessage); |
|
358 break; |
|
359 case EMMFDevSoundProxyRecordInit: |
|
360 complete = DoRecordInitL(aMessage); |
|
361 break; |
|
362 case EMMFDevSoundProxyPlayData: |
|
363 complete = DoPlayDataL(aMessage); |
|
364 break; |
|
365 case EMMFDevSoundProxyRecordData: |
|
366 complete = DoRecordDataL(aMessage); |
|
367 break; |
|
368 case EMMFDevSoundProxyStop: |
|
369 complete = DoStopL(aMessage); |
|
370 break; |
|
371 case EMMFDevSoundProxyPause: |
|
372 complete = DoPauseL(aMessage); |
|
373 break; |
|
374 case EMMFDevSoundProxyPlayTone: |
|
375 complete = DoPlayToneL(aMessage); |
|
376 break; |
|
377 case EMMFDevSoundProxyPlayDualTone: |
|
378 complete = DoPlayDualToneL(aMessage); |
|
379 break; |
|
380 case EMMFDevSoundProxyPlayDTMFString: |
|
381 complete = DoPlayDTMFStringL(aMessage); |
|
382 break; |
|
383 case EMMFDevSoundProxyPlayToneSequence: |
|
384 complete = DoPlayToneSequenceL(aMessage); |
|
385 break; |
|
386 case EMMFDevSoundProxyPlayFixedSequence: |
|
387 complete = DoPlayFixedSequenceL(aMessage); |
|
388 break; |
|
389 case EMMFDevSoundProxySetDTMFLengths: |
|
390 complete = DoSetDTMFLengthsL(aMessage); |
|
391 break; |
|
392 case EMMFDevSoundProxySetVolumeRamp: |
|
393 complete = DoSetVolumeRampL(aMessage); |
|
394 break; |
|
395 case EMMFDevSoundProxyGetSupportedInputDataTypes: |
|
396 complete = DoGetSupportedInputDataTypesL(aMessage); |
|
397 break; |
|
398 case EMMFDevSoundProxyGetSupportedOutputDataTypes: |
|
399 complete = DoGetSupportedOutputDataTypesL(aMessage); |
|
400 break; |
|
401 case EMMFDevSoundProxyCopyFourCCArrayData: |
|
402 complete = DoCopyFourCCArrayDataL(aMessage); |
|
403 break; |
|
404 case EMMFDevSoundProxySamplesRecorded: |
|
405 complete = DoSamplesRecordedL(aMessage); |
|
406 break; |
|
407 case EMMFDevSoundProxySamplesPlayed: |
|
408 complete = DoSamplesPlayedL(aMessage); |
|
409 break; |
|
410 case EMMFDevSoundProxySetToneRepeats: |
|
411 complete = DoSetToneRepeatsL(aMessage); |
|
412 break; |
|
413 case EMMFDevSoundProxySetPrioritySettings: |
|
414 complete = DoSetPrioritySettingsL(aMessage); |
|
415 break; |
|
416 case EMMFDevSoundProxyFixedSequenceCount: |
|
417 complete = DoFixedSequenceCountL(aMessage); |
|
418 break; |
|
419 case EMMFDevSoundProxyCancelInitialize: |
|
420 complete = DoCancelInitializeL(aMessage); |
|
421 break; |
|
422 case EMMFDevSoundProxyEmptyBuffers: |
|
423 complete = DoEmptyBuffersL(aMessage); |
|
424 break; |
|
425 case EMMFDevSoundProxyGetTimePlayed: |
|
426 complete = DoGetTimePlayedL(aMessage); |
|
427 break; |
|
428 case EMMFDevSoundProxyIsResumeSupported: |
|
429 complete = DoQueryResumeSupportedL(aMessage); |
|
430 break; |
|
431 case EMMFDevSoundProxyResume: |
|
432 complete = DoResumeL(aMessage); |
|
433 break; |
|
434 |
|
435 // DevSound custom command support |
|
436 case EMMFDevSoundProxySyncCustomCommand: |
|
437 case EMMFDevSoundProxySyncCustomCommandResult: |
|
438 case EMMFDevSoundProxyAsyncCustomCommand: |
|
439 case EMMFDevSoundProxyAsyncCustomCommandResult: |
|
440 complete = DoCustomCommandL(aMessage); |
|
441 break; |
|
442 case EMMFDevSoundProxyClose: |
|
443 complete = DoPrepareCloseL(aMessage); |
|
444 break; |
|
445 case EMMFDevSoundProxyRequestResourceNotification: |
|
446 complete = DoRegisterAsClientL(aMessage); |
|
447 break; |
|
448 case EMMFDevSoundProxyCancelRequestResourceNotification: |
|
449 complete = DoCancelRegisterAsClientL(aMessage); |
|
450 break; |
|
451 case EMMFDevSoundProxyGetResourceNotificationData: |
|
452 complete = DoGetResourceNotificationDataL(aMessage); |
|
453 break; |
|
454 case EMMFDevSoundProxyWillResumePlay: |
|
455 complete = DoWillResumePlayL(aMessage); |
|
456 break; |
|
457 case EMMFDevSoundProxySetClientThreadInfo: |
|
458 complete = DoSetClientThreadInfoL(aMessage); |
|
459 break; |
|
460 default: |
|
461 User::Leave(KErrNotSupported); |
|
462 break; |
|
463 } |
|
464 |
|
465 // Check if can complete the message now |
|
466 if (complete) |
|
467 { |
|
468 // Complete the message |
|
469 // Synchronous requests & Pseudo-asynchronous |
|
470 aMessage.Complete(KErrNone); |
|
471 |
|
472 // Store function if we need to re-apply it again due to pre-emption clash |
|
473 if(iRequestBeingServiced.Type() == TMMFDevSoundRequest::EAction_PseudoAsynchronous) |
|
474 { |
|
475 iRedoFunction = aMessage.Function(); |
|
476 } |
|
477 } |
|
478 } |
|
479 else |
|
480 { |
|
481 // If there's a CI extension, see if that handles this request |
|
482 TInt err = KErrNotSupported; |
|
483 if (iCIExtension) |
|
484 { |
|
485 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - CIExtensionRequest [%d]"), aMessage.Function()); |
|
486 iOperationCompletePending = ETrue; |
|
487 iHandlingExtdCI = ETrue; |
|
488 TRAPD(err2, err = iCIExtension->HandleMessageL(aMessage)); |
|
489 if (err2) |
|
490 { |
|
491 err = err2; |
|
492 } |
|
493 iOperationCompletePending = EFalse; |
|
494 iHandlingExtdCI = EFalse; |
|
495 SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - CIExtensionRequest[%d] - Exit with Error[%d] "), aMessage.Function(),err); |
|
496 } |
|
497 |
|
498 if (err != KErrNone) |
|
499 { |
|
500 // Not been handled, the request is not supported |
|
501 aMessage.Complete(KErrNotSupported); |
|
502 } |
|
503 } |
|
504 } |
|
505 |
|
506 void CMMFDevSoundSession::DoServiceAlreadyCompletedRequestL(const TInt aFunction) |
|
507 { |
|
508 ResetNotifiedError(); |
|
509 |
|
510 switch(aFunction) |
|
511 { |
|
512 case EMMFDevSoundProxyInitialize1: |
|
513 DoAlreadyCompletedInitialize1L(); |
|
514 break; |
|
515 case EMMFDevSoundProxyInitialize2: |
|
516 DoAlreadyCompletedInitialize2L(); |
|
517 break; |
|
518 case EMMFDevSoundProxyInitialize4: |
|
519 DoAlreadyCompletedInitialize4L(); |
|
520 break; |
|
521 case EMMFDevSoundProxyPlayInit: |
|
522 DoAlreadyCompletedPlayInitL(); |
|
523 break; |
|
524 case EMMFDevSoundProxyRecordInit: |
|
525 DoAlreadyCompletedRecordInitL(); |
|
526 break; |
|
527 case EMMFDevSoundProxyPlayTone: |
|
528 DoAlreadyCompletedPlayToneL(); |
|
529 break; |
|
530 case EMMFDevSoundProxyPlayDualTone: |
|
531 DoAlreadyCompletedPlayDualToneL(); |
|
532 break; |
|
533 case EMMFDevSoundProxyPlayDTMFString: |
|
534 DoAlreadyCompletedPlayDTMFStringL(); |
|
535 break; |
|
536 case EMMFDevSoundProxyPlayToneSequence: |
|
537 DoAlreadyCompletedPlayToneSequenceL(); |
|
538 break; |
|
539 case EMMFDevSoundProxyPlayFixedSequence: |
|
540 DoAlreadyCompletedPlayFixedSequenceL(); |
|
541 break; |
|
542 default: |
|
543 User::Leave(KErrNotSupported); |
|
544 break; |
|
545 } |
|
546 |
|
547 } |
|
548 |
|
549 void CMMFDevSoundSession::HandleAlreadyCompletedRequest() |
|
550 { |
|
551 TRAPD(err,DoServiceAlreadyCompletedRequestL(iRedoFunction)); |
|
552 |
|
553 if (err != KErrNone) |
|
554 { |
|
555 switch(iRedoFunction) |
|
556 { |
|
557 case EMMFDevSoundProxyInitialize1: |
|
558 case EMMFDevSoundProxyInitialize2: |
|
559 case EMMFDevSoundProxyInitialize4: |
|
560 InitializeComplete(err); |
|
561 break; |
|
562 case EMMFDevSoundProxyPlayInit: |
|
563 PlayError(err); |
|
564 break; |
|
565 case EMMFDevSoundProxyRecordInit: |
|
566 RecordError(err); |
|
567 break; |
|
568 case EMMFDevSoundProxyPlayTone: |
|
569 case EMMFDevSoundProxyPlayDualTone: |
|
570 case EMMFDevSoundProxyPlayDTMFString: |
|
571 case EMMFDevSoundProxyPlayToneSequence: |
|
572 case EMMFDevSoundProxyPlayFixedSequence: |
|
573 ToneFinished(err); |
|
574 break; |
|
575 default: |
|
576 break; |
|
577 } |
|
578 } |
|
579 } |
|
580 |
|
581 void CMMFDevSoundSession::EnqueueRequest(const RMmfIpcMessage& aMessage) |
|
582 { |
|
583 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::EnqueueRequest - Enter")); |
|
584 // Encapsule the request |
|
585 TMMFDevSoundRequest request; |
|
586 request.SetMessage(aMessage); |
|
587 // Append |
|
588 TInt error = iQueuedRequests.Append(request); |
|
589 __ASSERT_DEBUG(error == KErrNone, Panic(EQueueRequestsFailedToAppend)); |
|
590 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::EnqueueRequest - Exit")); |
|
591 } |
|
592 |
|
593 // |
|
594 // CMMFDevSoundSession::DoPostOpenL |
|
595 // |
|
596 TBool CMMFDevSoundSession::DoPostOpenL(const RMmfIpcMessage& /*aMessage*/) |
|
597 { |
|
598 iAdapter->PostOpenL(); |
|
599 iOperationCompletePending = ETrue; |
|
600 return EFalse; |
|
601 } |
|
602 |
|
603 // |
|
604 // CMMFDevSoundSession::DoInitialize1L |
|
605 // (other items were commented in a header). |
|
606 // |
|
607 TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage) |
|
608 { |
|
609 iMsgQueue.Close(); // close if already open |
|
610 TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread |
|
611 User::LeaveIfError(err); |
|
612 DoSetClientConfigL();// added here instead of the CreateL() |
|
613 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
614 User::LeaveIfError(MessageRead(aMessage,1,devSoundBuf)); |
|
615 iCachedClientData = devSoundBuf; |
|
616 TMMFState mode = devSoundBuf().iMode; |
|
617 iAdapter->InitializeL(mode); |
|
618 iBufferPlay = NULL; |
|
619 iPlayErrorOccured = EFalse; |
|
620 // Flag to queue any further request |
|
621 // but the message can be completed now |
|
622 iOperationCompletePending = ETrue; |
|
623 return ETrue; |
|
624 } |
|
625 |
|
626 // |
|
627 // CMMFDevSoundSession::DoAlreadyCompletedInitialize1L |
|
628 // (other items were commented in a header). |
|
629 // |
|
630 void CMMFDevSoundSession::DoAlreadyCompletedInitialize1L() |
|
631 { |
|
632 TMMFState mode = iCachedClientData().iMode; |
|
633 iAdapter->InitializeL(mode); |
|
634 iBufferPlay = NULL; |
|
635 iPlayErrorOccured = EFalse; |
|
636 // Flag to queue any further request |
|
637 iOperationCompletePending = ETrue; |
|
638 } |
|
639 |
|
640 // |
|
641 // CMMFDevSoundSession::DoInitialize2L |
|
642 // (other items were commented in a header). |
|
643 // |
|
644 TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage) |
|
645 { |
|
646 iMsgQueue.Close(); // close if already open |
|
647 TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread |
|
648 User::LeaveIfError(err); |
|
649 DoSetClientConfigL();// added here instead of the CreateL() |
|
650 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
651 User::LeaveIfError(MessageRead(aMessage,1,devSoundBuf)); |
|
652 iCachedClientData = devSoundBuf; |
|
653 TUid HWDev = devSoundBuf().iHWDev; |
|
654 TMMFState mode = devSoundBuf().iMode; |
|
655 iAdapter->InitializeL(HWDev, mode); |
|
656 iBufferPlay = NULL; |
|
657 iPlayErrorOccured = EFalse; |
|
658 return ETrue; |
|
659 } |
|
660 |
|
661 // |
|
662 // CMMFDevSoundSession::DoAlreadyCompletedInitialize2L |
|
663 // (other items were commented in a header). |
|
664 // |
|
665 void CMMFDevSoundSession::DoAlreadyCompletedInitialize2L() |
|
666 { |
|
667 TUid HWDev = iCachedClientData().iHWDev; |
|
668 TMMFState mode = iCachedClientData().iMode; |
|
669 iAdapter->InitializeL(HWDev, mode); |
|
670 iBufferPlay = NULL; |
|
671 iPlayErrorOccured = EFalse; |
|
672 } |
|
673 |
|
674 // |
|
675 // CMMFDevSoundSession::DoInitialize4L |
|
676 // (other items were commented in a header). |
|
677 // |
|
678 TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage) |
|
679 { |
|
680 iMsgQueue.Close(); |
|
681 TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread |
|
682 User::LeaveIfError(err); |
|
683 DoSetClientConfigL();// added here instead of the CreateL() |
|
684 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
685 User::LeaveIfError(MessageRead(aMessage, TInt(1), devSoundBuf)); |
|
686 iCachedClientData = devSoundBuf; |
|
687 TFourCC desiredFourCC = devSoundBuf().iDesiredFourCC; |
|
688 TMMFState mode = devSoundBuf().iMode; |
|
689 iAdapter->InitializeL(desiredFourCC, mode); |
|
690 iBufferPlay = NULL; |
|
691 iPlayErrorOccured = EFalse; |
|
692 // Flag to queue any further request |
|
693 // but the message can be completed now |
|
694 iOperationCompletePending = ETrue; |
|
695 return ETrue; |
|
696 } |
|
697 |
|
698 // |
|
699 // CMMFDevSoundSession::DoAlreadyCompletedInitialize4L |
|
700 // (other items were commented in a header). |
|
701 // |
|
702 void CMMFDevSoundSession::DoAlreadyCompletedInitialize4L() |
|
703 { |
|
704 TFourCC desiredFourCC = iCachedClientData().iDesiredFourCC; |
|
705 TMMFState mode = iCachedClientData().iMode; |
|
706 iAdapter->InitializeL(desiredFourCC, mode); |
|
707 iBufferPlay = NULL; |
|
708 iPlayErrorOccured = EFalse; |
|
709 // Flag to queue any further request |
|
710 iOperationCompletePending = ETrue; |
|
711 } |
|
712 |
|
713 // |
|
714 // CMMFDevSoundSession::DoCancelInitialize |
|
715 // (other items were commented in a header). |
|
716 // |
|
717 TBool CMMFDevSoundSession::DoCancelInitializeL(const RMmfIpcMessage& aMessage) |
|
718 { |
|
719 TInt err=iAdapter->CancelInitialize(); |
|
720 |
|
721 if (err != KErrNone) |
|
722 { |
|
723 aMessage.Complete(err); |
|
724 iOperationCompletePending = EFalse; |
|
725 return ETrue; |
|
726 } |
|
727 else |
|
728 { |
|
729 iOperationCompletePending = ETrue; |
|
730 } |
|
731 return EFalse; |
|
732 } |
|
733 |
|
734 // |
|
735 // CMMFDevSoundSession::DoCapabilitiesL |
|
736 // (other items were commented in a header). |
|
737 // |
|
738 TBool CMMFDevSoundSession::DoCapabilitiesL(const RMmfIpcMessage& aMessage) |
|
739 { |
|
740 TInt err = iAdapter->Capabilities(iDevSoundCapabilities); |
|
741 if(err != KErrNone) |
|
742 { |
|
743 aMessage.Complete(err); |
|
744 iOperationCompletePending = EFalse; |
|
745 } |
|
746 else |
|
747 { |
|
748 iOperationCompletePending = ETrue; |
|
749 } |
|
750 return EFalse; |
|
751 } |
|
752 |
|
753 // |
|
754 // CMMFDevSoundSession::DoConfigL |
|
755 // (other items were commented in a header). |
|
756 // |
|
757 TBool CMMFDevSoundSession::DoConfigL(const RMmfIpcMessage& aMessage) |
|
758 { |
|
759 TMMFDevSoundProxySettings devSoundSet; |
|
760 devSoundSet.iConfig = iAdapter->Config(); |
|
761 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
762 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
763 return ETrue; |
|
764 } |
|
765 |
|
766 // |
|
767 // CMMFDevSoundSession::DoSetConfigL |
|
768 // (other items were commented in a header). |
|
769 // |
|
770 TBool CMMFDevSoundSession::DoSetConfigL(const RMmfIpcMessage& aMessage) |
|
771 { |
|
772 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
773 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
774 TMMFCapabilities config = devSoundBuf().iConfig; |
|
775 iAdapter->SetConfigL(config); |
|
776 iOperationCompletePending = ETrue; |
|
777 return EFalse; |
|
778 } |
|
779 |
|
780 // |
|
781 // CMMFDevSoundSession::axVolumeL |
|
782 // (other items were commented in a header). |
|
783 // |
|
784 TBool CMMFDevSoundSession::DoMaxVolumeL(const RMmfIpcMessage& aMessage) |
|
785 { |
|
786 TMMFDevSoundProxySettings devSoundSet; |
|
787 devSoundSet.iMaxVolume = iAdapter->MaxVolume(); |
|
788 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
789 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
790 return ETrue; |
|
791 } |
|
792 |
|
793 // |
|
794 // CMMFDevSoundSession::DoVolumeL |
|
795 // (other items were commented in a header). |
|
796 // |
|
797 TBool CMMFDevSoundSession::DoVolumeL(const RMmfIpcMessage& aMessage) |
|
798 { |
|
799 TMMFDevSoundProxySettings devSoundSet; |
|
800 devSoundSet.iVolume = iAdapter->Volume(); |
|
801 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
802 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
803 return ETrue; |
|
804 } |
|
805 |
|
806 // |
|
807 // CMMFDevSoundSession::DoSetVolumeL |
|
808 // (other items were commented in a header). |
|
809 // |
|
810 TBool CMMFDevSoundSession::DoSetVolumeL(const RMmfIpcMessage& aMessage) |
|
811 { |
|
812 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
813 User::LeaveIfError(MessageRead(aMessage, TInt(1),devSoundBuf)); |
|
814 TInt volume = devSoundBuf().iVolume; |
|
815 TBool asyncOperation; |
|
816 User::LeaveIfError(iAdapter->SetVolume(volume, asyncOperation)); |
|
817 iOperationCompletePending = asyncOperation; |
|
818 return !asyncOperation; |
|
819 } |
|
820 |
|
821 // |
|
822 // CMMFDevSoundSession::DoMaxGainL |
|
823 // (other items were commented in a header). |
|
824 // |
|
825 TBool CMMFDevSoundSession::DoMaxGainL(const RMmfIpcMessage& aMessage) |
|
826 { |
|
827 TMMFDevSoundProxySettings devSoundSet; |
|
828 devSoundSet.iMaxGain = iAdapter->MaxGain(); |
|
829 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
830 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
831 return ETrue; |
|
832 } |
|
833 |
|
834 // |
|
835 // CMMFDevSoundSession::DoGainL |
|
836 // (other items were commented in a header). |
|
837 // |
|
838 TBool CMMFDevSoundSession::DoGainL(const RMmfIpcMessage& aMessage) |
|
839 { |
|
840 TMMFDevSoundProxySettings devSoundSet; |
|
841 devSoundSet.iGain = iAdapter->Gain(); |
|
842 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
843 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
844 return ETrue; |
|
845 } |
|
846 |
|
847 // |
|
848 // CMMFDevSoundSession::DoSetGainL |
|
849 // (other items were commented in a header). |
|
850 // |
|
851 TBool CMMFDevSoundSession::DoSetGainL(const RMmfIpcMessage& aMessage) |
|
852 { |
|
853 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
854 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
855 TInt gain = devSoundBuf().iGain; |
|
856 TBool asyncOperation; |
|
857 User::LeaveIfError(iAdapter->SetGain(gain, asyncOperation)); |
|
858 iOperationCompletePending = asyncOperation; |
|
859 return !asyncOperation; |
|
860 } |
|
861 |
|
862 // |
|
863 // CMMFDevSoundSession::DoGetPlayBalanceL |
|
864 // (other items were commented in a header). |
|
865 // |
|
866 TBool CMMFDevSoundSession::DoGetPlayBalanceL(const RMmfIpcMessage& aMessage) |
|
867 { |
|
868 TMMFDevSoundProxySettings devSoundSet; |
|
869 iAdapter->GetPlayBalanceL(devSoundSet.iLeftPercentage, devSoundSet.iRightPercentage); |
|
870 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
871 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
872 return ETrue; |
|
873 } |
|
874 |
|
875 // |
|
876 // CMMFDevSoundSession::DoSetPlayBalanceL |
|
877 // (other items were commented in a header). |
|
878 // |
|
879 TBool CMMFDevSoundSession::DoSetPlayBalanceL(const RMmfIpcMessage& aMessage) |
|
880 { |
|
881 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
882 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
883 TInt leftPercentage = devSoundBuf().iLeftPercentage; |
|
884 TInt rightPercentage = devSoundBuf().iRightPercentage; |
|
885 TBool asyncOperation; |
|
886 iAdapter->SetPlayBalanceL(leftPercentage, rightPercentage, asyncOperation); |
|
887 iOperationCompletePending = asyncOperation; |
|
888 return !asyncOperation; |
|
889 } |
|
890 |
|
891 // |
|
892 // CMMFDevSoundSession::DoGetRecordBalanceL |
|
893 // (other items were commented in a header). |
|
894 // |
|
895 TBool CMMFDevSoundSession::DoGetRecordBalanceL(const RMmfIpcMessage& aMessage) |
|
896 { |
|
897 TMMFDevSoundProxySettings devSoundSet; |
|
898 iAdapter->GetRecordBalanceL(devSoundSet.iLeftPercentage, devSoundSet.iRightPercentage); |
|
899 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
900 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
901 return ETrue; |
|
902 } |
|
903 |
|
904 // |
|
905 // CMMFDevSoundSession::DoSetRecordBalanceL |
|
906 // (other items were commented in a header). |
|
907 // |
|
908 TBool CMMFDevSoundSession::DoSetRecordBalanceL(const RMmfIpcMessage& aMessage) |
|
909 { |
|
910 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
911 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
912 TInt leftPercentage = devSoundBuf().iLeftPercentage; |
|
913 TInt rightPercentage = devSoundBuf().iRightPercentage; |
|
914 TBool asyncOperation; |
|
915 iAdapter->SetRecordBalanceL(leftPercentage, rightPercentage, asyncOperation); |
|
916 iOperationCompletePending = asyncOperation; |
|
917 return !asyncOperation; |
|
918 } |
|
919 |
|
920 // |
|
921 // CMMFDevSoundSession::DoPlayInitL |
|
922 // (other items were commented in a header). |
|
923 // |
|
924 TBool CMMFDevSoundSession::DoPlayInitL(const RMmfIpcMessage& /*aMessage*/) |
|
925 { |
|
926 iAdapter->PlayInitL(); |
|
927 iOperationCompletePending = ETrue; |
|
928 return ETrue; |
|
929 } |
|
930 |
|
931 // |
|
932 // CMMFDevSoundSession::DoAlreadyCompletedPlayInitL |
|
933 // (other items were commented in a header). |
|
934 // |
|
935 void CMMFDevSoundSession::DoAlreadyCompletedPlayInitL() |
|
936 { |
|
937 iAdapter->PlayInitL(); |
|
938 iOperationCompletePending = ETrue; |
|
939 } |
|
940 |
|
941 // |
|
942 // CMMFDevSoundSession::DoRecordInitL |
|
943 // (other items were commented in a header). |
|
944 // |
|
945 TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& /*aMessage*/) |
|
946 { |
|
947 iAdapter->RecordInitL(); |
|
948 iOperationCompletePending = ETrue; |
|
949 return ETrue; |
|
950 } |
|
951 |
|
952 // |
|
953 // CMMFDevSoundSession::DoAlreadyCompletedRecordInitL |
|
954 // (other items were commented in a header). |
|
955 // |
|
956 void CMMFDevSoundSession::DoAlreadyCompletedRecordInitL() |
|
957 { |
|
958 iAdapter->RecordInitL(); |
|
959 iOperationCompletePending = ETrue; |
|
960 } |
|
961 |
|
962 // |
|
963 // CMMFDevSoundSession::DoPlayDataL |
|
964 // (other items were commented in a header). |
|
965 // |
|
966 TBool CMMFDevSoundSession::DoPlayDataL(const RMmfIpcMessage& aMessage) |
|
967 { |
|
968 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDataL - Enter")); |
|
969 |
|
970 if( iPlayErrorOccured ) |
|
971 { |
|
972 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDataL - Ignore and Exit")); |
|
973 return ETrue; |
|
974 } |
|
975 |
|
976 TMMFDevSoundProxyHwBufPckg devSoundBuf; |
|
977 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
978 iBufferPlay->SetLastBuffer(devSoundBuf().iLastBuffer); |
|
979 |
|
980 TPtr8 dataPtr(iChunk.Base(), devSoundBuf().iBufferSize, devSoundBuf().iBufferSize); |
|
981 // Copy data over from chunk |
|
982 iBufferPlay->Data().Copy(dataPtr); |
|
983 iAdapter->PlayData(); |
|
984 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDataL - Exit")); |
|
985 return ETrue; |
|
986 } |
|
987 |
|
988 // |
|
989 // CMMFDevSoundSession::DoRecordDataL |
|
990 // (other items were commented in a header). |
|
991 // |
|
992 TBool CMMFDevSoundSession::DoRecordDataL(const RMmfIpcMessage& /*aMessage*/) |
|
993 { |
|
994 iAdapter->RecordData(); |
|
995 return ETrue; |
|
996 } |
|
997 |
|
998 // |
|
999 // CMMFDevSoundSession::DoStopL |
|
1000 // (other items were commented in a header). |
|
1001 // |
|
1002 TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/) |
|
1003 { |
|
1004 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoStopL - Enter")); |
|
1005 // Sometimes Stop is not involved on a commit cycle |
|
1006 TBool completed = iAdapter->Stop(); |
|
1007 if (completed) |
|
1008 { |
|
1009 FlushQueuedRequests(); |
|
1010 FlushEventQueue(); // completed returned here means we were idle to start with. TODO could possibly skip this flush |
|
1011 iChunk.Close(); |
|
1012 } |
|
1013 iOperationCompletePending = !completed; |
|
1014 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoStopL - Exit. Return value is [%d]"), completed); |
|
1015 return completed; |
|
1016 } |
|
1017 |
|
1018 // |
|
1019 // CMMFDevSoundSession::DoPauseL |
|
1020 // (other items were commented in a header). |
|
1021 // |
|
1022 TBool CMMFDevSoundSession::DoPauseL(const RMmfIpcMessage& /*aMessage*/) |
|
1023 { |
|
1024 User::LeaveIfError(iAdapter->Pause()); |
|
1025 iOperationCompletePending = ETrue; |
|
1026 return EFalse; |
|
1027 } |
|
1028 |
|
1029 // |
|
1030 // CMMFDevSoundSession::DoPlayToneL |
|
1031 // (other items were commented in a header). |
|
1032 // |
|
1033 TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage) |
|
1034 { |
|
1035 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayToneL - Enter")); |
|
1036 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
1037 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
1038 iCachedClientData = devSoundBuf; |
|
1039 TInt frequency = devSoundBuf().iFrequencyOne; |
|
1040 TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration); |
|
1041 iAdapter->PlayToneL(frequency, duration); |
|
1042 iOperationCompletePending = ETrue; |
|
1043 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayToneL - Exit. Return value is [%d]"), ETrue); |
|
1044 return ETrue; |
|
1045 } |
|
1046 |
|
1047 // |
|
1048 // CMMFDevSoundSession::DoAlreadyCompletedPlayToneL |
|
1049 // (other items were commented in a header). |
|
1050 // |
|
1051 void CMMFDevSoundSession::DoAlreadyCompletedPlayToneL() |
|
1052 { |
|
1053 TInt frequency = iCachedClientData().iFrequencyOne; |
|
1054 TTimeIntervalMicroSeconds duration(iCachedClientData().iDuration); |
|
1055 iAdapter->PlayToneL(frequency, duration); |
|
1056 iOperationCompletePending = ETrue; |
|
1057 } |
|
1058 |
|
1059 // |
|
1060 // CMMFDevSoundSession::DoPlayDualToneL |
|
1061 // (other items were commented in a header). |
|
1062 // |
|
1063 TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage) |
|
1064 { |
|
1065 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDualToneL - Enter")); |
|
1066 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
1067 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
1068 iCachedClientData = devSoundBuf; |
|
1069 TInt frequencyOne = devSoundBuf().iFrequencyOne; |
|
1070 TInt frequencyTwo = devSoundBuf().iFrequencyTwo; |
|
1071 TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration); |
|
1072 iAdapter->PlayDualToneL(frequencyOne, frequencyTwo, duration); |
|
1073 iOperationCompletePending = ETrue; |
|
1074 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayDualToneL - Exit. Return value is [%d]"), ETrue); |
|
1075 return ETrue; |
|
1076 } |
|
1077 |
|
1078 // |
|
1079 // CMMFDevSoundSession::DoAlreadyCompletedPlayDualToneL |
|
1080 // (other items were commented in a header). |
|
1081 // |
|
1082 void CMMFDevSoundSession::DoAlreadyCompletedPlayDualToneL() |
|
1083 { |
|
1084 TInt frequencyOne = iCachedClientData().iFrequencyOne; |
|
1085 TInt frequencyTwo = iCachedClientData().iFrequencyTwo; |
|
1086 TTimeIntervalMicroSeconds duration(iCachedClientData().iDuration); |
|
1087 iAdapter->PlayDualToneL(frequencyOne, frequencyTwo, duration); |
|
1088 iOperationCompletePending = ETrue; |
|
1089 } |
|
1090 |
|
1091 // |
|
1092 // CMMFDevSoundSession::DoPlayDTMFStringL |
|
1093 // (other items were commented in a header). |
|
1094 // |
|
1095 TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage) |
|
1096 { |
|
1097 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDTMFStringL - Enter")); |
|
1098 TInt dtmfLength = aMessage.GetDesLength(2); |
|
1099 |
|
1100 if(iDtmfString) |
|
1101 { |
|
1102 delete iDtmfString; |
|
1103 iDtmfString = NULL; |
|
1104 } |
|
1105 |
|
1106 iDtmfString = HBufC::NewL(dtmfLength); |
|
1107 TPtr dtmfPtr = iDtmfString->Des(); |
|
1108 User::LeaveIfError(MessageRead(aMessage, TInt(2), dtmfPtr)); |
|
1109 iAdapter->PlayDTMFStringL(*iDtmfString); |
|
1110 iOperationCompletePending = ETrue; |
|
1111 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayDTMFStringL - Exit. Return value is [%d]"), ETrue); |
|
1112 return ETrue; |
|
1113 } |
|
1114 |
|
1115 // |
|
1116 // CMMFDevSoundSession::DoAlreadyCompletedPlayDTMFStringL |
|
1117 // (other items were commented in a header). |
|
1118 // |
|
1119 void CMMFDevSoundSession::DoAlreadyCompletedPlayDTMFStringL() |
|
1120 { |
|
1121 iAdapter->PlayDTMFStringL(*iDtmfString); |
|
1122 iOperationCompletePending = ETrue; |
|
1123 } |
|
1124 |
|
1125 // |
|
1126 // CMMFDevSoundSession::DoPlayToneSequenceL |
|
1127 // (other items were commented in a header). |
|
1128 // |
|
1129 TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage) |
|
1130 { |
|
1131 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayToneSequenceL - Enter")); |
|
1132 TInt toneLength = aMessage.GetDesLength(1); |
|
1133 |
|
1134 if(iToneSeqBuf) |
|
1135 { |
|
1136 delete iToneSeqBuf; |
|
1137 iToneSeqBuf = NULL; |
|
1138 } |
|
1139 |
|
1140 iToneSeqBuf = HBufC8::NewL(toneLength); |
|
1141 TPtr8 toneSeqPtr = iToneSeqBuf->Des(); |
|
1142 User::LeaveIfError(MessageRead(aMessage,TInt(1), toneSeqPtr)); |
|
1143 |
|
1144 iAdapter->PlayToneSequenceL(*iToneSeqBuf); |
|
1145 iOperationCompletePending = ETrue; |
|
1146 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayToneSequenceL - Exit. Return value is [%d]"), ETrue); |
|
1147 return ETrue; |
|
1148 } |
|
1149 |
|
1150 // |
|
1151 // CMMFDevSoundSession::DoAlreadyCompletedPlayToneSequenceL |
|
1152 // (other items were commented in a header). |
|
1153 // |
|
1154 void CMMFDevSoundSession::DoAlreadyCompletedPlayToneSequenceL() |
|
1155 { |
|
1156 iAdapter->PlayToneSequenceL(*iToneSeqBuf); |
|
1157 iOperationCompletePending = ETrue; |
|
1158 } |
|
1159 |
|
1160 // |
|
1161 // CMMFDevSoundSession::DoPlayFixedSequenceL |
|
1162 // (other items were commented in a header). |
|
1163 // |
|
1164 TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage) |
|
1165 { |
|
1166 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayFixedSequenceL - Enter")); |
|
1167 TPckgBuf<TInt> buf; |
|
1168 User::LeaveIfError(MessageRead(aMessage,TInt(1),buf)); |
|
1169 TInt seqNum = buf(); |
|
1170 iSeqNum = seqNum; |
|
1171 iAdapter->PlayFixedSequenceL(seqNum); |
|
1172 iOperationCompletePending = ETrue; |
|
1173 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayFixedSequenceL - Exit. Return value is [%d]"), ETrue); |
|
1174 return ETrue; |
|
1175 } |
|
1176 |
|
1177 // |
|
1178 // CMMFDevSoundSession::DoAlreadyCompletedPlayFixedSequenceL |
|
1179 // (other items were commented in a header). |
|
1180 // |
|
1181 void CMMFDevSoundSession::DoAlreadyCompletedPlayFixedSequenceL() |
|
1182 { |
|
1183 iAdapter->PlayFixedSequenceL(iSeqNum); |
|
1184 iOperationCompletePending = ETrue; |
|
1185 } |
|
1186 |
|
1187 // |
|
1188 // CMMFDevSoundSession::DoSetDTMFLengthsL |
|
1189 // (other items were commented in a header). |
|
1190 // |
|
1191 TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage) |
|
1192 { |
|
1193 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetDTMFLengthsL - Enter")); |
|
1194 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
1195 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
1196 TTimeIntervalMicroSeconds32 toneOnLength = devSoundBuf().iToneOnLength; |
|
1197 TTimeIntervalMicroSeconds32 toneOffLength = devSoundBuf().iToneOffLength; |
|
1198 TTimeIntervalMicroSeconds32 pauseLength = devSoundBuf().iPauseLength; |
|
1199 User::LeaveIfError(iAdapter->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength)); |
|
1200 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetDTMFLengthsL - Exit. Return value is [%d]"), ETrue); |
|
1201 return ETrue; |
|
1202 } |
|
1203 |
|
1204 // |
|
1205 // CMMFDevSoundSession::DoSetVolumeRampL |
|
1206 // (other items were commented in a header). |
|
1207 // |
|
1208 TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage) |
|
1209 { |
|
1210 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetVolumeRampL - Enter")); |
|
1211 TMMFDevSoundProxySettingsPckg devSoundBuf; |
|
1212 User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf)); |
|
1213 TTimeIntervalMicroSeconds duration = devSoundBuf().iDuration; |
|
1214 User::LeaveIfError(iAdapter->SetVolumeRamp(duration)); |
|
1215 iOperationCompletePending = EFalse; // Volume ramp doesn't result on commit |
|
1216 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetVolumeRampL - Exit. Return value is [%d]"), ETrue); |
|
1217 return ETrue; // operation complete |
|
1218 } |
|
1219 |
|
1220 // |
|
1221 // CMMFDevSoundSession::DoGetSupportedInputDataTypesL |
|
1222 // (other items were commented in a header). |
|
1223 // |
|
1224 TBool CMMFDevSoundSession::DoGetSupportedInputDataTypesL( |
|
1225 const RMmfIpcMessage& aMessage) |
|
1226 { |
|
1227 iArray.Reset(); |
|
1228 |
|
1229 TMMFPrioritySettingsPckg prioritySetBuf; |
|
1230 User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySetBuf)); |
|
1231 TMMFPrioritySettings prioritySet = prioritySetBuf(); |
|
1232 |
|
1233 iAdapter->GetSupportedInputDataTypesL(iArray, prioritySet); |
|
1234 |
|
1235 TPckgBuf<TInt> pckg; |
|
1236 pckg() = iArray.Count(); |
|
1237 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
1238 |
|
1239 return ETrue; |
|
1240 } |
|
1241 |
|
1242 // |
|
1243 // CMMFDevSoundSession::DoGetSupportedOutputDataTypesL |
|
1244 // (other items were commented in a header). |
|
1245 // |
|
1246 TBool CMMFDevSoundSession::DoGetSupportedOutputDataTypesL( |
|
1247 const RMmfIpcMessage& aMessage) |
|
1248 { |
|
1249 iArray.Reset(); |
|
1250 |
|
1251 TMMFPrioritySettingsPckg prioritySetBuf; |
|
1252 User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySetBuf)); |
|
1253 TMMFPrioritySettings prioritySet = prioritySetBuf(); |
|
1254 |
|
1255 iAdapter->GetSupportedOutputDataTypesL(iArray, prioritySet); |
|
1256 |
|
1257 TPckgBuf<TInt> pckg; |
|
1258 pckg() = iArray.Count(); |
|
1259 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
1260 |
|
1261 return ETrue; |
|
1262 } |
|
1263 |
|
1264 // |
|
1265 // CMMFDevSoundSession::DoSamplesRecordedL |
|
1266 // (other items were commented in a header). |
|
1267 // |
|
1268 TBool CMMFDevSoundSession::DoSamplesRecordedL(const RMmfIpcMessage& aMessage) |
|
1269 { |
|
1270 TPckgBuf<TInt> pckg; |
|
1271 pckg() = iAdapter->SamplesRecorded(); |
|
1272 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
1273 return ETrue; |
|
1274 } |
|
1275 |
|
1276 // |
|
1277 // CMMFDevSoundSession::DoSamplesPlayedL |
|
1278 // (other items were commented in a header). |
|
1279 // |
|
1280 TBool CMMFDevSoundSession::DoSamplesPlayedL(const RMmfIpcMessage& aMessage) |
|
1281 { |
|
1282 TPckgBuf<TInt> pckg; |
|
1283 pckg() = iAdapter->SamplesPlayed(); |
|
1284 User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg)); |
|
1285 return ETrue; |
|
1286 } |
|
1287 |
|
1288 // |
|
1289 // CMMFDevSoundSession::DoSetToneRepeatsL |
|
1290 // (other items were commented in a header). |
|
1291 // |
|
1292 TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage) |
|
1293 { |
|
1294 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Enter")); |
|
1295 TPckgBuf<TInt> countRepeat; |
|
1296 User::LeaveIfError(MessageRead(aMessage,TInt(1),countRepeat)); |
|
1297 |
|
1298 TPckgBuf<TTimeIntervalMicroSeconds> repeatTS; |
|
1299 User::LeaveIfError(MessageRead(aMessage,TInt(2),repeatTS)); |
|
1300 User::LeaveIfError(iAdapter->SetToneRepeats(countRepeat(), repeatTS())); |
|
1301 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Exit. Return value is [%d]"), ETrue); |
|
1302 return ETrue; |
|
1303 } |
|
1304 |
|
1305 // |
|
1306 // CMMFDevSoundSession::DoSetPrioritySettingsL |
|
1307 // (other items were commented in a header). |
|
1308 // |
|
1309 TBool CMMFDevSoundSession::DoSetPrioritySettingsL( |
|
1310 const RMmfIpcMessage& aMessage) |
|
1311 { |
|
1312 TPckgBuf<TMMFPrioritySettings> prioritySet; |
|
1313 User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySet)); |
|
1314 |
|
1315 User::LeaveIfError(iAdapter->SetPrioritySettings(prioritySet())); |
|
1316 iOperationCompletePending = EFalse; |
|
1317 return ETrue; |
|
1318 } |
|
1319 |
|
1320 // |
|
1321 // CMMFDevSoundSession::DoFixedSequenceCountL |
|
1322 // (other items were commented in a header). |
|
1323 // |
|
1324 TBool CMMFDevSoundSession::DoFixedSequenceCountL( |
|
1325 const RMmfIpcMessage& aMessage) |
|
1326 { |
|
1327 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoFixedSequenceCountL - Enter")); |
|
1328 TPckgBuf<TInt> fixSeqCountPckg; |
|
1329 TInt fixSeqCount = iAdapter->FixedSequenceCount(); |
|
1330 fixSeqCountPckg = fixSeqCount; |
|
1331 |
|
1332 User::LeaveIfError(MessageWrite(aMessage,TInt(2),fixSeqCountPckg)); |
|
1333 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoFixedSequenceCountL - Exit. Return value is [%d]"), ETrue); |
|
1334 return ETrue; |
|
1335 } |
|
1336 |
|
1337 |
|
1338 // |
|
1339 // CMMFDevSoundSession::DoCopyFourCCArrayDataL |
|
1340 // (other items were commented in a header). |
|
1341 // |
|
1342 TBool CMMFDevSoundSession::DoCopyFourCCArrayDataL( |
|
1343 const RMmfIpcMessage& aMessage) |
|
1344 { |
|
1345 const TInt KBufExpandSize8 = 8;//two TInts |
|
1346 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8); |
|
1347 CleanupStack::PushL(dataCopyBuffer); |
|
1348 RBufWriteStream stream; |
|
1349 stream.Open(*dataCopyBuffer); |
|
1350 CleanupClosePushL(stream); |
|
1351 |
|
1352 TInt i = 0; |
|
1353 TInt count = iArray.Count(); |
|
1354 |
|
1355 while (i < count) |
|
1356 { |
|
1357 stream.WriteInt32L(iArray[i].FourCC()); |
|
1358 i++; |
|
1359 } |
|
1360 User::LeaveIfError(MessageWrite(aMessage, TInt(2), dataCopyBuffer->Ptr(0))); |
|
1361 stream.Close(); |
|
1362 CleanupStack::PopAndDestroy(&stream); |
|
1363 CleanupStack::PopAndDestroy(dataCopyBuffer); |
|
1364 return ETrue; |
|
1365 } |
|
1366 |
|
1367 |
|
1368 // |
|
1369 // CMMFDevSoundSession::DoBufferToBeFilledDataL |
|
1370 // (other items were commented in a header). |
|
1371 // |
|
1372 TBool CMMFDevSoundSession::DoBufferToBeFilledDataL( |
|
1373 const RMmfIpcMessage& aMessage) |
|
1374 { |
|
1375 // if CMMFDevSoundSession::PlayError() has been called, RChunk would have got closed. |
|
1376 // Need to check if Chunk Handle is still valid. If it is not,complete the message immediately and send a error to the Client. |
|
1377 if(!iChunk.Handle()) |
|
1378 { |
|
1379 aMessage.Complete(KErrBadHandle); |
|
1380 return EFalse; |
|
1381 } |
|
1382 TPckgBuf<TInt> requestChunkBuf; |
|
1383 User::LeaveIfError(MessageRead(aMessage, TInt(1), requestChunkBuf)); |
|
1384 TBool requestChunk = requestChunkBuf(); |
|
1385 if (requestChunk) |
|
1386 { |
|
1387 // if the client requests, always do EOpen |
|
1388 iHwBufPckgFill().iChunkOp = EOpen; |
|
1389 } |
|
1390 TInt err = MessageWrite(aMessage, TInt(2), iHwBufPckgFill); |
|
1391 if ( (err == KErrNone) && (iHwBufPckgFill().iChunkOp == EOpen) ) |
|
1392 { |
|
1393 aMessage.Complete(iChunk); |
|
1394 } |
|
1395 else |
|
1396 { |
|
1397 aMessage.Complete(err); |
|
1398 } |
|
1399 return EFalse; |
|
1400 } |
|
1401 |
|
1402 // CMMFDevSoundSession::DoBufferToBeEmptiedDataL |
|
1403 // (other items were commented in a header). |
|
1404 // |
|
1405 TBool CMMFDevSoundSession::DoBufferToBeEmptiedDataL( |
|
1406 const RMmfIpcMessage& aMessage) |
|
1407 { |
|
1408 // if CMMFDevSoundSession::RecordError() has been called, RChunk would have got closed. |
|
1409 // Need to check if Chunk Handle is still valid. If it is not,complete the message immediately and send a error to the Client. |
|
1410 if(!iChunk.Handle()) |
|
1411 { |
|
1412 aMessage.Complete(KErrBadHandle); |
|
1413 return EFalse; |
|
1414 } |
|
1415 |
|
1416 TInt err = MessageWrite(aMessage, TInt(2), iHwBufPckgEmpty); |
|
1417 if ( (err == KErrNone) && (iHwBufPckgEmpty().iChunkOp == EOpen) ) |
|
1418 { |
|
1419 aMessage.Complete(iChunk); |
|
1420 } |
|
1421 else |
|
1422 { |
|
1423 aMessage.Complete(err); |
|
1424 } |
|
1425 return EFalse; |
|
1426 } |
|
1427 |
|
1428 // |
|
1429 // CMMFDevSoundSession::DoEmptyBuffersL |
|
1430 // (other items were commented in a header). |
|
1431 // |
|
1432 |
|
1433 TBool CMMFDevSoundSession::DoEmptyBuffersL(const RMmfIpcMessage& aMessage) |
|
1434 { |
|
1435 TInt err = KErrNone; |
|
1436 FilterQueueEvent(EMMFDevSoundProxyBTBFEvent); |
|
1437 // This is now asynchronous |
|
1438 err = iAdapter->EmptyBuffers(); |
|
1439 if (err != KErrNone) |
|
1440 { |
|
1441 aMessage.Complete(err); |
|
1442 return EFalse; |
|
1443 } |
|
1444 iOperationCompletePending = ETrue; |
|
1445 return EFalse; |
|
1446 } |
|
1447 // |
|
1448 // CMMFDevSoundSession::DoGetTimePlayedL |
|
1449 // (other items were commented in a header). |
|
1450 // |
|
1451 TBool CMMFDevSoundSession::DoGetTimePlayedL(const RMmfIpcMessage& aMessage) |
|
1452 { |
|
1453 TInt err = KErrNone; |
|
1454 TTimeIntervalMicroSeconds time(0); |
|
1455 TPckgBuf<TTimeIntervalMicroSeconds> timePckg(time); |
|
1456 err = iAdapter->GetTimePlayed(timePckg()); |
|
1457 if (err != KErrNone) |
|
1458 { |
|
1459 aMessage.Complete(err); |
|
1460 return EFalse; |
|
1461 } |
|
1462 User::LeaveIfError(MessageWrite(aMessage,TInt(2),timePckg)); |
|
1463 return ETrue; |
|
1464 } |
|
1465 |
|
1466 TBool CMMFDevSoundSession::DoQueryResumeSupportedL(const RMmfIpcMessage& aMessage) |
|
1467 { |
|
1468 TBool isSupported = EFalse; |
|
1469 TPckgBuf<TBool> isSupportedPckg(isSupported); |
|
1470 isSupportedPckg() = iAdapter->IsResumeSupported(); |
|
1471 User::LeaveIfError(MessageWrite(aMessage,TInt(2),isSupportedPckg)); |
|
1472 return ETrue; |
|
1473 } |
|
1474 |
|
1475 TBool CMMFDevSoundSession::DoResumeL(const RMmfIpcMessage& /*aMessage*/) |
|
1476 { |
|
1477 User::LeaveIfError( iAdapter->Resume() ); |
|
1478 iOperationCompletePending = ETrue; |
|
1479 FilterQueueEvent(EMMFDevSoundProxyPausedRecordCompleteEvent); |
|
1480 return EFalse; |
|
1481 } |
|
1482 |
|
1483 TBool CMMFDevSoundSession::DoPrepareCloseL(const RMmfIpcMessage& /*aMessage*/) |
|
1484 { |
|
1485 TBool complete = iAdapter->CloseDevSound(); |
|
1486 if(!complete) |
|
1487 { |
|
1488 iOperationCompletePending = ETrue; |
|
1489 } |
|
1490 return complete; |
|
1491 } |
|
1492 |
|
1493 |
|
1494 TBool CMMFDevSoundSession::DoCustomCommandL(const RMmfIpcMessage& aMessage) |
|
1495 { |
|
1496 TInt retVal = KErrNone; |
|
1497 TRAPD(err, retVal = iDeMuxUtility->ProcessCustomInterfaceCommandL(aMessage)); |
|
1498 if (err != KErrNone) |
|
1499 { |
|
1500 // the framework left with an error condition |
|
1501 // so we complete the message with this error |
|
1502 // irrespective of whether its a Sync or Async custom command |
|
1503 aMessage.Complete(err); |
|
1504 } |
|
1505 else |
|
1506 { |
|
1507 TInt messageType = aMessage.Function(); |
|
1508 if ((messageType == EMMFDevSoundProxySyncCustomCommand) || |
|
1509 (messageType == EMMFDevSoundProxySyncCustomCommandResult)) |
|
1510 { |
|
1511 // If its a sync custom command |
|
1512 // we can pass back valid values here since command |
|
1513 // has been handled by the DeMux framework |
|
1514 aMessage.Complete(retVal); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 // we complete our own message so don't need the framework to do so |
|
1519 return EFalse; |
|
1520 } |
|
1521 |
|
1522 |
|
1523 // |
|
1524 // CMMFDevSoundSession::CMMFDevSoundSession |
|
1525 // (other items were commented in a header). |
|
1526 // |
|
1527 CMMFDevSoundSession::CMMFDevSoundSession() : |
|
1528 iSetClientConfigApplied (EFalse), |
|
1529 iDisconnecting (EFalse) |
|
1530 { |
|
1531 } |
|
1532 |
|
1533 // |
|
1534 // CMMFDevSoundSession::~CMMFDevSoundSession |
|
1535 // (other items were commented in a header). |
|
1536 // |
|
1537 CMMFDevSoundSession::~CMMFDevSoundSession() |
|
1538 { |
|
1539 delete iAsyncQueueStart; |
|
1540 // clear the array of custom interfaces |
|
1541 TInt count = iCustomInterfaceArray.Count(); |
|
1542 for (TInt i = 0; i < count; i++) |
|
1543 { |
|
1544 // we could have already deleted interfaces without |
|
1545 // removing them from the array so check for this |
|
1546 // and only delete release plugin if non-null |
|
1547 MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = iCustomInterfaceArray[i].iInterface; |
|
1548 if (ptr) |
|
1549 { |
|
1550 iCustomInterfaceArray[i].iInterface->Release(); |
|
1551 } |
|
1552 } |
|
1553 iCustomInterfaceArray.Reset(); |
|
1554 iCustomInterfaceArray.Close(); |
|
1555 |
|
1556 delete iDeMuxUtility; |
|
1557 |
|
1558 if (iCIExtension) |
|
1559 { |
|
1560 iCIExtension->Release(); |
|
1561 iCIExtension = NULL; |
|
1562 } |
|
1563 |
|
1564 iMsgQueue.Close(); |
|
1565 iArray.Close(); |
|
1566 iQueuedRequests.Close(); |
|
1567 delete iDtmfString; |
|
1568 delete iToneSeqBuf; |
|
1569 delete iAdapter; |
|
1570 delete iClosingWait; |
|
1571 |
|
1572 CMMFDevSoundServer* server = |
|
1573 const_cast<CMMFDevSoundServer*>( |
|
1574 static_cast<const CMMFDevSoundServer*>(Server())); |
|
1575 |
|
1576 if (server) |
|
1577 { |
|
1578 server->DecrementSessionId(); |
|
1579 } |
|
1580 |
|
1581 // delete iCustomCommandParserManager; |
|
1582 // delete iMMFObjectContainer; |
|
1583 |
|
1584 // Close chunk |
|
1585 iChunk.Close(); |
|
1586 } |
|
1587 |
|
1588 // |
|
1589 // CMMFDevSoundSession::FlushEventQueue() |
|
1590 // |
|
1591 void CMMFDevSoundSession::FlushEventQueue() |
|
1592 { |
|
1593 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FlushEventQueue - Enter")); |
|
1594 if(iMsgQueue.Handle() != 0) |
|
1595 { |
|
1596 TMMFDevSoundQueueItem queueItem; |
|
1597 TInt err = KErrNone; |
|
1598 while(err != KErrUnderflow) |
|
1599 { |
|
1600 err = iMsgQueue.Receive(queueItem); |
|
1601 } |
|
1602 } |
|
1603 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FlushEventQueue - Exit")); |
|
1604 } |
|
1605 |
|
1606 void CMMFDevSoundSession::FilterQueueEvent(TMMFDevSoundProxyRequest aRequest) |
|
1607 { |
|
1608 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FilterQueueEvent - Enter")); |
|
1609 if(iMsgQueue.Handle() != 0) |
|
1610 { |
|
1611 // Pop and push events result at the queue |
|
1612 // can be seen as "circular list" |
|
1613 // set a mark to traverse it safely |
|
1614 TMMFDevSoundQueueItem markItem; |
|
1615 markItem.iRequest = EMMFDevSoundProxyMarkEvent; |
|
1616 // assumes sufficient space in the queue |
|
1617 TInt err = iMsgQueue.Send(markItem); |
|
1618 __ASSERT_DEBUG(err == KErrNone, Panic(EMsgQueueFailedToSendMsg)); |
|
1619 |
|
1620 while(ETrue) |
|
1621 { |
|
1622 // At least the markEvent is at the queue so ignore the error |
|
1623 TMMFDevSoundQueueItem queueItem; |
|
1624 err = iMsgQueue.Receive(queueItem); |
|
1625 if(queueItem.iRequest == EMMFDevSoundProxyMarkEvent) |
|
1626 { |
|
1627 break; |
|
1628 } |
|
1629 // Look for the specific event |
|
1630 else if(queueItem.iRequest != aRequest) |
|
1631 { |
|
1632 // assumes sufficient space in the queue |
|
1633 err = iMsgQueue.Send(queueItem); |
|
1634 } |
|
1635 } |
|
1636 } |
|
1637 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FilterQueueEvent - Exit")); |
|
1638 } |
|
1639 |
|
1640 // |
|
1641 // CMMFDevSoundSession::Disconnect |
|
1642 // (other items were commented in a header). |
|
1643 // |
|
1644 void CMMFDevSoundSession::Disconnect(const RMessage2& aMessage) |
|
1645 { |
|
1646 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Enter")); |
|
1647 iDisconnecting = ETrue; |
|
1648 |
|
1649 if (NeedToQueue()) |
|
1650 { |
|
1651 // if we are in the middle of something, enqueue and wait |
|
1652 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Add to queue")); |
|
1653 EnqueueRequest(aMessage); |
|
1654 iClosingWait->Start(); |
|
1655 } |
|
1656 else |
|
1657 { |
|
1658 // else do now. Enter ActiveSchedulerWait to wait for AsyncOpComplete |
|
1659 TBool complete = iAdapter->CloseDevSound(); |
|
1660 if(!complete) |
|
1661 { |
|
1662 iRequestBeingServiced.SetMessage(aMessage); |
|
1663 iOperationCompletePending = ETrue; |
|
1664 ResetNotifiedError(); |
|
1665 iClosingWait->Start(); |
|
1666 } |
|
1667 } |
|
1668 CSession2::Disconnect(aMessage); |
|
1669 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Exit")); |
|
1670 } |
|
1671 |
|
1672 |
|
1673 // |
|
1674 // CMMFDevSoundSession::NewL |
|
1675 // (other items were commented in a header). |
|
1676 // |
|
1677 CMMFDevSoundSession* CMMFDevSoundSession::NewL(MGlobalProperties& aGlobalProperties) |
|
1678 { |
|
1679 CMMFDevSoundSession* self = new (ELeave) CMMFDevSoundSession; |
|
1680 CleanupStack::PushL(self); |
|
1681 self->ConstructL(aGlobalProperties); |
|
1682 CleanupStack::Pop(self); |
|
1683 return self; |
|
1684 } |
|
1685 |
|
1686 // |
|
1687 // CMMFDevSoundSession::ConstructL |
|
1688 // (other items were commented in a header). |
|
1689 // |
|
1690 void CMMFDevSoundSession::ConstructL(MGlobalProperties& aGlobalProperties) |
|
1691 { |
|
1692 iAdapter = CMMFDevSoundAdaptation::NewL(*this, aGlobalProperties); |
|
1693 |
|
1694 iClosingWait = new(ELeave) CActiveSchedulerWait(); |
|
1695 |
|
1696 // Create the Custom Interface DeMux Utility |
|
1697 iDeMuxUtility = CMMFDevSoundCIDeMuxUtility::NewL(this); |
|
1698 |
|
1699 // Create the Custom Interface extension |
|
1700 TUid implUid = {KMmfUidCIServerExtensionImpl}; |
|
1701 TInt uidAsInteger = implUid.iUid; |
|
1702 const TInt KCIExtTempBufferSize = 20; |
|
1703 TBuf8<KCIExtTempBufferSize> tempBuffer; |
|
1704 tempBuffer.Num(uidAsInteger, EHex); |
|
1705 TUid interfaceUid = {KUidDevSoundCIServerExtension}; |
|
1706 TUid destructorKey; |
|
1707 TRAPD(err, iCIExtension = static_cast<MDevSoundCIServerExtension*> |
|
1708 (MmPluginUtils::CreateImplementationL(interfaceUid, destructorKey, tempBuffer, KRomOnlyResolverUid))); |
|
1709 if (KErrNotSupported == err) |
|
1710 { |
|
1711 iCIExtension = NULL; |
|
1712 } |
|
1713 else |
|
1714 { |
|
1715 User::LeaveIfError(err); |
|
1716 } |
|
1717 if (iCIExtension) |
|
1718 { |
|
1719 // Extension exists. Complete the setup |
|
1720 iCIExtension->PassDestructorKey(destructorKey); |
|
1721 User::LeaveIfError(iCIExtension->Setup(*this)); |
|
1722 } |
|
1723 |
|
1724 iQueuedRequests.ReserveL(KMaxQueueRequest); |
|
1725 iAsyncQueueStart = new (ELeave) CAsyncCallBack(CActive::EPriorityStandard); |
|
1726 TCallBack asyncCallback(AsyncQueueStartCallback, this); |
|
1727 iAsyncQueueStart->Set(asyncCallback); |
|
1728 } |
|
1729 |
|
1730 // CMMFDevSoundSession::InitializeComplete |
|
1731 // (other items were commented in a header). |
|
1732 // |
|
1733 void CMMFDevSoundSession::InitializeComplete(TInt aError) |
|
1734 { |
|
1735 // this may be a re-initialization and so we need to |
|
1736 // re-get our custom interfaces on the DeMux plugins |
|
1737 TInt count = iCustomInterfaceArray.Count(); |
|
1738 for (TInt i = 0; i < count; i++) |
|
1739 { |
|
1740 // we could have already deleted interfaces without |
|
1741 // removing them from the array so check for this |
|
1742 // and only refresh plugin if non-null |
|
1743 MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = iCustomInterfaceArray[i].iInterface; |
|
1744 if (ptr) |
|
1745 { |
|
1746 // we can't keep track of.. |
|
1747 // 1. where a custom interface is implemented |
|
1748 // 2. the uid of the custom interface to be refreshed |
|
1749 // so assume all have to be refreshed |
|
1750 TRAPD(err, ptr->RefreshL()); |
|
1751 |
|
1752 // Error indicates this is no longer a valid interface |
|
1753 if (err != KErrNone) |
|
1754 { |
|
1755 TMMFEvent event; |
|
1756 TMMFDevSoundQueueItem item; |
|
1757 item.iRequest = EMMFDevSoundCustomCommandCloseMuxDemuxPair; |
|
1758 item.iErrorCode = err; |
|
1759 event.iEventType.iUid = i+1; |
|
1760 item.iEventPckg() = event; |
|
1761 TInt lErr = iMsgQueue.Send(item); |
|
1762 __ASSERT_DEBUG(lErr == KErrNone, Panic(EMsgQueueFailedToSendMsg)); |
|
1763 |
|
1764 // NB proper panic code required here for this part. |
|
1765 } |
|
1766 } |
|
1767 } |
|
1768 TMMFDevSoundQueueItem item; |
|
1769 item.iRequest = EMMFDevSoundProxyICEvent; |
|
1770 item.iErrorCode = aError; |
|
1771 // assumes sufficient space in the queue so ignores the return value |
|
1772 iMsgQueue.Send(item); |
|
1773 } |
|
1774 |
|
1775 // |
|
1776 // CMMFDevSoundSession::ToneFinished |
|
1777 // (other items were commented in a header). |
|
1778 // |
|
1779 void CMMFDevSoundSession::ToneFinished(TInt aError) |
|
1780 { |
|
1781 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::ToneFinished - Enter. Error [%d]"), aError); |
|
1782 TMMFDevSoundQueueItem item; |
|
1783 item.iRequest = EMMFDevSoundProxyTFEvent; |
|
1784 item.iErrorCode = aError; |
|
1785 // assumes sufficient space in the queue so ignores the return value |
|
1786 iMsgQueue.Send(item); |
|
1787 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::ToneFinished - Exit")); |
|
1788 } |
|
1789 |
|
1790 // |
|
1791 // CMMFDevSoundSession::BufferToBeFilled |
|
1792 // (other items were commented in a header). |
|
1793 // |
|
1794 void CMMFDevSoundSession::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
1795 { |
|
1796 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::BufferToBeFilled - Enter")); |
|
1797 |
|
1798 // Set play error flag to false |
|
1799 iPlayErrorOccured = EFalse; |
|
1800 |
|
1801 // Store pointer to the buffer to use it later with PlayData |
|
1802 iBufferPlay = reinterpret_cast<CMMFDataBuffer*>(aBuffer); |
|
1803 TInt status = CreateChunk(iHwBufPckgFill, iBufferPlay->RequestSize()); |
|
1804 iHwBufPckgFill().iRequestSize = iBufferPlay->RequestSize(); |
|
1805 iHwBufPckgFill().iBufferSize = iBufferPlay->Data().MaxLength(); |
|
1806 iHwBufPckgFill().iLastBuffer = iBufferPlay->LastBuffer(); |
|
1807 TMMFDevSoundQueueItem queueItem; |
|
1808 if ( status != KErrNone ) |
|
1809 { |
|
1810 BufferErrorEvent(); |
|
1811 PlayError(status); |
|
1812 } |
|
1813 else |
|
1814 { |
|
1815 queueItem.iRequest = EMMFDevSoundProxyBTBFEvent; |
|
1816 // assumes sufficient space in the queue so ignores the return value |
|
1817 status = iMsgQueue.Send(queueItem); |
|
1818 } |
|
1819 |
|
1820 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::BufferToBeFilled - Exit [%d]"), status); |
|
1821 } |
|
1822 |
|
1823 // |
|
1824 // CMMFDevSoundSession::PlayError |
|
1825 // (other items were commented in a header). |
|
1826 // |
|
1827 void CMMFDevSoundSession::PlayError(TInt aError) |
|
1828 { |
|
1829 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::PlayError - Enter [%d]"), aError); |
|
1830 |
|
1831 // Set play error flag to ignore following PlayData requests |
|
1832 iPlayErrorOccured = ETrue; |
|
1833 |
|
1834 TMMFDevSoundQueueItem item; |
|
1835 item.iRequest = EMMFDevSoundProxyPEEvent; |
|
1836 item.iErrorCode = aError; |
|
1837 iChunk.Close(); |
|
1838 // assumes sufficient space in the queue so ignores the return value |
|
1839 iMsgQueue.Send(item); |
|
1840 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PlayError - Exit")); |
|
1841 } |
|
1842 |
|
1843 // |
|
1844 // CMMFDevSoundSession::BufferToBeEmptied |
|
1845 // (other items were commented in a header). |
|
1846 // |
|
1847 void CMMFDevSoundSession::BufferToBeEmptied(CMMFBuffer* aBuffer) |
|
1848 { |
|
1849 // Store pointer to the buffer to use it later with RecordData |
|
1850 iBufferRecord = reinterpret_cast<CMMFDataBuffer*>(aBuffer); |
|
1851 TInt status = CreateChunk(iHwBufPckgEmpty, iBufferRecord->RequestSize()); |
|
1852 |
|
1853 if ( status != KErrNone ) |
|
1854 { |
|
1855 BufferErrorEvent(); |
|
1856 RecordError(status); |
|
1857 } |
|
1858 else |
|
1859 { |
|
1860 iHwBufPckgEmpty().iRequestSize = iBufferRecord->RequestSize(); |
|
1861 iHwBufPckgEmpty().iBufferSize = iBufferRecord->Data().MaxLength(); |
|
1862 iHwBufPckgEmpty().iLastBuffer = iBufferRecord->LastBuffer(); |
|
1863 //copy the data into the chunk |
|
1864 Mem::Copy(iChunk.Base(),iBufferRecord->Data().Ptr(),iBufferRecord->RequestSize()); |
|
1865 TMMFDevSoundQueueItem queueItem; |
|
1866 queueItem.iRequest = EMMFDevSoundProxyBTBEEvent; |
|
1867 // assumes sufficient space in the queue so ignores the return value |
|
1868 iMsgQueue.Send(queueItem); |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 // CMMFDevSoundSession::RecordError |
|
1873 // (other items were commented in a header). |
|
1874 // |
|
1875 void CMMFDevSoundSession::RecordError(TInt aError) |
|
1876 { |
|
1877 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::Record Error [%d]"), aError); |
|
1878 TMMFDevSoundQueueItem item; |
|
1879 item.iRequest = EMMFDevSoundProxyREEvent; |
|
1880 item.iErrorCode = aError; |
|
1881 iChunk.Close(); |
|
1882 // assumes sufficient space in the queue so ignores the return value |
|
1883 iMsgQueue.Send(item); |
|
1884 } |
|
1885 |
|
1886 // |
|
1887 // CMMFDevSoundSession::DeviceMessage |
|
1888 // (other items were commented in a header). |
|
1889 // |
|
1890 void CMMFDevSoundSession::DeviceMessage(TUid /*aMessageType*/, |
|
1891 const TDesC8& /*aMsg*/) |
|
1892 { |
|
1893 // Not used |
|
1894 } |
|
1895 |
|
1896 void CMMFDevSoundSession::InterfaceDeleted(TUid aInterfaceId) |
|
1897 { |
|
1898 MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = InterfaceFromUid(aInterfaceId); |
|
1899 if (ptr == NULL) |
|
1900 { |
|
1901 // Not found |
|
1902 return; |
|
1903 } |
|
1904 TRAPD(err, ptr->RefreshL()); |
|
1905 if (err != KErrNone) |
|
1906 { |
|
1907 // Refresh failed, so tear down Mux/DeMux pair |
|
1908 TMMFEvent event; |
|
1909 TMMFDevSoundQueueItem item; |
|
1910 item.iRequest = EMMFDevSoundCustomCommandCloseMuxDemuxPair; |
|
1911 item.iErrorCode = err; |
|
1912 event.iEventType = aInterfaceId; |
|
1913 item.iEventPckg() = event; |
|
1914 iMsgQueue.Send(item); |
|
1915 } |
|
1916 } |
|
1917 |
|
1918 // |
|
1919 // CMMFDevSoundSession::CallbackFromAdaptorReceived |
|
1920 // (other items were commented in a header). |
|
1921 // |
|
1922 void CMMFDevSoundSession::CallbackFromAdaptorReceived(TInt aType, TInt aError) |
|
1923 { |
|
1924 SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Enter. Type[%d] Error[%d]"), aType, aError); |
|
1925 if(aType == KCallbackRecordPauseComplete) |
|
1926 { |
|
1927 TMMFDevSoundQueueItem item; |
|
1928 item.iRequest = EMMFDevSoundProxyPausedRecordCompleteEvent; |
|
1929 item.iErrorCode = KErrNone; |
|
1930 TInt status = iMsgQueue.Send(item); |
|
1931 } |
|
1932 else if(aType == KCallbackAutoPauseResume) |
|
1933 { |
|
1934 TMMFEvent event; |
|
1935 event.iErrorCode = KErrNone; |
|
1936 event.iEventType = KMMFEventCategoryAudioResourceAvailable; |
|
1937 SendEventToClient(event); |
|
1938 //coverity[uninit_use_in_call] |
|
1939 // Disabled Coverity warning, since it complains about iReserved1 member in TMMFEvent being uninitialised |
|
1940 } |
|
1941 else if (aType == KCallbackFlushComplete) |
|
1942 { |
|
1943 if(!iHandlingExtdCI && iRequestBeingServiced.Function()==EMMFDevSoundProxyEmptyBuffers) |
|
1944 { |
|
1945 //If we come here then it is due to a EMMFDevSoundProxyEmptyBuffers request from client. |
|
1946 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Calling TMMFDevSoundRequest::Complete on iRequestBeingServiced")); |
|
1947 iRequestBeingServiced.Complete(aError); |
|
1948 iOperationCompletePending = EFalse; |
|
1949 } |
|
1950 } |
|
1951 else |
|
1952 { |
|
1953 if( NeedToQueue() ) |
|
1954 { |
|
1955 // If not possible to service now, then queue request |
|
1956 // Encapsule the request |
|
1957 TMMFDevSoundRequest request(aType); |
|
1958 // assumes sufficient space in the queue so ignores the return value |
|
1959 iQueuedRequests.Insert(request, 0); |
|
1960 } |
|
1961 else |
|
1962 { |
|
1963 // If there is no oustanding operation service inmediately |
|
1964 if (aType == KCallbackProcessingFinished) |
|
1965 { |
|
1966 DoProcessingFinished(); |
|
1967 } |
|
1968 else if(aType == KCallbackProcessingUnitError) |
|
1969 { |
|
1970 DoProcessingError(); |
|
1971 } |
|
1972 } |
|
1973 } |
|
1974 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Exit")); |
|
1975 } |
|
1976 |
|
1977 |
|
1978 // |
|
1979 // CMMFDevSoundSession::PreemptionStartedCallbackReceived |
|
1980 // (other items were commented in a header). |
|
1981 // |
|
1982 void CMMFDevSoundSession::PreemptionStartedCallbackReceived() |
|
1983 { |
|
1984 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionStartedCallbackReceived - Enter")); |
|
1985 // Solution: Enqueue any request that arrives before preemption is completed |
|
1986 iOperationCompletePending = ETrue; |
|
1987 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionStartedCallbackReceived - Exit")); |
|
1988 } |
|
1989 |
|
1990 // |
|
1991 // CMMFDevSoundSession::PreemptionFinishedCallbackReceived |
|
1992 // (other items were commented in a header). |
|
1993 // |
|
1994 void CMMFDevSoundSession::PreemptionFinishedCallbackReceived(TBool aCanStartNewOperation) |
|
1995 { |
|
1996 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Enter")); |
|
1997 if (iHandlingExtdCI) |
|
1998 { |
|
1999 // we are in the middle of handling a CI, so ignore - will handle later when unwinding |
|
2000 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Exit. Exiting from if block for CI")); |
|
2001 return; |
|
2002 } |
|
2003 iOperationCompletePending = EFalse; |
|
2004 if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 ) |
|
2005 { |
|
2006 DequeueRequest(); |
|
2007 } |
|
2008 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Exit")); |
|
2009 } |
|
2010 |
|
2011 // |
|
2012 // CMMFDevSoundSession::PreemptionClash |
|
2013 // (other items were commented in a header). |
|
2014 // |
|
2015 void CMMFDevSoundSession::PreemptionClash() |
|
2016 { |
|
2017 //assumes sufficient space in the queue so ignore the return value |
|
2018 iQueuedRequests.Insert(iRequestBeingServiced, 0); |
|
2019 iPreemptionClash=ETrue; |
|
2020 } |
|
2021 |
|
2022 // |
|
2023 // CMMFDevSoundSession::PreemptionClashWithStateChange |
|
2024 // (other items were commented in a header). |
|
2025 // |
|
2026 void CMMFDevSoundSession::PreemptionClashWithStateChange() |
|
2027 { |
|
2028 #ifdef _DEBUG |
|
2029 TMMFDevSoundRequest msg = iQueuedRequests[0]; |
|
2030 // message being removed should be the one we previously pushed via PreemptionClash() |
|
2031 __ASSERT_DEBUG(iRequestBeingServiced==msg, Panic(ERequestBeingServicedMismatch)); |
|
2032 #endif |
|
2033 // remove without processing request with AsynchronousOperationComplete() completing the message |
|
2034 iQueuedRequests.Remove(0); |
|
2035 iPreemptionClash=EFalse; |
|
2036 } |
|
2037 |
|
2038 // |
|
2039 // CMMFDevSoundSession::AdaptorControlsContext() |
|
2040 // |
|
2041 |
|
2042 TBool CMMFDevSoundSession::AdaptorControlsContext() const |
|
2043 { |
|
2044 return !iHandlingExtdCI; |
|
2045 } |
|
2046 |
|
2047 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDevSoundSession::InterfaceFromUid(TUid aUid) |
|
2048 { |
|
2049 TInt count = iCustomInterfaceArray.Count(); |
|
2050 TInt id = aUid.iUid; |
|
2051 MMMFDevSoundCustomInterfaceDeMuxPlugin* interface = NULL; |
|
2052 for (TInt i = 0; i < count; i++) |
|
2053 { |
|
2054 if (id == iCustomInterfaceArray[i].iId.iUid) |
|
2055 { |
|
2056 interface = iCustomInterfaceArray[i].iInterface; |
|
2057 break; |
|
2058 } |
|
2059 } |
|
2060 return interface; |
|
2061 } |
|
2062 |
|
2063 // |
|
2064 // CMMFDevSoundSession::SendEventToClient |
|
2065 // (other items were commented in a header). |
|
2066 // |
|
2067 void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent) |
|
2068 { |
|
2069 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::SendEventToClient - Enter")); |
|
2070 TMMFDevSoundQueueItem item; |
|
2071 item.iRequest = EMMFDevSoundProxySETCEvent; |
|
2072 item.iErrorCode = KErrNone; |
|
2073 item.iEventPckg() = aEvent; |
|
2074 // assumes sufficient space in the queue so ignores the return value |
|
2075 TInt err = iMsgQueue.Send(item); |
|
2076 __ASSERT_DEBUG(err == KErrNone, Panic(EMsgQueueFailedToSendMsg)); |
|
2077 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::SendEventToClient - Exit")); |
|
2078 } |
|
2079 |
|
2080 void CMMFDevSoundSession::AsynchronousOperationComplete(TInt aError, TBool aCanStartNewOperation) |
|
2081 { |
|
2082 __ASSERT_DEBUG(!iHandlingExtdCI, Panic(EUnexpectedAsyncOpCompleteHandlingCI)); |
|
2083 // when handling CIs we should not reach here |
|
2084 |
|
2085 TInt error = aError; |
|
2086 if (!error) |
|
2087 { |
|
2088 // if have no error payload, use notified error. It will be KErrNone if not set, so just use. |
|
2089 error = NotifiedError(); |
|
2090 } |
|
2091 |
|
2092 switch (iRequestBeingServiced.Type()) |
|
2093 { |
|
2094 case TMMFDevSoundRequest::ESessionEvents: |
|
2095 { |
|
2096 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x] ==== ClosingDueException ==== ")); |
|
2097 iOperationCompletePending = EFalse; |
|
2098 if(iClosingWait->IsStarted()) |
|
2099 { |
|
2100 iClosingWait->AsyncStop(); |
|
2101 } |
|
2102 return; |
|
2103 } |
|
2104 // Complete the message for asynchronous requests |
|
2105 case TMMFDevSoundRequest::EConfigure_Asynchronous: |
|
2106 case TMMFDevSoundRequest::EAction_Asynchronous: |
|
2107 case TMMFDevSoundRequest::EQuery_Asynchronous: |
|
2108 case TMMFDevSoundRequest::ECustomInterfacesRelated: |
|
2109 { |
|
2110 if(iOperationCompletePending && aCanStartNewOperation) |
|
2111 { |
|
2112 if (iRequestBeingServiced.Function()==EMMFDevSoundProxyStop) |
|
2113 { |
|
2114 // flush the queue - will have removed any stale items added between initial call and MMRC's reaction |
|
2115 FlushQueuedRequests(); |
|
2116 FlushEventQueue(); |
|
2117 iChunk.Close(); |
|
2118 } |
|
2119 |
|
2120 if(iRequestBeingServiced.Function()==EMMFDevSoundProxyCapabilities) |
|
2121 { |
|
2122 TMMFDevSoundProxySettings devSoundSet; |
|
2123 devSoundSet.iCaps = iDevSoundCapabilities; |
|
2124 TMMFDevSoundProxySettingsPckg pckg(devSoundSet); |
|
2125 MessageWrite(iRequestBeingServiced.Message(),TInt(2),pckg); |
|
2126 } |
|
2127 |
|
2128 if(iRequestBeingServiced.Function()==EMMFDevSoundProxyCancelInitialize) |
|
2129 { |
|
2130 FlushEventQueue(); |
|
2131 } |
|
2132 |
|
2133 iRequestBeingServiced.Complete(error); |
|
2134 iOperationCompletePending = EFalse; |
|
2135 } |
|
2136 } |
|
2137 break; |
|
2138 case TMMFDevSoundRequest::EAction_PseudoAsynchronous: |
|
2139 { |
|
2140 if(iOperationCompletePending && aCanStartNewOperation) |
|
2141 { |
|
2142 iOperationCompletePending = EFalse; |
|
2143 } |
|
2144 } |
|
2145 break; |
|
2146 case TMMFDevSoundRequest::EQuery_Synchronous: |
|
2147 case TMMFDevSoundRequest::EConfigure_Synchronous: |
|
2148 case TMMFDevSoundRequest::EBufferExchangeRelated: |
|
2149 break; |
|
2150 case TMMFDevSoundRequest::ECallBackType: |
|
2151 { |
|
2152 if(iOperationCompletePending && aCanStartNewOperation) |
|
2153 { |
|
2154 iOperationCompletePending = EFalse; |
|
2155 } |
|
2156 } |
|
2157 break; |
|
2158 default: |
|
2159 break; |
|
2160 } |
|
2161 |
|
2162 if(iRequestBeingServiced.Type() == TMMFDevSoundRequest::ECallBackType ) |
|
2163 { |
|
2164 SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x] AsynchronousOperationComplete CallbackPF=%d pending=%d"), |
|
2165 iRequestBeingServiced.IsCallBack(), iOperationCompletePending ); |
|
2166 } |
|
2167 else |
|
2168 { |
|
2169 SYMBIAN_DEBPRN3(_L("CMMFDevSoundSession[0x%x] AsynchronousOperationComplete %x pending=%d Requestype=%d"), |
|
2170 iRequestBeingServiced.Function(), iOperationCompletePending, iRequestBeingServiced.Type() ); |
|
2171 } |
|
2172 |
|
2173 |
|
2174 if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 ) |
|
2175 { |
|
2176 DequeueRequest(); |
|
2177 } |
|
2178 } |
|
2179 |
|
2180 void CMMFDevSoundSession::DequeueRequest() |
|
2181 { |
|
2182 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DequeueRequest - Enter")); |
|
2183 iAsyncQueueStart->Cancel(); // if we're in here cancel any background request |
|
2184 |
|
2185 TMMFDevSoundRequest msg = iQueuedRequests[0]; |
|
2186 |
|
2187 if (msg.IsCallBack() > 0) |
|
2188 { |
|
2189 iRequestBeingServiced.SetMessageCallback(); |
|
2190 //Call iPf function |
|
2191 SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x] ======== Service a queued request\n")); |
|
2192 if (msg.IsCallBack() == KCallbackProcessingFinished) |
|
2193 { |
|
2194 iQueuedRequests.Remove(0); |
|
2195 DoProcessingFinished(); |
|
2196 } |
|
2197 else if(msg.IsCallBack() == KCallbackProcessingUnitError) |
|
2198 { |
|
2199 iQueuedRequests.Remove(0); |
|
2200 DoProcessingError(); |
|
2201 } |
|
2202 |
|
2203 } |
|
2204 |
|
2205 if (iQueuedRequests.Count()>0) |
|
2206 { |
|
2207 // Some rules about what request can be followed |
|
2208 SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Flag can service new request\n")); |
|
2209 iAsyncQueueStart->CallBack(); |
|
2210 } |
|
2211 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DequeueRequest - Exit")); |
|
2212 } |
|
2213 |
|
2214 // AsyncQueueStartCallback |
|
2215 |
|
2216 |
|
2217 TInt CMMFDevSoundSession::AsyncQueueStartCallback(TAny* aPtr) |
|
2218 { |
|
2219 CMMFDevSoundSession* self = static_cast<CMMFDevSoundSession*>(aPtr); |
|
2220 self->AsyncQueueStartCallback(); |
|
2221 return KErrNone; |
|
2222 } |
|
2223 |
|
2224 void CMMFDevSoundSession::AsyncQueueStartCallback() |
|
2225 { |
|
2226 SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Service a queued request\n")); |
|
2227 TMMFDevSoundRequest msg = iQueuedRequests[0]; |
|
2228 iQueuedRequests.Remove(0); |
|
2229 TInt err = KErrNone; |
|
2230 TBool doRequest = ETrue; |
|
2231 if(iPreemptionClash) |
|
2232 { |
|
2233 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::AsyncQueueStartCallback - Re-applying client request due to Pre-emption clash")); |
|
2234 iPreemptionClash=EFalse; // clear flag before reading next request in queue |
|
2235 iAdapter->RollbackAdaptorActiveStateToBeforeCommit(); |
|
2236 if ((iRequestBeingServiced.Type() == TMMFDevSoundRequest::EAction_PseudoAsynchronous)) |
|
2237 { |
|
2238 doRequest = EFalse; |
|
2239 HandleAlreadyCompletedRequest(); |
|
2240 } |
|
2241 } |
|
2242 |
|
2243 if (doRequest) |
|
2244 { |
|
2245 TRAP(err,DoServiceRequestL(msg.Message())); |
|
2246 if(err != KErrNone) |
|
2247 { |
|
2248 msg.Complete(err); |
|
2249 } |
|
2250 } |
|
2251 |
|
2252 if (!iOperationCompletePending && iQueuedRequests.Count() != 0) |
|
2253 { |
|
2254 //dequeue next |
|
2255 DequeueRequest(); |
|
2256 } |
|
2257 } |
|
2258 |
|
2259 // CMMFDevSoundSession::CustomInterface() |
|
2260 // Returns a pointer reference to custom interface implementation returned by |
|
2261 // adaptation::CustomInterface method. |
|
2262 // Note this method is called indirectly by CI server-side plugins - both DeMux and |
|
2263 // CIServerExtension call this variously via MMMFDevSoundCustomInterfaceTarget or MCustomInterface |
|
2264 // |
|
2265 TAny* CMMFDevSoundSession::CustomInterface(TUid aInterfaceId) |
|
2266 { |
|
2267 TInt err = DoSetClientConfig(); // if required, this will connect to MMRC etc |
|
2268 if (err) |
|
2269 { |
|
2270 return NULL; // on any error, return NULL - not much more we can do |
|
2271 } |
|
2272 return iAdapter->CustomInterface(aInterfaceId); |
|
2273 } |
|
2274 |
|
2275 // |
|
2276 // CMMFDevSoundSession::DoProcessingFinished() |
|
2277 // |
|
2278 void CMMFDevSoundSession::DoProcessingFinished() |
|
2279 { |
|
2280 ResetNotifiedError(); |
|
2281 |
|
2282 TBool asyncOperation = EFalse; |
|
2283 //ProcessingFinished should never fail |
|
2284 __ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingFinishedReceived(asyncOperation)); |
|
2285 iOperationCompletePending = asyncOperation; |
|
2286 if (iOperationCompletePending) |
|
2287 { |
|
2288 iRequestBeingServiced.SetMessageCallback(); |
|
2289 } |
|
2290 } |
|
2291 |
|
2292 // |
|
2293 // CMMFDevSoundSession::DoProcessingError() |
|
2294 // |
|
2295 void CMMFDevSoundSession::DoProcessingError() |
|
2296 { |
|
2297 ResetNotifiedError(); |
|
2298 |
|
2299 TBool asyncOperation = EFalse; |
|
2300 //ProcessingFinished should never fail |
|
2301 __ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingError(asyncOperation)); |
|
2302 iOperationCompletePending = asyncOperation; |
|
2303 if (iOperationCompletePending) |
|
2304 { |
|
2305 iRequestBeingServiced.SetMessageCallback(); |
|
2306 } |
|
2307 } |
|
2308 |
|
2309 // |
|
2310 // CMMFDevSoundSession::DoSetClientConfigL() |
|
2311 // Sets client configuration information to Adaptation. |
|
2312 // |
|
2313 TInt CMMFDevSoundSession::DoSetClientConfig() |
|
2314 { |
|
2315 TInt err = KErrNone; |
|
2316 if(!iSetClientConfigApplied) |
|
2317 { |
|
2318 CMMFDevSoundServer* server = |
|
2319 const_cast<CMMFDevSoundServer*>( |
|
2320 static_cast<const CMMFDevSoundServer*>(Server())); |
|
2321 |
|
2322 ASSERT(server); // session should always have a server! |
|
2323 |
|
2324 TProcessId actualProcessId = server->ActualProcessId(); |
|
2325 TProcessId processId = server->ProcessId(); |
|
2326 |
|
2327 if (actualProcessId!=processId) |
|
2328 { |
|
2329 // we have a differing actual process id, so pass that to the adaptor too |
|
2330 err = iAdapter->SetClientConfig(actualProcessId, processId); |
|
2331 } |
|
2332 else |
|
2333 { |
|
2334 err = iAdapter->SetClientConfig(processId); |
|
2335 } |
|
2336 |
|
2337 if (!err) |
|
2338 { |
|
2339 iSetClientConfigApplied = ETrue; |
|
2340 } |
|
2341 } |
|
2342 return err; |
|
2343 } |
|
2344 |
|
2345 // CMMFDevSoundSession::DoSetClientConfigL() |
|
2346 // Sets client configuration information to Adaptation. |
|
2347 // |
|
2348 void CMMFDevSoundSession::DoSetClientConfigL() |
|
2349 { |
|
2350 User::LeaveIfError(DoSetClientConfig()); |
|
2351 } |
|
2352 |
|
2353 // |
|
2354 // CMMFDevSoundSession::CreateChunk() |
|
2355 // Requests kernel to create global RChunk |
|
2356 // |
|
2357 TInt CMMFDevSoundSession::CreateChunk(TMMFDevSoundProxyHwBufPckg& aBufPckg, TInt aRequestedSize) |
|
2358 { |
|
2359 TInt status(KErrNone); |
|
2360 |
|
2361 if ( iChunk.Handle() ) |
|
2362 { |
|
2363 // If the DevSound Adaptation component requests a buffer size |
|
2364 // that can fit into current chunk's size, then re-use chunk. |
|
2365 if ( aRequestedSize <= iChunk.Size() ) |
|
2366 { |
|
2367 if (iForceSendOfChunkHandle) |
|
2368 { |
|
2369 iForceSendOfChunkHandle = EFalse; |
|
2370 aBufPckg().iChunkOp = EOpen; |
|
2371 } |
|
2372 else |
|
2373 { |
|
2374 aBufPckg().iChunkOp = ENull; |
|
2375 } |
|
2376 return status; |
|
2377 } |
|
2378 // The new request size exceeds the current chunk's area, close it. We |
|
2379 // will be creating new one in the following sequences. Note we could |
|
2380 // try to Adjust() the chunk, and see if the existing chunk could be |
|
2381 // extended instead, but this is assumed too rare an event for this |
|
2382 // optimisation |
|
2383 else |
|
2384 { |
|
2385 iChunk.Close(); |
|
2386 } |
|
2387 } |
|
2388 |
|
2389 // Request kernel to create global RChunk if needed |
|
2390 if ( !iChunk.Handle() ) |
|
2391 { |
|
2392 status = iChunk.CreateGlobal(KNullDesC, aRequestedSize, aRequestedSize, EOwnerThread); |
|
2393 if ( status == KErrNone ) |
|
2394 { |
|
2395 aBufPckg().iChunkOp = EOpen; |
|
2396 } |
|
2397 else |
|
2398 { |
|
2399 aBufPckg().iChunkOp = ENull; |
|
2400 } |
|
2401 } |
|
2402 iForceSendOfChunkHandle = EFalse; |
|
2403 return status; |
|
2404 } |
|
2405 |
|
2406 |
|
2407 // Custom Interface // |
|
2408 TInt CMMFDevSoundSession::DoOpenSlaveL(TUid aInterface, const TDesC8& aPackageBuf) |
|
2409 { |
|
2410 // it shouldn't be necessary to check if we have already instantiated this |
|
2411 // interface since the client would already know - however this is something |
|
2412 // that a licensee could implement if they required additional functionality |
|
2413 // e.g. many : 1 mappings between client and DevSound. |
|
2414 |
|
2415 MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = NULL; |
|
2416 |
|
2417 // try and instantiate a plugin tunnelling |
|
2418 // pair to support this Custom Interface |
|
2419 ptr = iDeMuxUtility->CreateCustomInterfaceDeMuxL(aInterface); |
|
2420 |
|
2421 TInt handle = KNullHandle; |
|
2422 |
|
2423 if (ptr) |
|
2424 { |
|
2425 TMMFDevSoundCustomInterfaceDeMuxData data; |
|
2426 data.iInterface = ptr; |
|
2427 data.iId = aInterface; |
|
2428 |
|
2429 CleanupReleasePushL(*ptr); |
|
2430 |
|
2431 // setup demux plugin |
|
2432 ptr->SetInterfaceTarget(this); |
|
2433 |
|
2434 // try and open interface |
|
2435 // this will fetch the interface from the svr implementation |
|
2436 ptr->DoOpenSlaveL(aInterface, aPackageBuf); |
|
2437 User::LeaveIfError(iCustomInterfaceArray.Append(data)); |
|
2438 |
|
2439 CleanupStack::Pop(); // ptr |
|
2440 |
|
2441 handle = iCustomInterfaceArray.Count(); |
|
2442 return handle; |
|
2443 } |
|
2444 |
|
2445 // we couldn't set up the interface correctly so return a NULL |
|
2446 // handle to the client |
|
2447 return KNullHandle; |
|
2448 } |
|
2449 |
|
2450 void CMMFDevSoundSession::DoCloseSlaveL(TInt aHandle) |
|
2451 { |
|
2452 if (aHandle==KNullHandle) |
|
2453 { |
|
2454 // null-handle -> NOP |
|
2455 return; |
|
2456 } |
|
2457 |
|
2458 if (aHandle<KNullHandle || aHandle > iCustomInterfaceArray.Count()) |
|
2459 { |
|
2460 // handle out of range - should not happen, but leave to show error |
|
2461 User::Leave(KErrBadHandle); |
|
2462 } |
|
2463 |
|
2464 TMMFDevSoundCustomInterfaceDeMuxData& data = iCustomInterfaceArray[aHandle-1]; |
|
2465 |
|
2466 // close and delete the plugin |
|
2467 MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = data.iInterface; |
|
2468 ptr->DoCloseSlaveL(aHandle); |
|
2469 ptr->Release(); |
|
2470 |
|
2471 // clear the entry |
|
2472 data.iInterface = NULL; |
|
2473 data.iId.iUid = 0; |
|
2474 } |
|
2475 |
|
2476 TInt CMMFDevSoundSession::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) |
|
2477 { |
|
2478 // use the demux utility to get the handle |
|
2479 TMMFDevSoundCIMessageData data; |
|
2480 iDeMuxUtility->GetSyncMessageDataL(aMessage, data); |
|
2481 |
|
2482 TInt handle = data.iHandle; |
|
2483 |
|
2484 if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count()))) |
|
2485 { |
|
2486 |
|
2487 User::Leave(KErrBadHandle); |
|
2488 } |
|
2489 |
|
2490 // call on demux plugin |
|
2491 return iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveSyncCommandL(aMessage); |
|
2492 } |
|
2493 |
|
2494 TInt CMMFDevSoundSession::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) |
|
2495 { |
|
2496 // use the demux utility to get the handle |
|
2497 TMMFDevSoundCIMessageData data; |
|
2498 iDeMuxUtility->GetSyncMessageDataL(aMessage, data); |
|
2499 |
|
2500 TInt handle = data.iHandle; |
|
2501 |
|
2502 if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count()))) |
|
2503 { |
|
2504 |
|
2505 User::Leave(KErrBadHandle); |
|
2506 } |
|
2507 |
|
2508 // call on demux plugin |
|
2509 return iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveSyncCommandResultL(aMessage); |
|
2510 } |
|
2511 |
|
2512 void CMMFDevSoundSession::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& aMessage) |
|
2513 { |
|
2514 // use the demux utility to get the handle |
|
2515 TMMFDevSoundCIMessageData data; |
|
2516 iDeMuxUtility->GetAsyncMessageDataL(aMessage, data); |
|
2517 |
|
2518 TInt handle = data.iHandle; |
|
2519 |
|
2520 if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count()))) |
|
2521 { |
|
2522 User::Leave(KErrBadHandle); |
|
2523 } |
|
2524 |
|
2525 // call on demux plugin |
|
2526 iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveAsyncCommandL(aMessage); |
|
2527 } |
|
2528 |
|
2529 void CMMFDevSoundSession::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& aMessage) |
|
2530 { |
|
2531 // use the demux utility to get the handle |
|
2532 TMMFDevSoundCIMessageData data; |
|
2533 iDeMuxUtility->GetAsyncMessageDataL(aMessage, data); |
|
2534 |
|
2535 TInt handle = data.iHandle; |
|
2536 |
|
2537 if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count()))) |
|
2538 { |
|
2539 User::Leave(KErrBadHandle); |
|
2540 } |
|
2541 |
|
2542 // call on demux plugin |
|
2543 iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveAsyncCommandResultL(aMessage); |
|
2544 } |
|
2545 |
|
2546 |
|
2547 TBool CMMFDevSoundSession::DoRegisterAsClientL(const RMmfIpcMessage& aMessage) |
|
2548 { |
|
2549 TMMFDevSoundProxySettingsPckg buf; |
|
2550 User::LeaveIfError(MessageRead(aMessage,0,buf)); |
|
2551 HBufC8* notificationRegistrationData = NULL; |
|
2552 notificationRegistrationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLengthL(1))); |
|
2553 TPtr8 dataPtr(notificationRegistrationData->Des()); |
|
2554 User::LeaveIfError(MessageRead(aMessage,1,dataPtr)); |
|
2555 DoSetClientConfigL();// added here instead of the CreateL() |
|
2556 TInt err = KErrNone; |
|
2557 err = iAdapter->RegisterAsClient(buf().iNotificationEventUid,dataPtr); |
|
2558 CleanupStack::PopAndDestroy(1); // Notification Registeration data |
|
2559 if (err != KErrNone) |
|
2560 { |
|
2561 aMessage.Complete(err); |
|
2562 return EFalse; |
|
2563 } |
|
2564 return ETrue; |
|
2565 } |
|
2566 |
|
2567 TBool CMMFDevSoundSession::DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage) |
|
2568 { |
|
2569 TMMFDevSoundProxySettingsPckg buf; |
|
2570 User::LeaveIfError(MessageRead(aMessage,0,buf)); |
|
2571 TInt err = KErrNone; |
|
2572 err = iAdapter->CancelRegisterAsClient(buf().iNotificationEventUid); |
|
2573 if (err != KErrNone) |
|
2574 { |
|
2575 aMessage.Complete(err); |
|
2576 return EFalse; |
|
2577 } |
|
2578 return ETrue; |
|
2579 } |
|
2580 |
|
2581 TBool CMMFDevSoundSession::DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage) |
|
2582 { |
|
2583 TMMFDevSoundProxySettingsPckg buf; |
|
2584 User::LeaveIfError(MessageRead(aMessage,0,buf)); |
|
2585 HBufC8* notificationData = NULL; |
|
2586 notificationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesMaxLengthL(2))); |
|
2587 TPtr8 dataPtr(notificationData->Des()); |
|
2588 User::LeaveIfError(MessageRead(aMessage,2,dataPtr)); |
|
2589 TInt err = KErrNone; |
|
2590 err = iAdapter->GetResourceNotificationData(buf().iNotificationEventUid,dataPtr); |
|
2591 User::LeaveIfError(MessageWrite(aMessage,2,*notificationData)); |
|
2592 CleanupStack::PopAndDestroy(1); // Notification data |
|
2593 if (err != KErrNone) |
|
2594 { |
|
2595 aMessage.Complete(err); |
|
2596 return EFalse; |
|
2597 } |
|
2598 return ETrue; |
|
2599 } |
|
2600 |
|
2601 TBool CMMFDevSoundSession::DoWillResumePlayL(const RMmfIpcMessage& aMessage) |
|
2602 { |
|
2603 TInt err = KErrNone; |
|
2604 err = iAdapter->WillResumePlay(); |
|
2605 if (err != KErrNone) |
|
2606 { |
|
2607 aMessage.Complete(err); |
|
2608 return EFalse; |
|
2609 } |
|
2610 return ETrue; |
|
2611 } |
|
2612 |
|
2613 TBool CMMFDevSoundSession::DoSetClientThreadInfoL(const RMmfIpcMessage& aMessage) |
|
2614 { |
|
2615 if(!iSetClientConfigApplied) |
|
2616 { |
|
2617 if (aMessage.HasCapability(ECapabilityMultimediaDD) && aMessage.HasCapability(ECapabilityUserEnvironment)) |
|
2618 { |
|
2619 TPckgBuf<TThreadId> threadId; |
|
2620 User::LeaveIfError(MessageRead(aMessage, 1, threadId)); |
|
2621 |
|
2622 CMMFDevSoundServer* server = |
|
2623 const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server())); |
|
2624 server->SetClientProcessIdL(threadId()); |
|
2625 } |
|
2626 else |
|
2627 { |
|
2628 User::Leave(KErrPermissionDenied); |
|
2629 } |
|
2630 } |
|
2631 else |
|
2632 { |
|
2633 User::Leave(KErrNotReady); |
|
2634 } |
|
2635 return ETrue; |
|
2636 } |
|
2637 |
|
2638 void CMMFDevSoundSession::Panic(TMMFDevSoundSessionPanicCodes aCode) |
|
2639 { |
|
2640 User::Panic(KMMFDevSoundSessionPanicCategory, aCode); |
|
2641 } |
|
2642 |
|
2643 void CMMFDevSoundSession::BufferErrorEvent() |
|
2644 { |
|
2645 // this will generate an processing error event and callback |
|
2646 iAdapter->BufferErrorEvent(); |
|
2647 } |
|
2648 |
|
2649 void CMMFDevSoundSession::FlushQueuedRequests() |
|
2650 { |
|
2651 for (TInt queueIndex = (iQueuedRequests.Count() - 1); queueIndex >= 0; --queueIndex) |
|
2652 { |
|
2653 if ((iQueuedRequests[queueIndex].Type() == TMMFDevSoundRequest::ESessionEvents) && |
|
2654 (iQueuedRequests[queueIndex].Function() == RMessage2::EDisConnect)) |
|
2655 { |
|
2656 continue; |
|
2657 } |
|
2658 iQueuedRequests.Remove(queueIndex); |
|
2659 } |
|
2660 } |
|
2661 |
|
2662 TInt CMMFDevSoundSession::MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes8& aResult) |
|
2663 { |
|
2664 if (!iDisconnecting) |
|
2665 { |
|
2666 return MmfMessageUtil::Read(aMessage, aParam, aResult); |
|
2667 } |
|
2668 return KErrBadHandle; |
|
2669 } |
|
2670 |
|
2671 TInt CMMFDevSoundSession::MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes16& aResult) |
|
2672 { |
|
2673 if (!iDisconnecting) |
|
2674 { |
|
2675 return aMessage.Read(aParam, aResult); |
|
2676 } |
|
2677 return KErrBadHandle; |
|
2678 } |
|
2679 |
|
2680 TInt CMMFDevSoundSession::MessageWrite(const RMmfIpcMessage& aMessage, TInt aParam, const TDesC8& aValue) |
|
2681 { |
|
2682 if (!iDisconnecting) |
|
2683 { |
|
2684 return MmfMessageUtil::Write(aMessage, aParam, aValue); |
|
2685 } |
|
2686 return KErrBadHandle; |
|
2687 } |
|
2688 |
|
2689 void CMMFDevSoundSession::ResetNotifiedError() |
|
2690 // called at beginning of commit cycle, so any error will be from callbacks |
|
2691 { |
|
2692 SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::ResetNotifiedError")); |
|
2693 iNotifiedError = KErrNone; |
|
2694 } |
|
2695 |
|
2696 TInt CMMFDevSoundSession::NotifiedError() const |
|
2697 // NotifiedError property |
|
2698 { |
|
2699 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::NotifiedError(%d)"), iNotifiedError); |
|
2700 return iNotifiedError; |
|
2701 } |
|
2702 |
|
2703 void CMMFDevSoundSession::NotifyError(TInt aError) |
|
2704 // cache notified error |
|
2705 { |
|
2706 SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::NotifyError(%d)"), aError); |
|
2707 iNotifiedError = aError; |
|
2708 } |
|
2709 |
|
2710 // End of file |