|
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 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "mmfdevsoundproxy.h" |
|
20 |
|
21 // SYMBIAN_CHECK used to add extra asserts when MACRO is added - helps debugging overall A3F |
|
22 |
|
23 #ifdef SYMBIAN_FULL_STATE_CHECK |
|
24 #define SYMBIAN_CHECK(c,p) __ASSERT_ALWAYS(c,p) |
|
25 #else |
|
26 #define SYMBIAN_CHECK(c,p) |
|
27 #endif |
|
28 |
|
29 const TInt KMaxMessageQueueItems = 8; |
|
30 |
|
31 const TMMFCapabilities KZeroCapabilities = |
|
32 { |
|
33 0,0,0,0 // all zero's |
|
34 }; |
|
35 |
|
36 // ============================ LOCAL FUNCTIONS ================================ |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // This function raises a panic |
|
40 // |
|
41 // @param aError |
|
42 // one of the several panic codes that may be raised by this dll |
|
43 // |
|
44 // @panic EMMFDevSoundProxyPlayDataWithoutInitialize is raised when playdata |
|
45 // is called without initialization |
|
46 // @panic EMMFDevSoundProxyRecordDataWithoutInitialize is raised when |
|
47 // recorddata is called without initialization |
|
48 // |
|
49 GLDEF_C void Panic(TMMFDevSoundProxyPanicCodes aPanicCode) |
|
50 { |
|
51 User::Panic(KMMFDevSoundProxyPanicCategory, aPanicCode); |
|
52 } |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // RMMFDevsoundProxy::RMMFDevsoundProxy |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C RMMFDevSoundProxy::RMMFDevSoundProxy() : |
|
63 iBuffer(NULL), |
|
64 iSeqName(NULL), |
|
65 iDestinationPckg(TMMFMessageDestination(KUidInterfaceMMFDevSound, |
|
66 KMMFObjectHandleDevSound)), |
|
67 iState(EIdle), |
|
68 iAudioServerProxy(NULL), |
|
69 iDevSoundObserver(NULL), |
|
70 iMsgQueueHandler(NULL), |
|
71 iCustIntPckg() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // RMMFDevSoundProxy::Close |
|
77 // Close the server session |
|
78 // (other items were commented in a header). |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C void RMMFDevSoundProxy::Close() |
|
82 { |
|
83 if (iAudioServerProxy) |
|
84 { |
|
85 if (iAudioServerProxy->Handle() != NULL) |
|
86 { |
|
87 TMMFDevSoundProxySettings set; |
|
88 TMMFDevSoundProxySettingsPckg pckg(set); |
|
89 TInt err = SendReceive(EMMFDevSoundProxyClose, |
|
90 iDestinationPckg, |
|
91 pckg); |
|
92 } |
|
93 iAudioServerProxy->Close(); |
|
94 delete iAudioServerProxy; |
|
95 iAudioServerProxy = NULL; |
|
96 } |
|
97 RMmfSessionBase::Close(); |
|
98 iState = EIdle; |
|
99 if (iMsgQueueHandler) |
|
100 { |
|
101 iMsgQueueHandler->Cancel(); |
|
102 delete iMsgQueueHandler; |
|
103 iMsgQueueHandler = NULL; |
|
104 } |
|
105 iMsgQueue.Close(); |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // RMMFDevSoundProxy::Open |
|
110 // Open a DevSound server session |
|
111 // (other items were commented in a header). |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 EXPORT_C TInt RMMFDevSoundProxy::Open() |
|
115 { |
|
116 TInt err = iMsgQueue.CreateGlobal(KNullDesC, KMaxMessageQueueItems); |
|
117 // global, accessible to all that have its handle |
|
118 |
|
119 if (err == KErrNone) |
|
120 { |
|
121 iAudioServerProxy = NULL; |
|
122 iMsgQueueHandler = NULL; |
|
123 iBuffer = NULL; |
|
124 iAudioServerProxy = new RMMFAudioServerProxy(); |
|
125 if (iAudioServerProxy == NULL) |
|
126 { |
|
127 err = KErrNoMemory; |
|
128 } |
|
129 } |
|
130 if (err == KErrNone) |
|
131 { |
|
132 err = iAudioServerProxy->Open(); |
|
133 } |
|
134 if (err == KErrNone) |
|
135 { |
|
136 err = SetReturnedHandle(iAudioServerProxy->GetDevSoundSessionHandle()); |
|
137 } |
|
138 if (err) |
|
139 { |
|
140 Close(); |
|
141 } |
|
142 return err; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // RMMFDevSoundProxy::PostOpen |
|
147 // Finish opening process |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 EXPORT_C TInt RMMFDevSoundProxy::PostOpen() |
|
151 { |
|
152 return SendReceive(EMMFDevSoundProxyPostOpen, iDestinationPckg); |
|
153 } |
|
154 |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // RMMFDevSoundProxy::SetDevSoundInfo |
|
158 // Launch DevSound that might have been waiting for audio policy. |
|
159 // (other items were commented in a header). |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C TInt RMMFDevSoundProxy::SetDevSoundInfo() |
|
163 { |
|
164 return SendReceive(EMMFAudioLaunchRequests); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // RMMFDevSoundProxy::InitializeL |
|
169 // Initialize DevSound for a specific mode. |
|
170 // (other items were commented in a header). |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C void RMMFDevSoundProxy::InitializeL( |
|
174 MDevSoundObserver& aDevSoundObserver, |
|
175 TMMFState aMode, |
|
176 MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver) |
|
177 { |
|
178 TInt err = KErrNone; |
|
179 iDevSoundObserver = &aDevSoundObserver; |
|
180 |
|
181 if (!(iState==EIdle || iState==EInitialized)) |
|
182 { |
|
183 err = KErrNotReady; |
|
184 } |
|
185 else |
|
186 { |
|
187 TMMFDevSoundProxySettings set; |
|
188 set.iMode = aMode; |
|
189 TMMFDevSoundProxySettingsPckg pckg(set); |
|
190 TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue); |
|
191 err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize1, args); |
|
192 if (err == KErrNone) |
|
193 { |
|
194 StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver); |
|
195 iState = EInitializing; |
|
196 } |
|
197 } |
|
198 |
|
199 User::LeaveIfError(err); |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // RMMFDevSoundProxy::InitializeL |
|
204 // Initialize DevSound with specific HwDevice id and mode. |
|
205 // (other items were commented in a header). |
|
206 // ----------------------------------------------------------------------------- |
|
207 // |
|
208 EXPORT_C void RMMFDevSoundProxy::InitializeL( |
|
209 MDevSoundObserver& /*aDevSoundObserver*/, |
|
210 TUid /*aHWDev*/, |
|
211 TMMFState /*aMode*/, |
|
212 MMMFDevSoundCustomInterfaceObserver& /*aDevSoundCIObserver*/) |
|
213 { |
|
214 TInt err = KErrNotSupported; |
|
215 User::LeaveIfError(err); |
|
216 } |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // RMMFDevSoundProxy::InitializeL |
|
220 // Initialize DevSound for the specific FourCC and mode. |
|
221 // (other items were commented in a header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 EXPORT_C void RMMFDevSoundProxy::InitializeL( |
|
225 MDevSoundObserver& aDevSoundObserver, |
|
226 TFourCC aDesiredFourCC, |
|
227 TMMFState aMode, |
|
228 MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver) |
|
229 { |
|
230 TInt err = KErrNone; |
|
231 if(aMode == EMMFStateTonePlaying) |
|
232 { |
|
233 User::Leave(KErrNotSupported); |
|
234 } |
|
235 iDevSoundObserver = &aDevSoundObserver; |
|
236 if (!(iState==EIdle || iState==EInitialized)) |
|
237 { |
|
238 err = KErrNotReady; |
|
239 } |
|
240 else |
|
241 { |
|
242 TMMFDevSoundProxySettings set; |
|
243 set.iDesiredFourCC = aDesiredFourCC; |
|
244 set.iMode = aMode; |
|
245 TMMFDevSoundProxySettingsPckg pckg(set); |
|
246 TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue); |
|
247 err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize4, args); |
|
248 if (err == KErrNone) |
|
249 { |
|
250 StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver); |
|
251 iState = EInitializing; |
|
252 } |
|
253 } |
|
254 |
|
255 User::LeaveIfError(err); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // RMMFDevSoundProxy::Capabilities |
|
260 // Returns the capabilities of the DevSound server. |
|
261 // (other items were commented in a header). |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Capabilities() |
|
265 { |
|
266 // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyCapabilitiesInWrongState)); |
|
267 if (iState < EInitialized) |
|
268 { |
|
269 // call has been made before we are initialized. Not much we can do, so return |
|
270 // dummy values but hit debugger on the emulator |
|
271 __DEBUGGER() |
|
272 RDebug::Print(_L("BRDBG:CapabilitiesCalledWhenNotInitialised")); // TODO Remove or redo as trace |
|
273 return KZeroCapabilities; |
|
274 } |
|
275 TMMFDevSoundProxySettings set; |
|
276 TMMFDevSoundProxySettingsPckg pckg(set); |
|
277 TInt err = SendReceiveResult(EMMFDevSoundProxyCapabilities, |
|
278 iDestinationPckg, |
|
279 KNullDesC8, |
|
280 pckg); |
|
281 if (err == KErrNone) |
|
282 { |
|
283 return pckg().iCaps; |
|
284 } |
|
285 else |
|
286 { |
|
287 return KZeroCapabilities; |
|
288 } |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // TMMFCapabilities RMMFDevSoundProxy::Config |
|
293 // Returns the current configuration of the DevSound. |
|
294 // (other items were commented in a header). |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Config() |
|
298 { |
|
299 // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyConfigInWrongState)); |
|
300 if (iState < EInitialized) |
|
301 { |
|
302 // call has been made before we are initialized. Not much we can do, so return |
|
303 // dummy values but hit debugger on the emulator |
|
304 __DEBUGGER() |
|
305 RDebug::Print(_L("BRDBG:ConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace |
|
306 return KZeroCapabilities; |
|
307 } |
|
308 TMMFDevSoundProxySettings set; |
|
309 TMMFDevSoundProxySettingsPckg pckg(set); |
|
310 SendReceiveResult(EMMFDevSoundProxyConfig, |
|
311 iDestinationPckg, |
|
312 KNullDesC8, |
|
313 pckg); |
|
314 return pckg().iConfig; |
|
315 } |
|
316 |
|
317 // ----------------------------------------------------------------------------- |
|
318 // RMMFDevSoundProxy::SetConfigL |
|
319 // Configures the DevSound server. |
|
320 // (other items were commented in a header). |
|
321 // ----------------------------------------------------------------------------- |
|
322 // |
|
323 EXPORT_C void RMMFDevSoundProxy::SetConfigL( |
|
324 const TMMFCapabilities& aConfig ) |
|
325 { |
|
326 TInt err = KErrNone; |
|
327 |
|
328 if (iState==EInitialized) |
|
329 { |
|
330 TMMFDevSoundProxySettings set; |
|
331 set.iConfig = aConfig; |
|
332 TMMFDevSoundProxySettingsPckg pckg(set); |
|
333 TInt err = SendReceive(EMMFDevSoundProxySetConfig, |
|
334 iDestinationPckg, |
|
335 pckg); |
|
336 User::LeaveIfError(err); |
|
337 } |
|
338 else |
|
339 { |
|
340 RDebug::Print(_L("BRDBG:SetConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace |
|
341 err = KErrNotReady; |
|
342 } |
|
343 |
|
344 User::LeaveIfError(err); |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // RMMFDevSoundProxy::MaxVolume |
|
349 // Returns the maximum volume supported by DevSound server for playing back.. |
|
350 // (other items were commented in a header). |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 EXPORT_C TInt RMMFDevSoundProxy::MaxVolume() |
|
354 { |
|
355 TMMFDevSoundProxySettings set; |
|
356 TMMFDevSoundProxySettingsPckg pckg(set); |
|
357 SendReceiveResult(EMMFDevSoundProxyMaxVolume, |
|
358 iDestinationPckg, |
|
359 KNullDesC8, |
|
360 pckg); |
|
361 return pckg().iMaxVolume; |
|
362 } |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // RMMFDevSoundProxy::Volume |
|
366 // Returns the current volume. |
|
367 // (other items were commented in a header). |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 EXPORT_C TInt RMMFDevSoundProxy::Volume() |
|
371 { |
|
372 TMMFDevSoundProxySettings set; |
|
373 TMMFDevSoundProxySettingsPckg pckg(set); |
|
374 SendReceiveResult(EMMFDevSoundProxyVolume, |
|
375 iDestinationPckg, |
|
376 KNullDesC8, |
|
377 pckg); |
|
378 return pckg().iVolume; |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // RMMFDevSoundProxy::SetVolume |
|
383 // Sets the current volume. |
|
384 // (other items were commented in a header). |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 EXPORT_C TInt RMMFDevSoundProxy::SetVolume(TInt aVolume ) |
|
388 { |
|
389 TMMFDevSoundProxySettings set; |
|
390 set.iVolume = aVolume; |
|
391 TMMFDevSoundProxySettingsPckg pckg(set); |
|
392 return SendReceive(EMMFDevSoundProxySetVolume, |
|
393 iDestinationPckg, |
|
394 pckg); |
|
395 } |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // RMMFDevSoundProxy::MaxGain |
|
399 // Returns maximum gain supported by DevSound server for recording. |
|
400 // (other items were commented in a header). |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 EXPORT_C TInt RMMFDevSoundProxy::MaxGain() |
|
404 { |
|
405 TMMFDevSoundProxySettings set; |
|
406 TMMFDevSoundProxySettingsPckg pckg(set); |
|
407 SendReceiveResult(EMMFDevSoundProxyMaxGain, |
|
408 iDestinationPckg, |
|
409 KNullDesC8, |
|
410 pckg); |
|
411 return pckg().iMaxGain; |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // RMMFDevSoundProxy::Gain |
|
416 // Returns the current gain. |
|
417 // (other items were commented in a header). |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 EXPORT_C TInt RMMFDevSoundProxy::Gain() |
|
421 { |
|
422 TMMFDevSoundProxySettings set; |
|
423 TMMFDevSoundProxySettingsPckg pckg(set); |
|
424 SendReceiveResult(EMMFDevSoundProxyGain, |
|
425 iDestinationPckg, |
|
426 KNullDesC8, |
|
427 pckg); |
|
428 return pckg().iGain; |
|
429 } |
|
430 |
|
431 // ----------------------------------------------------------------------------- |
|
432 // RMMFDevSoundProxy::SetGain |
|
433 // Sets the current gain. |
|
434 // (other items were commented in a header). |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 EXPORT_C TInt RMMFDevSoundProxy::SetGain( |
|
438 TInt aGain ) |
|
439 { |
|
440 TMMFDevSoundProxySettings set; |
|
441 set.iGain = aGain; |
|
442 TMMFDevSoundProxySettingsPckg pckg(set); |
|
443 return SendReceive(EMMFDevSoundProxySetGain, |
|
444 iDestinationPckg, |
|
445 pckg); |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // RMMFDevSoundProxy::GetPlayBalanceL |
|
450 // Returns play balance. |
|
451 // (other items were commented in a header). |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 EXPORT_C void RMMFDevSoundProxy::GetPlayBalanceL( |
|
455 TInt& aLeftPercentage, |
|
456 TInt& aRightPercentage ) |
|
457 { |
|
458 TMMFDevSoundProxySettings set; |
|
459 TMMFDevSoundProxySettingsPckg pckg(set); |
|
460 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayBalance, |
|
461 iDestinationPckg, |
|
462 KNullDesC8, |
|
463 pckg)); |
|
464 aLeftPercentage = pckg().iLeftPercentage; |
|
465 aRightPercentage = pckg().iRightPercentage; |
|
466 } |
|
467 |
|
468 // ----------------------------------------------------------------------------- |
|
469 // RMMFDevSoundProxy::SetPlayBalanceL |
|
470 // Sets playbalance. |
|
471 // (other items were commented in a header). |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 EXPORT_C void RMMFDevSoundProxy::SetPlayBalanceL( |
|
475 TInt aLeftPercentage, |
|
476 TInt aRightPercentage ) |
|
477 { |
|
478 TMMFDevSoundProxySettings set; |
|
479 set.iLeftPercentage = aLeftPercentage; |
|
480 set.iRightPercentage = aRightPercentage; |
|
481 TMMFDevSoundProxySettingsPckg pckg(set); |
|
482 User::LeaveIfError(SendReceive(EMMFDevSoundProxySetPlayBalance, |
|
483 iDestinationPckg, |
|
484 pckg)); |
|
485 } |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // RMMFDevSoundProxy::GetRecordBalanceL |
|
489 // Returns record balance. |
|
490 // (other items were commented in a header). |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 EXPORT_C void RMMFDevSoundProxy::GetRecordBalanceL( |
|
494 TInt& aLeftPercentage, |
|
495 TInt& aRightPercentage ) |
|
496 { |
|
497 TMMFDevSoundProxySettings set; |
|
498 TMMFDevSoundProxySettingsPckg pckg(set); |
|
499 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyRecordBalance, |
|
500 iDestinationPckg, |
|
501 KNullDesC8, |
|
502 pckg)); |
|
503 aLeftPercentage = pckg().iLeftPercentage; |
|
504 aRightPercentage = pckg().iRightPercentage; |
|
505 } |
|
506 |
|
507 // ----------------------------------------------------------------------------- |
|
508 // RMMFDevSoundProxy::SetRecordBalanceL |
|
509 // Sets record balance. |
|
510 // (other items were commented in a header). |
|
511 // ----------------------------------------------------------------------------- |
|
512 // |
|
513 EXPORT_C void RMMFDevSoundProxy::SetRecordBalanceL( |
|
514 TInt aLeftPercentage, |
|
515 TInt aRightPercentage ) |
|
516 { |
|
517 TMMFDevSoundProxySettings set; |
|
518 set.iLeftPercentage = aLeftPercentage; |
|
519 set.iRightPercentage = aRightPercentage; |
|
520 TMMFDevSoundProxySettingsPckg pckg(set); |
|
521 User::LeaveIfError(SendReceive(EMMFDevSoundProxySetRecordBalance, |
|
522 iDestinationPckg, |
|
523 pckg)); |
|
524 } |
|
525 |
|
526 // ----------------------------------------------------------------------------- |
|
527 // RMMFDevSoundProxy::PlayInitL |
|
528 // Initilaizes DevSound to play digital audio and starts the play process. |
|
529 // (other items were commented in a header). |
|
530 // ----------------------------------------------------------------------------- |
|
531 // |
|
532 EXPORT_C void RMMFDevSoundProxy::PlayInitL() |
|
533 { |
|
534 if (!iDevSoundObserver || iState!=EInitialized) |
|
535 { |
|
536 if (iState == EPlaying || iState == EPlayingBufferWait) |
|
537 { |
|
538 // treat PlayInitL() during play as Resume() |
|
539 User::LeaveIfError(Resume()); |
|
540 return; |
|
541 } |
|
542 User::Leave(KErrNotReady); |
|
543 } |
|
544 |
|
545 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayInit, |
|
546 iDestinationPckg)); |
|
547 iState = EPlaying; |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // RMMFDevSoundProxy::RecordInitL |
|
552 // Initilaizes DevSound to record digital audio and starts the record process. |
|
553 // (other items were commented in a header). |
|
554 // ----------------------------------------------------------------------------- |
|
555 // |
|
556 EXPORT_C void RMMFDevSoundProxy::RecordInitL() |
|
557 { |
|
558 if (!iDevSoundObserver || iState!=EInitialized) |
|
559 { |
|
560 if(iState == ERecording || iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle |
|
561 || iState == ERecordingResumingInLastBufferCycle) |
|
562 { |
|
563 // treat RecordInitL() during record as Resume() |
|
564 User::LeaveIfError(Resume()); |
|
565 return; |
|
566 } |
|
567 User::Leave(KErrNotReady); |
|
568 } |
|
569 |
|
570 User::LeaveIfError(SendReceive(EMMFDevSoundProxyRecordInit, |
|
571 iDestinationPckg)); |
|
572 iState = ERecording; |
|
573 } |
|
574 |
|
575 // ----------------------------------------------------------------------------- |
|
576 // RMMFDevSoundProxy::PlayData |
|
577 // Plays the data in the buffer at the current volume. |
|
578 // (other items were commented in a header). |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 EXPORT_C void RMMFDevSoundProxy::PlayData() |
|
582 { |
|
583 __ASSERT_ALWAYS(iState == EPlaying || iState == EPlayingBufferWait, |
|
584 Panic(EMMFDevSoundProxyPlayDataWithoutInitialize)); |
|
585 ASSERT(iDevSoundObserver); |
|
586 SYMBIAN_CHECK( iState == EPlayingBufferWait, |
|
587 Panic(EMMFDevSoundProxyPlayDataInWrongState)); |
|
588 TMMFDevSoundProxyHwBuf set; |
|
589 set.iLastBuffer = iBuffer->LastBuffer(); |
|
590 set.iBufferSize = iBuffer->Data().Size(); |
|
591 TMMFDevSoundProxyHwBufPckg pckg(set); |
|
592 |
|
593 SendReceive(EMMFDevSoundProxyPlayData, iDestinationPckg, pckg); |
|
594 iState = EPlaying; |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // RMMFDevSoundProxy::RecordData |
|
599 // Signals the device to continue recording. |
|
600 // (other items were commented in a header). |
|
601 // ----------------------------------------------------------------------------- |
|
602 // |
|
603 EXPORT_C void RMMFDevSoundProxy::RecordData() |
|
604 { |
|
605 __ASSERT_ALWAYS(iState == ERecording || iState == ERecordingBufferWait || |
|
606 iState == ERecordingInLastBufferCycle || iState == ERecordingResumingInLastBufferCycle, |
|
607 Panic(EMMFDevSoundProxyRecordDataWithoutInitialize)); |
|
608 ASSERT(iDevSoundObserver); |
|
609 SYMBIAN_CHECK(iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle || |
|
610 iState == ERecordingResumingInLastBufferCycle, |
|
611 Panic(EMMFDevSoundProxyPlayDataInWrongState)); |
|
612 switch (iState) |
|
613 { |
|
614 case ERecordingBufferWait: |
|
615 // standard case |
|
616 SendReceive(EMMFDevSoundProxyRecordData, iDestinationPckg); |
|
617 iState = ERecording; |
|
618 break; |
|
619 case ERecordingInLastBufferCycle: |
|
620 // ack of the last buffer. Just swallow - the server should not be sent an ack |
|
621 iState = ERecording; |
|
622 break; |
|
623 case ERecordingResumingInLastBufferCycle: |
|
624 // this is a RecordData() following a Resume() in the last cycle. This is where we do the resume! |
|
625 SendReceive(EMMFDevSoundProxyResume, iDestinationPckg); // note ignore any error |
|
626 iState = ERecording; |
|
627 break; |
|
628 } |
|
629 } |
|
630 |
|
631 // ----------------------------------------------------------------------------- |
|
632 // RMMFDevSoundProxy::Stop |
|
633 // Stops the ongoing opeartion. |
|
634 // (other items were commented in a header). |
|
635 // ----------------------------------------------------------------------------- |
|
636 // |
|
637 EXPORT_C void RMMFDevSoundProxy::Stop() |
|
638 { |
|
639 if (iState > EInitialized) |
|
640 { |
|
641 SendReceive(EMMFDevSoundProxyStop, iDestinationPckg); |
|
642 iState = EInitialized; |
|
643 iMsgQueueHandler->Finish(); // will delete the buffer |
|
644 } |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // RMMFDevSoundProxy::Pause |
|
649 // Temporarily stops the ongoing operation. |
|
650 // (other items were commented in a header). |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 EXPORT_C void RMMFDevSoundProxy::Pause() |
|
654 { |
|
655 if(iState > EInitialized) |
|
656 { |
|
657 SendReceive(EMMFDevSoundProxyPause, iDestinationPckg); |
|
658 } |
|
659 } |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // RMMFDevSoundProxy::PlayToneL |
|
663 // Plays the simple tone. |
|
664 // (other items were commented in a header). |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 EXPORT_C void RMMFDevSoundProxy::PlayToneL( |
|
668 TInt aFrequency, |
|
669 const TTimeIntervalMicroSeconds& aDuration) |
|
670 { |
|
671 if(iState==ETonePlaying) |
|
672 { |
|
673 return; |
|
674 } |
|
675 |
|
676 if (!iDevSoundObserver || iState!=EInitialized) |
|
677 { |
|
678 User::Leave(KErrNotReady); |
|
679 } |
|
680 |
|
681 TMMFDevSoundProxySettings set; |
|
682 set.iFrequencyOne = aFrequency; |
|
683 set.iDuration = aDuration; |
|
684 TMMFDevSoundProxySettingsPckg pckg(set); |
|
685 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayTone, |
|
686 iDestinationPckg, |
|
687 pckg)); |
|
688 iState = ETonePlaying; |
|
689 iToneMode = ESimple; |
|
690 } |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // RMMFDevSoundProxy::PlayDualToneL |
|
694 // Plays the dual tone. |
|
695 // (other items were commented in a header). |
|
696 // ----------------------------------------------------------------------------- |
|
697 // |
|
698 EXPORT_C void RMMFDevSoundProxy::PlayDualToneL( |
|
699 TInt aFrequencyOne, |
|
700 TInt aFrequencyTwo, |
|
701 const TTimeIntervalMicroSeconds& aDuration) |
|
702 { |
|
703 if(iState==ETonePlaying) |
|
704 { |
|
705 return; |
|
706 } |
|
707 |
|
708 if (!iDevSoundObserver || iState!=EInitialized) |
|
709 { |
|
710 User::Leave(KErrNotReady); |
|
711 } |
|
712 |
|
713 TMMFDevSoundProxySettings set; |
|
714 set.iFrequencyOne = aFrequencyOne; |
|
715 set.iFrequencyTwo = aFrequencyTwo; |
|
716 set.iDuration = aDuration; |
|
717 TMMFDevSoundProxySettingsPckg pckg(set); |
|
718 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayDualTone, iDestinationPckg, pckg)); |
|
719 iState = ETonePlaying; |
|
720 iToneMode = EDual; |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // RMMFDevSoundProxy::PlayDTMFStringL |
|
725 // Plays the DTMF string. |
|
726 // (other items were commented in a header). |
|
727 // ----------------------------------------------------------------------------- |
|
728 // |
|
729 EXPORT_C void RMMFDevSoundProxy::PlayDTMFStringL(const TDesC& aDTMFString) |
|
730 { |
|
731 if(iState==ETonePlaying) |
|
732 { |
|
733 return; |
|
734 } |
|
735 |
|
736 if (!iDevSoundObserver || iState!=EInitialized) |
|
737 { |
|
738 User::Leave(KErrNotReady); |
|
739 } |
|
740 |
|
741 TPtr tempPtr(0,0); |
|
742 tempPtr.Set(CONST_CAST(TUint16*, aDTMFString.Ptr()), |
|
743 aDTMFString.Length(), |
|
744 aDTMFString.Length()); |
|
745 |
|
746 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayDTMFString, |
|
747 iDestinationPckg, |
|
748 KNullDesC8, |
|
749 tempPtr)); |
|
750 iState = ETonePlaying; |
|
751 iToneMode = EDTMFString; |
|
752 } |
|
753 |
|
754 // ----------------------------------------------------------------------------- |
|
755 // RMMFDevSoundProxy::PlayToneSequenceL |
|
756 // Plays the tone sequence. (NRT/RNG) |
|
757 // (other items were commented in a header). |
|
758 // ----------------------------------------------------------------------------- |
|
759 // |
|
760 EXPORT_C void RMMFDevSoundProxy::PlayToneSequenceL(const TDesC8& aData ) |
|
761 { |
|
762 if(iState==ETonePlaying) |
|
763 { |
|
764 return; |
|
765 } |
|
766 |
|
767 if (!iDevSoundObserver || iState!=EInitialized) |
|
768 { |
|
769 User::Leave(KErrNotReady); |
|
770 } |
|
771 |
|
772 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayToneSequence, |
|
773 iDestinationPckg, |
|
774 aData)); |
|
775 iState = ETonePlaying; |
|
776 iToneMode = ESequence; |
|
777 } |
|
778 |
|
779 // ----------------------------------------------------------------------------- |
|
780 // RMMFDevSoundProxy::PlayFixedSequenceL |
|
781 // Plays the fixed sequence. |
|
782 // (other items were commented in a header). |
|
783 // ----------------------------------------------------------------------------- |
|
784 // |
|
785 EXPORT_C void RMMFDevSoundProxy::PlayFixedSequenceL(TInt aSequenceNumber) |
|
786 { |
|
787 if(iState==ETonePlaying) |
|
788 { |
|
789 return; |
|
790 } |
|
791 |
|
792 if (!iDevSoundObserver || iState!=EInitialized) |
|
793 { |
|
794 User::Leave(KErrNotReady); |
|
795 } |
|
796 |
|
797 TPckgBuf<TInt> seqNum(aSequenceNumber); |
|
798 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayFixedSequence, iDestinationPckg, seqNum)); |
|
799 iState = ETonePlaying; |
|
800 iToneMode = EFixedSequence; |
|
801 } |
|
802 |
|
803 // ----------------------------------------------------------------------------- |
|
804 // RMMFDevSoundProxy::SetDTMFLengths |
|
805 // Set attributes for playing DTMF String. |
|
806 // (other items were commented in a header). |
|
807 // ----------------------------------------------------------------------------- |
|
808 // |
|
809 EXPORT_C void RMMFDevSoundProxy::SetDTMFLengths( |
|
810 TTimeIntervalMicroSeconds32& aToneOnLength, |
|
811 TTimeIntervalMicroSeconds32& aToneOffLength, |
|
812 TTimeIntervalMicroSeconds32& aPauseLength ) |
|
813 { |
|
814 TMMFDevSoundProxySettings set; |
|
815 set.iToneOnLength = aToneOnLength; |
|
816 set.iToneOffLength = aToneOffLength; |
|
817 set.iPauseLength = aPauseLength; |
|
818 TMMFDevSoundProxySettingsPckg pckg(set); |
|
819 SendReceive(EMMFDevSoundProxySetDTMFLengths, iDestinationPckg, pckg); |
|
820 } |
|
821 |
|
822 // ----------------------------------------------------------------------------- |
|
823 // RMMFDevSoundProxy::SetVolumeRamp |
|
824 // Sets the volume ramp duration. |
|
825 // (other items were commented in a header). |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 EXPORT_C void RMMFDevSoundProxy::SetVolumeRamp( |
|
829 const TTimeIntervalMicroSeconds& aRampDuration) |
|
830 { |
|
831 TMMFDevSoundProxySettings set; |
|
832 set.iDuration = aRampDuration; |
|
833 TMMFDevSoundProxySettingsPckg pckg(set); |
|
834 SendReceive(EMMFDevSoundProxySetVolumeRamp, iDestinationPckg, pckg); |
|
835 } |
|
836 |
|
837 // ----------------------------------------------------------------------------- |
|
838 // RMMFDevSoundProxy::GetSupportedInputDataTypesL |
|
839 // Returns supported datatypes for playing audio. |
|
840 // (other items were commented in a header). |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 EXPORT_C void RMMFDevSoundProxy::GetSupportedInputDataTypesL( |
|
844 RArray<TFourCC>& aSupportedDataTypes, |
|
845 const TMMFPrioritySettings& aPrioritySettings) |
|
846 { |
|
847 aSupportedDataTypes.Reset(); |
|
848 |
|
849 TMMFPrioritySettings prioritySet = aPrioritySettings; |
|
850 TMMFPrioritySettingsPckg pckg(prioritySet); |
|
851 |
|
852 TPckgBuf<TInt> numberOfElementsPckg; |
|
853 User::LeaveIfError(SendReceiveResult( |
|
854 EMMFDevSoundProxyGetSupportedInputDataTypes, |
|
855 iDestinationPckg, |
|
856 pckg, |
|
857 numberOfElementsPckg)); |
|
858 |
|
859 |
|
860 HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC)); |
|
861 TPtr8 ptr = buf->Des(); |
|
862 |
|
863 |
|
864 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData, |
|
865 iDestinationPckg, |
|
866 KNullDesC8, |
|
867 ptr)); |
|
868 |
|
869 RDesReadStream stream(ptr); |
|
870 CleanupClosePushL(stream); |
|
871 |
|
872 |
|
873 TInt count = numberOfElementsPckg(); |
|
874 for (TInt i = 0; i < count; i++) |
|
875 { |
|
876 TInt err = aSupportedDataTypes.Append(stream.ReadInt32L()); |
|
877 if (err) |
|
878 {//note we don't destroy array because we don't own it |
|
879 //but we do reset it as it is incomplete |
|
880 aSupportedDataTypes.Reset(); |
|
881 User::Leave(err); |
|
882 } |
|
883 } |
|
884 CleanupStack::PopAndDestroy(&stream); |
|
885 CleanupStack::PopAndDestroy(buf); |
|
886 } |
|
887 |
|
888 // ----------------------------------------------------------------------------- |
|
889 // RMMFDevSoundProxy::GetSupportedOutputDataTypesL |
|
890 // Returns supported datatypes for recording audio. |
|
891 // (other items were commented in a header). |
|
892 // ----------------------------------------------------------------------------- |
|
893 // |
|
894 EXPORT_C void RMMFDevSoundProxy::GetSupportedOutputDataTypesL( |
|
895 RArray<TFourCC>& aSupportedDataTypes, |
|
896 const TMMFPrioritySettings& aPrioritySettings) |
|
897 { |
|
898 aSupportedDataTypes.Reset(); |
|
899 |
|
900 TMMFPrioritySettings prioritySet = aPrioritySettings; |
|
901 TMMFPrioritySettingsPckg pckg(prioritySet); |
|
902 |
|
903 TPckgBuf<TInt> numberOfElementsPckg; |
|
904 User::LeaveIfError(SendReceiveResult( |
|
905 EMMFDevSoundProxyGetSupportedOutputDataTypes, |
|
906 iDestinationPckg, |
|
907 pckg, |
|
908 numberOfElementsPckg)); |
|
909 |
|
910 |
|
911 HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC)); |
|
912 TPtr8 ptr = buf->Des(); |
|
913 |
|
914 |
|
915 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData, |
|
916 iDestinationPckg, |
|
917 KNullDesC8, |
|
918 ptr)); |
|
919 RDesReadStream stream(ptr); |
|
920 CleanupClosePushL(stream); |
|
921 |
|
922 |
|
923 TInt count = numberOfElementsPckg(); |
|
924 for (TInt i = 0; i < count; i++) |
|
925 { |
|
926 TInt err = aSupportedDataTypes.Append(stream.ReadInt32L()); |
|
927 if (err) |
|
928 {//note we don't destroy array because we don't own it |
|
929 //but we do reset it as it is incomplete |
|
930 aSupportedDataTypes.Reset(); |
|
931 User::Leave(err); |
|
932 } |
|
933 } |
|
934 CleanupStack::PopAndDestroy(&stream); |
|
935 CleanupStack::PopAndDestroy(buf); |
|
936 } |
|
937 |
|
938 // ----------------------------------------------------------------------------- |
|
939 // RMMFDevSoundProxy::SamplesRecorded |
|
940 // Returns samples recorded so far. |
|
941 // (other items were commented in a header). |
|
942 // ----------------------------------------------------------------------------- |
|
943 // |
|
944 EXPORT_C TInt RMMFDevSoundProxy::SamplesRecorded() |
|
945 { |
|
946 TPckgBuf<TInt> numSamples; |
|
947 SendReceiveResult(EMMFDevSoundProxySamplesRecorded, |
|
948 iDestinationPckg, |
|
949 KNullDesC8, |
|
950 numSamples); |
|
951 |
|
952 return numSamples(); |
|
953 } |
|
954 |
|
955 // ----------------------------------------------------------------------------- |
|
956 // RMMFDevSoundProxy::SamplesPlayed |
|
957 // Returns samples played so far. |
|
958 // (other items were commented in a header). |
|
959 // ----------------------------------------------------------------------------- |
|
960 // |
|
961 EXPORT_C TInt RMMFDevSoundProxy::SamplesPlayed() |
|
962 { |
|
963 TPckgBuf<TInt> numSamples; |
|
964 SendReceiveResult(EMMFDevSoundProxySamplesPlayed, |
|
965 iDestinationPckg, |
|
966 KNullDesC8, |
|
967 numSamples); |
|
968 return numSamples(); |
|
969 } |
|
970 |
|
971 // ----------------------------------------------------------------------------- |
|
972 // RMMFDevSoundProxy::SetToneRepeats |
|
973 // Sets tone repeats |
|
974 // (other items were commented in a header). |
|
975 // ----------------------------------------------------------------------------- |
|
976 // |
|
977 EXPORT_C void RMMFDevSoundProxy::SetToneRepeats( |
|
978 TInt aRepeatCount, |
|
979 const TTimeIntervalMicroSeconds& |
|
980 aRepeatTrailingSilence) |
|
981 { |
|
982 TPckgBuf<TInt> countRepeat(aRepeatCount); |
|
983 TPckgBuf<TTimeIntervalMicroSeconds> repeatTS(aRepeatTrailingSilence); |
|
984 SendReceive(EMMFDevSoundProxySetToneRepeats, |
|
985 iDestinationPckg, |
|
986 countRepeat, |
|
987 repeatTS); |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // RMMFDevSoundProxy::SetPrioritySettings |
|
992 // Sets priority settings |
|
993 // (other items were commented in a header). |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 EXPORT_C void RMMFDevSoundProxy::SetPrioritySettings( |
|
997 const TMMFPrioritySettings& aPrioritySettings) |
|
998 { |
|
999 TPckgBuf<TMMFPrioritySettings> prioritySet(aPrioritySettings); |
|
1000 SendReceive(EMMFDevSoundProxySetPrioritySettings, |
|
1001 iDestinationPckg, |
|
1002 prioritySet); |
|
1003 } |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // RMMFDevSoundProxy::FixedSequenceName |
|
1007 // Returns the name of fixed sequence for a given sequence number. |
|
1008 // (other items were commented in a header). |
|
1009 // ----------------------------------------------------------------------------- |
|
1010 // |
|
1011 EXPORT_C const TDesC& RMMFDevSoundProxy::FixedSequenceName(TInt /*aSequenceNumber*/) |
|
1012 { |
|
1013 _LIT(KNullDesC, ""); |
|
1014 return KNullDesC; |
|
1015 } |
|
1016 |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // RMMFDevSoundProxy::CustomInterface |
|
1019 // Returns a pointer to CustomInterface object. |
|
1020 // (other items were commented in a header). |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // |
|
1023 EXPORT_C TAny* RMMFDevSoundProxy::CustomInterface(TUid aInterfaceId) |
|
1024 { |
|
1025 TMMFDevSoundProxySettings set; |
|
1026 set.iInterface = aInterfaceId; |
|
1027 // Added for ask for custom interface |
|
1028 TAny* customInterface = NULL; |
|
1029 if (aInterfaceId == KMmfUidDevSoundCancelInitializeCustomInterface) |
|
1030 { |
|
1031 MMMFDevSoundCancelInitialize* result = this; |
|
1032 return result; |
|
1033 } |
|
1034 TPckgBuf<TAny*> pckg2(customInterface); |
|
1035 |
|
1036 TMMFDevSoundProxySettingsPckg pckg(set); |
|
1037 SendReceiveResult(EMMFDevSoundProxyCustomInterface, |
|
1038 iDestinationPckg, |
|
1039 pckg, pckg2); |
|
1040 return reinterpret_cast<TAny*> (customInterface); |
|
1041 } |
|
1042 |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // RMMFDevSoundProxy::FixedSequenceCount |
|
1045 // Returns the number of fixed sequences supported by DevSound. |
|
1046 // (other items were commented in a header). |
|
1047 // ----------------------------------------------------------------------------- |
|
1048 // |
|
1049 EXPORT_C TInt RMMFDevSoundProxy::FixedSequenceCount() |
|
1050 { |
|
1051 TPckgBuf<TInt> fixSeqCountPckg; |
|
1052 SendReceiveResult(EMMFDevSoundProxyFixedSequenceCount, |
|
1053 iDestinationPckg, |
|
1054 KNullDesC8, |
|
1055 fixSeqCountPckg); |
|
1056 |
|
1057 |
|
1058 return fixSeqCountPckg(); |
|
1059 } |
|
1060 |
|
1061 // ----------------------------------------------------------------------------- |
|
1062 // RMMFDevSoundProxy::BufferToBeFilledData |
|
1063 // Returns data buffer for playback. |
|
1064 // ----------------------------------------------------------------------------- |
|
1065 // |
|
1066 EXPORT_C TInt RMMFDevSoundProxy::BufferToBeFilledData( |
|
1067 TBool aRequestChunk, TMMFDevSoundProxyHwBufPckg& aSetPckg) |
|
1068 { |
|
1069 // Note that there will only ever be one of these requests outstanding |
|
1070 // per session |
|
1071 TPckgBuf<TInt> requestChunkBuf (aRequestChunk); |
|
1072 return SendReceiveResult(EMMFDevSoundProxyBTBFData, |
|
1073 iDestinationPckg, |
|
1074 requestChunkBuf, |
|
1075 aSetPckg); |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // RMMFDevSoundProxy::BufferToBeEmptiedData |
|
1080 // Returns data buffer for recording. |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 EXPORT_C TInt RMMFDevSoundProxy::BufferToBeEmptiedData( |
|
1084 TMMFDevSoundProxyHwBufPckg& aSetPckg) |
|
1085 { |
|
1086 // Note that there will only ever be one of these requests outstanding |
|
1087 // per session |
|
1088 return SendReceiveResult(EMMFDevSoundProxyBTBEData, |
|
1089 iDestinationPckg, |
|
1090 KNullDesC8, |
|
1091 aSetPckg); |
|
1092 } |
|
1093 |
|
1094 // ----------------------------------------------------------------------------- |
|
1095 // RMMFDevSoundProxy::RegisterAsClient |
|
1096 // Registers the client for notification of resource avalibility. |
|
1097 // ----------------------------------------------------------------------------- |
|
1098 // |
|
1099 EXPORT_C TInt RMMFDevSoundProxy::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData) |
|
1100 { |
|
1101 TMMFDevSoundProxySettings set; |
|
1102 set.iNotificationEventUid = aEventType; |
|
1103 TMMFDevSoundProxySettingsPckg pckg(set); |
|
1104 return SendReceive(EMMFDevSoundProxyRequestResourceNotification, iDestinationPckg, pckg, aNotificationRegistrationData); |
|
1105 } |
|
1106 |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // RMMFDevSoundProxy::CancelRegisterAsClient |
|
1109 // Cancels the Registered Notification. |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // |
|
1112 EXPORT_C TInt RMMFDevSoundProxy::CancelRegisterAsClient(TUid aEventType) |
|
1113 { |
|
1114 TMMFDevSoundProxySettings set; |
|
1115 set.iNotificationEventUid = aEventType; |
|
1116 TMMFDevSoundProxySettingsPckg pckg(set); |
|
1117 return SendReceiveResult(EMMFDevSoundProxyCancelRequestResourceNotification, iDestinationPckg, KNullDesC8, pckg); |
|
1118 } |
|
1119 |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // RMMFDevSoundProxy::GetResourceNotificationData |
|
1122 // Returns the Notification data which the client needs to resume playing. |
|
1123 // ----------------------------------------------------------------------------- |
|
1124 // |
|
1125 EXPORT_C TInt RMMFDevSoundProxy::GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData) |
|
1126 { |
|
1127 TMMFDevSoundProxySettings set; |
|
1128 set.iNotificationEventUid = aEventType; |
|
1129 TMMFDevSoundProxySettingsPckg pckg(set); |
|
1130 return SendReceiveResult(EMMFDevSoundProxyGetResourceNotificationData, iDestinationPckg, pckg, aNotificationData); |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // RMMFDevSoundProxy::WillResumePlay |
|
1135 // Wait for the clients to resume play back even after the default timeout |
|
1136 // expires. Unless the client cancels the notification request or completes |
|
1137 // no other client gets notification. |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // |
|
1140 EXPORT_C TInt RMMFDevSoundProxy::WillResumePlay() |
|
1141 { |
|
1142 return SendReceive(EMMFDevSoundProxyWillResumePlay, iDestinationPckg); |
|
1143 } |
|
1144 |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // RMMFDevSoundProxy::EmptyBuffers |
|
1147 // Empties the play buffers below DevSound without causing the codec |
|
1148 // to be deleted. |
|
1149 // ----------------------------------------------------------------------------- |
|
1150 // |
|
1151 |
|
1152 EXPORT_C TInt RMMFDevSoundProxy::EmptyBuffers() |
|
1153 { |
|
1154 TInt error = SendReceive(EMMFDevSoundProxyEmptyBuffers, iDestinationPckg); |
|
1155 |
|
1156 if(error==KErrNone) |
|
1157 { |
|
1158 if (iState==EPlayingBufferWait) |
|
1159 { |
|
1160 // Empty buffers terminates the buffer cycle |
|
1161 iState = EPlaying; |
|
1162 } |
|
1163 } |
|
1164 return error; |
|
1165 } |
|
1166 |
|
1167 // ----------------------------------------------------------------------------- |
|
1168 // RMMFDevSoundProxy::CancelInitialize |
|
1169 // Cancels the initialization process |
|
1170 // ----------------------------------------------------------------------------- |
|
1171 // |
|
1172 EXPORT_C TInt RMMFDevSoundProxy::CancelInitialize() |
|
1173 { |
|
1174 TInt err=KErrNone; |
|
1175 |
|
1176 if (iState==EInitializing) |
|
1177 { |
|
1178 err = SendReceive(EMMFDevSoundProxyCancelInitialize, iDestinationPckg); |
|
1179 iState = EIdle; |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 err = KErrNotReady; |
|
1184 } |
|
1185 |
|
1186 return err; |
|
1187 } |
|
1188 |
|
1189 |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // RMMFDevSoundProxy::SetClientThreadInfo |
|
1192 // |
|
1193 // ----------------------------------------------------------------------------- |
|
1194 // |
|
1195 EXPORT_C TInt RMMFDevSoundProxy::SetClientThreadInfo(TThreadId& aTid) |
|
1196 { |
|
1197 TPckgBuf<TThreadId> threadId(aTid); |
|
1198 return SendReceive(EMMFDevSoundProxySetClientThreadInfo, iDestinationPckg, threadId); |
|
1199 } |
|
1200 |
|
1201 |
|
1202 // ----------------------------------------------------------------------------- |
|
1203 // RMMFDevSoundProxy::CustomCommandSync() |
|
1204 // Send Message synchronously to DevSound server and return the result to client |
|
1205 // ----------------------------------------------------------------------------- |
|
1206 // |
|
1207 EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync( |
|
1208 const TMMFMessageDestinationPckg& aDestination, |
|
1209 TInt aFunction, |
|
1210 const TDesC8& aDataTo1, |
|
1211 const TDesC8& aDataTo2, |
|
1212 TDes8& aDataFrom) |
|
1213 { |
|
1214 return SendReceiveResult(aFunction, |
|
1215 aDestination, |
|
1216 aDataTo1, |
|
1217 aDataTo2, |
|
1218 aDataFrom); |
|
1219 } |
|
1220 |
|
1221 // ----------------------------------------------------------------------------- |
|
1222 // RMMFDevSoundProxy::RMMFDevSoundProxy() |
|
1223 // Send Message synchronously to DevSound server and return the result to client |
|
1224 // ----------------------------------------------------------------------------- |
|
1225 // |
|
1226 EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync( |
|
1227 const TMMFMessageDestinationPckg& aDestination, |
|
1228 TInt aFunction, |
|
1229 const TDesC8& aDataTo1, |
|
1230 const TDesC8& aDataTo2) |
|
1231 { |
|
1232 return SendReceive(aFunction, aDestination, aDataTo1, aDataTo2); |
|
1233 } |
|
1234 |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // RMMFDevSoundProxy::RMMFDevSoundProxy() |
|
1237 // Send Message asynchronously to DevSound server |
|
1238 // ----------------------------------------------------------------------------- |
|
1239 // |
|
1240 EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync( |
|
1241 const TMMFMessageDestinationPckg& aDestination, |
|
1242 TInt aFunction, |
|
1243 const TDesC8& aDataTo1, |
|
1244 const TDesC8& aDataTo2, |
|
1245 TDes8& aDataFrom, |
|
1246 TRequestStatus& aStatus ) |
|
1247 { |
|
1248 SendReceiveResult(aFunction, |
|
1249 aDestination, |
|
1250 aDataTo1, |
|
1251 aDataTo2, |
|
1252 aDataFrom, |
|
1253 aStatus); |
|
1254 } |
|
1255 |
|
1256 // ----------------------------------------------------------------------------- |
|
1257 // RMMFDevSoundProxy::RMMFDevSoundProxy() |
|
1258 // Send Message asynchronously to DevSound server |
|
1259 // ----------------------------------------------------------------------------- |
|
1260 // |
|
1261 EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync( |
|
1262 const TMMFMessageDestinationPckg& aDestination, |
|
1263 TInt aFunction, |
|
1264 const TDesC8& aDataTo1, |
|
1265 const TDesC8& aDataTo2, |
|
1266 TRequestStatus& aStatus ) |
|
1267 { |
|
1268 SendReceive(aFunction, aDestination, aDataTo1, aDataTo2, aStatus); |
|
1269 } |
|
1270 |
|
1271 // implementation of a simple CustomCommand() scheme |
|
1272 EXPORT_C TInt RMMFDevSoundProxy::SyncCustomCommand(TUid aUid, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam) |
|
1273 { |
|
1274 TMMFMessageDestinationPckg dest(TMMFMessageDestination(aUid, KMMFObjectHandleDevSound)); |
|
1275 |
|
1276 if (aOutParam==NULL) |
|
1277 { |
|
1278 return SendReceive(EMMFDevSoundProxySyncCustomCommand, dest, aParam1, aParam2); |
|
1279 } |
|
1280 else |
|
1281 { |
|
1282 return SendReceiveResult(EMMFDevSoundProxySyncCustomCommandResult, dest, aParam1, aParam2, *aOutParam); |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 EXPORT_C void RMMFDevSoundProxy::AsyncCustomCommand(TUid aUid, TRequestStatus& aStatus, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam) |
|
1287 { |
|
1288 TMMFMessageDestination dest(aUid, KMMFObjectHandleDevSound); |
|
1289 iCustIntPckg = dest; |
|
1290 if (aOutParam==NULL) |
|
1291 { |
|
1292 SendReceive(EMMFDevSoundProxyAsyncCustomCommand, iCustIntPckg, aParam1, aParam2, aStatus); |
|
1293 } |
|
1294 else |
|
1295 { |
|
1296 SendReceiveResult(EMMFDevSoundProxyAsyncCustomCommandResult, iCustIntPckg, aParam1, aParam2, *aOutParam, aStatus); |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 EXPORT_C TInt RMMFDevSoundProxy::GetTimePlayed(TTimeIntervalMicroSeconds& aTime) |
|
1301 { |
|
1302 TTimeIntervalMicroSeconds time(0); |
|
1303 TPckgBuf<TTimeIntervalMicroSeconds> timePckg(time); |
|
1304 TInt err = SendReceiveResult(EMMFDevSoundProxyGetTimePlayed, iDestinationPckg, KNullDesC8, timePckg); |
|
1305 if(err==KErrNone) |
|
1306 { |
|
1307 aTime = timePckg(); |
|
1308 } |
|
1309 return err; |
|
1310 } |
|
1311 |
|
1312 EXPORT_C TBool RMMFDevSoundProxy::IsResumeSupported() |
|
1313 { |
|
1314 TPckgBuf<TBool> isResumeSupported; |
|
1315 TInt err = SendReceiveResult(EMMFDevSoundProxyIsResumeSupported, |
|
1316 iDestinationPckg, |
|
1317 KNullDesC8, |
|
1318 isResumeSupported); |
|
1319 if(err == KErrNone) |
|
1320 { |
|
1321 return isResumeSupported(); |
|
1322 } |
|
1323 else |
|
1324 { |
|
1325 return EFalse; |
|
1326 } |
|
1327 } |
|
1328 |
|
1329 EXPORT_C TInt RMMFDevSoundProxy::Resume() |
|
1330 { |
|
1331 TInt err = KErrNone; |
|
1332 if (!iDevSoundObserver || iState <= EInitialized ) |
|
1333 { |
|
1334 err = KErrNotReady; |
|
1335 } |
|
1336 else if(iState == ETonePlaying && iToneMode != ESequence) |
|
1337 { |
|
1338 return KErrNotSupported; |
|
1339 } |
|
1340 else |
|
1341 { |
|
1342 if (iState==ERecordingInLastBufferCycle) |
|
1343 { |
|
1344 // if we're in a last buffer cycle and get Resume() we have to be careful as the |
|
1345 // server side sent a PausedRecordCompleteEvent and did not actually request a buffer! |
|
1346 // just record the fact we've done this and wait until RecordData() is called |
|
1347 // don't actually resume until then! |
|
1348 iState = ERecordingResumingInLastBufferCycle; |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 err = SendReceive(EMMFDevSoundProxyResume, |
|
1353 iDestinationPckg); |
|
1354 } |
|
1355 } |
|
1356 return err; |
|
1357 } |
|
1358 |
|
1359 // ----------------------------------------------------------------------------- |
|
1360 // RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL() |
|
1361 // Starts message queue handler (A/O) to monitor client side events |
|
1362 // ----------------------------------------------------------------------------- |
|
1363 // |
|
1364 void RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL(MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver) |
|
1365 { |
|
1366 if (iMsgQueueHandler) |
|
1367 { |
|
1368 iMsgQueueHandler->Cancel(); |
|
1369 } |
|
1370 else |
|
1371 { |
|
1372 iMsgQueueHandler = CMsgQueueHandler::NewL(this, |
|
1373 *this, |
|
1374 &iMsgQueue, |
|
1375 aDevSoundCIObserver); |
|
1376 } |
|
1377 |
|
1378 iMsgQueueHandler->ReceiveEvents(); |
|
1379 } |
|
1380 |
|
1381 // MDevSoundObserver |
|
1382 // intercept the calls from the msgQueueHandler going back to the client, so we can track real state |
|
1383 |
|
1384 void RMMFDevSoundProxy::InitializeComplete(TInt aError) |
|
1385 { |
|
1386 SYMBIAN_CHECK(iState==EInitializing, Panic(EMMFDevSoundProxyInitCompleteInWrongState)); |
|
1387 if (aError==KErrNone) |
|
1388 { |
|
1389 iState = EInitialized; |
|
1390 } |
|
1391 else |
|
1392 { |
|
1393 iState = EIdle; |
|
1394 } |
|
1395 iDevSoundObserver->InitializeComplete(aError); |
|
1396 } |
|
1397 |
|
1398 void RMMFDevSoundProxy::ToneFinished(TInt aError) |
|
1399 { |
|
1400 SYMBIAN_CHECK(iState==ETonePlaying, Panic(EMMFDevSoundProxyToneFinishedInWrongState)); |
|
1401 iState = EInitialized; |
|
1402 iDevSoundObserver->ToneFinished(aError); |
|
1403 } |
|
1404 |
|
1405 void RMMFDevSoundProxy::PlayError(TInt aError) |
|
1406 { |
|
1407 SYMBIAN_CHECK(iState==EPlaying||iState==EPlayingBufferWait, Panic(EMMFDevSoundProxyPlayErrorInWrongState)); |
|
1408 iState = EInitialized; |
|
1409 iDevSoundObserver->PlayError(aError); |
|
1410 } |
|
1411 |
|
1412 void RMMFDevSoundProxy::RecordError(TInt aError) |
|
1413 { |
|
1414 SYMBIAN_CHECK(iState==ERecording||iState==ERecordingBufferWait, Panic(EMMFDevSoundProxyRecordErrorInWrongState)); |
|
1415 iState = EInitialized; |
|
1416 iDevSoundObserver->RecordError(aError); |
|
1417 } |
|
1418 |
|
1419 void RMMFDevSoundProxy::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
1420 { |
|
1421 SYMBIAN_CHECK(iState==EPlaying, Panic(EMMFDevSoundProxyBTBFInWrongState)); |
|
1422 iState = EPlayingBufferWait; |
|
1423 iBuffer = static_cast<CMMFDataBuffer*>(aBuffer); // cache buffer for use in PlayData() later |
|
1424 iDevSoundObserver->BufferToBeFilled(aBuffer); |
|
1425 } |
|
1426 |
|
1427 void RMMFDevSoundProxy::BufferToBeEmptied(CMMFBuffer* aBuffer) |
|
1428 { |
|
1429 SYMBIAN_CHECK(iState==ERecording, Panic(EMMFDevSoundProxyBTBEInWrongState)); |
|
1430 if (aBuffer->LastBuffer()) |
|
1431 { |
|
1432 // this is end of recording. Assume have an empty buffer. Different state so that Resume() is handled as special case. |
|
1433 iState = ERecordingInLastBufferCycle; |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 iState = ERecordingBufferWait; |
|
1438 } |
|
1439 iDevSoundObserver->BufferToBeEmptied(aBuffer); |
|
1440 } |
|
1441 |
|
1442 void RMMFDevSoundProxy::ConvertError(TInt /*aError*/) |
|
1443 { |
|
1444 SYMBIAN_CHECK(EFalse, Panic(EMMFDevSoundProxyUnexpectedConvError)); |
|
1445 } |
|
1446 |
|
1447 void RMMFDevSoundProxy::DeviceMessage(TUid aMessageType, const TDesC8& aMsg) |
|
1448 { |
|
1449 iDevSoundObserver->DeviceMessage(aMessageType, aMsg); |
|
1450 } |
|
1451 |
|
1452 void RMMFDevSoundProxy::SendEventToClient(const TMMFEvent& aEvent) |
|
1453 { |
|
1454 iDevSoundObserver->SendEventToClient(aEvent); |
|
1455 } |
|
1456 |
|
1457 |
|
1458 // End of File |