Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
19 #include "mmfdevsoundproxy.h"
23 #define SYMBIAN_DEBPRN0(str) RDebug::Print(str, this)
24 #define SYMBIAN_DEBPRN1(str, val1) RDebug::Print(str, this, val1)
25 #define SYMBIAN_DEBPRN2(str, val1, val2) RDebug::Print(str, this, val1, val2)
27 #define SYMBIAN_DEBPRN0(str)
28 #define SYMBIAN_DEBPRN1(str, val1)
29 #define SYMBIAN_DEBPRN2(str, val1, val2)
32 // SYMBIAN_CHECK used to add extra asserts when MACRO is added - helps debugging overall A3F
34 #ifdef SYMBIAN_FULL_STATE_CHECK
35 #define SYMBIAN_CHECK(c,p) __ASSERT_ALWAYS(c,p)
37 #define SYMBIAN_CHECK(c,p)
40 const TInt KMaxMessageQueueItems = 8;
42 const TMMFCapabilities KZeroCapabilities =
47 // ============================ LOCAL FUNCTIONS ================================
49 // -----------------------------------------------------------------------------
50 // This function raises a panic
53 // one of the several panic codes that may be raised by this dll
55 // @panic EMMFDevSoundProxyPlayDataWithoutInitialize is raised when playdata
56 // is called without initialization
57 // @panic EMMFDevSoundProxyRecordDataWithoutInitialize is raised when
58 // recorddata is called without initialization
60 GLDEF_C void Panic(TMMFDevSoundProxyPanicCodes aPanicCode)
62 User::Panic(KMMFDevSoundProxyPanicCategory, aPanicCode);
65 // ============================ MEMBER FUNCTIONS ===============================
67 // -----------------------------------------------------------------------------
68 // RMMFDevsoundProxy::RMMFDevsoundProxy
69 // C++ default constructor can NOT contain any code, that
71 // -----------------------------------------------------------------------------
73 EXPORT_C RMMFDevSoundProxy::RMMFDevSoundProxy() :
76 iDestinationPckg(TMMFMessageDestination(KUidInterfaceMMFDevSound,
77 KMMFObjectHandleDevSound)),
79 iAudioServerProxy(NULL),
80 iDevSoundObserver(NULL),
81 iMsgQueueHandler(NULL),
86 // -----------------------------------------------------------------------------
87 // RMMFDevSoundProxy::Close
88 // Close the server session
89 // (other items were commented in a header).
90 // -----------------------------------------------------------------------------
92 EXPORT_C void RMMFDevSoundProxy::Close()
94 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Close - Enter"));
95 if (iAudioServerProxy)
97 if (iAudioServerProxy->Handle() != NULL)
99 TMMFDevSoundProxySettings set;
100 TMMFDevSoundProxySettingsPckg pckg(set);
101 TInt err = SendReceive(EMMFDevSoundProxyClose,
105 iAudioServerProxy->Close();
106 delete iAudioServerProxy;
107 iAudioServerProxy = NULL;
109 RMmfSessionBase::Close();
111 if (iMsgQueueHandler)
113 iMsgQueueHandler->Cancel();
114 delete iMsgQueueHandler;
115 iMsgQueueHandler = NULL;
118 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Close - Exit"));
121 // -----------------------------------------------------------------------------
122 // RMMFDevSoundProxy::Open
123 // Open a DevSound server session
124 // (other items were commented in a header).
125 // -----------------------------------------------------------------------------
127 EXPORT_C TInt RMMFDevSoundProxy::Open()
129 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Open - Enter"));
130 TInt err = iMsgQueue.CreateGlobal(KNullDesC, KMaxMessageQueueItems, EOwnerThread);
131 // global, accessible to all that have its handle
135 iAudioServerProxy = NULL;
136 iMsgQueueHandler = NULL;
138 iAudioServerProxy = new RMMFAudioServerProxy();
139 if (iAudioServerProxy == NULL)
146 err = iAudioServerProxy->Open();
150 err = SetReturnedHandle(iAudioServerProxy->GetDevSoundSessionHandle());
156 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Open - Exit [%d]"), err);
160 // -----------------------------------------------------------------------------
161 // RMMFDevSoundProxy::PostOpen
162 // Finish opening process
163 // -----------------------------------------------------------------------------
165 EXPORT_C TInt RMMFDevSoundProxy::PostOpen()
167 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PostOpen - Enter"));
168 TInt err = SendReceive(EMMFDevSoundProxyPostOpen, iDestinationPckg);
169 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::PostOpen - Exit [%d]"), err);
174 // -----------------------------------------------------------------------------
175 // RMMFDevSoundProxy::SetDevSoundInfo
176 // Launch DevSound that might have been waiting for audio policy.
177 // (other items were commented in a header).
178 // -----------------------------------------------------------------------------
180 EXPORT_C TInt RMMFDevSoundProxy::SetDevSoundInfo()
182 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDevSoundInfo - Enter"));
183 TInt err = SendReceive(EMMFAudioLaunchRequests);
184 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetDevSoundInfo - Exit [%d]"), err);
188 // -----------------------------------------------------------------------------
189 // RMMFDevSoundProxy::InitializeL
190 // Initialize DevSound for a specific mode.
191 // (other items were commented in a header).
192 // -----------------------------------------------------------------------------
194 EXPORT_C void RMMFDevSoundProxy::InitializeL(
195 MDevSoundObserver& aDevSoundObserver,
197 MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
199 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Enter"));
201 iDevSoundObserver = &aDevSoundObserver;
203 if (!(iState==EIdle || iState==EInitialized))
209 TMMFDevSoundProxySettings set;
211 TMMFDevSoundProxySettingsPckg pckg(set);
212 TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue);
213 err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize1, args);
216 StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver);
217 iState = EInitializing;
220 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Exit [%d]"), err);
221 User::LeaveIfError(err);
224 // -----------------------------------------------------------------------------
225 // RMMFDevSoundProxy::InitializeL
226 // Initialize DevSound with specific HwDevice id and mode.
227 // (other items were commented in a header).
228 // -----------------------------------------------------------------------------
230 EXPORT_C void RMMFDevSoundProxy::InitializeL(
231 MDevSoundObserver& /*aDevSoundObserver*/,
234 MMMFDevSoundCustomInterfaceObserver& /*aDevSoundCIObserver*/)
236 TInt err = KErrNotSupported;
237 User::LeaveIfError(err);
240 // -----------------------------------------------------------------------------
241 // RMMFDevSoundProxy::InitializeL
242 // Initialize DevSound for the specific FourCC and mode.
243 // (other items were commented in a header).
244 // -----------------------------------------------------------------------------
246 EXPORT_C void RMMFDevSoundProxy::InitializeL(
247 MDevSoundObserver& aDevSoundObserver,
248 TFourCC aDesiredFourCC,
250 MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
252 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Enter"));
254 if(aMode == EMMFStateTonePlaying)
256 User::Leave(KErrNotSupported);
258 iDevSoundObserver = &aDevSoundObserver;
259 if (!(iState==EIdle || iState==EInitialized))
265 TMMFDevSoundProxySettings set;
266 set.iDesiredFourCC = aDesiredFourCC;
268 TMMFDevSoundProxySettingsPckg pckg(set);
269 TIpcArgs args(&iDestinationPckg, &pckg, iMsgQueue);
270 err = RSessionBase::SendReceive(EMMFDevSoundProxyInitialize4, args);
273 StartReceivingMsgQueueHandlerEventsL(aDevSoundCIObserver);
274 iState = EInitializing;
277 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::InitializeL - Exit [%d]"), err);
278 User::LeaveIfError(err);
281 // -----------------------------------------------------------------------------
282 // RMMFDevSoundProxy::Capabilities
283 // Returns the capabilities of the DevSound server.
284 // (other items were commented in a header).
285 // -----------------------------------------------------------------------------
287 EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Capabilities()
289 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Enter"));
290 // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyCapabilitiesInWrongState));
291 if (iState < EInitialized)
293 // call has been made before we are initialized. Not much we can do, so return
294 // dummy values but hit debugger on the emulator
296 RDebug::Print(_L("BRDBG:CapabilitiesCalledWhenNotInitialised")); // TODO Remove or redo as trace
297 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit"));
298 return KZeroCapabilities;
300 TMMFDevSoundProxySettings set;
301 TMMFDevSoundProxySettingsPckg pckg(set);
302 TInt err = SendReceiveResult(EMMFDevSoundProxyCapabilities,
308 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit"));
313 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Capabilities - Exit [%d]"), err);
314 return KZeroCapabilities;
318 // -----------------------------------------------------------------------------
319 // TMMFCapabilities RMMFDevSoundProxy::Config
320 // Returns the current configuration of the DevSound.
321 // (other items were commented in a header).
322 // -----------------------------------------------------------------------------
324 EXPORT_C TMMFCapabilities RMMFDevSoundProxy::Config()
326 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Enter"));
327 // TODO should we use the following ? SYMBIAN_CHECK(iState>=EInitialized, Panic(EMMFDevSoundProxyConfigInWrongState));
328 if (iState < EInitialized)
330 // call has been made before we are initialized. Not much we can do, so return
331 // dummy values but hit debugger on the emulator
333 RDebug::Print(_L("BRDBG:ConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace
334 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Exit"));
335 return KZeroCapabilities;
337 TMMFDevSoundProxySettings set;
338 TMMFDevSoundProxySettingsPckg pckg(set);
339 SendReceiveResult(EMMFDevSoundProxyConfig,
343 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Config - Exit"));
344 return pckg().iConfig;
347 // -----------------------------------------------------------------------------
348 // RMMFDevSoundProxy::SetConfigL
349 // Configures the DevSound server.
350 // (other items were commented in a header).
351 // -----------------------------------------------------------------------------
353 EXPORT_C void RMMFDevSoundProxy::SetConfigL(
354 const TMMFCapabilities& aConfig )
356 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetConfigL - Enter"));
359 if (iState==EInitialized)
361 TMMFDevSoundProxySettings set;
362 set.iConfig = aConfig;
363 TMMFDevSoundProxySettingsPckg pckg(set);
364 err = SendReceive(EMMFDevSoundProxySetConfig,
370 RDebug::Print(_L("BRDBG:SetConfigCalledWhenNotInitialised")); // TODO Remove or redo as trace
373 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetConfigL - Exit [%d]"), err);
374 User::LeaveIfError(err);
377 // -----------------------------------------------------------------------------
378 // RMMFDevSoundProxy::MaxVolume
379 // Returns the maximum volume supported by DevSound server for playing back..
380 // (other items were commented in a header).
381 // -----------------------------------------------------------------------------
383 EXPORT_C TInt RMMFDevSoundProxy::MaxVolume()
385 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxVolume - Enter"));
386 TMMFDevSoundProxySettings set;
387 TMMFDevSoundProxySettingsPckg pckg(set);
388 SendReceiveResult(EMMFDevSoundProxyMaxVolume,
392 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxVolume - Exit"));
393 return pckg().iMaxVolume;
396 // -----------------------------------------------------------------------------
397 // RMMFDevSoundProxy::Volume
398 // Returns the current volume.
399 // (other items were commented in a header).
400 // -----------------------------------------------------------------------------
402 EXPORT_C TInt RMMFDevSoundProxy::Volume()
404 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Volume - Enter"));
405 TMMFDevSoundProxySettings set;
406 TMMFDevSoundProxySettingsPckg pckg(set);
407 SendReceiveResult(EMMFDevSoundProxyVolume,
411 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Volume - Exit"));
412 return pckg().iVolume;
415 // -----------------------------------------------------------------------------
416 // RMMFDevSoundProxy::SetVolume
417 // Sets the current volume.
418 // (other items were commented in a header).
419 // -----------------------------------------------------------------------------
421 EXPORT_C TInt RMMFDevSoundProxy::SetVolume(TInt aVolume )
423 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolume - Enter"));
424 TMMFDevSoundProxySettings set;
425 set.iVolume = aVolume;
426 TMMFDevSoundProxySettingsPckg pckg(set);
427 TInt err = SendReceive(EMMFDevSoundProxySetVolume,
430 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetVolume - Exit [%d]"), err);
434 // -----------------------------------------------------------------------------
435 // RMMFDevSoundProxy::MaxGain
436 // Returns maximum gain supported by DevSound server for recording.
437 // (other items were commented in a header).
438 // -----------------------------------------------------------------------------
440 EXPORT_C TInt RMMFDevSoundProxy::MaxGain()
442 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxGain - Enter"));
443 TMMFDevSoundProxySettings set;
444 TMMFDevSoundProxySettingsPckg pckg(set);
445 SendReceiveResult(EMMFDevSoundProxyMaxGain,
449 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::MaxGain - Exit"));
450 return pckg().iMaxGain;
453 // -----------------------------------------------------------------------------
454 // RMMFDevSoundProxy::Gain
455 // Returns the current gain.
456 // (other items were commented in a header).
457 // -----------------------------------------------------------------------------
459 EXPORT_C TInt RMMFDevSoundProxy::Gain()
461 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Gain - Enter"));
462 TMMFDevSoundProxySettings set;
463 TMMFDevSoundProxySettingsPckg pckg(set);
464 SendReceiveResult(EMMFDevSoundProxyGain,
468 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Gain - Exit"));
472 // -----------------------------------------------------------------------------
473 // RMMFDevSoundProxy::SetGain
474 // Sets the current gain.
475 // (other items were commented in a header).
476 // -----------------------------------------------------------------------------
478 EXPORT_C TInt RMMFDevSoundProxy::SetGain(
481 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetGain - Enter"));
482 TMMFDevSoundProxySettings set;
484 TMMFDevSoundProxySettingsPckg pckg(set);
486 TInt err = SendReceive(EMMFDevSoundProxySetGain,
489 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetGain - Exit [%d]"), err);
493 // -----------------------------------------------------------------------------
494 // RMMFDevSoundProxy::GetPlayBalanceL
495 // Returns play balance.
496 // (other items were commented in a header).
497 // -----------------------------------------------------------------------------
499 EXPORT_C void RMMFDevSoundProxy::GetPlayBalanceL(
500 TInt& aLeftPercentage,
501 TInt& aRightPercentage )
503 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetPlayBalanceL - Enter"));
504 TMMFDevSoundProxySettings set;
505 TMMFDevSoundProxySettingsPckg pckg(set);
506 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayBalance,
510 aLeftPercentage = pckg().iLeftPercentage;
511 aRightPercentage = pckg().iRightPercentage;
512 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetPlayBalanceL - Exit"));
515 // -----------------------------------------------------------------------------
516 // RMMFDevSoundProxy::SetPlayBalanceL
518 // (other items were commented in a header).
519 // -----------------------------------------------------------------------------
521 EXPORT_C void RMMFDevSoundProxy::SetPlayBalanceL(
522 TInt aLeftPercentage,
523 TInt aRightPercentage )
525 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPlayBalanceL - Enter"));
526 TMMFDevSoundProxySettings set;
527 set.iLeftPercentage = aLeftPercentage;
528 set.iRightPercentage = aRightPercentage;
529 TMMFDevSoundProxySettingsPckg pckg(set);
530 User::LeaveIfError(SendReceive(EMMFDevSoundProxySetPlayBalance,
533 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPlayBalanceL - Exit"));
536 // -----------------------------------------------------------------------------
537 // RMMFDevSoundProxy::GetRecordBalanceL
538 // Returns record balance.
539 // (other items were commented in a header).
540 // -----------------------------------------------------------------------------
542 EXPORT_C void RMMFDevSoundProxy::GetRecordBalanceL(
543 TInt& aLeftPercentage,
544 TInt& aRightPercentage )
546 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetRecordBalanceL - Enter"));
547 TMMFDevSoundProxySettings set;
548 TMMFDevSoundProxySettingsPckg pckg(set);
549 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyRecordBalance,
553 aLeftPercentage = pckg().iLeftPercentage;
554 aRightPercentage = pckg().iRightPercentage;
555 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetRecordBalanceL - Exit"));
558 // -----------------------------------------------------------------------------
559 // RMMFDevSoundProxy::SetRecordBalanceL
560 // Sets record balance.
561 // (other items were commented in a header).
562 // -----------------------------------------------------------------------------
564 EXPORT_C void RMMFDevSoundProxy::SetRecordBalanceL(
565 TInt aLeftPercentage,
566 TInt aRightPercentage )
568 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetRecordBalanceL - Enter"));
569 TMMFDevSoundProxySettings set;
570 set.iLeftPercentage = aLeftPercentage;
571 set.iRightPercentage = aRightPercentage;
572 TMMFDevSoundProxySettingsPckg pckg(set);
573 User::LeaveIfError(SendReceive(EMMFDevSoundProxySetRecordBalance,
576 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetRecordBalanceL - Exit"));
579 // -----------------------------------------------------------------------------
580 // RMMFDevSoundProxy::PlayInitL
581 // Initilaizes DevSound to play digital audio and starts the play process.
582 // (other items were commented in a header).
583 // -----------------------------------------------------------------------------
585 EXPORT_C void RMMFDevSoundProxy::PlayInitL()
587 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Enter"));
588 if (!iDevSoundObserver || iState!=EInitialized)
590 if (iState == EPlaying || iState == EPlayingBufferWait)
592 // treat PlayInitL() during play as Resume()
593 User::LeaveIfError(Resume());
594 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Exit"));
597 User::Leave(KErrNotReady);
600 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayInit,
603 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayInitL - Exit"));
606 // -----------------------------------------------------------------------------
607 // RMMFDevSoundProxy::RecordInitL
608 // Initilaizes DevSound to record digital audio and starts the record process.
609 // (other items were commented in a header).
610 // -----------------------------------------------------------------------------
612 EXPORT_C void RMMFDevSoundProxy::RecordInitL()
614 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Enter"));
615 if (!iDevSoundObserver || iState!=EInitialized)
617 if(iState == ERecording || iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle
618 || iState == ERecordingResumingInLastBufferCycle)
620 // treat RecordInitL() during record as Resume()
621 User::LeaveIfError(Resume());
622 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Exit"));
625 User::Leave(KErrNotReady);
628 User::LeaveIfError(SendReceive(EMMFDevSoundProxyRecordInit,
631 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordInitL - Exit"));
634 // -----------------------------------------------------------------------------
635 // RMMFDevSoundProxy::PlayData
636 // Plays the data in the buffer at the current volume.
637 // (other items were commented in a header).
638 // -----------------------------------------------------------------------------
640 EXPORT_C void RMMFDevSoundProxy::PlayData()
642 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayData - Enter")); //Uncommenting this will produce a lot of logging!
643 __ASSERT_ALWAYS(iState == EPlaying || iState == EPlayingBufferWait,
644 Panic(EMMFDevSoundProxyPlayDataWithoutInitialize));
645 ASSERT(iDevSoundObserver);
646 SYMBIAN_CHECK( iState == EPlayingBufferWait,
647 Panic(EMMFDevSoundProxyPlayDataInWrongState));
648 TMMFDevSoundProxyHwBuf set;
649 set.iLastBuffer = iBuffer->LastBuffer();
650 set.iBufferSize = iBuffer->Data().Size();
651 TMMFDevSoundProxyHwBufPckg pckg(set);
653 SendReceive(EMMFDevSoundProxyPlayData, iDestinationPckg, pckg);
655 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayData - Exit")); //Uncommenting this will produce a lot of logging!
658 // -----------------------------------------------------------------------------
659 // RMMFDevSoundProxy::RecordData
660 // Signals the device to continue recording.
661 // (other items were commented in a header).
662 // -----------------------------------------------------------------------------
664 EXPORT_C void RMMFDevSoundProxy::RecordData()
666 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordData - Enter")); //Uncommenting this will produce a lot of logging!
667 __ASSERT_ALWAYS(iState == ERecording || iState == ERecordingBufferWait ||
668 iState == ERecordingInLastBufferCycle || iState == ERecordingResumingInLastBufferCycle,
669 Panic(EMMFDevSoundProxyRecordDataWithoutInitialize));
670 ASSERT(iDevSoundObserver);
671 SYMBIAN_CHECK(iState == ERecordingBufferWait || iState == ERecordingInLastBufferCycle ||
672 iState == ERecordingResumingInLastBufferCycle,
673 Panic(EMMFDevSoundProxyPlayDataInWrongState));
676 case ERecordingBufferWait:
678 SendReceive(EMMFDevSoundProxyRecordData, iDestinationPckg);
681 case ERecordingInLastBufferCycle:
682 // ack of the last buffer. Just swallow - the server should not be sent an ack
685 case ERecordingResumingInLastBufferCycle:
686 // this is a RecordData() following a Resume() in the last cycle. This is where we do the resume!
687 SendReceive(EMMFDevSoundProxyResume, iDestinationPckg); // note ignore any error
691 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RecordData - Exit")); //Uncommenting this will produce a lot of logging!
694 // -----------------------------------------------------------------------------
695 // RMMFDevSoundProxy::Stop
696 // Stops the ongoing opeartion.
697 // (other items were commented in a header).
698 // -----------------------------------------------------------------------------
700 EXPORT_C void RMMFDevSoundProxy::Stop()
702 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Stop - Enter"));
703 if (iState > EInitialized)
705 SendReceive(EMMFDevSoundProxyStop, iDestinationPckg);
706 iState = EInitialized;
707 iMsgQueueHandler->Finish(); // will delete the buffer
709 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Stop - Exit"));
712 // -----------------------------------------------------------------------------
713 // RMMFDevSoundProxy::Pause
714 // Temporarily stops the ongoing operation.
715 // (other items were commented in a header).
716 // -----------------------------------------------------------------------------
718 EXPORT_C void RMMFDevSoundProxy::Pause()
720 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Pause - Enter"));
721 if(iState > EInitialized)
723 SendReceive(EMMFDevSoundProxyPause, iDestinationPckg);
725 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Pause - Exit"));
728 // -----------------------------------------------------------------------------
729 // RMMFDevSoundProxy::PlayToneL
730 // Plays the simple tone.
731 // (other items were commented in a header).
732 // -----------------------------------------------------------------------------
734 EXPORT_C void RMMFDevSoundProxy::PlayToneL(
736 const TTimeIntervalMicroSeconds& aDuration)
738 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Enter"));
739 if(iState==ETonePlaying)
741 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Exit"));
745 if (!iDevSoundObserver || iState!=EInitialized)
747 User::Leave(KErrNotReady);
750 TMMFDevSoundProxySettings set;
751 set.iFrequencyOne = aFrequency;
752 set.iDuration = aDuration;
753 TMMFDevSoundProxySettingsPckg pckg(set);
754 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayTone,
757 iState = ETonePlaying;
759 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneL - Exit"));
762 // -----------------------------------------------------------------------------
763 // RMMFDevSoundProxy::PlayDualToneL
764 // Plays the dual tone.
765 // (other items were commented in a header).
766 // -----------------------------------------------------------------------------
768 EXPORT_C void RMMFDevSoundProxy::PlayDualToneL(
771 const TTimeIntervalMicroSeconds& aDuration)
773 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Enter"));
774 if(iState==ETonePlaying)
776 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Exit"));
780 if (!iDevSoundObserver || iState!=EInitialized)
782 User::Leave(KErrNotReady);
785 TMMFDevSoundProxySettings set;
786 set.iFrequencyOne = aFrequencyOne;
787 set.iFrequencyTwo = aFrequencyTwo;
788 set.iDuration = aDuration;
789 TMMFDevSoundProxySettingsPckg pckg(set);
790 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayDualTone, iDestinationPckg, pckg));
791 iState = ETonePlaying;
793 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDualToneL - Exit"));
796 // -----------------------------------------------------------------------------
797 // RMMFDevSoundProxy::PlayDTMFStringL
798 // Plays the DTMF string.
799 // (other items were commented in a header).
800 // -----------------------------------------------------------------------------
802 EXPORT_C void RMMFDevSoundProxy::PlayDTMFStringL(const TDesC& aDTMFString)
804 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Enter"));
805 if(iState==ETonePlaying)
807 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Exit"));
811 if (!iDevSoundObserver || iState!=EInitialized)
813 User::Leave(KErrNotReady);
817 tempPtr.Set(CONST_CAST(TUint16*, aDTMFString.Ptr()),
818 aDTMFString.Length(),
819 aDTMFString.Length());
821 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyPlayDTMFString,
825 iState = ETonePlaying;
826 iToneMode = EDTMFString;
827 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayDTMFStringL - Exit"));
830 // -----------------------------------------------------------------------------
831 // RMMFDevSoundProxy::PlayToneSequenceL
832 // Plays the tone sequence. (NRT/RNG)
833 // (other items were commented in a header).
834 // -----------------------------------------------------------------------------
836 EXPORT_C void RMMFDevSoundProxy::PlayToneSequenceL(const TDesC8& aData )
838 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Enter"));
839 if(iState==ETonePlaying)
841 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Exit"));
845 if (!iDevSoundObserver || iState!=EInitialized)
847 User::Leave(KErrNotReady);
850 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayToneSequence,
853 iState = ETonePlaying;
854 iToneMode = ESequence;
855 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayToneSequenceL - Exit"));
858 // -----------------------------------------------------------------------------
859 // RMMFDevSoundProxy::PlayFixedSequenceL
860 // Plays the fixed sequence.
861 // (other items were commented in a header).
862 // -----------------------------------------------------------------------------
864 EXPORT_C void RMMFDevSoundProxy::PlayFixedSequenceL(TInt aSequenceNumber)
866 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Enter"));
867 if(iState==ETonePlaying)
869 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Exit"));
873 if (!iDevSoundObserver || iState!=EInitialized)
875 User::Leave(KErrNotReady);
878 TPckgBuf<TInt> seqNum(aSequenceNumber);
879 User::LeaveIfError(SendReceive(EMMFDevSoundProxyPlayFixedSequence, iDestinationPckg, seqNum));
880 iState = ETonePlaying;
881 iToneMode = EFixedSequence;
882 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::PlayFixedSequenceL - Exit"));
885 // -----------------------------------------------------------------------------
886 // RMMFDevSoundProxy::SetDTMFLengths
887 // Set attributes for playing DTMF String.
888 // (other items were commented in a header).
889 // -----------------------------------------------------------------------------
891 EXPORT_C void RMMFDevSoundProxy::SetDTMFLengths(
892 TTimeIntervalMicroSeconds32& aToneOnLength,
893 TTimeIntervalMicroSeconds32& aToneOffLength,
894 TTimeIntervalMicroSeconds32& aPauseLength )
896 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDTMFLengths - Enter"));
897 TMMFDevSoundProxySettings set;
898 set.iToneOnLength = aToneOnLength;
899 set.iToneOffLength = aToneOffLength;
900 set.iPauseLength = aPauseLength;
901 TMMFDevSoundProxySettingsPckg pckg(set);
902 SendReceive(EMMFDevSoundProxySetDTMFLengths, iDestinationPckg, pckg);
903 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetDTMFLengths - Exit"));
906 // -----------------------------------------------------------------------------
907 // RMMFDevSoundProxy::SetVolumeRamp
908 // Sets the volume ramp duration.
909 // (other items were commented in a header).
910 // -----------------------------------------------------------------------------
912 EXPORT_C void RMMFDevSoundProxy::SetVolumeRamp(
913 const TTimeIntervalMicroSeconds& aRampDuration)
915 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolumeRamp - Enter"));
916 TMMFDevSoundProxySettings set;
917 set.iDuration = aRampDuration;
918 TMMFDevSoundProxySettingsPckg pckg(set);
919 SendReceive(EMMFDevSoundProxySetVolumeRamp, iDestinationPckg, pckg);
920 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetVolumeRamp - Exit"));
923 // -----------------------------------------------------------------------------
924 // RMMFDevSoundProxy::GetSupportedInputDataTypesL
925 // Returns supported datatypes for playing audio.
926 // (other items were commented in a header).
927 // -----------------------------------------------------------------------------
929 EXPORT_C void RMMFDevSoundProxy::GetSupportedInputDataTypesL(
930 RArray<TFourCC>& aSupportedDataTypes,
931 const TMMFPrioritySettings& aPrioritySettings)
933 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Enter"));
934 aSupportedDataTypes.Reset();
936 TMMFPrioritySettings prioritySet = aPrioritySettings;
937 TMMFPrioritySettingsPckg pckg(prioritySet);
939 TPckgBuf<TInt> numberOfElementsPckg;
940 User::LeaveIfError(SendReceiveResult(
941 EMMFDevSoundProxyGetSupportedInputDataTypes,
944 numberOfElementsPckg));
946 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Exit 1"));
948 HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC));
949 TPtr8 ptr = buf->Des();
952 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData,
957 RDesReadStream stream(ptr);
958 CleanupClosePushL(stream);
961 TInt count = numberOfElementsPckg();
962 for (TInt i = 0; i < count; i++)
964 TInt err = aSupportedDataTypes.Append(stream.ReadInt32L());
966 {//note we don't destroy array because we don't own it
967 //but we do reset it as it is incomplete
968 aSupportedDataTypes.Reset();
972 CleanupStack::PopAndDestroy(&stream);
973 CleanupStack::PopAndDestroy(buf);
974 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedInputDataTypesL - Exit 2"));
977 // -----------------------------------------------------------------------------
978 // RMMFDevSoundProxy::GetSupportedOutputDataTypesL
979 // Returns supported datatypes for recording audio.
980 // (other items were commented in a header).
981 // -----------------------------------------------------------------------------
983 EXPORT_C void RMMFDevSoundProxy::GetSupportedOutputDataTypesL(
984 RArray<TFourCC>& aSupportedDataTypes,
985 const TMMFPrioritySettings& aPrioritySettings)
987 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Enter"));
988 aSupportedDataTypes.Reset();
990 TMMFPrioritySettings prioritySet = aPrioritySettings;
991 TMMFPrioritySettingsPckg pckg(prioritySet);
993 TPckgBuf<TInt> numberOfElementsPckg;
994 User::LeaveIfError(SendReceiveResult(
995 EMMFDevSoundProxyGetSupportedOutputDataTypes,
998 numberOfElementsPckg));
1000 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Exit 1"));
1002 HBufC8* buf = HBufC8::NewLC(numberOfElementsPckg()*sizeof(TFourCC));
1003 TPtr8 ptr = buf->Des();
1006 User::LeaveIfError(SendReceiveResult(EMMFDevSoundProxyCopyFourCCArrayData,
1010 RDesReadStream stream(ptr);
1011 CleanupClosePushL(stream);
1014 TInt count = numberOfElementsPckg();
1015 for (TInt i = 0; i < count; i++)
1017 TInt err = aSupportedDataTypes.Append(stream.ReadInt32L());
1019 {//note we don't destroy array because we don't own it
1020 //but we do reset it as it is incomplete
1021 aSupportedDataTypes.Reset();
1025 CleanupStack::PopAndDestroy(&stream);
1026 CleanupStack::PopAndDestroy(buf);
1027 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetSupportedOutputDataTypesL - Exit 2"));
1030 // -----------------------------------------------------------------------------
1031 // RMMFDevSoundProxy::SamplesRecorded
1032 // Returns samples recorded so far.
1033 // (other items were commented in a header).
1034 // -----------------------------------------------------------------------------
1036 EXPORT_C TInt RMMFDevSoundProxy::SamplesRecorded()
1038 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesRecorded - Enter"));
1039 TPckgBuf<TInt> numSamples;
1040 SendReceiveResult(EMMFDevSoundProxySamplesRecorded,
1044 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesRecorded - Exit"));
1045 return numSamples();
1048 // -----------------------------------------------------------------------------
1049 // RMMFDevSoundProxy::SamplesPlayed
1050 // Returns samples played so far.
1051 // (other items were commented in a header).
1052 // -----------------------------------------------------------------------------
1054 EXPORT_C TInt RMMFDevSoundProxy::SamplesPlayed()
1056 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesPlayed - Enter"));
1057 TPckgBuf<TInt> numSamples;
1058 SendReceiveResult(EMMFDevSoundProxySamplesPlayed,
1062 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SamplesPlayed - Exit"));
1063 return numSamples();
1066 // -----------------------------------------------------------------------------
1067 // RMMFDevSoundProxy::SetToneRepeats
1068 // Sets tone repeats
1069 // (other items were commented in a header).
1070 // -----------------------------------------------------------------------------
1072 EXPORT_C void RMMFDevSoundProxy::SetToneRepeats(
1074 const TTimeIntervalMicroSeconds&
1075 aRepeatTrailingSilence)
1077 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetToneRepeats - Enter"));
1078 TPckgBuf<TInt> countRepeat(aRepeatCount);
1079 TPckgBuf<TTimeIntervalMicroSeconds> repeatTS(aRepeatTrailingSilence);
1080 SendReceive(EMMFDevSoundProxySetToneRepeats,
1084 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetToneRepeats - Exit"));
1087 // -----------------------------------------------------------------------------
1088 // RMMFDevSoundProxy::SetPrioritySettings
1089 // Sets priority settings
1090 // (other items were commented in a header).
1091 // -----------------------------------------------------------------------------
1093 EXPORT_C void RMMFDevSoundProxy::SetPrioritySettings(
1094 const TMMFPrioritySettings& aPrioritySettings)
1096 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPrioritySettings - Enter"));
1097 TPckgBuf<TMMFPrioritySettings> prioritySet(aPrioritySettings);
1098 SendReceive(EMMFDevSoundProxySetPrioritySettings,
1101 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetPrioritySettings - Exit"));
1104 // -----------------------------------------------------------------------------
1105 // RMMFDevSoundProxy::FixedSequenceName
1106 // Returns the name of fixed sequence for a given sequence number.
1107 // (other items were commented in a header).
1108 // -----------------------------------------------------------------------------
1110 EXPORT_C const TDesC& RMMFDevSoundProxy::FixedSequenceName(TInt /*aSequenceNumber*/)
1112 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceName - Enter"));
1113 _LIT(KNullDesC, "");
1114 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceName - Exit"));
1118 // -----------------------------------------------------------------------------
1119 // RMMFDevSoundProxy::CustomInterface
1120 // Returns a pointer to CustomInterface object.
1121 // (other items were commented in a header).
1122 // -----------------------------------------------------------------------------
1124 EXPORT_C TAny* RMMFDevSoundProxy::CustomInterface(TUid aInterfaceId)
1126 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Enter"));
1127 TMMFDevSoundProxySettings set;
1128 set.iInterface = aInterfaceId;
1129 // Added for ask for custom interface
1130 TAny* customInterface = NULL;
1131 if (aInterfaceId == KMmfUidDevSoundCancelInitializeCustomInterface)
1133 MMMFDevSoundCancelInitialize* result = this;
1134 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Exit"));
1137 TPckgBuf<TAny*> pckg2(customInterface);
1139 TMMFDevSoundProxySettingsPckg pckg(set);
1140 SendReceiveResult(EMMFDevSoundProxyCustomInterface,
1143 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomInterface - Exit"));
1144 return reinterpret_cast<TAny*> (customInterface);
1147 // -----------------------------------------------------------------------------
1148 // RMMFDevSoundProxy::FixedSequenceCount
1149 // Returns the number of fixed sequences supported by DevSound.
1150 // (other items were commented in a header).
1151 // -----------------------------------------------------------------------------
1153 EXPORT_C TInt RMMFDevSoundProxy::FixedSequenceCount()
1155 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceCount - Enter"));
1156 TPckgBuf<TInt> fixSeqCountPckg;
1157 SendReceiveResult(EMMFDevSoundProxyFixedSequenceCount,
1162 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::FixedSequenceCount - Exit"));
1163 return fixSeqCountPckg();
1166 // -----------------------------------------------------------------------------
1167 // RMMFDevSoundProxy::BufferToBeFilledData
1168 // Returns data buffer for playback.
1169 // -----------------------------------------------------------------------------
1171 EXPORT_C TInt RMMFDevSoundProxy::BufferToBeFilledData(
1172 TBool aRequestChunk, TMMFDevSoundProxyHwBufPckg& aSetPckg)
1174 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeFilledData - Enter")); //Uncommenting this will produce a lot of logging!
1175 // Note that there will only ever be one of these requests outstanding
1177 TPckgBuf<TInt> requestChunkBuf (aRequestChunk);
1178 TInt err = SendReceiveResult(EMMFDevSoundProxyBTBFData,
1182 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeFilledData - Exit [%d]"), err); //Uncommenting this will produce a lot of logging!
1186 // -----------------------------------------------------------------------------
1187 // RMMFDevSoundProxy::BufferToBeEmptiedData
1188 // Returns data buffer for recording.
1189 // -----------------------------------------------------------------------------
1191 EXPORT_C TInt RMMFDevSoundProxy::BufferToBeEmptiedData(
1192 TMMFDevSoundProxyHwBufPckg& aSetPckg)
1194 //SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::BufferToBeEmptiedData - Enter")); //Uncommenting this will produce a lot of logging!
1195 // Note that there will only ever be one of these requests outstanding
1197 TInt err = SendReceiveResult(EMMFDevSoundProxyBTBEData,
1201 //SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::BufferToBeEmptiedData - Exit [%d]"), err); //Uncommenting this will produce a lot of logging!
1205 // -----------------------------------------------------------------------------
1206 // RMMFDevSoundProxy::RegisterAsClient
1207 // Registers the client for notification of resource avalibility.
1208 // -----------------------------------------------------------------------------
1210 EXPORT_C TInt RMMFDevSoundProxy::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData)
1212 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::RegisterAsClient - Enter"));
1213 TMMFDevSoundProxySettings set;
1214 set.iNotificationEventUid = aEventType;
1215 TMMFDevSoundProxySettingsPckg pckg(set);
1216 TInt err = SendReceive(EMMFDevSoundProxyRequestResourceNotification, iDestinationPckg, pckg, aNotificationRegistrationData);
1217 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::RegisterAsClient - Exit [%d]"), err);
1221 // -----------------------------------------------------------------------------
1222 // RMMFDevSoundProxy::CancelRegisterAsClient
1223 // Cancels the Registered Notification.
1224 // -----------------------------------------------------------------------------
1226 EXPORT_C TInt RMMFDevSoundProxy::CancelRegisterAsClient(TUid aEventType)
1228 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CancelRegisterAsClient - Enter"));
1229 TMMFDevSoundProxySettings set;
1230 set.iNotificationEventUid = aEventType;
1231 TMMFDevSoundProxySettingsPckg pckg(set);
1232 TInt err = SendReceiveResult(EMMFDevSoundProxyCancelRequestResourceNotification, iDestinationPckg, KNullDesC8, pckg);
1233 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CancelRegisterAsClient - Exit [%d]"), err);
1237 // -----------------------------------------------------------------------------
1238 // RMMFDevSoundProxy::GetResourceNotificationData
1239 // Returns the Notification data which the client needs to resume playing.
1240 // -----------------------------------------------------------------------------
1242 EXPORT_C TInt RMMFDevSoundProxy::GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData)
1244 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetResourceNotificationData - Enter"));
1245 TMMFDevSoundProxySettings set;
1246 set.iNotificationEventUid = aEventType;
1247 TMMFDevSoundProxySettingsPckg pckg(set);
1248 TInt err = SendReceiveResult(EMMFDevSoundProxyGetResourceNotificationData, iDestinationPckg, pckg, aNotificationData);
1249 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::GetResourceNotificationData - Exit [%d]"), err);
1253 // -----------------------------------------------------------------------------
1254 // RMMFDevSoundProxy::WillResumePlay
1255 // Wait for the clients to resume play back even after the default timeout
1256 // expires. Unless the client cancels the notification request or completes
1257 // no other client gets notification.
1258 // -----------------------------------------------------------------------------
1260 EXPORT_C TInt RMMFDevSoundProxy::WillResumePlay()
1262 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::WillResumePlay - Enter"));
1263 TInt err = SendReceive(EMMFDevSoundProxyWillResumePlay, iDestinationPckg);
1264 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::WillResumePlay - Exit [%d]"), err);
1268 // -----------------------------------------------------------------------------
1269 // RMMFDevSoundProxy::EmptyBuffers
1270 // Empties the play buffers below DevSound without causing the codec
1272 // -----------------------------------------------------------------------------
1275 EXPORT_C TInt RMMFDevSoundProxy::EmptyBuffers()
1277 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::EmptyBuffers - Enter"));
1278 TInt error = SendReceive(EMMFDevSoundProxyEmptyBuffers, iDestinationPckg);
1282 if (iState==EPlayingBufferWait)
1284 // Empty buffers terminates the buffer cycle
1288 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::EmptyBuffers - Exit [%d]"), error);
1292 // -----------------------------------------------------------------------------
1293 // RMMFDevSoundProxy::CancelInitialize
1294 // Cancels the initialization process
1295 // -----------------------------------------------------------------------------
1297 EXPORT_C TInt RMMFDevSoundProxy::CancelInitialize()
1299 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CancelInitialize - Enter"));
1302 if (iState==EInitializing)
1304 err = SendReceive(EMMFDevSoundProxyCancelInitialize, iDestinationPckg);
1311 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CancelInitialize - Exit [%d]"), err);
1316 // -----------------------------------------------------------------------------
1317 // RMMFDevSoundProxy::SetClientThreadInfo
1319 // -----------------------------------------------------------------------------
1321 EXPORT_C TInt RMMFDevSoundProxy::SetClientThreadInfo(TThreadId& aTid)
1323 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SetClientThreadInfo - Enter"));
1324 TPckgBuf<TThreadId> threadId(aTid);
1325 TInt err = SendReceive(EMMFDevSoundProxySetClientThreadInfo, iDestinationPckg, threadId);
1326 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::SetClientThreadInfo - Exit [%d]"), err);
1331 // -----------------------------------------------------------------------------
1332 // RMMFDevSoundProxy::CustomCommandSync()
1333 // Send Message synchronously to DevSound server and return the result to client
1334 // -----------------------------------------------------------------------------
1336 EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync(
1337 const TMMFMessageDestinationPckg& aDestination,
1339 const TDesC8& aDataTo1,
1340 const TDesC8& aDataTo2,
1343 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Enter"));
1344 TInt err = SendReceiveResult(aFunction,
1349 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Exit [%d]"), err);
1353 // -----------------------------------------------------------------------------
1354 // RMMFDevSoundProxy::RMMFDevSoundProxy()
1355 // Send Message synchronously to DevSound server and return the result to client
1356 // -----------------------------------------------------------------------------
1358 EXPORT_C TInt RMMFDevSoundProxy::CustomCommandSync(
1359 const TMMFMessageDestinationPckg& aDestination,
1361 const TDesC8& aDataTo1,
1362 const TDesC8& aDataTo2)
1364 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Enter"));
1365 TInt err = SendReceive(aFunction, aDestination, aDataTo1, aDataTo2);
1366 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::CustomCommandSync - Exit [%d]"), err);
1370 // -----------------------------------------------------------------------------
1371 // RMMFDevSoundProxy::RMMFDevSoundProxy()
1372 // Send Message asynchronously to DevSound server
1373 // -----------------------------------------------------------------------------
1375 EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync(
1376 const TMMFMessageDestinationPckg& aDestination,
1378 const TDesC8& aDataTo1,
1379 const TDesC8& aDataTo2,
1381 TRequestStatus& aStatus )
1383 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Enter"));
1384 SendReceiveResult(aFunction,
1390 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Exit"));
1393 // -----------------------------------------------------------------------------
1394 // RMMFDevSoundProxy::RMMFDevSoundProxy()
1395 // Send Message asynchronously to DevSound server
1396 // -----------------------------------------------------------------------------
1398 EXPORT_C void RMMFDevSoundProxy::CustomCommandAsync(
1399 const TMMFMessageDestinationPckg& aDestination,
1401 const TDesC8& aDataTo1,
1402 const TDesC8& aDataTo2,
1403 TRequestStatus& aStatus )
1405 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Enter"));
1406 SendReceive(aFunction, aDestination, aDataTo1, aDataTo2, aStatus);
1407 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::CustomCommandAsync - Exit"));
1410 // implementation of a simple CustomCommand() scheme
1411 EXPORT_C TInt RMMFDevSoundProxy::SyncCustomCommand(TUid aUid, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam)
1413 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Enter"));
1414 TMMFMessageDestinationPckg dest(TMMFMessageDestination(aUid, KMMFObjectHandleDevSound));
1416 TInt err = KErrNone;
1417 if (aOutParam==NULL)
1419 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Exit"));
1420 err = SendReceive(EMMFDevSoundProxySyncCustomCommand, dest, aParam1, aParam2);
1425 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::SyncCustomCommand - Exit"));
1426 err = SendReceiveResult(EMMFDevSoundProxySyncCustomCommandResult, dest, aParam1, aParam2, *aOutParam);
1431 EXPORT_C void RMMFDevSoundProxy::AsyncCustomCommand(TUid aUid, TRequestStatus& aStatus, const TDesC8& aParam1, const TDesC8& aParam2, TDes8* aOutParam)
1433 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Enter"));
1434 TMMFMessageDestination dest(aUid, KMMFObjectHandleDevSound);
1435 iCustIntPckg = dest;
1436 if (aOutParam==NULL)
1438 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Exit"));
1439 SendReceive(EMMFDevSoundProxyAsyncCustomCommand, iCustIntPckg, aParam1, aParam2, aStatus);
1443 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::AsyncCustomCommand - Exit"));
1444 SendReceiveResult(EMMFDevSoundProxyAsyncCustomCommandResult, iCustIntPckg, aParam1, aParam2, *aOutParam, aStatus);
1448 EXPORT_C TInt RMMFDevSoundProxy::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
1450 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::GetTimePlayed - Enter"));
1451 TTimeIntervalMicroSeconds time(0);
1452 TPckgBuf<TTimeIntervalMicroSeconds> timePckg(time);
1453 TInt err = SendReceiveResult(EMMFDevSoundProxyGetTimePlayed, iDestinationPckg, KNullDesC8, timePckg);
1458 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::GetTimePlayed - Exit [%d]"), err);
1462 EXPORT_C TBool RMMFDevSoundProxy::IsResumeSupported()
1464 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Enter"));
1465 TPckgBuf<TBool> isResumeSupported;
1466 TInt err = SendReceiveResult(EMMFDevSoundProxyIsResumeSupported,
1472 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Exit"));
1473 return isResumeSupported();
1477 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::IsResumeSupported - Exit"));
1482 EXPORT_C TInt RMMFDevSoundProxy::Resume()
1484 SYMBIAN_DEBPRN0(_L("RMMFDevSoundProxy[0x%x]::Resume - Enter"));
1485 TInt err = KErrNone;
1486 if (!iDevSoundObserver || iState <= EInitialized )
1490 else if(iState == ETonePlaying && iToneMode != ESequence)
1492 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Resume - Exit [%d]"), err);
1493 return KErrNotSupported;
1497 if (iState==ERecordingInLastBufferCycle)
1499 // if we're in a last buffer cycle and get Resume() we have to be careful as the
1500 // server side sent a PausedRecordCompleteEvent and did not actually request a buffer!
1501 // just record the fact we've done this and wait until RecordData() is called
1502 // don't actually resume until then!
1503 iState = ERecordingResumingInLastBufferCycle;
1505 else if (iState == ERecordingResumingInLastBufferCycle)
1507 //Do Nothing as you can't resume twice on last buffer
1511 err = SendReceive(EMMFDevSoundProxyResume,
1515 SYMBIAN_DEBPRN1(_L("RMMFDevSoundProxy[0x%x]::Resume - Exit [%d]"), err);
1519 // -----------------------------------------------------------------------------
1520 // RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL()
1521 // Starts message queue handler (A/O) to monitor client side events
1522 // -----------------------------------------------------------------------------
1524 void RMMFDevSoundProxy::StartReceivingMsgQueueHandlerEventsL(MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver)
1526 if (iMsgQueueHandler)
1528 iMsgQueueHandler->Cancel();
1532 iMsgQueueHandler = CMsgQueueHandler::NewL(this,
1535 aDevSoundCIObserver);
1538 iMsgQueueHandler->ReceiveEvents();
1541 // MDevSoundObserver
1542 // intercept the calls from the msgQueueHandler going back to the client, so we can track real state
1544 void RMMFDevSoundProxy::InitializeComplete(TInt aError)
1546 SYMBIAN_CHECK(iState==EInitializing, Panic(EMMFDevSoundProxyInitCompleteInWrongState));
1547 if (aError==KErrNone)
1549 iState = EInitialized;
1555 iDevSoundObserver->InitializeComplete(aError);
1558 void RMMFDevSoundProxy::ToneFinished(TInt aError)
1560 SYMBIAN_CHECK(iState==ETonePlaying, Panic(EMMFDevSoundProxyToneFinishedInWrongState));
1561 iState = EInitialized;
1562 iDevSoundObserver->ToneFinished(aError);
1565 void RMMFDevSoundProxy::PlayError(TInt aError)
1567 SYMBIAN_CHECK(iState==EPlaying||iState==EPlayingBufferWait, Panic(EMMFDevSoundProxyPlayErrorInWrongState));
1568 iState = EInitialized;
1569 iDevSoundObserver->PlayError(aError);
1572 void RMMFDevSoundProxy::RecordError(TInt aError)
1574 SYMBIAN_CHECK(iState==ERecording||iState==ERecordingBufferWait, Panic(EMMFDevSoundProxyRecordErrorInWrongState));
1575 iState = EInitialized;
1576 iDevSoundObserver->RecordError(aError);
1579 void RMMFDevSoundProxy::BufferToBeFilled(CMMFBuffer* aBuffer)
1581 SYMBIAN_CHECK(iState==EPlaying, Panic(EMMFDevSoundProxyBTBFInWrongState));
1582 iState = EPlayingBufferWait;
1583 iBuffer = static_cast<CMMFDataBuffer*>(aBuffer); // cache buffer for use in PlayData() later
1584 iDevSoundObserver->BufferToBeFilled(aBuffer);
1587 void RMMFDevSoundProxy::BufferToBeEmptied(CMMFBuffer* aBuffer)
1589 SYMBIAN_CHECK(iState==ERecording, Panic(EMMFDevSoundProxyBTBEInWrongState));
1590 if (aBuffer->LastBuffer())
1592 // this is end of recording. Assume have an empty buffer. Different state so that Resume() is handled as special case.
1593 iState = ERecordingInLastBufferCycle;
1597 iState = ERecordingBufferWait;
1599 iDevSoundObserver->BufferToBeEmptied(aBuffer);
1602 void RMMFDevSoundProxy::ConvertError(TInt /*aError*/)
1604 SYMBIAN_CHECK(EFalse, Panic(EMMFDevSoundProxyUnexpectedConvError));
1607 void RMMFDevSoundProxy::DeviceMessage(TUid aMessageType, const TDesC8& aMsg)
1609 iDevSoundObserver->DeviceMessage(aMessageType, aMsg);
1612 void RMMFDevSoundProxy::SendEventToClient(const TMMFEvent& aEvent)
1614 iDevSoundObserver->SendEventToClient(aEvent);