os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtDevSoundSession.cpp
Update contrib.
1 // Copyright (c) 2004-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.
17 #include "MmfBtDevSoundSession.h"
18 #include "MmfBtDevSoundSessionXtnd.h"
19 #include "MmfBtDevSoundSessionBody.h"
21 #include "MmfBtAudioClientServer.h"
22 #include "MmfBtAudioServer.h"
23 #include "MmfBtDevSoundServer.h"
26 void CMMFDevSoundSession::CreateL(const CMmfIpcServer& aServer)
28 CMmfIpcSession::CreateL(aServer);
29 CMMFDevSoundServer& server =
30 const_cast<CMMFDevSoundServer&>(static_cast<const CMMFDevSoundServer&>(aServer));
31 server.IncrementSessionId();
32 iDevSoundSessionId = server.DevSoundSessionId();
33 iClientHasCaps = server.CheckClientCapabilities();
36 TBool CMMFDevSoundSession::CheckClientCapabilities()
38 return iClientHasCaps;
41 void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage)
43 TBool complete = EFalse;
44 switch(aMessage.Function())
46 case EMMFDevSoundProxyInitialize1:
47 complete = DoInitialize1L(aMessage);
49 case EMMFDevSoundProxyInitialize2:
50 complete = DoInitialize2L(aMessage);
52 case EMMFDevSoundProxyInitialize3:
53 complete = DoInitialize3L(aMessage);
55 case EMMFDevSoundProxyInitialize4:
56 complete = DoInitialize4L(aMessage);
58 case EMMFDevSoundProxyCapabilities:
59 complete = DoCapabilitiesL(aMessage);
61 case EMMFDevSoundProxyConfig:
62 complete = DoConfigL(aMessage);
64 case EMMFDevSoundProxySetConfig:
65 complete = DoSetConfigL(aMessage);
67 case EMMFDevSoundProxyMaxVolume:
68 complete = DoMaxVolumeL(aMessage);
70 case EMMFDevSoundProxyVolume:
71 complete = DoVolumeL(aMessage);
73 case EMMFDevSoundProxySetVolume:
74 complete = DoSetVolumeL(aMessage);
76 case EMMFDevSoundProxyMaxGain:
77 complete = DoMaxGainL(aMessage);
79 case EMMFDevSoundProxyGain:
80 complete = DoGainL(aMessage);
82 case EMMFDevSoundProxySetGain:
83 complete = DoSetGainL(aMessage);
85 case EMMFDevSoundProxyPlayBalance:
86 complete = DoGetPlayBalanceL(aMessage);
88 case EMMFDevSoundProxySetPlayBalance:
89 complete = DoSetPlayBalanceL(aMessage);
91 case EMMFDevSoundProxyRecordBalance:
92 complete = DoGetRecordBalanceL(aMessage);
94 case EMMFDevSoundProxySetRecordBalance:
95 complete = DoSetRecordBalanceL(aMessage);
97 case EMMFDevSoundProxyReceiveICEvent:
98 complete = DoInitializeCompleteEventL(aMessage);
100 case EMMFDevSoundProxyCancelReceiveICEvent:
101 complete = DoCancelInitializeCompleteEventL(aMessage);
103 case EMMFDevSoundProxyReceiveBTBFEvent:
104 complete = DoBufferToBeFilledEventL(aMessage);
106 case EMMFDevSoundProxyCancelReceiveBTBFEvent:
107 complete = DoCancelBufferToBeFilledEventL(aMessage);
109 case EMMFDevSoundProxyReceiveBTBEEvent:
110 complete = DoBufferToBeEmptiedEventL(aMessage);
112 case EMMFDevSoundProxyCancelReceiveBTBEEvent:
113 complete = DoCancelBufferToBeEmptiedEventL(aMessage);
115 case EMMFDevSoundProxyReceivePEEvent:
116 complete = DoPlayErrorEventL(aMessage);
118 case EMMFDevSoundProxyCancelReceivePEEvent:
119 complete = DoCancelPlayErrorEventL(aMessage);
121 case EMMFDevSoundProxyReceiveREEvent:
122 complete = DoRecordErrorEventL(aMessage);
124 case EMMFDevSoundProxyCancelReceiveREEvent:
125 complete = DoCancelRecordErrorEventL(aMessage);
127 case EMMFDevSoundProxyReceiveSETCEvent:
128 complete = DoSendEventToClientEventL(aMessage);
130 case EMMFDevSoundProxyCancelReceiveSETCEvent:
131 complete = DoCancelSendEventToClientEventL(aMessage);
133 case EMMFDevSoundProxyReceiveTFEvent:
134 complete = DoToneFinishedEventL(aMessage);
136 case EMMFDevSoundProxyCancelReceiveTFEvent:
137 complete = DoCancelToneFinishedEventL(aMessage);
139 case EMMFDevSoundProxyPlayInit:
140 complete = DoPlayInitL(aMessage);
142 case EMMFDevSoundProxyRecordInit:
143 complete = DoRecordInitL(aMessage);
145 case EMMFDevSoundProxyPlayData:
146 complete = DoPlayDataL(aMessage);
148 case EMMFDevSoundProxyRecordData:
149 complete = DoRecordDataL(aMessage);
151 case EMMFDevSoundProxyStop:
152 complete = DoStopL(aMessage);
154 case EMMFDevSoundProxyPause:
155 complete = DoPauseL(aMessage);
157 case EMMFDevSoundProxyPlayTone:
158 complete = DoPlayToneL(aMessage);
160 case EMMFDevSoundProxyPlayDualTone:
161 complete = DoPlayDualToneL(aMessage);
163 case EMMFDevSoundProxyPlayDTMFString:
164 complete = DoPlayDTMFStringL(aMessage);
166 case EMMFDevSoundProxyPlayToneSequence:
167 complete = DoPlayToneSequenceL(aMessage);
169 case EMMFDevSoundProxyPlayFixedSequence:
170 complete = DoPlayFixedSequenceL(aMessage);
172 case EMMFDevSoundProxySetDTMFLengths:
173 complete = DoSetDTMFLengthsL(aMessage);
175 case EMMFDevSoundProxySetVolumeRamp:
176 complete = DoSetVolumeRampL(aMessage);
178 case EMMFDevSoundProxyGetSupportedInputDataTypes:
179 complete = DoGetSupportedInputDataTypesL(aMessage);
181 case EMMFDevSoundProxyGetSupportedOutputDataTypes:
182 complete = DoGetSupportedOutputDataTypesL(aMessage);
184 case EMMFDevSoundProxyCopyFourCCArrayData:
185 complete = DoCopyFourCCArrayDataL(aMessage);
187 case EMMFDevSoundProxyGetRecordedBuffer:
188 complete = DoGetRecordedBufferL(aMessage);
190 case EMMFDevSoundProxySamplesRecorded:
191 complete = DoSamplesRecordedL(aMessage);
193 case EMMFDevSoundProxySamplesPlayed:
194 complete = DoSamplesPlayedL(aMessage);
196 case EMMFDevSoundProxySetToneRepeats:
197 complete = DoSetToneRepeatsL(aMessage);
199 case EMMFDevSoundProxySetPrioritySettings:
200 complete = DoSetPrioritySettingsL(aMessage);
202 case EMMFDevSoundProxyFixedSequenceName:
203 complete = DoFixedSequenceNameL(aMessage);
205 case EMMFDevSoundProxyConvertInit:
206 complete = DoConvertInitL(aMessage);
208 case EMMFDevSoundProxyConvertData:
209 complete = DoConvertDataL(aMessage);
211 case EMMFDevSoundProxyFixedSequenceCount:
212 complete = DoFixedSequenceCountL(aMessage);
214 case EMMFDevSoundProxyRequestResourceNotification:
215 complete = DoRegisterAsClientL(aMessage);
217 case EMMFDevSoundProxyCancelRequestResourceNotification:
218 complete = DoCancelRegisterAsClientL(aMessage);
220 case EMMFDevSoundProxyGetResourceNotificationData:
221 complete = DoGetResourceNotificationDataL(aMessage);
223 case EMMFDevSoundProxyWillResumePlay:
224 complete = DoWillResumePlayL(aMessage);
226 case EMMFDevSoundProxySetClientThreadInfo:
227 complete = DoSetClientThreadInfoL(aMessage);
230 User::Leave(KErrNotSupported);
234 aMessage.Complete(KErrNone);
237 TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage)
239 TMMFDevSoundProxySettingsPckg buf;
240 MmfMessageUtil::ReadL(aMessage,0,buf);
241 TMMFState mode = buf().iMode;
242 iBody->InitializeL(*this, mode);
246 TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage)
248 TMMFDevSoundProxySettingsPckg buf;
249 MmfMessageUtil::ReadL(aMessage,0,buf);
250 TUid HWDev = buf().iHWDev;
251 TMMFState mode = buf().iMode;
252 iBody->InitializeL(*this, HWDev, mode);
256 TBool CMMFDevSoundSession::DoInitialize3L(const RMmfIpcMessage& /*aMessage*/)
258 User::Leave(KErrNotSupported);
262 TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage)
264 TMMFDevSoundProxySettingsPckg buf;
265 aMessage.ReadL(TInt(0),buf);
266 TFourCC desiredFourCC = buf().iDesiredFourCC;
267 TMMFState mode = buf().iMode;
268 iBody->InitializeL(*this, desiredFourCC, mode);
272 TBool CMMFDevSoundSession::DoCapabilitiesL(const RMmfIpcMessage& aMessage)
274 TMMFDevSoundProxySettings set;
275 set.iCaps = iBody->Capabilities();
276 TMMFDevSoundProxySettingsPckg pckg(set);
277 aMessage.WriteL(TInt(2),pckg);
281 TBool CMMFDevSoundSession::DoConfigL(const RMmfIpcMessage& aMessage)
283 TMMFDevSoundProxySettings set;
284 set.iConfig = iBody->Config();
285 TMMFDevSoundProxySettingsPckg pckg(set);
286 aMessage.WriteL(TInt(2),pckg);
290 TBool CMMFDevSoundSession::DoSetConfigL(const RMmfIpcMessage& aMessage)
292 TMMFDevSoundProxySettingsPckg buf;
293 aMessage.ReadL(TInt(0),buf);
294 TMMFCapabilities config = buf().iConfig;
295 iBody->SetConfigL(config);
299 TBool CMMFDevSoundSession::DoMaxVolumeL(const RMmfIpcMessage& aMessage)
301 TMMFDevSoundProxySettings set;
302 set.iMaxVolume = iBody->MaxVolume();
303 TMMFDevSoundProxySettingsPckg pckg(set);
304 aMessage.WriteL(TInt(2),pckg);
308 TBool CMMFDevSoundSession::DoVolumeL(const RMmfIpcMessage& aMessage)
310 TMMFDevSoundProxySettings set;
311 set.iVolume = iBody->Volume();
312 TMMFDevSoundProxySettingsPckg pckg(set);
313 aMessage.WriteL(TInt(2),pckg);
317 TBool CMMFDevSoundSession::DoSetVolumeL(const RMmfIpcMessage& aMessage)
319 TMMFDevSoundProxySettingsPckg buf;
320 aMessage.ReadL(TInt(0),buf);
321 TInt volume = buf().iVolume;
322 iBody->SetVolume(volume);
326 TBool CMMFDevSoundSession::DoMaxGainL(const RMmfIpcMessage& aMessage)
328 TMMFDevSoundProxySettings set;
329 set.iMaxGain = iBody->MaxGain();
330 TMMFDevSoundProxySettingsPckg pckg(set);
331 aMessage.WriteL(TInt(2),pckg);
335 TBool CMMFDevSoundSession::DoGainL(const RMmfIpcMessage& aMessage)
337 TMMFDevSoundProxySettings set;
338 set.iGain = iBody->Gain();
339 TMMFDevSoundProxySettingsPckg pckg(set);
340 aMessage.WriteL(TInt(2),pckg);
344 TBool CMMFDevSoundSession::DoSetGainL(const RMmfIpcMessage& aMessage)
346 TMMFDevSoundProxySettingsPckg buf;
347 aMessage.ReadL(TInt(0),buf);
348 TInt gain = buf().iGain;
349 iBody->SetGain(gain);
353 TBool CMMFDevSoundSession::DoGetPlayBalanceL(const RMmfIpcMessage& aMessage)
355 TMMFDevSoundProxySettings set;
356 iBody->GetPlayBalanceL(set.iLeftPercentage, set.iRightPercentage);
357 TMMFDevSoundProxySettingsPckg pckg(set);
358 aMessage.WriteL(TInt(2),pckg);
362 TBool CMMFDevSoundSession::DoSetPlayBalanceL(const RMmfIpcMessage& aMessage)
364 TMMFDevSoundProxySettingsPckg buf;
365 aMessage.ReadL(TInt(0),buf);
366 TInt leftPercentage = buf().iLeftPercentage;
367 TInt rightPercentage = buf().iRightPercentage;
368 iBody->SetPlayBalanceL(leftPercentage, rightPercentage);
372 TBool CMMFDevSoundSession::DoGetRecordBalanceL(const RMmfIpcMessage& aMessage)
374 TMMFDevSoundProxySettings set;
375 iBody->GetRecordBalanceL(set.iLeftPercentage, set.iRightPercentage);
376 TMMFDevSoundProxySettingsPckg pckg(set);
377 aMessage.WriteL(TInt(2),pckg);
381 TBool CMMFDevSoundSession::DoSetRecordBalanceL(const RMmfIpcMessage& aMessage)
383 TMMFDevSoundProxySettingsPckg buf;
384 aMessage.ReadL(TInt(0),buf);
385 TInt leftPercentage = buf().iLeftPercentage;
386 TInt rightPercentage = buf().iRightPercentage;
387 iBody->SetRecordBalanceL(leftPercentage, rightPercentage);
391 TBool CMMFDevSoundSession::DoPlayInitL(const RMmfIpcMessage& /*aMessage*/)
397 TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& aMessage)
399 iBody->RecordInitL(aMessage);
403 TBool CMMFDevSoundSession::DoPlayDataL(const RMmfIpcMessage& aMessage)
405 TMMFDevSoundProxyHwBufPckg buf;
406 aMessage.ReadL(TInt(0),buf);
407 iBufferPlay->SetLastBuffer(buf().iLastBuffer);
409 aMessage.ReadL(TInt(1),iBufferPlay->Data());
414 TBool CMMFDevSoundSession::DoRecordDataL(const RMmfIpcMessage& aMessage)
416 iBody->RecordData(aMessage);
420 TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/)
426 TBool CMMFDevSoundSession::DoPauseL(const RMmfIpcMessage& /*aMessage*/)
432 TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage)
434 TMMFDevSoundProxySettingsPckg buf;
435 aMessage.ReadL(TInt(0),buf);
436 TInt frequency = buf().iFrequencyOne;
437 TTimeIntervalMicroSeconds duration(buf().iDuration);
438 iBody->PlayToneL(frequency, duration);
442 TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage)
444 TMMFDevSoundProxySettingsPckg buf;
445 aMessage.ReadL(TInt(0),buf);
446 TInt frequencyOne = buf().iFrequencyOne;
447 TInt frequencyTwo = buf().iFrequencyTwo;
448 TTimeIntervalMicroSeconds duration(buf().iDuration);
449 iBody->PlayDualToneL(frequencyOne, frequencyTwo, duration);
453 TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage)
455 TInt DTMFLength = aMessage.GetDesLength(0);
463 iDTMFString = HBufC::NewL(DTMFLength);
464 TPtr DTMFPtr = iDTMFString->Des();
465 aMessage.ReadL(TInt(0), DTMFPtr);
467 iBody->PlayDTMFStringL(*iDTMFString);
471 TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage)
473 TInt toneLength = aMessage.GetDesLength(0);
481 iToneSeqBuf = HBufC8::NewL(toneLength);
482 TPtr8 toneSeqPtr = iToneSeqBuf->Des();
483 aMessage.ReadL(TInt(0), toneSeqPtr);
485 iBody->PlayToneSequenceL(*iToneSeqBuf);
489 TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage)
492 aMessage.ReadL(TInt(0),buf);
495 iBody->PlayFixedSequenceL(seqNum);
499 TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage)
501 TMMFDevSoundProxySettingsPckg buf;
502 aMessage.ReadL(TInt(0),buf);
503 TTimeIntervalMicroSeconds32 toneOnLength = buf().iToneOnLength;
504 TTimeIntervalMicroSeconds32 toneOffLength = buf().iToneOffLength;
505 TTimeIntervalMicroSeconds32 pauseLength = buf().iPauseLength;
506 iBody->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength);
510 TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage)
512 TMMFDevSoundProxySettingsPckg buf;
513 aMessage.ReadL(TInt(0),buf);
514 TTimeIntervalMicroSeconds duration = buf().iDuration;
515 iBody->SetVolumeRamp(duration);
519 TBool CMMFDevSoundSession::DoGetSupportedInputDataTypesL(const RMmfIpcMessage& aMessage)
523 TMMFPrioritySettingsPckg buf;
524 aMessage.ReadL(TInt(0),buf);
525 TMMFPrioritySettings prioritySet = buf();
527 iBody->GetSupportedInputDataTypesL(iArray, prioritySet);
530 pckg() = iArray.Count();
531 aMessage.WriteL(TInt(2),pckg);
536 TBool CMMFDevSoundSession::DoGetSupportedOutputDataTypesL(const RMmfIpcMessage& aMessage)
540 TMMFPrioritySettingsPckg buf;
541 aMessage.ReadL(TInt(0),buf);
542 TMMFPrioritySettings prioritySet = buf();
544 iBody->GetSupportedOutputDataTypesL(iArray, prioritySet);
547 pckg() = iArray.Count();
548 aMessage.WriteL(TInt(2),pckg);
553 TBool CMMFDevSoundSession::DoSamplesRecordedL(const RMmfIpcMessage& aMessage)
556 pckg() = iBody->SamplesRecorded();
557 aMessage.WriteL(TInt(2),pckg);
561 TBool CMMFDevSoundSession::DoSamplesPlayedL(const RMmfIpcMessage& aMessage)
564 pckg() = iBody->SamplesPlayed();
565 aMessage.WriteL(TInt(2),pckg);
569 TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage)
571 TPckgBuf<TInt> countRepeat;
572 aMessage.ReadL(TInt(0),countRepeat);
574 TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
575 aMessage.ReadL(TInt(1),repeatTS);
577 iBody->SetToneRepeats(countRepeat(), repeatTS());
581 TBool CMMFDevSoundSession::DoSetPrioritySettingsL(const RMmfIpcMessage& aMessage)
583 TPckgBuf<TMMFPrioritySettings> prioritySet;
584 aMessage.ReadL(TInt(0),prioritySet);
586 iBody->SetPrioritySettings(prioritySet());
590 TBool CMMFDevSoundSession::DoFixedSequenceNameL(const RMmfIpcMessage& aMessage)
592 TPckgBuf<TInt> seqNum;
593 aMessage.ReadL(0, seqNum);
594 aMessage.WriteL(2, iBody->FixedSequenceName(seqNum()).Left(KMaxFixedSequenceNameLength));
598 TBool CMMFDevSoundSession::DoConvertInitL(const RMmfIpcMessage& /*aMessage*/)
600 iBody->ConvertInitL();
604 TBool CMMFDevSoundSession::DoConvertDataL(const RMmfIpcMessage& /*aMessage*/)
606 iBody->ConvertData();
610 TBool CMMFDevSoundSession::DoFixedSequenceCountL(const RMmfIpcMessage& aMessage)
612 TPckgBuf<TInt> fixSeqCountPckg;
613 TInt fixSeqCount = iBody->FixedSequenceCount();
614 fixSeqCountPckg = fixSeqCount;
616 aMessage.WriteL(TInt(0),fixSeqCountPckg);
621 TBool CMMFDevSoundSession::DoCopyFourCCArrayDataL(const RMmfIpcMessage& aMessage)
623 const TInt KBufExpandSize8 = 8;//two TInts
624 CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8);
625 CleanupStack::PushL(dataCopyBuffer);
626 RBufWriteStream stream;
627 stream.Open(*dataCopyBuffer);
628 CleanupClosePushL(stream);
629 for (TInt i=0;i<iArray.Count();i++)
631 stream.WriteInt32L(iArray[i].FourCC());
633 aMessage.WriteL(TInt(2), dataCopyBuffer->Ptr(0));
635 CleanupStack::PopAndDestroy(2);//iDataCopyBuffer, stream
640 TBool CMMFDevSoundSession::DoGetRecordedBufferL(const RMmfIpcMessage& aMessage)
642 MmfMessageUtil::Write(aMessage, TInt(0), iBufferRecord->Data());
647 TBool CMMFDevSoundSession::DoInitializeCompleteEventL(const RMmfIpcMessage& aMessage)
654 iICMessage = new (ELeave) RMmfIpcMessage(aMessage);
658 TBool CMMFDevSoundSession::DoCancelInitializeCompleteEventL(const RMmfIpcMessage& /*aMessage*/)
661 iICMessage->Complete(KErrCancel);
666 TBool CMMFDevSoundSession::DoBufferToBeFilledEventL(const RMmfIpcMessage& aMessage)
673 iBTBFMessage = new (ELeave) RMmfIpcMessage(aMessage);
677 TBool CMMFDevSoundSession::DoCancelBufferToBeFilledEventL(const RMmfIpcMessage& /*aMessage*/)
680 iBTBFMessage->Complete(KErrCancel);
684 TBool CMMFDevSoundSession::DoBufferToBeEmptiedEventL(const RMmfIpcMessage& aMessage)
691 iBTBEMessage = new (ELeave) RMmfIpcMessage(aMessage);
695 TBool CMMFDevSoundSession::DoCancelBufferToBeEmptiedEventL(const RMmfIpcMessage& /*aMessage*/)
698 iBTBEMessage->Complete(KErrCancel);
702 TBool CMMFDevSoundSession::DoPlayErrorEventL(const RMmfIpcMessage& aMessage)
709 iPEMessage = new (ELeave) RMmfIpcMessage(aMessage);
713 TBool CMMFDevSoundSession::DoCancelPlayErrorEventL(const RMmfIpcMessage& /*aMessage*/)
716 iPEMessage->Complete(KErrCancel);
720 TBool CMMFDevSoundSession::DoRecordErrorEventL(const RMmfIpcMessage& aMessage)
727 iREMessage = new (ELeave) RMmfIpcMessage(aMessage);
731 TBool CMMFDevSoundSession::DoCancelRecordErrorEventL(const RMmfIpcMessage& /*aMessage*/)
734 iREMessage->Complete(KErrCancel);
738 TBool CMMFDevSoundSession::DoToneFinishedEventL(const RMmfIpcMessage& aMessage)
745 iTFMessage = new (ELeave) RMmfIpcMessage(aMessage);
749 TBool CMMFDevSoundSession::DoCancelToneFinishedEventL(const RMmfIpcMessage& /*aMessage*/)
752 iTFMessage->Complete(KErrCancel);
756 TBool CMMFDevSoundSession::DoSendEventToClientEventL(const RMmfIpcMessage& aMessage)
763 iSETCMessage = new (ELeave) RMmfIpcMessage(aMessage);
767 TBool CMMFDevSoundSession::DoCancelSendEventToClientEventL(const RMmfIpcMessage& /*aMessage*/)
770 iSETCMessage->Complete(KErrCancel);
774 TBool CMMFDevSoundSession::DoRegisterAsClientL(const RMmfIpcMessage& aMessage)
776 TMMFDevSoundProxySettingsPckg buf;
777 aMessage.ReadL(0,buf);
778 HBufC8* notificationRegistrationData = NULL;
779 notificationRegistrationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLengthL(1)));
780 TPtr8 dataPtr(notificationRegistrationData->Des());
781 aMessage.ReadL(1,dataPtr);
783 err = iBody->RegisterAsClient(buf().iNotificationEventUid,dataPtr);
784 CleanupStack::PopAndDestroy(1); // Notification Registeration data
787 aMessage.Complete(err);
793 TBool CMMFDevSoundSession::DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage)
795 TMMFDevSoundProxySettingsPckg buf;
796 aMessage.ReadL(0,buf);
798 err = iBody->CancelRegisterAsClient(buf().iNotificationEventUid);
801 aMessage.Complete(err);
807 TBool CMMFDevSoundSession::DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage)
809 TMMFDevSoundProxySettingsPckg buf;
810 aMessage.ReadL(0,buf);
811 HBufC8* notificationData = NULL;
812 notificationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesMaxLengthL(2)));
813 TPtr8 dataPtr(notificationData->Des());
814 aMessage.ReadL(2,dataPtr);
816 err = iBody->GetResourceNotificationData(buf().iNotificationEventUid,dataPtr);
817 aMessage.WriteL(2,*notificationData);
818 CleanupStack::PopAndDestroy(1); // Notification data
821 aMessage.Complete(err);
827 TBool CMMFDevSoundSession::DoWillResumePlayL(const RMmfIpcMessage& aMessage)
830 if(CheckClientCapabilities())
832 err = iBody->WillResumePlay();
836 err = KErrPermissionDenied;
841 aMessage.Complete(err);
847 TBool CMMFDevSoundSession::DoSetClientThreadInfoL(const RMmfIpcMessage& aMessage)
849 if (aMessage.HasCapability(ECapabilityMultimediaDD))
851 TPckgBuf<TThreadId> threadId;
852 aMessage.ReadL(0, threadId);
854 CMMFDevSoundServer* server =
855 const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
856 server->SetClientCapabilitiesL(threadId());
857 iClientHasCaps = server->CheckClientCapabilities();
861 User::Leave(KErrPermissionDenied);
867 void CMMFDevSoundSession::SendEventToClient(/*TMMFAudioPolicyEvent& aEvent*/)
874 * Default Constructor.
878 CMMFDevSoundSession::CMMFDevSoundSession()
882 CMMFDevSoundSession::~CMMFDevSoundSession()
896 CMMFDevSoundServer* server =
897 const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
900 server->DecrementSessionId();
905 * -doxygen comments moved to header-
907 * Constructs, and returns a pointer to, a new CMMFDevSoundProxy object.
912 CMMFDevSoundSession* CMMFDevSoundSession::NewL(RServer2& aPolicyServerHandle)
914 CMMFDevSoundSession* self = new (ELeave) CMMFDevSoundSessionXtnd;
915 CleanupStack::PushL(self);
916 self->ConstructL(aPolicyServerHandle);
922 * -doxygen comments moved to header-
924 * Second phase constructor.
927 void CMMFDevSoundSession::ConstructL(RServer2& aPolicyServerHandle)
929 iBody = CMMFDevSoundSvrImp::NewL(static_cast<CMMFDevSoundSessionXtnd*>(this));
930 iBody->Construct3L(aPolicyServerHandle);
934 void CMMFDevSoundSession::InitializeComplete(TInt aError)
938 iICMessage->Complete(aError);
944 void CMMFDevSoundSession::ToneFinished(TInt aError)
946 iTFMessage->Complete(aError);
951 void CMMFDevSoundSession::BufferToBeFilled(CMMFBuffer* aBuffer)
953 /* store here "aBuffer" to be used later with PlayData*/
954 iBufferPlay = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
956 TMMFDevSoundProxyHwBuf set;
957 set.iBufferType = iBufferPlay->Type();
958 set.iRequestSize = iBufferPlay->RequestSize();
959 set.iBufferSize = iBufferPlay->Data().MaxLength();
960 set.iLastBuffer = iBufferPlay->LastBuffer();
961 TMMFDevSoundProxyHwBufPckg pckg(set);
962 TInt err = MmfMessageUtil::Write(*iBTBFMessage, 0, pckg);
963 iBTBFMessage->Complete(err);
968 void CMMFDevSoundSession::PlayError(TInt aError)
972 iPEMessage->Complete(aError);
978 // need to send message but for some reason nobody to send to - just swallow
983 void CMMFDevSoundSession::BufferToBeEmptied(CMMFBuffer* aBuffer)
985 iBufferRecord = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
987 TMMFDevSoundProxyHwBuf set;
988 set.iBufferType = iBufferRecord->Type();
989 set.iRequestSize = iBufferRecord->RequestSize();
990 set.iBufferSize = iBufferRecord->Data().MaxLength();
991 set.iLastBuffer = iBufferRecord->LastBuffer();
992 TMMFDevSoundProxyHwBufPckg pckg(set);
993 TInt err = MmfMessageUtil::Write(*iBTBEMessage, 0, pckg);
994 iBTBEMessage->Complete(err);
999 void CMMFDevSoundSession::RecordError(TInt aError)
1001 iREMessage->Complete(aError);
1006 void CMMFDevSoundSession::ConvertError(TInt /*aError*/)
1009 void CMMFDevSoundSession::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
1013 void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent)
1015 TMMFEventPckg iEventPckg(aEvent);
1016 TInt err = MmfMessageUtil::Write(*iSETCMessage, 0, iEventPckg);
1017 iSETCMessage->Complete(err);
1018 delete iSETCMessage;
1019 iSETCMessage = NULL;
1022 /********************************************************************************
1023 * Non Exported public functions begins here *
1024 ********************************************************************************/
1027 // Audio Policy specific implementation begins here //
1032 * Sets Id for this instance of DevSound
1034 * @param "TInt aDevSoundId"
1035 * Integer value assigned by Audio Policy Server
1038 void CMMFDevSoundSessionXtnd::SetDevSoundId(TInt aDevSoundId)
1040 iBody->SetDevSoundId(aDevSoundId);
1045 * Returns information about this DevSound instance.
1047 * This method is used by Audio Policy Server to make audio policy decisions.
1049 * @return "TMMFDevSoundinfo"
1050 * A reference to TMMFDevSoundinfo object holding the current settings
1051 * of this DevSound instance.
1054 TMMFDevSoundInfo CMMFDevSoundSessionXtnd::DevSoundInfo()
1056 return iBody->DevSoundInfo();
1061 * Called by Audio Policy Server when a request to play is approved by the
1062 * Audio Policy Server.
1064 * Leaves on failure.
1067 void CMMFDevSoundSessionXtnd::StartPlayDataL()
1069 iBody->StartPlayDataL();
1074 * Called by Audio Policy Server when a request to record is approved by the
1075 * Audio Policy Server.
1077 * Leaves on failure.
1080 void CMMFDevSoundSessionXtnd::StartRecordDataL()
1082 iBody->StartRecordDataL();
1087 * Called by Audio Policy Server when a request to play tone is approved by
1088 * the Audio Policy Server.
1090 * Leaves on failure.
1093 void CMMFDevSoundSessionXtnd::StartPlayToneL()
1095 iBody->StartPlayToneL();
1100 * Called by Audio Policy Server when a request to play a dual tone is approved by
1101 * the Audio Policy Server.
1104 void CMMFDevSoundSessionXtnd::StartPlayDualToneL()
1106 iBody->StartPlayDualToneL();
1111 * Called by Audio Policy Server when a request to play DTMF String is approved
1112 * by the Audio Policy Server.
1114 * Leaves on failure.
1117 void CMMFDevSoundSessionXtnd::StartPlayDTMFStringL()
1119 iBody->StartPlayDTMFStringL();
1124 * Called by Audio Policy Server when a request to play tone sequence is
1125 * approved by the Audio Policy Server.
1127 * Leaves on failure.
1130 void CMMFDevSoundSessionXtnd::StartPlayToneSequenceL()
1132 iBody->StartPlayToneSequenceL();
1137 * Called by Audio Policy Server when the current DevSound instance looses the
1138 * policy because of another instance with a higher priority wants the device.
1141 void CMMFDevSoundSessionXtnd::SendEvent(const TMMFEvent& aEvent)
1143 iBody->SendEventToClient(aEvent);
1148 // Audio Policy specific implementation begins here //
1153 * Updates the total bytes played.
1156 void CMMFDevSoundSessionXtnd::UpdateBytesPlayed()
1158 iBody->UpdateBytesPlayed();