os/mm/devsound/devsoundrefplugin/src/platsec/server/AudioServer/MmfDevSoundSession.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/devsoundrefplugin/src/platsec/server/AudioServer/MmfDevSoundSession.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1351 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <s32mem.h>
1.20 +#include "MmfDevSoundSession.h"
1.21 +#include "MmfDevSoundSessionXtnd.h"
1.22 +#include "MmfDevSoundSessionBody.h"
1.23 +
1.24 +#include "MmfAudioClientServer.h"
1.25 +#include "MmfAudioServer.h"
1.26 +#include "MmfDevSoundServer.h"
1.27 +
1.28 +void CMMFDevSoundSession::CreateL(const CMmfIpcServer& aServer)
1.29 + {
1.30 + CMmfIpcSession::CreateL(aServer);
1.31 + CMMFDevSoundServer& server =
1.32 + const_cast<CMMFDevSoundServer&>(static_cast<const CMMFDevSoundServer&>(aServer));
1.33 + server.IncrementSessionId();
1.34 + iDevSoundSessionId = server.DevSoundSessionId();
1.35 + iClientHasCaps = server.CheckClientCapabilities();
1.36 + }
1.37 +
1.38 +TBool CMMFDevSoundSession::CheckClientCapabilities()
1.39 + {
1.40 + return iClientHasCaps;
1.41 + }
1.42 +
1.43 +void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage)
1.44 + {
1.45 + TBool complete = EFalse;
1.46 + switch(aMessage.Function())
1.47 + {
1.48 + case EMMFDevSoundProxyInitialize1:
1.49 + complete = DoInitialize1L(aMessage);
1.50 + break;
1.51 + case EMMFDevSoundProxyInitialize2:
1.52 + complete = DoInitialize2L(aMessage);
1.53 + break;
1.54 + case EMMFDevSoundProxyInitialize3:
1.55 + complete = DoInitialize3L(aMessage);
1.56 + break;
1.57 + case EMMFDevSoundProxyInitialize4:
1.58 + complete = DoInitialize4L(aMessage);
1.59 + break;
1.60 + case EMMFDevSoundProxyCapabilities:
1.61 + complete = DoCapabilitiesL(aMessage);
1.62 + break;
1.63 + case EMMFDevSoundProxyConfig:
1.64 + complete = DoConfigL(aMessage);
1.65 + break;
1.66 + case EMMFDevSoundProxySetConfig:
1.67 + complete = DoSetConfigL(aMessage);
1.68 + break;
1.69 + case EMMFDevSoundProxyMaxVolume:
1.70 + complete = DoMaxVolumeL(aMessage);
1.71 + break;
1.72 + case EMMFDevSoundProxyVolume:
1.73 + complete = DoVolumeL(aMessage);
1.74 + break;
1.75 + case EMMFDevSoundProxySetVolume:
1.76 + complete = DoSetVolumeL(aMessage);
1.77 + break;
1.78 + case EMMFDevSoundProxyMaxGain:
1.79 + complete = DoMaxGainL(aMessage);
1.80 + break;
1.81 + case EMMFDevSoundProxyGain:
1.82 + complete = DoGainL(aMessage);
1.83 + break;
1.84 + case EMMFDevSoundProxySetGain:
1.85 + complete = DoSetGainL(aMessage);
1.86 + break;
1.87 + case EMMFDevSoundProxyPlayBalance:
1.88 + complete = DoGetPlayBalanceL(aMessage);
1.89 + break;
1.90 + case EMMFDevSoundProxySetPlayBalance:
1.91 + complete = DoSetPlayBalanceL(aMessage);
1.92 + break;
1.93 + case EMMFDevSoundProxyRecordBalance:
1.94 + complete = DoGetRecordBalanceL(aMessage);
1.95 + break;
1.96 + case EMMFDevSoundProxySetRecordBalance:
1.97 + complete = DoSetRecordBalanceL(aMessage);
1.98 + break;
1.99 + case EMMFDevSoundProxyBTBFData:
1.100 + complete = DoBufferToBeFilledDataL(aMessage);
1.101 + break;
1.102 + case EMMFDevSoundProxyBTBEData:
1.103 + complete = DoBufferToBeEmptiedDataL(aMessage);
1.104 + break;
1.105 + case EMMFDevSoundProxyPlayInit:
1.106 + complete = DoPlayInitL(aMessage);
1.107 + break;
1.108 + case EMMFDevSoundProxyRecordInit:
1.109 + complete = DoRecordInitL(aMessage);
1.110 + break;
1.111 + case EMMFDevSoundProxyPlayData:
1.112 + complete = DoPlayDataL(aMessage);
1.113 + break;
1.114 + case EMMFDevSoundProxyRecordData:
1.115 + complete = DoRecordDataL(aMessage);
1.116 + break;
1.117 + case EMMFDevSoundProxyStop:
1.118 + complete = DoStopL(aMessage);
1.119 + break;
1.120 + case EMMFDevSoundProxyPause:
1.121 + complete = DoPauseL(aMessage);
1.122 + break;
1.123 + case EMMFDevSoundProxyPlayTone:
1.124 + complete = DoPlayToneL(aMessage);
1.125 + break;
1.126 + case EMMFDevSoundProxyPlayDualTone:
1.127 + complete = DoPlayDualToneL(aMessage);
1.128 + break;
1.129 + case EMMFDevSoundProxyPlayDTMFString:
1.130 + complete = DoPlayDTMFStringL(aMessage);
1.131 + break;
1.132 + case EMMFDevSoundProxyPlayToneSequence:
1.133 + complete = DoPlayToneSequenceL(aMessage);
1.134 + break;
1.135 + case EMMFDevSoundProxyPlayFixedSequence:
1.136 + complete = DoPlayFixedSequenceL(aMessage);
1.137 + break;
1.138 + case EMMFDevSoundProxySetDTMFLengths:
1.139 + complete = DoSetDTMFLengthsL(aMessage);
1.140 + break;
1.141 + case EMMFDevSoundProxySetVolumeRamp:
1.142 + complete = DoSetVolumeRampL(aMessage);
1.143 + break;
1.144 + case EMMFDevSoundProxyGetSupportedInputDataTypes:
1.145 + complete = DoGetSupportedInputDataTypesL(aMessage);
1.146 + break;
1.147 + case EMMFDevSoundProxyGetSupportedOutputDataTypes:
1.148 + complete = DoGetSupportedOutputDataTypesL(aMessage);
1.149 + break;
1.150 + case EMMFDevSoundProxyCopyFourCCArrayData:
1.151 + complete = DoCopyFourCCArrayDataL(aMessage);
1.152 + break;
1.153 + case EMMFDevSoundProxyGetRecordedBuffer:
1.154 + complete = DoGetRecordedBufferL(aMessage);
1.155 + break;
1.156 + case EMMFDevSoundProxySamplesRecorded:
1.157 + complete = DoSamplesRecordedL(aMessage);
1.158 + break;
1.159 + case EMMFDevSoundProxySamplesPlayed:
1.160 + complete = DoSamplesPlayedL(aMessage);
1.161 + break;
1.162 + case EMMFDevSoundProxySetToneRepeats:
1.163 + complete = DoSetToneRepeatsL(aMessage);
1.164 + break;
1.165 + case EMMFDevSoundProxySetPrioritySettings:
1.166 + complete = DoSetPrioritySettingsL(aMessage);
1.167 + break;
1.168 + case EMMFDevSoundProxyFixedSequenceName:
1.169 + complete = DoFixedSequenceNameL(aMessage);
1.170 + break;
1.171 + case EMMFDevSoundProxyFixedSequenceCount:
1.172 + complete = DoFixedSequenceCountL(aMessage);
1.173 + break;
1.174 + case EMMFDevSoundProxyRequestResourceNotification:
1.175 + complete = DoRegisterAsClientL(aMessage);
1.176 + break;
1.177 + case EMMFDevSoundProxyCancelRequestResourceNotification:
1.178 + complete = DoCancelRegisterAsClientL(aMessage);
1.179 + break;
1.180 + case EMMFDevSoundProxyGetResourceNotificationData:
1.181 + complete = DoGetResourceNotificationDataL(aMessage);
1.182 + break;
1.183 + case EMMFDevSoundProxyWillResumePlay:
1.184 + complete = DoWillResumePlayL(aMessage);
1.185 + break;
1.186 + case EMMFDevSoundProxySetClientThreadInfo:
1.187 + complete = DoSetClientThreadInfoL(aMessage);
1.188 + break;
1.189 + case EMMFDevSoundProxyGetTimePlayed:
1.190 + complete = DoGetTimePlayedL(aMessage);
1.191 + break;
1.192 +
1.193 + // custom command support
1.194 + case EMMFDevSoundProxySyncCustomCommand:
1.195 + complete = DoSyncCustomCommandL(aMessage);
1.196 + break;
1.197 + case EMMFDevSoundProxySyncCustomCommandResult:
1.198 + complete = DoSyncCustomCommandResultL(aMessage);
1.199 + break;
1.200 + case EMMFDevSoundProxyAsyncCustomCommand:
1.201 + complete = DoAsyncCustomCommandL(aMessage);
1.202 + break;
1.203 + case EMMFDevSoundProxyAsyncCustomCommandResult:
1.204 + complete = DoAsyncCustomCommandResultL(aMessage);
1.205 + break;
1.206 + case EMMFDevSoundProxyEmptyBuffers:
1.207 + complete = DoEmptyBuffersL(aMessage);
1.208 + break;
1.209 + default:
1.210 + User::Leave(KErrNotSupported);
1.211 + break;
1.212 + }
1.213 + if (complete)
1.214 + aMessage.Complete(KErrNone);
1.215 + }
1.216 +
1.217 +TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage)
1.218 + {
1.219 + if(iMsgQueue.Handle() == 0)
1.220 + {
1.221 + TInt err = iMsgQueue.Open(aMessage, 1); // a global queue.
1.222 + User::LeaveIfError(err);
1.223 + }
1.224 + TMMFDevSoundProxySettingsPckg buf;
1.225 + MmfMessageUtil::ReadL(aMessage,0,buf);
1.226 + TMMFState mode = buf().iMode;
1.227 + iBody->InitializeL(*this, mode);
1.228 + iBufferPlay = NULL;
1.229 + return ETrue;
1.230 + }
1.231 +
1.232 +TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage)
1.233 + {
1.234 + if(iMsgQueue.Handle() == 0)
1.235 + {
1.236 + TInt err = iMsgQueue.Open(aMessage, 1); // a global queue.
1.237 + User::LeaveIfError(err);
1.238 + }
1.239 + TMMFDevSoundProxySettingsPckg buf;
1.240 + MmfMessageUtil::ReadL(aMessage,0,buf);
1.241 + TUid HWDev = buf().iHWDev;
1.242 + TMMFState mode = buf().iMode;
1.243 + iBody->InitializeL(*this, HWDev, mode);
1.244 + iBufferPlay = NULL;
1.245 + return ETrue;
1.246 + }
1.247 +
1.248 +TBool CMMFDevSoundSession::DoInitialize3L(const RMmfIpcMessage& /*aMessage*/)
1.249 + {
1.250 + User::Leave(KErrNotSupported);
1.251 + return ETrue;
1.252 + }
1.253 +
1.254 +TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage)
1.255 + {
1.256 + if(iMsgQueue.Handle() == 0)
1.257 + {
1.258 + TInt err = iMsgQueue.Open(aMessage, 1); // a global queue.
1.259 + User::LeaveIfError(err);
1.260 + }
1.261 + TMMFDevSoundProxySettingsPckg buf;
1.262 + aMessage.ReadL(TInt(0),buf);
1.263 + TFourCC desiredFourCC = buf().iDesiredFourCC;
1.264 + TMMFState mode = buf().iMode;
1.265 + iBody->InitializeL(*this, desiredFourCC, mode);
1.266 + iBufferPlay = NULL;
1.267 + return ETrue;
1.268 + }
1.269 +
1.270 +TBool CMMFDevSoundSession::DoCapabilitiesL(const RMmfIpcMessage& aMessage)
1.271 + {
1.272 + TMMFDevSoundProxySettings set;
1.273 + set.iCaps = iBody->Capabilities();
1.274 + TMMFDevSoundProxySettingsPckg pckg(set);
1.275 + aMessage.WriteL(TInt(2),pckg);
1.276 + return ETrue;
1.277 + }
1.278 +
1.279 +TBool CMMFDevSoundSession::DoConfigL(const RMmfIpcMessage& aMessage)
1.280 + {
1.281 + TMMFDevSoundProxySettings set;
1.282 + set.iConfig = iBody->Config();
1.283 + TMMFDevSoundProxySettingsPckg pckg(set);
1.284 + aMessage.WriteL(TInt(2),pckg);
1.285 + return ETrue;
1.286 + }
1.287 +
1.288 +TBool CMMFDevSoundSession::DoSetConfigL(const RMmfIpcMessage& aMessage)
1.289 + {
1.290 + TMMFDevSoundProxySettingsPckg buf;
1.291 + aMessage.ReadL(TInt(0),buf);
1.292 + TMMFCapabilities config = buf().iConfig;
1.293 + iBody->SetConfigL(config);
1.294 + return ETrue;
1.295 + }
1.296 +
1.297 +TBool CMMFDevSoundSession::DoMaxVolumeL(const RMmfIpcMessage& aMessage)
1.298 + {
1.299 + TMMFDevSoundProxySettings set;
1.300 + set.iMaxVolume = iBody->MaxVolume();
1.301 + TMMFDevSoundProxySettingsPckg pckg(set);
1.302 + aMessage.WriteL(TInt(2),pckg);
1.303 + return ETrue;
1.304 + }
1.305 +
1.306 +TBool CMMFDevSoundSession::DoVolumeL(const RMmfIpcMessage& aMessage)
1.307 + {
1.308 + TMMFDevSoundProxySettings set;
1.309 + set.iVolume = iBody->Volume();
1.310 + TMMFDevSoundProxySettingsPckg pckg(set);
1.311 + aMessage.WriteL(TInt(2),pckg);
1.312 + return ETrue;
1.313 + }
1.314 +
1.315 +TBool CMMFDevSoundSession::DoSetVolumeL(const RMmfIpcMessage& aMessage)
1.316 + {
1.317 + TMMFDevSoundProxySettingsPckg buf;
1.318 + aMessage.ReadL(TInt(0),buf);
1.319 + TInt volume = buf().iVolume;
1.320 + iBody->SetVolume(volume);
1.321 + return ETrue;
1.322 + }
1.323 +
1.324 +TBool CMMFDevSoundSession::DoMaxGainL(const RMmfIpcMessage& aMessage)
1.325 + {
1.326 + TMMFDevSoundProxySettings set;
1.327 + set.iMaxGain = iBody->MaxGain();
1.328 + TMMFDevSoundProxySettingsPckg pckg(set);
1.329 + aMessage.WriteL(TInt(2),pckg);
1.330 + return ETrue;
1.331 + }
1.332 +
1.333 +TBool CMMFDevSoundSession::DoGainL(const RMmfIpcMessage& aMessage)
1.334 + {
1.335 + TMMFDevSoundProxySettings set;
1.336 + set.iGain = iBody->Gain();
1.337 + TMMFDevSoundProxySettingsPckg pckg(set);
1.338 + aMessage.WriteL(TInt(2),pckg);
1.339 + return ETrue;
1.340 + }
1.341 +
1.342 +TBool CMMFDevSoundSession::DoSetGainL(const RMmfIpcMessage& aMessage)
1.343 + {
1.344 + TMMFDevSoundProxySettingsPckg buf;
1.345 + aMessage.ReadL(TInt(0),buf);
1.346 + TInt gain = buf().iGain;
1.347 + iBody->SetGain(gain);
1.348 + return ETrue;
1.349 + }
1.350 +
1.351 +TBool CMMFDevSoundSession::DoGetPlayBalanceL(const RMmfIpcMessage& aMessage)
1.352 + {
1.353 + TMMFDevSoundProxySettings set;
1.354 + iBody->GetPlayBalanceL(set.iLeftPercentage, set.iRightPercentage);
1.355 + TMMFDevSoundProxySettingsPckg pckg(set);
1.356 + aMessage.WriteL(TInt(2),pckg);
1.357 + return ETrue;
1.358 + }
1.359 +
1.360 +TBool CMMFDevSoundSession::DoSetPlayBalanceL(const RMmfIpcMessage& aMessage)
1.361 + {
1.362 + TMMFDevSoundProxySettingsPckg buf;
1.363 + aMessage.ReadL(TInt(0),buf);
1.364 + TInt leftPercentage = buf().iLeftPercentage;
1.365 + TInt rightPercentage = buf().iRightPercentage;
1.366 + iBody->SetPlayBalanceL(leftPercentage, rightPercentage);
1.367 + return ETrue;
1.368 + }
1.369 +
1.370 +TBool CMMFDevSoundSession::DoGetRecordBalanceL(const RMmfIpcMessage& aMessage)
1.371 + {
1.372 + TMMFDevSoundProxySettings set;
1.373 + iBody->GetRecordBalanceL(set.iLeftPercentage, set.iRightPercentage);
1.374 + TMMFDevSoundProxySettingsPckg pckg(set);
1.375 + aMessage.WriteL(TInt(2),pckg);
1.376 + return ETrue;
1.377 + }
1.378 +
1.379 +TBool CMMFDevSoundSession::DoSetRecordBalanceL(const RMmfIpcMessage& aMessage)
1.380 + {
1.381 + TMMFDevSoundProxySettingsPckg buf;
1.382 + aMessage.ReadL(TInt(0),buf);
1.383 + TInt leftPercentage = buf().iLeftPercentage;
1.384 + TInt rightPercentage = buf().iRightPercentage;
1.385 + iBody->SetRecordBalanceL(leftPercentage, rightPercentage);
1.386 + return ETrue;
1.387 + }
1.388 +
1.389 +TBool CMMFDevSoundSession::DoPlayInitL(const RMmfIpcMessage& /*aMessage*/)
1.390 + {
1.391 + iBody->PlayInitL();
1.392 + return ETrue;
1.393 + }
1.394 +
1.395 +TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& aMessage)
1.396 + {
1.397 + iBody->RecordInitL(aMessage);
1.398 + return ETrue;
1.399 + }
1.400 +
1.401 +TBool CMMFDevSoundSession::DoPlayDataL(const RMmfIpcMessage& aMessage)
1.402 + {
1.403 + TMMFDevSoundProxyHwBufPckg buf;
1.404 + aMessage.ReadL(TInt(0),buf);
1.405 + iBufferPlay->SetLastBuffer(buf().iLastBuffer);
1.406 +
1.407 + aMessage.ReadL(TInt(1),iBufferPlay->Data());
1.408 + return iBody->PlayData(aMessage);
1.409 + }
1.410 +
1.411 +TBool CMMFDevSoundSession::DoRecordDataL(const RMmfIpcMessage& aMessage)
1.412 + {
1.413 + return iBody->RecordData(aMessage);
1.414 + }
1.415 +
1.416 +TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/)
1.417 + {
1.418 + if(iMsgQueue.Handle() != 0)
1.419 + {
1.420 + TMMFDevSoundQueueItem queueItem;
1.421 + TInt err = KErrNone;
1.422 + while(err != KErrUnderflow)
1.423 + {
1.424 + err = iMsgQueue.Receive(queueItem);
1.425 + }
1.426 + }
1.427 + iBody->Stop();
1.428 + return ETrue;
1.429 + }
1.430 +
1.431 +TBool CMMFDevSoundSession::DoPauseL(const RMmfIpcMessage& /*aMessage*/)
1.432 + {
1.433 + iBody->Pause();
1.434 + return ETrue;
1.435 + }
1.436 +
1.437 +TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage)
1.438 + {
1.439 + TMMFDevSoundProxySettingsPckg buf;
1.440 + aMessage.ReadL(TInt(0),buf);
1.441 + TInt frequency = buf().iFrequencyOne;
1.442 + TTimeIntervalMicroSeconds duration(buf().iDuration);
1.443 + iBody->PlayToneL(frequency, duration);
1.444 + return ETrue;
1.445 + }
1.446 +
1.447 +TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage)
1.448 + {
1.449 + TMMFDevSoundProxySettingsPckg buf;
1.450 + aMessage.ReadL(TInt(0),buf);
1.451 + TInt frequencyOne = buf().iFrequencyOne;
1.452 + TInt frequencyTwo = buf().iFrequencyTwo;
1.453 + TTimeIntervalMicroSeconds duration(buf().iDuration);
1.454 + iBody->PlayDualToneL(frequencyOne, frequencyTwo, duration);
1.455 + return ETrue;
1.456 + }
1.457 +
1.458 +TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage)
1.459 + {
1.460 + TInt DTMFLength = User::LeaveIfError(aMessage.GetDesLength(0));
1.461 +
1.462 + if(iDTMFString)
1.463 + {
1.464 + delete iDTMFString;
1.465 + iDTMFString = NULL;
1.466 + }
1.467 +
1.468 + iDTMFString = HBufC::NewL(DTMFLength);
1.469 + TPtr DTMFPtr = iDTMFString->Des();
1.470 + aMessage.ReadL(TInt(0), DTMFPtr);
1.471 +
1.472 + iBody->PlayDTMFStringL(*iDTMFString);
1.473 + return ETrue;
1.474 + }
1.475 +
1.476 +TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage)
1.477 + {
1.478 + TInt toneLength = User::LeaveIfError(aMessage.GetDesLength(0));
1.479 +
1.480 + if(iToneSeqBuf)
1.481 + {
1.482 + delete iToneSeqBuf;
1.483 + iToneSeqBuf = NULL;
1.484 + }
1.485 +
1.486 + iToneSeqBuf = HBufC8::NewL(toneLength);
1.487 + TPtr8 toneSeqPtr = iToneSeqBuf->Des();
1.488 + aMessage.ReadL(TInt(0), toneSeqPtr);
1.489 +
1.490 + iBody->PlayToneSequenceL(*iToneSeqBuf);
1.491 + return ETrue;
1.492 + }
1.493 +
1.494 +TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage)
1.495 + {
1.496 + TPckgBuf<TInt> buf;
1.497 + aMessage.ReadL(TInt(0),buf);
1.498 + TInt seqNum = buf();
1.499 +
1.500 + iBody->PlayFixedSequenceL(seqNum);
1.501 + return ETrue;
1.502 + }
1.503 +
1.504 +TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage)
1.505 + {
1.506 + TMMFDevSoundProxySettingsPckg buf;
1.507 + aMessage.ReadL(TInt(0),buf);
1.508 + TTimeIntervalMicroSeconds32 toneOnLength = buf().iToneOnLength;
1.509 + TTimeIntervalMicroSeconds32 toneOffLength = buf().iToneOffLength;
1.510 + TTimeIntervalMicroSeconds32 pauseLength = buf().iPauseLength;
1.511 + iBody->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength);
1.512 + return ETrue;
1.513 + }
1.514 +
1.515 +TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage)
1.516 + {
1.517 + TMMFDevSoundProxySettingsPckg buf;
1.518 + aMessage.ReadL(TInt(0),buf);
1.519 + TTimeIntervalMicroSeconds duration = buf().iDuration;
1.520 + iBody->SetVolumeRamp(duration);
1.521 + return ETrue;
1.522 + }
1.523 +
1.524 +TBool CMMFDevSoundSession::DoGetSupportedInputDataTypesL(const RMmfIpcMessage& aMessage)
1.525 + {
1.526 + iArray.Reset();
1.527 +
1.528 + TMMFPrioritySettingsPckg buf;
1.529 + aMessage.ReadL(TInt(0),buf);
1.530 + TMMFPrioritySettings prioritySet = buf();
1.531 +
1.532 + iBody->GetSupportedInputDataTypesL(iArray, prioritySet);
1.533 +
1.534 + TPckgBuf<TInt> pckg;
1.535 + pckg() = iArray.Count();
1.536 + aMessage.WriteL(TInt(2),pckg);
1.537 +
1.538 + return ETrue;
1.539 + }
1.540 +
1.541 +TBool CMMFDevSoundSession::DoGetSupportedOutputDataTypesL(const RMmfIpcMessage& aMessage)
1.542 + {
1.543 + iArray.Reset();
1.544 +
1.545 + TMMFPrioritySettingsPckg buf;
1.546 + aMessage.ReadL(TInt(0),buf);
1.547 + TMMFPrioritySettings prioritySet = buf();
1.548 +
1.549 + iBody->GetSupportedOutputDataTypesL(iArray, prioritySet);
1.550 +
1.551 + TPckgBuf<TInt> pckg;
1.552 + pckg() = iArray.Count();
1.553 + aMessage.WriteL(TInt(2),pckg);
1.554 +
1.555 + return ETrue;
1.556 + }
1.557 +
1.558 +TBool CMMFDevSoundSession::DoSamplesRecordedL(const RMmfIpcMessage& aMessage)
1.559 + {
1.560 + TPckgBuf<TInt> pckg;
1.561 + pckg() = iBody->SamplesRecorded();
1.562 + aMessage.WriteL(TInt(2),pckg);
1.563 + return ETrue;
1.564 + }
1.565 +
1.566 +TBool CMMFDevSoundSession::DoSamplesPlayedL(const RMmfIpcMessage& aMessage)
1.567 + {
1.568 + TPckgBuf<TInt> pckg;
1.569 + pckg() = iBody->SamplesPlayed();
1.570 + aMessage.WriteL(TInt(2),pckg);
1.571 + return ETrue;
1.572 + }
1.573 +
1.574 +TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage)
1.575 + {
1.576 + TPckgBuf<TInt> countRepeat;
1.577 + aMessage.ReadL(TInt(0),countRepeat);
1.578 +
1.579 + TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
1.580 + aMessage.ReadL(TInt(1),repeatTS);
1.581 +
1.582 + iBody->SetToneRepeats(countRepeat(), repeatTS());
1.583 + return ETrue;
1.584 + }
1.585 +
1.586 +TBool CMMFDevSoundSession::DoSetPrioritySettingsL(const RMmfIpcMessage& aMessage)
1.587 + {
1.588 + TPckgBuf<TMMFPrioritySettings> prioritySet;
1.589 + aMessage.ReadL(TInt(0),prioritySet);
1.590 +
1.591 + iBody->SetPrioritySettings(prioritySet());
1.592 + return ETrue;
1.593 + }
1.594 +
1.595 +TBool CMMFDevSoundSession::DoFixedSequenceNameL(const RMmfIpcMessage& aMessage)
1.596 + {
1.597 + TPckgBuf<TInt> seqNum;
1.598 + aMessage.ReadL(0, seqNum);
1.599 + aMessage.WriteL(2, iBody->FixedSequenceName(seqNum()).Left(KMaxFixedSequenceNameLength));
1.600 + return ETrue;
1.601 + }
1.602 +
1.603 +TBool CMMFDevSoundSession::DoFixedSequenceCountL(const RMmfIpcMessage& aMessage)
1.604 + {
1.605 + TPckgBuf<TInt> fixSeqCountPckg;
1.606 + TInt fixSeqCount = iBody->FixedSequenceCount();
1.607 + fixSeqCountPckg = fixSeqCount;
1.608 +
1.609 + aMessage.WriteL(TInt(0),fixSeqCountPckg);
1.610 + return ETrue;
1.611 + }
1.612 +
1.613 +
1.614 +TBool CMMFDevSoundSession::DoCopyFourCCArrayDataL(const RMmfIpcMessage& aMessage)
1.615 + {
1.616 + const TInt KBufExpandSize8 = 8;//two TInts
1.617 + CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8);
1.618 + CleanupStack::PushL(dataCopyBuffer);
1.619 + RBufWriteStream stream;
1.620 + stream.Open(*dataCopyBuffer);
1.621 + CleanupClosePushL(stream);
1.622 + for (TInt i=0;i<iArray.Count();i++)
1.623 + {
1.624 + stream.WriteInt32L(iArray[i].FourCC());
1.625 + }
1.626 + aMessage.WriteL(TInt(2), dataCopyBuffer->Ptr(0));
1.627 + CleanupStack::PopAndDestroy(2);//iDataCopyBuffer, stream
1.628 + return ETrue;
1.629 + }
1.630 +
1.631 +
1.632 +TBool CMMFDevSoundSession::DoGetRecordedBufferL(const RMmfIpcMessage& aMessage)
1.633 + {
1.634 + MmfMessageUtil::Write(aMessage, TInt(0), iBufferRecord->Data());
1.635 + return ETrue;
1.636 + }
1.637 +
1.638 +TBool CMMFDevSoundSession::DoBufferToBeFilledDataL(const RMmfIpcMessage& aMessage)
1.639 + {
1.640 + TInt err = MmfMessageUtil::Write(aMessage, 0, iHwBufPckgFill);
1.641 + aMessage.Complete(err);
1.642 + return EFalse;
1.643 + }
1.644 +
1.645 +TBool CMMFDevSoundSession::DoBufferToBeEmptiedDataL(const RMmfIpcMessage& aMessage)
1.646 + {
1.647 + TInt err = MmfMessageUtil::Write(aMessage, 0, iHwBufPckgEmpty);
1.648 + aMessage.Complete(err);
1.649 + return EFalse;
1.650 + }
1.651 +
1.652 +TBool CMMFDevSoundSession::DoRegisterAsClientL(const RMmfIpcMessage& aMessage)
1.653 + {
1.654 + TMMFDevSoundProxySettingsPckg buf;
1.655 + aMessage.ReadL(0,buf);
1.656 + HBufC8* notificationRegistrationData = NULL;
1.657 + notificationRegistrationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLengthL(1)));
1.658 + TPtr8 dataPtr(notificationRegistrationData->Des());
1.659 + aMessage.ReadL(1,dataPtr);
1.660 + TInt err = KErrNone;
1.661 + err = iBody->RegisterAsClient(buf().iNotificationEventUid,dataPtr);
1.662 + CleanupStack::PopAndDestroy(1); // Notification Registeration data
1.663 + if (err != KErrNone)
1.664 + {
1.665 + aMessage.Complete(err);
1.666 + return EFalse;
1.667 + }
1.668 + return ETrue;
1.669 + }
1.670 +
1.671 +TBool CMMFDevSoundSession::DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage)
1.672 + {
1.673 + TMMFDevSoundProxySettingsPckg buf;
1.674 + aMessage.ReadL(0,buf);
1.675 + TInt err = KErrNone;
1.676 + err = iBody->CancelRegisterAsClient(buf().iNotificationEventUid);
1.677 + if (err != KErrNone)
1.678 + {
1.679 + aMessage.Complete(err);
1.680 + return EFalse;
1.681 + }
1.682 + return ETrue;
1.683 + }
1.684 +
1.685 +TBool CMMFDevSoundSession::DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage)
1.686 + {
1.687 + TMMFDevSoundProxySettingsPckg buf;
1.688 + aMessage.ReadL(0,buf);
1.689 + HBufC8* notificationData = NULL;
1.690 + notificationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesMaxLengthL(2)));
1.691 + TPtr8 dataPtr(notificationData->Des());
1.692 + aMessage.ReadL(2,dataPtr);
1.693 + TInt err = KErrNone;
1.694 + err = iBody->GetResourceNotificationData(buf().iNotificationEventUid,dataPtr);
1.695 + aMessage.WriteL(2,*notificationData);
1.696 + CleanupStack::PopAndDestroy(1); // Notification data
1.697 + if (err != KErrNone)
1.698 + {
1.699 + aMessage.Complete(err);
1.700 + return EFalse;
1.701 + }
1.702 + return ETrue;
1.703 + }
1.704 +
1.705 +TBool CMMFDevSoundSession::DoWillResumePlayL(const RMmfIpcMessage& aMessage)
1.706 + {
1.707 + TInt err = KErrNone;
1.708 + if(CheckClientCapabilities())
1.709 + {
1.710 + err = iBody->WillResumePlay();
1.711 + }
1.712 + else
1.713 + {
1.714 + err = KErrPermissionDenied;
1.715 + }
1.716 +
1.717 + if (err != KErrNone)
1.718 + {
1.719 + aMessage.Complete(err);
1.720 + return EFalse;
1.721 + }
1.722 + return ETrue;
1.723 + }
1.724 +
1.725 +TBool CMMFDevSoundSession::DoEmptyBuffersL(const RMmfIpcMessage& aMessage)
1.726 + {
1.727 + TInt err = KErrNone;
1.728 + err = iBody->EmptyBuffers();
1.729 + if (err != KErrNone)
1.730 + {
1.731 + aMessage.Complete(err);
1.732 + return EFalse;
1.733 + }
1.734 + return ETrue;
1.735 + }
1.736 +
1.737 +TBool CMMFDevSoundSession::DoSetClientThreadInfoL(const RMmfIpcMessage& aMessage)
1.738 + {
1.739 + if (aMessage.HasCapability(ECapabilityMultimediaDD))
1.740 + {
1.741 + TPckgBuf<TThreadId> threadId;
1.742 + aMessage.ReadL(0, threadId);
1.743 +
1.744 + CMMFDevSoundServer* server =
1.745 + const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
1.746 + server->SetClientCapabilitiesL(threadId());
1.747 + iClientHasCaps = server->CheckClientCapabilities();
1.748 + }
1.749 + else
1.750 + {
1.751 + User::Leave(KErrPermissionDenied);
1.752 + }
1.753 + return ETrue;
1.754 + }
1.755 +
1.756 +TBool CMMFDevSoundSession::DoGetTimePlayedL(const RMmfIpcMessage& aMessage)
1.757 + {
1.758 + TInt err = KErrNone;
1.759 + TPckgBuf<TTimeIntervalMicroSeconds> timePckg;
1.760 + err = iBody->GetTimePlayed(timePckg());
1.761 + if (err != KErrNone)
1.762 + {
1.763 + aMessage.Complete(err);
1.764 + return EFalse;
1.765 + }
1.766 + aMessage.WriteL(TInt(2),timePckg);
1.767 + return ETrue;
1.768 + }
1.769 +
1.770 +TBool CMMFDevSoundSession::DoSyncCustomCommandL(const RMmfIpcMessage& aMessage)
1.771 + {
1.772 + // check whether these are custom interface commands
1.773 + // if so then send them into the demux pipeline
1.774 + TInt retVal = KErrNone;
1.775 +
1.776 + // try and process this as a custom interface
1.777 + TRAPD(err, retVal = iDeMuxUtility->ProcessCustomInterfaceCommandL(aMessage));
1.778 + if (err == KErrNone)
1.779 + {
1.780 + // we can pass back valid values here since command
1.781 + // has been handled by the DeMux framework
1.782 + aMessage.Complete(retVal);
1.783 + }
1.784 + else if (err != KErrNotFound)
1.785 + {
1.786 + // the framework left with an error condition
1.787 + // so we complete the message with this error
1.788 + aMessage.Complete(err);
1.789 + }
1.790 + else
1.791 + {
1.792 + // commmand was not found inside the Custom Interface framework
1.793 + // so we can pass onto the DevSound server implementation
1.794 + // assume that this will either leave or complete the message
1.795 + iBody->DoSyncCustomCommandL(aMessage);
1.796 + }
1.797 +
1.798 + // we complete our own message so don't need the framework to do so
1.799 + return EFalse;
1.800 + }
1.801 +
1.802 +TBool CMMFDevSoundSession::DoSyncCustomCommandResultL(const RMmfIpcMessage& aMessage)
1.803 + {
1.804 + // check whether these are custom interface commands
1.805 + TInt retVal = KErrNone;
1.806 + TRAPD(err, retVal = iDeMuxUtility->ProcessCustomInterfaceCommandL(aMessage));
1.807 + if (err == KErrNone)
1.808 + {
1.809 + // we can pass back valid values here since command
1.810 + // has been handled by the DeMux framework
1.811 + aMessage.Complete(retVal);
1.812 + }
1.813 + else if (err != KErrNotFound)
1.814 + {
1.815 + // the framework left with an error condition
1.816 + // so we complete the message with this error
1.817 + aMessage.Complete(err);
1.818 + }
1.819 + else
1.820 + {
1.821 + // commmand was not found inside the Custom Interface framework
1.822 + // so we can pass onto the DevSound server implementation
1.823 + // assume that this will either leave or complete the message
1.824 + iBody->DoSyncCustomCommandResultL(aMessage);
1.825 + }
1.826 + // we complete our own message so don't need the framework to do so
1.827 + return EFalse;
1.828 + }
1.829 +
1.830 +TBool CMMFDevSoundSession::DoAsyncCustomCommandL(const RMmfIpcMessage& aMessage)
1.831 + {
1.832 + // check whether these are custom interface commands
1.833 + // async message will complete later
1.834 + TRAPD(err, iDeMuxUtility->ProcessCustomInterfaceCommandL(aMessage));
1.835 + if ((err != KErrNotFound) && (err != KErrNone))
1.836 + {
1.837 + // the framework left with an error condition
1.838 + // so we complete the message with this error
1.839 + aMessage.Complete(err);
1.840 + }
1.841 + else if (err == KErrNotFound)
1.842 + {
1.843 + // commmand was not found inside the Custom Interface framework
1.844 + // so we can pass onto the DevSound server implementation
1.845 + // assume that this will either leave or complete the message
1.846 + iBody->DoAsyncCustomCommandL(aMessage);
1.847 + }
1.848 + return EFalse;
1.849 + }
1.850 +
1.851 +TBool CMMFDevSoundSession::DoAsyncCustomCommandResultL(const RMmfIpcMessage& aMessage)
1.852 + {
1.853 + // check whether these are custom interface commands
1.854 + // async message will complete later
1.855 + TRAPD(err, iDeMuxUtility->ProcessCustomInterfaceCommandL(aMessage));
1.856 + if ((err != KErrNotFound) && (err != KErrNone))
1.857 + {
1.858 + // the framework left with an error condition
1.859 + // so we complete the message with this error
1.860 + aMessage.Complete(err);
1.861 + }
1.862 + else if (err == KErrNotFound)
1.863 + {
1.864 + // commmand was not found inside the Custom Interface framework
1.865 + // so we can pass onto the DevSound server implementation
1.866 + // assume that this will either leave or complete the message
1.867 + iBody->DoAsyncCustomCommandL(aMessage);
1.868 + }
1.869 + return EFalse;
1.870 + }
1.871 +
1.872 +
1.873 +
1.874 +void CMMFDevSoundSession::SendEventToClient(/*TMMFAudioPolicyEvent& aEvent*/)
1.875 + {
1.876 + }
1.877 +
1.878 +
1.879 +/*
1.880 + *
1.881 + * Default Constructor.
1.882 + *
1.883 + *
1.884 + */
1.885 +CMMFDevSoundSession::CMMFDevSoundSession()
1.886 + {
1.887 + }
1.888 +
1.889 +CMMFDevSoundSession::~CMMFDevSoundSession()
1.890 + {
1.891 + // clear the array of custom interfaces
1.892 + for (TInt i = 0; i < iCustomInterfaceArray.Count(); i++)
1.893 + {
1.894 + // we could have already deleted interfaces without
1.895 + // removing them from the array so check for this
1.896 + // and only delete release plugin if non-null
1.897 + MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = iCustomInterfaceArray[i].iInterface;
1.898 + if (ptr)
1.899 + {
1.900 + iCustomInterfaceArray[i].iInterface->Release();
1.901 + }
1.902 + }
1.903 + iCustomInterfaceArray.Reset();
1.904 + iCustomInterfaceArray.Close();
1.905 +
1.906 + delete iDeMuxUtility;
1.907 +
1.908 + iMsgQueue.Close();
1.909 + iArray.Close();
1.910 + delete iDTMFString;
1.911 + delete iToneSeqBuf;
1.912 + delete iBody;
1.913 +
1.914 + CMMFDevSoundServer* server =
1.915 + const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
1.916 + if (server)
1.917 + {
1.918 + server->DecrementSessionId();
1.919 + }
1.920 + }
1.921 +
1.922 +/*
1.923 + * -doxygen comments moved to header-
1.924 + *
1.925 + * Constructs, and returns a pointer to, a new CMMFDevSoundProxy object.
1.926 + *
1.927 + * Leaves on failure.
1.928 + *
1.929 + */
1.930 +CMMFDevSoundSession* CMMFDevSoundSession::NewL(RServer2& aPolicyServerHandle)
1.931 + {
1.932 + CMMFDevSoundSession* self = new (ELeave) CMMFDevSoundSessionXtnd;
1.933 + CleanupStack::PushL(self);
1.934 + self->ConstructL(aPolicyServerHandle);
1.935 + CleanupStack::Pop();
1.936 + return self;
1.937 + }
1.938 +
1.939 +/*
1.940 + * -doxygen comments moved to header-
1.941 + *
1.942 + * Second phase constructor.
1.943 + *
1.944 + */
1.945 +void CMMFDevSoundSession::ConstructL(RServer2& aPolicyServerHandle)
1.946 + {
1.947 + iBody = CMMFDevSoundSvrImp::NewL(static_cast<CMMFDevSoundSessionXtnd*>(this));
1.948 + iBody->Construct3L(aPolicyServerHandle);
1.949 +
1.950 + iDeMuxUtility = CMMFDevSoundCIDeMuxUtility::NewL(this);
1.951 + }
1.952 +
1.953 +//callbacks
1.954 +void CMMFDevSoundSession::InitializeComplete(TInt aError)
1.955 + {
1.956 + // this may be a re-initialization and so we need to
1.957 + // re-get our custom interfaces on the DeMux plugins
1.958 + for (TInt i = 0; i < iCustomInterfaceArray.Count(); i++)
1.959 + {
1.960 + // we could have already deleted interfaces without
1.961 + // removing them from the array so check for this
1.962 + // and only delete release plugin if non-null
1.963 + MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = iCustomInterfaceArray[i].iInterface;
1.964 + if (ptr)
1.965 + {
1.966 + // we can't keep track of..
1.967 + // 1. where a custom interface is implemented
1.968 + // 2. the uid of the custom interface to be refreshed
1.969 + // so assume all have to be refreshed
1.970 + TRAPD(err, iCustomInterfaceArray[i].iInterface->RefreshL());
1.971 +
1.972 + // if there is an error then this is no longer a
1.973 + // valid interface so could be deleted this from the array
1.974 + // but this would involve notifying the client side
1.975 + //
1.976 + // since we have no way of notifying the client in this
1.977 + // implementation and the fact that this is a prototype
1.978 + // implementation and we will leave this up to the licensee
1.979 + // to implement as required
1.980 + if (err != KErrNone)
1.981 + {
1.982 + TMMFEvent event;
1.983 + TMMFDevSoundQueueItem item;
1.984 + item.iRequest = EMMFDevSoundCustomCommandCloseMuxDemuxPair;
1.985 + item.iErrorCode = err;
1.986 + event.iEventType.iUid = i+1;
1.987 + item.iEventPckg() = event;
1.988 + iMsgQueue.Send(item);
1.989 + }
1.990 + }
1.991 + }
1.992 +
1.993 + // The previous implementation was commented out,
1.994 + // so add a new commented out implementation :)
1.995 + TMMFDevSoundQueueItem item;
1.996 + item.iRequest = EMMFDevSoundProxyICEvent;
1.997 + item.iErrorCode = aError;
1.998 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.999 + }
1.1000 +
1.1001 +void CMMFDevSoundSession::ToneFinished(TInt aError)
1.1002 + {
1.1003 + TMMFDevSoundQueueItem item;
1.1004 + item.iRequest = EMMFDevSoundProxyTFEvent;
1.1005 + item.iErrorCode = aError;
1.1006 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1007 + }
1.1008 +
1.1009 +void CMMFDevSoundSession::BufferToBeFilled(CMMFBuffer* aBuffer)
1.1010 + {
1.1011 + // Package up the data for retrieval later (using a two stage process
1.1012 + // as this payload is too large to be sent via the queue in one message)
1.1013 + iBufferPlay = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
1.1014 + iHwBufPckgFill().iBufferType = iBufferPlay->Type();
1.1015 + iHwBufPckgFill().iRequestSize = iBufferPlay->RequestSize();
1.1016 + iHwBufPckgFill().iBufferSize = iBufferPlay->Data().MaxLength();
1.1017 + iHwBufPckgFill().iLastBuffer = iBufferPlay->LastBuffer();
1.1018 +
1.1019 + TMMFDevSoundQueueItem item;
1.1020 + item.iRequest = EMMFDevSoundProxyBTBFEvent;
1.1021 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1022 + }
1.1023 +
1.1024 +void CMMFDevSoundSession::PlayError(TInt aError)
1.1025 + {
1.1026 + TMMFDevSoundQueueItem item;
1.1027 + item.iRequest = EMMFDevSoundProxyPEEvent;
1.1028 + item.iErrorCode = aError;
1.1029 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1030 + }
1.1031 +
1.1032 +void CMMFDevSoundSession::BufferToBeEmptied(CMMFBuffer* aBuffer)
1.1033 + {
1.1034 + iBufferRecord = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
1.1035 +
1.1036 + iHwBufPckgEmpty().iBufferType = iBufferRecord->Type();
1.1037 + iHwBufPckgEmpty().iRequestSize = iBufferRecord->RequestSize();
1.1038 + iHwBufPckgEmpty().iBufferSize = iBufferRecord->Data().MaxLength();
1.1039 + iHwBufPckgEmpty().iLastBuffer = iBufferRecord->LastBuffer();
1.1040 +
1.1041 + TMMFDevSoundQueueItem item;
1.1042 + item.iRequest = EMMFDevSoundProxyBTBEEvent;
1.1043 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1044 + }
1.1045 +
1.1046 +void CMMFDevSoundSession::RecordError(TInt aError)
1.1047 + {
1.1048 + TMMFDevSoundQueueItem item;
1.1049 + item.iRequest = EMMFDevSoundProxyREEvent;
1.1050 + item.iErrorCode = aError;
1.1051 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1052 + }
1.1053 +
1.1054 +void CMMFDevSoundSession::ConvertError(TInt /*aError*/)
1.1055 + {
1.1056 + }
1.1057 +
1.1058 +void CMMFDevSoundSession::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
1.1059 + {
1.1060 + }
1.1061 +
1.1062 +void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent)
1.1063 + {
1.1064 + TMMFDevSoundQueueItem item;
1.1065 + item.iRequest = EMMFDevSoundProxySETCEvent;
1.1066 + item.iEventPckg() = aEvent;
1.1067 + iMsgQueue.Send(item); // assumes sufficient space in the queue so ignores the return value
1.1068 + }
1.1069 +
1.1070 +/********************************************************************************
1.1071 + * Non Exported public functions begins here *
1.1072 + ********************************************************************************/
1.1073 +
1.1074 +//
1.1075 +// Audio Policy specific implementation begins here //
1.1076 +//
1.1077 +
1.1078 +/**
1.1079 + *
1.1080 + * Sets Id for this instance of DevSound
1.1081 + *
1.1082 + * @param "TInt aDevSoundId"
1.1083 + * Integer value assigned by Audio Policy Server
1.1084 + *
1.1085 + */
1.1086 +void CMMFDevSoundSessionXtnd::SetDevSoundId(TInt aDevSoundId)
1.1087 + {
1.1088 + iBody->SetDevSoundId(aDevSoundId);
1.1089 + }
1.1090 +
1.1091 +/**
1.1092 + *
1.1093 + * Returns information about this DevSound instance.
1.1094 + *
1.1095 + * This method is used by Audio Policy Server to make audio policy decisions.
1.1096 + *
1.1097 + * @return "TMMFDevSoundinfo"
1.1098 + * A reference to TMMFDevSoundinfo object holding the current settings
1.1099 + * of this DevSound instance.
1.1100 + *
1.1101 + */
1.1102 +TMMFDevSoundInfo CMMFDevSoundSessionXtnd::DevSoundInfo()
1.1103 + {
1.1104 + return iBody->DevSoundInfo();
1.1105 + }
1.1106 +
1.1107 +/**
1.1108 + *
1.1109 + * Called by Audio Policy Server when a request to play is approved by the
1.1110 + * Audio Policy Server.
1.1111 + *
1.1112 + * Leaves on failure.
1.1113 + *
1.1114 + */
1.1115 +void CMMFDevSoundSessionXtnd::StartPlayDataL()
1.1116 + {
1.1117 + iBody->StartPlayDataL();
1.1118 + }
1.1119 +
1.1120 +/**
1.1121 + *
1.1122 + * Called by Audio Policy Server when a request to record is approved by the
1.1123 + * Audio Policy Server.
1.1124 + *
1.1125 + * Leaves on failure.
1.1126 + *
1.1127 + */
1.1128 +void CMMFDevSoundSessionXtnd::StartRecordDataL()
1.1129 + {
1.1130 + iBody->StartRecordDataL();
1.1131 + }
1.1132 +
1.1133 +/**
1.1134 + *
1.1135 + * Called by Audio Policy Server when a request to play tone is approved by
1.1136 + * the Audio Policy Server.
1.1137 + *
1.1138 + * Leaves on failure.
1.1139 + *
1.1140 + */
1.1141 +void CMMFDevSoundSessionXtnd::StartPlayToneL()
1.1142 + {
1.1143 + iBody->StartPlayToneL();
1.1144 + }
1.1145 +
1.1146 +/**
1.1147 + *
1.1148 + * Called by Audio Policy Server when a request to play a dual tone is approved by
1.1149 + * the Audio Policy Server.
1.1150 + *
1.1151 + */
1.1152 +void CMMFDevSoundSessionXtnd::StartPlayDualToneL()
1.1153 + {
1.1154 + iBody->StartPlayDualToneL();
1.1155 + }
1.1156 +
1.1157 +/**
1.1158 + *
1.1159 + * Called by Audio Policy Server when a request to play DTMF String is approved
1.1160 + * by the Audio Policy Server.
1.1161 + *
1.1162 + * Leaves on failure.
1.1163 + *
1.1164 + */
1.1165 +void CMMFDevSoundSessionXtnd::StartPlayDTMFStringL()
1.1166 + {
1.1167 + iBody->StartPlayDTMFStringL();
1.1168 + }
1.1169 +
1.1170 +/**
1.1171 + *
1.1172 + * Called by Audio Policy Server when a request to play tone sequence is
1.1173 + * approved by the Audio Policy Server.
1.1174 + *
1.1175 + * Leaves on failure.
1.1176 + *
1.1177 + */
1.1178 +void CMMFDevSoundSessionXtnd::StartPlayToneSequenceL()
1.1179 + {
1.1180 + iBody->StartPlayToneSequenceL();
1.1181 + }
1.1182 +
1.1183 +/**
1.1184 + *
1.1185 + * Called by Audio Policy Server when the current DevSound instance looses the
1.1186 + * policy because of another instance with a higher priority wants the device.
1.1187 + *
1.1188 + */
1.1189 +void CMMFDevSoundSessionXtnd::SendEvent(const TMMFEvent& aEvent)
1.1190 + {
1.1191 + iBody->SendEventToClient(aEvent);
1.1192 + }
1.1193 +
1.1194 +
1.1195 +//
1.1196 +// Audio Policy specific implementation begins here //
1.1197 +//
1.1198 +
1.1199 +/**
1.1200 + *
1.1201 + * Updates the total bytes played.
1.1202 + *
1.1203 + */
1.1204 +void CMMFDevSoundSessionXtnd::UpdateBytesPlayed()
1.1205 + {
1.1206 + iBody->UpdateBytesPlayed();
1.1207 + }
1.1208 +
1.1209 +
1.1210 +// Custom Interface //
1.1211 +TInt CMMFDevSoundSession::DoOpenSlaveL(TUid aInterface, const TDesC8& aPackageBuf)
1.1212 + {
1.1213 + // it shouldn't be necessary to check if we have already instantiated this
1.1214 + // interface since the client would already know - however this is something
1.1215 + // that a licensee could implement if they required additional functionality
1.1216 + // e.g. many : 1 mappings between client and DevSound.
1.1217 +
1.1218 + MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = NULL;
1.1219 +
1.1220 + // try and instantiate a plugin tunnelling
1.1221 + // pair to support this Custom Interface
1.1222 + ptr = iDeMuxUtility->CreateCustomInterfaceDeMuxL(aInterface);
1.1223 +
1.1224 + TInt handle = KNullHandle;
1.1225 +
1.1226 + if (ptr)
1.1227 + {
1.1228 + TMMFDevSoundCustomInterfaceDeMuxData data;
1.1229 + data.iInterface = ptr;
1.1230 + data.iId = aInterface;
1.1231 +
1.1232 + CleanupReleasePushL(*ptr);
1.1233 +
1.1234 + // setup demux plugin
1.1235 + ptr->SetInterfaceTarget(iBody);
1.1236 +
1.1237 + // try and open interface
1.1238 + // this will fetch the interface from the svr implementation
1.1239 + ptr->DoOpenSlaveL(aInterface, aPackageBuf);
1.1240 + User::LeaveIfError(iCustomInterfaceArray.Append(data));
1.1241 +
1.1242 + CleanupStack::Pop(); // ptr
1.1243 +
1.1244 + handle = iCustomInterfaceArray.Count();
1.1245 + return handle;
1.1246 + }
1.1247 +
1.1248 + // we couldn't set up the interface correctly so return a NULL
1.1249 + // handle to the client
1.1250 + return KNullHandle;
1.1251 + }
1.1252 +
1.1253 +void CMMFDevSoundSession::DoCloseSlaveL(TInt aHandle)
1.1254 + {
1.1255 + if (aHandle==KNullHandle)
1.1256 + {
1.1257 + // null-handle -> NOP
1.1258 + return;
1.1259 + }
1.1260 +
1.1261 + if (aHandle<KNullHandle || aHandle > iCustomInterfaceArray.Count())
1.1262 + {
1.1263 + // handle out of range - should not happen, but leave to show error
1.1264 + User::Leave(KErrBadHandle);
1.1265 + }
1.1266 +
1.1267 + // set the current handle location to NULL
1.1268 + // can't re-compress array because this will alter handles
1.1269 + // we could change this to a list type structure but this
1.1270 + // seems overkill for the current prototype
1.1271 + TMMFDevSoundCustomInterfaceDeMuxData& data = iCustomInterfaceArray[aHandle-1];
1.1272 +
1.1273 + // close and delete the plugin
1.1274 + MMMFDevSoundCustomInterfaceDeMuxPlugin* ptr = data.iInterface;
1.1275 + ptr->DoCloseSlaveL(aHandle);
1.1276 + ptr->Release();
1.1277 +
1.1278 + // clear the entry
1.1279 + data.iInterface = NULL;
1.1280 + data.iId.iUid = 0;
1.1281 + }
1.1282 +
1.1283 +TInt CMMFDevSoundSession::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
1.1284 + {
1.1285 + // use the demux utility to get the handle
1.1286 + TMMFDevSoundCIMessageData data;
1.1287 + iDeMuxUtility->GetSyncMessageDataL(aMessage, data);
1.1288 +
1.1289 + TInt handle = data.iHandle;
1.1290 +
1.1291 + if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count())))
1.1292 + {
1.1293 +
1.1294 + User::Leave(KErrBadHandle);
1.1295 + }
1.1296 +
1.1297 + // call on demux plugin
1.1298 + return iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveSyncCommandL(aMessage);
1.1299 + }
1.1300 +
1.1301 +TInt CMMFDevSoundSession::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
1.1302 + {
1.1303 + // use the demux utility to get the handle
1.1304 + TMMFDevSoundCIMessageData data;
1.1305 + iDeMuxUtility->GetSyncMessageDataL(aMessage, data);
1.1306 +
1.1307 + TInt handle = data.iHandle;
1.1308 +
1.1309 + if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count())))
1.1310 + {
1.1311 +
1.1312 + User::Leave(KErrBadHandle);
1.1313 + }
1.1314 +
1.1315 + // call on demux plugin
1.1316 + return iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveSyncCommandResultL(aMessage);
1.1317 + }
1.1318 +
1.1319 +void CMMFDevSoundSession::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& aMessage)
1.1320 + {
1.1321 + // use the demux utility to get the handle
1.1322 + TMMFDevSoundCIMessageData data;
1.1323 + iDeMuxUtility->GetAsyncMessageDataL(aMessage, data);
1.1324 +
1.1325 + TInt handle = data.iHandle;
1.1326 +
1.1327 + if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count())))
1.1328 + {
1.1329 + User::Leave(KErrBadHandle);
1.1330 + }
1.1331 +
1.1332 + // call on demux plugin
1.1333 + iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveAsyncCommandL(aMessage);
1.1334 + }
1.1335 +
1.1336 +void CMMFDevSoundSession::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& aMessage)
1.1337 + {
1.1338 + // use the demux utility to get the handle
1.1339 + TMMFDevSoundCIMessageData data;
1.1340 + iDeMuxUtility->GetAsyncMessageDataL(aMessage, data);
1.1341 +
1.1342 + TInt handle = data.iHandle;
1.1343 +
1.1344 + if ((handle <= 0) || (handle > (iCustomInterfaceArray.Count())))
1.1345 + {
1.1346 + User::Leave(KErrBadHandle);
1.1347 + }
1.1348 +
1.1349 + // call on demux plugin
1.1350 + iCustomInterfaceArray[handle-1].iInterface->DoSendSlaveAsyncCommandResultL(aMessage);
1.1351 + }
1.1352 +
1.1353 +
1.1354 +