os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtDevSoundSession.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtDevSoundSession.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1163 @@
     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 "MmfBtDevSoundSession.h"
    1.21 +#include "MmfBtDevSoundSessionXtnd.h"
    1.22 +#include "MmfBtDevSoundSessionBody.h"
    1.23 +
    1.24 +#include "MmfBtAudioClientServer.h"
    1.25 +#include "MmfBtAudioServer.h"
    1.26 +#include "MmfBtDevSoundServer.h"
    1.27 +
    1.28 +
    1.29 +void CMMFDevSoundSession::CreateL(const CMmfIpcServer& aServer)
    1.30 +	{
    1.31 +	CMmfIpcSession::CreateL(aServer);
    1.32 +	CMMFDevSoundServer& server = 
    1.33 +		const_cast<CMMFDevSoundServer&>(static_cast<const CMMFDevSoundServer&>(aServer));
    1.34 +	server.IncrementSessionId();
    1.35 +	iDevSoundSessionId = server.DevSoundSessionId();
    1.36 +	iClientHasCaps = server.CheckClientCapabilities();
    1.37 +	}
    1.38 +
    1.39 +TBool CMMFDevSoundSession::CheckClientCapabilities()
    1.40 +	{
    1.41 +	return iClientHasCaps;
    1.42 +	}
    1.43 +
    1.44 +void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage)
    1.45 +	{
    1.46 +	TBool complete = EFalse;
    1.47 +	switch(aMessage.Function())
    1.48 +		{
    1.49 +	case EMMFDevSoundProxyInitialize1:
    1.50 +		complete = DoInitialize1L(aMessage);
    1.51 +		break;
    1.52 +	case EMMFDevSoundProxyInitialize2:
    1.53 +		complete = DoInitialize2L(aMessage);
    1.54 +		break;
    1.55 +	case EMMFDevSoundProxyInitialize3:
    1.56 +		complete = DoInitialize3L(aMessage);
    1.57 +		break;
    1.58 +	case EMMFDevSoundProxyInitialize4:
    1.59 +		complete = DoInitialize4L(aMessage);
    1.60 +		break;
    1.61 +	case EMMFDevSoundProxyCapabilities:
    1.62 +		complete = DoCapabilitiesL(aMessage);
    1.63 +		break;
    1.64 +	case EMMFDevSoundProxyConfig:
    1.65 +		complete = DoConfigL(aMessage);
    1.66 +		break;
    1.67 +	case EMMFDevSoundProxySetConfig:
    1.68 +		complete = DoSetConfigL(aMessage);
    1.69 +		break;
    1.70 +	case EMMFDevSoundProxyMaxVolume:
    1.71 +		complete = DoMaxVolumeL(aMessage);
    1.72 +		break;
    1.73 +	case EMMFDevSoundProxyVolume:
    1.74 +		complete = DoVolumeL(aMessage);
    1.75 +		break;
    1.76 +	case EMMFDevSoundProxySetVolume:
    1.77 +		complete = DoSetVolumeL(aMessage);
    1.78 +		break;
    1.79 +	case EMMFDevSoundProxyMaxGain:
    1.80 +		complete = DoMaxGainL(aMessage);
    1.81 +		break;
    1.82 +	case EMMFDevSoundProxyGain:
    1.83 +		complete = DoGainL(aMessage);
    1.84 +		break;
    1.85 +	case EMMFDevSoundProxySetGain:
    1.86 +		complete = DoSetGainL(aMessage);
    1.87 +		break;
    1.88 +	case EMMFDevSoundProxyPlayBalance:
    1.89 +		complete = DoGetPlayBalanceL(aMessage);
    1.90 +		break;
    1.91 +	case EMMFDevSoundProxySetPlayBalance:
    1.92 +		complete = DoSetPlayBalanceL(aMessage);
    1.93 +		break;
    1.94 +	case EMMFDevSoundProxyRecordBalance:
    1.95 +		complete = DoGetRecordBalanceL(aMessage);
    1.96 +		break;
    1.97 +	case EMMFDevSoundProxySetRecordBalance:
    1.98 +		complete = DoSetRecordBalanceL(aMessage);
    1.99 +		break;
   1.100 +	case EMMFDevSoundProxyReceiveICEvent:
   1.101 +		complete = DoInitializeCompleteEventL(aMessage);
   1.102 +		break;
   1.103 +	case EMMFDevSoundProxyCancelReceiveICEvent:
   1.104 +		complete = DoCancelInitializeCompleteEventL(aMessage);
   1.105 +		break;
   1.106 +	case EMMFDevSoundProxyReceiveBTBFEvent:
   1.107 +		complete = DoBufferToBeFilledEventL(aMessage);
   1.108 +		break;
   1.109 +	case EMMFDevSoundProxyCancelReceiveBTBFEvent:
   1.110 +		complete = DoCancelBufferToBeFilledEventL(aMessage);
   1.111 +		break;	
   1.112 +	case EMMFDevSoundProxyReceiveBTBEEvent:
   1.113 +		complete = DoBufferToBeEmptiedEventL(aMessage);
   1.114 +		break;
   1.115 +	case EMMFDevSoundProxyCancelReceiveBTBEEvent:
   1.116 +		complete = DoCancelBufferToBeEmptiedEventL(aMessage);
   1.117 +		break;
   1.118 +	case EMMFDevSoundProxyReceivePEEvent:
   1.119 +		complete = DoPlayErrorEventL(aMessage);
   1.120 +		break;
   1.121 +	case EMMFDevSoundProxyCancelReceivePEEvent:
   1.122 +		complete = DoCancelPlayErrorEventL(aMessage);
   1.123 +		break;
   1.124 +	case EMMFDevSoundProxyReceiveREEvent:
   1.125 +		complete = DoRecordErrorEventL(aMessage);
   1.126 +		break;
   1.127 +	case EMMFDevSoundProxyCancelReceiveREEvent:
   1.128 +		complete = DoCancelRecordErrorEventL(aMessage);
   1.129 +		break;
   1.130 +	case EMMFDevSoundProxyReceiveSETCEvent:
   1.131 +		complete = DoSendEventToClientEventL(aMessage);
   1.132 +		break;
   1.133 +	case EMMFDevSoundProxyCancelReceiveSETCEvent:
   1.134 +		complete = DoCancelSendEventToClientEventL(aMessage);
   1.135 +		break;
   1.136 +	case EMMFDevSoundProxyReceiveTFEvent:
   1.137 +		complete = DoToneFinishedEventL(aMessage);
   1.138 +		break;
   1.139 +	case EMMFDevSoundProxyCancelReceiveTFEvent:
   1.140 +		complete = DoCancelToneFinishedEventL(aMessage);
   1.141 +		break;
   1.142 +	case EMMFDevSoundProxyPlayInit:
   1.143 +		complete = DoPlayInitL(aMessage);
   1.144 +		break;
   1.145 +	case EMMFDevSoundProxyRecordInit:
   1.146 +		complete = DoRecordInitL(aMessage);
   1.147 +		break;
   1.148 +	case EMMFDevSoundProxyPlayData:
   1.149 +		complete = DoPlayDataL(aMessage);
   1.150 +		break;
   1.151 +	case EMMFDevSoundProxyRecordData:
   1.152 +		complete = DoRecordDataL(aMessage);
   1.153 +		break;
   1.154 +	case EMMFDevSoundProxyStop:
   1.155 +		complete = DoStopL(aMessage);
   1.156 +		break;
   1.157 +	case EMMFDevSoundProxyPause:
   1.158 +		complete = DoPauseL(aMessage);
   1.159 +		break;
   1.160 +	case EMMFDevSoundProxyPlayTone:
   1.161 +		complete = DoPlayToneL(aMessage);
   1.162 +		break;
   1.163 +	case EMMFDevSoundProxyPlayDualTone:
   1.164 +		complete = DoPlayDualToneL(aMessage);
   1.165 +		break;
   1.166 +	case EMMFDevSoundProxyPlayDTMFString:
   1.167 +		complete = DoPlayDTMFStringL(aMessage);
   1.168 +		break;
   1.169 +	case EMMFDevSoundProxyPlayToneSequence:
   1.170 +		complete = DoPlayToneSequenceL(aMessage);
   1.171 +		break;
   1.172 +	case EMMFDevSoundProxyPlayFixedSequence:
   1.173 +		complete = DoPlayFixedSequenceL(aMessage);
   1.174 +		break;
   1.175 +	case EMMFDevSoundProxySetDTMFLengths:
   1.176 +		complete = DoSetDTMFLengthsL(aMessage);
   1.177 +		break;
   1.178 +	case EMMFDevSoundProxySetVolumeRamp:
   1.179 +		complete = DoSetVolumeRampL(aMessage);
   1.180 +		break;
   1.181 +	case EMMFDevSoundProxyGetSupportedInputDataTypes:
   1.182 +		complete = DoGetSupportedInputDataTypesL(aMessage);
   1.183 +		break;
   1.184 +	case EMMFDevSoundProxyGetSupportedOutputDataTypes:
   1.185 +		complete = DoGetSupportedOutputDataTypesL(aMessage);
   1.186 +		break;
   1.187 +	case EMMFDevSoundProxyCopyFourCCArrayData:
   1.188 +		complete = DoCopyFourCCArrayDataL(aMessage);
   1.189 +		break;
   1.190 +	case EMMFDevSoundProxyGetRecordedBuffer:
   1.191 +		complete = DoGetRecordedBufferL(aMessage);
   1.192 +		break;
   1.193 +	case EMMFDevSoundProxySamplesRecorded:
   1.194 +		complete = DoSamplesRecordedL(aMessage);
   1.195 +		break;
   1.196 +	case EMMFDevSoundProxySamplesPlayed:
   1.197 +		complete = DoSamplesPlayedL(aMessage);
   1.198 +		break;
   1.199 +	case EMMFDevSoundProxySetToneRepeats:
   1.200 +		complete = DoSetToneRepeatsL(aMessage);
   1.201 +		break;
   1.202 +	case EMMFDevSoundProxySetPrioritySettings:
   1.203 +		complete = DoSetPrioritySettingsL(aMessage);
   1.204 +		break;
   1.205 +	case EMMFDevSoundProxyFixedSequenceName:
   1.206 +		complete = DoFixedSequenceNameL(aMessage);
   1.207 +		break;
   1.208 +	case EMMFDevSoundProxyConvertInit:
   1.209 +		complete = DoConvertInitL(aMessage);
   1.210 +		break;
   1.211 +	case EMMFDevSoundProxyConvertData:
   1.212 +		complete = DoConvertDataL(aMessage);
   1.213 +		break;
   1.214 +	case EMMFDevSoundProxyFixedSequenceCount:
   1.215 +		complete = DoFixedSequenceCountL(aMessage);
   1.216 +		break;
   1.217 +	case EMMFDevSoundProxyRequestResourceNotification:
   1.218 +		complete = DoRegisterAsClientL(aMessage);
   1.219 +		break;
   1.220 +	case EMMFDevSoundProxyCancelRequestResourceNotification:
   1.221 +		complete = DoCancelRegisterAsClientL(aMessage);
   1.222 +		break;
   1.223 +	case EMMFDevSoundProxyGetResourceNotificationData:
   1.224 +		complete = DoGetResourceNotificationDataL(aMessage);
   1.225 +		break;
   1.226 +	case EMMFDevSoundProxyWillResumePlay:
   1.227 +		complete = DoWillResumePlayL(aMessage);
   1.228 +		break;
   1.229 +	case EMMFDevSoundProxySetClientThreadInfo:
   1.230 +		complete = DoSetClientThreadInfoL(aMessage);
   1.231 +		break;
   1.232 +	default:
   1.233 +		User::Leave(KErrNotSupported);
   1.234 +		break;
   1.235 +		}
   1.236 +	if (complete)
   1.237 +		aMessage.Complete(KErrNone);
   1.238 +	}
   1.239 +
   1.240 +TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage)
   1.241 +	{
   1.242 +	TMMFDevSoundProxySettingsPckg buf;
   1.243 +	MmfMessageUtil::ReadL(aMessage,0,buf);
   1.244 +	TMMFState mode = buf().iMode;
   1.245 +	iBody->InitializeL(*this, mode);
   1.246 +	return ETrue;
   1.247 +	}
   1.248 +
   1.249 +TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage)
   1.250 +	{
   1.251 +	TMMFDevSoundProxySettingsPckg buf;
   1.252 +	MmfMessageUtil::ReadL(aMessage,0,buf);
   1.253 +	TUid HWDev = buf().iHWDev;
   1.254 +	TMMFState mode = buf().iMode;
   1.255 +	iBody->InitializeL(*this, HWDev, mode);
   1.256 +	return ETrue;
   1.257 +	}
   1.258 +
   1.259 +TBool CMMFDevSoundSession::DoInitialize3L(const RMmfIpcMessage& /*aMessage*/)
   1.260 +	{
   1.261 +	User::Leave(KErrNotSupported);
   1.262 +	return ETrue;
   1.263 +	}
   1.264 +
   1.265 +TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage)
   1.266 +	{
   1.267 +	TMMFDevSoundProxySettingsPckg buf;
   1.268 +	aMessage.ReadL(TInt(0),buf);
   1.269 +	TFourCC desiredFourCC = buf().iDesiredFourCC;
   1.270 +	TMMFState mode = buf().iMode;
   1.271 +	iBody->InitializeL(*this, desiredFourCC, mode);
   1.272 +	return ETrue;
   1.273 +	}
   1.274 +
   1.275 +TBool CMMFDevSoundSession::DoCapabilitiesL(const RMmfIpcMessage& aMessage)
   1.276 +	{
   1.277 +	TMMFDevSoundProxySettings set;
   1.278 +	set.iCaps = iBody->Capabilities();
   1.279 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.280 +	aMessage.WriteL(TInt(2),pckg);
   1.281 +	return ETrue;
   1.282 +	}
   1.283 +
   1.284 +TBool CMMFDevSoundSession::DoConfigL(const RMmfIpcMessage& aMessage)
   1.285 +	{
   1.286 +	TMMFDevSoundProxySettings set;
   1.287 +	set.iConfig = iBody->Config();
   1.288 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.289 +	aMessage.WriteL(TInt(2),pckg);
   1.290 +	return ETrue;
   1.291 +	}
   1.292 +
   1.293 +TBool CMMFDevSoundSession::DoSetConfigL(const RMmfIpcMessage& aMessage)
   1.294 +	{
   1.295 +	TMMFDevSoundProxySettingsPckg buf;
   1.296 +	aMessage.ReadL(TInt(0),buf);
   1.297 +	TMMFCapabilities config = buf().iConfig;
   1.298 +	iBody->SetConfigL(config);
   1.299 +	return ETrue;
   1.300 +	}
   1.301 +
   1.302 +TBool CMMFDevSoundSession::DoMaxVolumeL(const RMmfIpcMessage& aMessage)
   1.303 +	{
   1.304 +	TMMFDevSoundProxySettings set;
   1.305 +	set.iMaxVolume = iBody->MaxVolume();
   1.306 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.307 +	aMessage.WriteL(TInt(2),pckg);
   1.308 +	return ETrue;
   1.309 +	}
   1.310 +
   1.311 +TBool CMMFDevSoundSession::DoVolumeL(const RMmfIpcMessage& aMessage)
   1.312 +	{
   1.313 +	TMMFDevSoundProxySettings set;
   1.314 +	set.iVolume = iBody->Volume();
   1.315 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.316 +	aMessage.WriteL(TInt(2),pckg);
   1.317 +	return ETrue;
   1.318 +	}
   1.319 +
   1.320 +TBool CMMFDevSoundSession::DoSetVolumeL(const RMmfIpcMessage& aMessage)
   1.321 +	{
   1.322 +	TMMFDevSoundProxySettingsPckg buf;
   1.323 +	aMessage.ReadL(TInt(0),buf);
   1.324 +	TInt volume = buf().iVolume;
   1.325 +	iBody->SetVolume(volume);
   1.326 +	return ETrue;
   1.327 +	}
   1.328 +
   1.329 +TBool CMMFDevSoundSession::DoMaxGainL(const RMmfIpcMessage& aMessage)
   1.330 +	{
   1.331 +	TMMFDevSoundProxySettings set;
   1.332 +	set.iMaxGain = iBody->MaxGain();
   1.333 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.334 +	aMessage.WriteL(TInt(2),pckg);
   1.335 +	return ETrue;
   1.336 +	}
   1.337 +
   1.338 +TBool CMMFDevSoundSession::DoGainL(const RMmfIpcMessage& aMessage)
   1.339 +	{
   1.340 +	TMMFDevSoundProxySettings set;
   1.341 +	set.iGain = iBody->Gain();
   1.342 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.343 +	aMessage.WriteL(TInt(2),pckg);
   1.344 +	return ETrue;
   1.345 +	}
   1.346 +
   1.347 +TBool CMMFDevSoundSession::DoSetGainL(const RMmfIpcMessage& aMessage)
   1.348 +	{
   1.349 +	TMMFDevSoundProxySettingsPckg buf;
   1.350 +	aMessage.ReadL(TInt(0),buf);
   1.351 +	TInt gain = buf().iGain;
   1.352 +	iBody->SetGain(gain);
   1.353 +	return ETrue;
   1.354 +	}
   1.355 +
   1.356 +TBool CMMFDevSoundSession::DoGetPlayBalanceL(const RMmfIpcMessage& aMessage)
   1.357 +	{
   1.358 +	TMMFDevSoundProxySettings set;
   1.359 +	iBody->GetPlayBalanceL(set.iLeftPercentage, set.iRightPercentage);
   1.360 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.361 +	aMessage.WriteL(TInt(2),pckg);
   1.362 +	return ETrue;
   1.363 +	}
   1.364 +
   1.365 +TBool CMMFDevSoundSession::DoSetPlayBalanceL(const RMmfIpcMessage& aMessage)
   1.366 +	{
   1.367 +	TMMFDevSoundProxySettingsPckg buf;
   1.368 +	aMessage.ReadL(TInt(0),buf);
   1.369 +	TInt leftPercentage = buf().iLeftPercentage;
   1.370 +	TInt rightPercentage = buf().iRightPercentage;
   1.371 +	iBody->SetPlayBalanceL(leftPercentage, rightPercentage);
   1.372 +	return ETrue;
   1.373 +	}
   1.374 +
   1.375 +TBool CMMFDevSoundSession::DoGetRecordBalanceL(const RMmfIpcMessage& aMessage)
   1.376 +	{
   1.377 +	TMMFDevSoundProxySettings set;
   1.378 +	iBody->GetRecordBalanceL(set.iLeftPercentage, set.iRightPercentage);
   1.379 +	TMMFDevSoundProxySettingsPckg pckg(set);
   1.380 +	aMessage.WriteL(TInt(2),pckg);
   1.381 +	return ETrue;
   1.382 +	}
   1.383 +
   1.384 +TBool CMMFDevSoundSession::DoSetRecordBalanceL(const RMmfIpcMessage& aMessage)
   1.385 +	{
   1.386 +	TMMFDevSoundProxySettingsPckg buf;
   1.387 +	aMessage.ReadL(TInt(0),buf);
   1.388 +	TInt leftPercentage = buf().iLeftPercentage;
   1.389 +	TInt rightPercentage = buf().iRightPercentage;
   1.390 +	iBody->SetRecordBalanceL(leftPercentage, rightPercentage);
   1.391 +	return ETrue;
   1.392 +	}
   1.393 +
   1.394 +TBool CMMFDevSoundSession::DoPlayInitL(const RMmfIpcMessage& /*aMessage*/)
   1.395 +	{
   1.396 +	iBody->PlayInitL();
   1.397 +	return ETrue;
   1.398 +	}
   1.399 +
   1.400 +TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& aMessage)
   1.401 +	{
   1.402 +	iBody->RecordInitL(aMessage);
   1.403 +	return ETrue;
   1.404 +	}
   1.405 +
   1.406 +TBool CMMFDevSoundSession::DoPlayDataL(const RMmfIpcMessage& aMessage)
   1.407 +	{
   1.408 +	TMMFDevSoundProxyHwBufPckg buf;
   1.409 +	aMessage.ReadL(TInt(0),buf);
   1.410 +	iBufferPlay->SetLastBuffer(buf().iLastBuffer);
   1.411 +
   1.412 +	aMessage.ReadL(TInt(1),iBufferPlay->Data());
   1.413 +	iBody->PlayData();
   1.414 +	return ETrue;
   1.415 +	}
   1.416 +
   1.417 +TBool CMMFDevSoundSession::DoRecordDataL(const RMmfIpcMessage& aMessage)
   1.418 +	{
   1.419 +	iBody->RecordData(aMessage);
   1.420 +	return ETrue;
   1.421 +	}
   1.422 +
   1.423 +TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/)
   1.424 +	{
   1.425 +	iBody->Stop();
   1.426 +	return ETrue;
   1.427 +	}
   1.428 +
   1.429 +TBool CMMFDevSoundSession::DoPauseL(const RMmfIpcMessage& /*aMessage*/)
   1.430 +	{
   1.431 +	iBody->Pause();
   1.432 +	return ETrue;
   1.433 +	}
   1.434 +
   1.435 +TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage)
   1.436 +	{
   1.437 +	TMMFDevSoundProxySettingsPckg buf;
   1.438 +	aMessage.ReadL(TInt(0),buf);
   1.439 +	TInt frequency = buf().iFrequencyOne;
   1.440 +	TTimeIntervalMicroSeconds duration(buf().iDuration);
   1.441 +	iBody->PlayToneL(frequency, duration);
   1.442 +	return ETrue;
   1.443 +	}
   1.444 +
   1.445 +TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage)
   1.446 +	{
   1.447 +	TMMFDevSoundProxySettingsPckg buf;
   1.448 +	aMessage.ReadL(TInt(0),buf);
   1.449 +	TInt frequencyOne = buf().iFrequencyOne;
   1.450 +	TInt frequencyTwo = buf().iFrequencyTwo;
   1.451 +	TTimeIntervalMicroSeconds duration(buf().iDuration);
   1.452 +	iBody->PlayDualToneL(frequencyOne, frequencyTwo, duration);
   1.453 +	return ETrue;
   1.454 +	}
   1.455 +
   1.456 +TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage)
   1.457 +	{
   1.458 +	TInt DTMFLength = aMessage.GetDesLength(0);
   1.459 +
   1.460 +	if(iDTMFString)
   1.461 +		{
   1.462 +		delete iDTMFString;
   1.463 +		iDTMFString = NULL;
   1.464 +		}
   1.465 +
   1.466 +	iDTMFString = HBufC::NewL(DTMFLength);
   1.467 +	TPtr DTMFPtr = iDTMFString->Des();
   1.468 +	aMessage.ReadL(TInt(0), DTMFPtr);
   1.469 +
   1.470 +	iBody->PlayDTMFStringL(*iDTMFString);
   1.471 +	return ETrue;
   1.472 +	}
   1.473 +
   1.474 +TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage)
   1.475 +	{
   1.476 +	TInt toneLength = aMessage.GetDesLength(0);
   1.477 +
   1.478 +	if(iToneSeqBuf)
   1.479 +		{
   1.480 +		delete iToneSeqBuf;
   1.481 +		iToneSeqBuf = NULL;
   1.482 +		}
   1.483 +
   1.484 +	iToneSeqBuf = HBufC8::NewL(toneLength);
   1.485 +	TPtr8 toneSeqPtr = iToneSeqBuf->Des();
   1.486 +	aMessage.ReadL(TInt(0), toneSeqPtr);
   1.487 +
   1.488 +	iBody->PlayToneSequenceL(*iToneSeqBuf);
   1.489 +	return ETrue;
   1.490 +	}
   1.491 +
   1.492 +TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage)
   1.493 +	{
   1.494 +	TPckgBuf<TInt> buf;
   1.495 +	aMessage.ReadL(TInt(0),buf);
   1.496 +	TInt seqNum = buf();
   1.497 +
   1.498 +	iBody->PlayFixedSequenceL(seqNum);
   1.499 +	return ETrue;
   1.500 +	}
   1.501 +
   1.502 +TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage)
   1.503 +	{
   1.504 +	TMMFDevSoundProxySettingsPckg buf;
   1.505 +	aMessage.ReadL(TInt(0),buf);
   1.506 +	TTimeIntervalMicroSeconds32 toneOnLength = buf().iToneOnLength;
   1.507 +	TTimeIntervalMicroSeconds32 toneOffLength = buf().iToneOffLength;
   1.508 +	TTimeIntervalMicroSeconds32 pauseLength = buf().iPauseLength;
   1.509 +	iBody->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength);
   1.510 +	return ETrue;
   1.511 +	}
   1.512 +
   1.513 +TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage)
   1.514 +	{
   1.515 +	TMMFDevSoundProxySettingsPckg buf;
   1.516 +	aMessage.ReadL(TInt(0),buf);
   1.517 +	TTimeIntervalMicroSeconds duration = buf().iDuration;
   1.518 +	iBody->SetVolumeRamp(duration);
   1.519 +	return ETrue;
   1.520 +	}
   1.521 +
   1.522 +TBool CMMFDevSoundSession::DoGetSupportedInputDataTypesL(const RMmfIpcMessage& aMessage)
   1.523 +	{
   1.524 +	iArray.Reset();
   1.525 +
   1.526 +	TMMFPrioritySettingsPckg buf;
   1.527 +	aMessage.ReadL(TInt(0),buf);
   1.528 +	TMMFPrioritySettings prioritySet = buf();
   1.529 +
   1.530 +	iBody->GetSupportedInputDataTypesL(iArray, prioritySet);
   1.531 +
   1.532 +	TPckgBuf<TInt> pckg;
   1.533 +	pckg() = iArray.Count();
   1.534 +	aMessage.WriteL(TInt(2),pckg);
   1.535 +
   1.536 +	return ETrue;
   1.537 +	}
   1.538 +
   1.539 +TBool CMMFDevSoundSession::DoGetSupportedOutputDataTypesL(const RMmfIpcMessage& aMessage)
   1.540 +	{
   1.541 +	iArray.Reset();
   1.542 +
   1.543 +	TMMFPrioritySettingsPckg buf;
   1.544 +	aMessage.ReadL(TInt(0),buf);
   1.545 +	TMMFPrioritySettings prioritySet = buf();
   1.546 +
   1.547 +	iBody->GetSupportedOutputDataTypesL(iArray, prioritySet);
   1.548 +
   1.549 +	TPckgBuf<TInt> pckg;
   1.550 +	pckg() = iArray.Count();
   1.551 +	aMessage.WriteL(TInt(2),pckg);
   1.552 +
   1.553 +	return ETrue;
   1.554 +	}
   1.555 +
   1.556 +TBool CMMFDevSoundSession::DoSamplesRecordedL(const RMmfIpcMessage& aMessage)
   1.557 +	{
   1.558 +	TPckgBuf<TInt> pckg;
   1.559 +	pckg() = iBody->SamplesRecorded();
   1.560 +	aMessage.WriteL(TInt(2),pckg);
   1.561 +	return ETrue;
   1.562 +	}
   1.563 +
   1.564 +TBool CMMFDevSoundSession::DoSamplesPlayedL(const RMmfIpcMessage& aMessage)
   1.565 +	{
   1.566 +	TPckgBuf<TInt> pckg;
   1.567 +	pckg() = iBody->SamplesPlayed();
   1.568 +	aMessage.WriteL(TInt(2),pckg);
   1.569 +	return ETrue;
   1.570 +	}
   1.571 +
   1.572 +TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage)
   1.573 +	{
   1.574 +	TPckgBuf<TInt> countRepeat;
   1.575 +	aMessage.ReadL(TInt(0),countRepeat);
   1.576 +
   1.577 +	TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
   1.578 +	aMessage.ReadL(TInt(1),repeatTS);
   1.579 +
   1.580 +	iBody->SetToneRepeats(countRepeat(), repeatTS());
   1.581 +	return ETrue;
   1.582 +	}
   1.583 +
   1.584 +TBool CMMFDevSoundSession::DoSetPrioritySettingsL(const RMmfIpcMessage& aMessage)
   1.585 +	{
   1.586 +	TPckgBuf<TMMFPrioritySettings> prioritySet;
   1.587 +	aMessage.ReadL(TInt(0),prioritySet);
   1.588 +
   1.589 +	iBody->SetPrioritySettings(prioritySet());
   1.590 +	return ETrue;
   1.591 +	}
   1.592 +
   1.593 +TBool CMMFDevSoundSession::DoFixedSequenceNameL(const RMmfIpcMessage& aMessage)
   1.594 +	{
   1.595 +	TPckgBuf<TInt> seqNum;
   1.596 +	aMessage.ReadL(0, seqNum);
   1.597 +	aMessage.WriteL(2, iBody->FixedSequenceName(seqNum()).Left(KMaxFixedSequenceNameLength));
   1.598 +	return ETrue;
   1.599 +	}
   1.600 +
   1.601 +TBool CMMFDevSoundSession::DoConvertInitL(const RMmfIpcMessage& /*aMessage*/)
   1.602 +	{
   1.603 +	iBody->ConvertInitL();
   1.604 +	return ETrue;
   1.605 +	}
   1.606 +
   1.607 +TBool CMMFDevSoundSession::DoConvertDataL(const RMmfIpcMessage& /*aMessage*/)
   1.608 +	{
   1.609 +	iBody->ConvertData();
   1.610 +	return ETrue;
   1.611 +	}
   1.612 +
   1.613 +TBool CMMFDevSoundSession::DoFixedSequenceCountL(const RMmfIpcMessage& aMessage)
   1.614 +	{
   1.615 +	TPckgBuf<TInt> fixSeqCountPckg;
   1.616 +	TInt fixSeqCount = iBody->FixedSequenceCount();
   1.617 +	fixSeqCountPckg = fixSeqCount;
   1.618 +
   1.619 +	aMessage.WriteL(TInt(0),fixSeqCountPckg);
   1.620 +	return ETrue;
   1.621 +	}
   1.622 +
   1.623 +
   1.624 +TBool CMMFDevSoundSession::DoCopyFourCCArrayDataL(const RMmfIpcMessage& aMessage)
   1.625 +	{
   1.626 +	const TInt KBufExpandSize8 = 8;//two TInts
   1.627 +	CBufFlat* dataCopyBuffer = CBufFlat::NewL(KBufExpandSize8);
   1.628 +	CleanupStack::PushL(dataCopyBuffer);
   1.629 +	RBufWriteStream stream;
   1.630 +	stream.Open(*dataCopyBuffer);
   1.631 +	CleanupClosePushL(stream);
   1.632 +	for (TInt i=0;i<iArray.Count();i++)
   1.633 +		{
   1.634 +		stream.WriteInt32L(iArray[i].FourCC());
   1.635 +		}
   1.636 +	aMessage.WriteL(TInt(2), dataCopyBuffer->Ptr(0));
   1.637 +	stream.Close();
   1.638 +	CleanupStack::PopAndDestroy(2);//iDataCopyBuffer, stream
   1.639 +	return ETrue;
   1.640 +	}
   1.641 +
   1.642 +
   1.643 +TBool CMMFDevSoundSession::DoGetRecordedBufferL(const RMmfIpcMessage& aMessage)
   1.644 +	{
   1.645 +	MmfMessageUtil::Write(aMessage, TInt(0), iBufferRecord->Data());
   1.646 +	return ETrue;
   1.647 +	}
   1.648 +
   1.649 +
   1.650 +TBool CMMFDevSoundSession::DoInitializeCompleteEventL(const RMmfIpcMessage& aMessage)
   1.651 +	{
   1.652 +	if (iICMessage)
   1.653 +		{
   1.654 +		delete iICMessage;
   1.655 +		iICMessage = NULL;
   1.656 +		}
   1.657 +	iICMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.658 +	return EFalse;
   1.659 +	}
   1.660 +
   1.661 +TBool CMMFDevSoundSession::DoCancelInitializeCompleteEventL(const RMmfIpcMessage& /*aMessage*/)
   1.662 +	{
   1.663 +	if(iICMessage)
   1.664 +		iICMessage->Complete(KErrCancel);
   1.665 +	return ETrue;
   1.666 +	}
   1.667 +
   1.668 +
   1.669 +TBool CMMFDevSoundSession::DoBufferToBeFilledEventL(const RMmfIpcMessage& aMessage)
   1.670 +	{
   1.671 +	if(iBTBFMessage)
   1.672 +		{
   1.673 +		delete iBTBFMessage;
   1.674 +		iBTBFMessage = NULL;
   1.675 +		}
   1.676 +	iBTBFMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.677 +	return EFalse;
   1.678 +	}
   1.679 +
   1.680 +TBool CMMFDevSoundSession::DoCancelBufferToBeFilledEventL(const RMmfIpcMessage& /*aMessage*/)
   1.681 +	{
   1.682 +	if(iBTBFMessage)
   1.683 +		iBTBFMessage->Complete(KErrCancel);
   1.684 +	return ETrue;
   1.685 +	}
   1.686 +
   1.687 +TBool CMMFDevSoundSession::DoBufferToBeEmptiedEventL(const RMmfIpcMessage& aMessage)
   1.688 +	{
   1.689 +	if(iBTBEMessage)
   1.690 +		{
   1.691 +		delete iBTBEMessage;
   1.692 +		iBTBEMessage = NULL;
   1.693 +		}
   1.694 +	iBTBEMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.695 +	return EFalse;
   1.696 +	}
   1.697 +
   1.698 +TBool CMMFDevSoundSession::DoCancelBufferToBeEmptiedEventL(const RMmfIpcMessage& /*aMessage*/)
   1.699 +	{
   1.700 +	if(iBTBEMessage)
   1.701 +		iBTBEMessage->Complete(KErrCancel);
   1.702 +	return ETrue;
   1.703 +	}
   1.704 +
   1.705 +TBool CMMFDevSoundSession::DoPlayErrorEventL(const RMmfIpcMessage& aMessage)
   1.706 +	{
   1.707 +	if(iPEMessage)
   1.708 +		{
   1.709 +		delete iPEMessage;
   1.710 +		iPEMessage = NULL;
   1.711 +		}
   1.712 +	iPEMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.713 +	return EFalse;
   1.714 +	}
   1.715 +
   1.716 +TBool CMMFDevSoundSession::DoCancelPlayErrorEventL(const RMmfIpcMessage& /*aMessage*/)
   1.717 +	{
   1.718 +	if(iPEMessage)
   1.719 +		iPEMessage->Complete(KErrCancel);
   1.720 +	return ETrue;
   1.721 +	}
   1.722 +
   1.723 +TBool CMMFDevSoundSession::DoRecordErrorEventL(const RMmfIpcMessage& aMessage)
   1.724 +	{
   1.725 +	if(iREMessage)
   1.726 +		{
   1.727 +		delete iREMessage;
   1.728 +		iREMessage = NULL;
   1.729 +		}
   1.730 +	iREMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.731 +	return EFalse;
   1.732 +	}
   1.733 +
   1.734 +TBool CMMFDevSoundSession::DoCancelRecordErrorEventL(const RMmfIpcMessage& /*aMessage*/)
   1.735 +	{
   1.736 +	if(iREMessage)
   1.737 +		iREMessage->Complete(KErrCancel);
   1.738 +	return ETrue;
   1.739 +	}
   1.740 +
   1.741 +TBool CMMFDevSoundSession::DoToneFinishedEventL(const RMmfIpcMessage& aMessage)
   1.742 +	{
   1.743 +	if(iTFMessage)
   1.744 +		{
   1.745 +		delete iTFMessage;
   1.746 +		iTFMessage = NULL;
   1.747 +		}
   1.748 +	iTFMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.749 +	return EFalse;
   1.750 +	}
   1.751 +
   1.752 +TBool CMMFDevSoundSession::DoCancelToneFinishedEventL(const RMmfIpcMessage& /*aMessage*/)
   1.753 +	{
   1.754 +	if(iTFMessage)
   1.755 +		iTFMessage->Complete(KErrCancel);
   1.756 +	return ETrue;
   1.757 +	}
   1.758 +
   1.759 +TBool CMMFDevSoundSession::DoSendEventToClientEventL(const RMmfIpcMessage& aMessage)
   1.760 +	{
   1.761 +	if(iSETCMessage)
   1.762 +		{
   1.763 +		delete iSETCMessage;
   1.764 +		iSETCMessage = NULL;
   1.765 +		}
   1.766 +	iSETCMessage = new (ELeave) RMmfIpcMessage(aMessage);
   1.767 +	return EFalse;
   1.768 +	}
   1.769 +
   1.770 +TBool CMMFDevSoundSession::DoCancelSendEventToClientEventL(const RMmfIpcMessage& /*aMessage*/)
   1.771 +	{
   1.772 +	if(iSETCMessage)
   1.773 +		iSETCMessage->Complete(KErrCancel);
   1.774 +	return ETrue;
   1.775 +	}
   1.776 +
   1.777 +TBool CMMFDevSoundSession::DoRegisterAsClientL(const RMmfIpcMessage& aMessage)
   1.778 +	{
   1.779 +	TMMFDevSoundProxySettingsPckg buf;
   1.780 +	aMessage.ReadL(0,buf);
   1.781 +	HBufC8* notificationRegistrationData = NULL;
   1.782 +	notificationRegistrationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLengthL(1)));
   1.783 +	TPtr8 dataPtr(notificationRegistrationData->Des());  	
   1.784 +	aMessage.ReadL(1,dataPtr);
   1.785 +	TInt err = KErrNone;
   1.786 +	err = iBody->RegisterAsClient(buf().iNotificationEventUid,dataPtr);
   1.787 +	CleanupStack::PopAndDestroy(1); // Notification Registeration data
   1.788 +	if (err != KErrNone)
   1.789 +		{
   1.790 +		aMessage.Complete(err);
   1.791 +		return EFalse;		
   1.792 +		}
   1.793 +	return ETrue;
   1.794 +	}
   1.795 +	
   1.796 +TBool CMMFDevSoundSession::DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage)
   1.797 +	{
   1.798 +	TMMFDevSoundProxySettingsPckg buf;
   1.799 +	aMessage.ReadL(0,buf);
   1.800 +	TInt err = KErrNone;
   1.801 +	err = iBody->CancelRegisterAsClient(buf().iNotificationEventUid);
   1.802 +	if (err != KErrNone)
   1.803 +		{
   1.804 +		aMessage.Complete(err);
   1.805 +		return EFalse;		
   1.806 +		}
   1.807 +	return ETrue;
   1.808 +	}
   1.809 +
   1.810 +TBool CMMFDevSoundSession::DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage)
   1.811 +	{
   1.812 +	TMMFDevSoundProxySettingsPckg buf;
   1.813 +	aMessage.ReadL(0,buf);
   1.814 +	HBufC8* notificationData = NULL;
   1.815 +	notificationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesMaxLengthL(2)));
   1.816 +	TPtr8 dataPtr(notificationData->Des());  	
   1.817 +	aMessage.ReadL(2,dataPtr);
   1.818 +	TInt err = KErrNone;
   1.819 +	err = iBody->GetResourceNotificationData(buf().iNotificationEventUid,dataPtr);
   1.820 +	aMessage.WriteL(2,*notificationData);
   1.821 +	CleanupStack::PopAndDestroy(1); // Notification data
   1.822 +	if (err != KErrNone)
   1.823 +		{
   1.824 +		aMessage.Complete(err);
   1.825 +		return EFalse;		
   1.826 +		}
   1.827 +	return ETrue;
   1.828 +	}
   1.829 +
   1.830 +TBool CMMFDevSoundSession::DoWillResumePlayL(const RMmfIpcMessage& aMessage)
   1.831 +	{
   1.832 +	TInt err = KErrNone;
   1.833 +	if(CheckClientCapabilities())
   1.834 +		{
   1.835 +		err = iBody->WillResumePlay();
   1.836 +		}
   1.837 +	else
   1.838 +		{
   1.839 +		err = KErrPermissionDenied;
   1.840 +		}
   1.841 +		
   1.842 +	if (err != KErrNone)
   1.843 +		{
   1.844 +		aMessage.Complete(err);
   1.845 +		return EFalse;		
   1.846 +		}
   1.847 +	return ETrue;
   1.848 +	}
   1.849 +
   1.850 +TBool CMMFDevSoundSession::DoSetClientThreadInfoL(const RMmfIpcMessage& aMessage)
   1.851 +	{
   1.852 +	if (aMessage.HasCapability(ECapabilityMultimediaDD))
   1.853 +		{		
   1.854 +		TPckgBuf<TThreadId> threadId;
   1.855 +		aMessage.ReadL(0, threadId);
   1.856 +		
   1.857 +		CMMFDevSoundServer* server = 
   1.858 +			const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
   1.859 +		server->SetClientCapabilitiesL(threadId());
   1.860 +		iClientHasCaps = server->CheckClientCapabilities();
   1.861 +		}
   1.862 +	else
   1.863 +		{
   1.864 +		User::Leave(KErrPermissionDenied);
   1.865 +		}
   1.866 +	
   1.867 +	return ETrue;
   1.868 +	}
   1.869 +
   1.870 +void CMMFDevSoundSession::SendEventToClient(/*TMMFAudioPolicyEvent& aEvent*/)
   1.871 +	{
   1.872 +	}
   1.873 +
   1.874 +
   1.875 +/*
   1.876 + *
   1.877 + *	Default Constructor.
   1.878 + *
   1.879 + *
   1.880 + */
   1.881 +CMMFDevSoundSession::CMMFDevSoundSession()
   1.882 +	{
   1.883 +	}
   1.884 +
   1.885 +CMMFDevSoundSession::~CMMFDevSoundSession()
   1.886 +	{
   1.887 +	delete iBTBFMessage;
   1.888 +	delete iBTBEMessage;
   1.889 +	delete iPEMessage;
   1.890 +	delete iREMessage;
   1.891 +	delete iTFMessage;
   1.892 +	delete iICMessage;
   1.893 +	delete iSETCMessage;
   1.894 +	iArray.Close();
   1.895 +	delete iDTMFString;
   1.896 +	delete iToneSeqBuf;
   1.897 +	delete iBody;
   1.898 +
   1.899 +	CMMFDevSoundServer* server = 
   1.900 +		const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
   1.901 +	if (server)
   1.902 +		{
   1.903 +		server->DecrementSessionId();		
   1.904 +		}
   1.905 +	}
   1.906 +
   1.907 +/*
   1.908 + *  -doxygen comments moved to header-
   1.909 + *
   1.910 + *	Constructs, and returns a pointer to, a new CMMFDevSoundProxy object.
   1.911 + *
   1.912 + *	Leaves on failure.
   1.913 + *
   1.914 + */
   1.915 +CMMFDevSoundSession* CMMFDevSoundSession::NewL(RServer2& aPolicyServerHandle)
   1.916 +	{
   1.917 +	CMMFDevSoundSession* self = new (ELeave) CMMFDevSoundSessionXtnd;
   1.918 +	CleanupStack::PushL(self);
   1.919 +	self->ConstructL(aPolicyServerHandle);
   1.920 +	CleanupStack::Pop();
   1.921 +	return self;
   1.922 +	}
   1.923 +
   1.924 +/*
   1.925 + *  -doxygen comments moved to header-
   1.926 + *
   1.927 + *	Second phase constructor.
   1.928 + *
   1.929 + */
   1.930 +void CMMFDevSoundSession::ConstructL(RServer2& aPolicyServerHandle)
   1.931 +	{
   1.932 +	iBody = CMMFDevSoundSvrImp::NewL(static_cast<CMMFDevSoundSessionXtnd*>(this));
   1.933 +	iBody->Construct3L(aPolicyServerHandle);
   1.934 +	}
   1.935 +
   1.936 +//callbacks
   1.937 +void CMMFDevSoundSession::InitializeComplete(TInt aError)
   1.938 +	{
   1.939 +	if (iICMessage)
   1.940 +		{
   1.941 +		iICMessage->Complete(aError);
   1.942 +		delete iICMessage;
   1.943 +		iICMessage = NULL;
   1.944 +		}
   1.945 +	}
   1.946 +
   1.947 +void CMMFDevSoundSession::ToneFinished(TInt aError)
   1.948 +	{
   1.949 +	iTFMessage->Complete(aError);
   1.950 +	delete iTFMessage;
   1.951 +	iTFMessage = NULL;
   1.952 +	}
   1.953 +
   1.954 +void CMMFDevSoundSession::BufferToBeFilled(CMMFBuffer* aBuffer)
   1.955 +	{
   1.956 +	/* store here "aBuffer" to be used later with PlayData*/
   1.957 +	iBufferPlay = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
   1.958 +
   1.959 +	TMMFDevSoundProxyHwBuf set;
   1.960 +	set.iBufferType = iBufferPlay->Type();
   1.961 +	set.iRequestSize = iBufferPlay->RequestSize();
   1.962 +	set.iBufferSize = iBufferPlay->Data().MaxLength();
   1.963 +	set.iLastBuffer = iBufferPlay->LastBuffer();
   1.964 +	TMMFDevSoundProxyHwBufPckg pckg(set);
   1.965 +	TInt err = MmfMessageUtil::Write(*iBTBFMessage, 0, pckg);
   1.966 +	iBTBFMessage->Complete(err);
   1.967 +	delete iBTBFMessage;
   1.968 +	iBTBFMessage = NULL;
   1.969 +	}
   1.970 +
   1.971 +void CMMFDevSoundSession::PlayError(TInt aError)
   1.972 +	{
   1.973 +	if (iPEMessage)
   1.974 +		{
   1.975 +		iPEMessage->Complete(aError);
   1.976 +		delete iPEMessage;
   1.977 +		iPEMessage = NULL;
   1.978 +		}
   1.979 +	else
   1.980 +		{
   1.981 +		// need to send message but for some reason nobody to send to - just swallow
   1.982 +		__DEBUGGER() 
   1.983 +		}
   1.984 +	}
   1.985 +
   1.986 +void CMMFDevSoundSession::BufferToBeEmptied(CMMFBuffer* aBuffer)
   1.987 +	{
   1.988 +	iBufferRecord = reinterpret_cast<CMMFDataBuffer*>(aBuffer);
   1.989 +
   1.990 +	TMMFDevSoundProxyHwBuf set;
   1.991 +	set.iBufferType = iBufferRecord->Type();
   1.992 +	set.iRequestSize = iBufferRecord->RequestSize();
   1.993 +	set.iBufferSize = iBufferRecord->Data().MaxLength();
   1.994 +	set.iLastBuffer = iBufferRecord->LastBuffer();
   1.995 +	TMMFDevSoundProxyHwBufPckg pckg(set);
   1.996 +	TInt err = MmfMessageUtil::Write(*iBTBEMessage, 0, pckg);
   1.997 +	iBTBEMessage->Complete(err);
   1.998 +	delete iBTBEMessage;
   1.999 +	iBTBEMessage = NULL;
  1.1000 +	}
  1.1001 +
  1.1002 +void CMMFDevSoundSession::RecordError(TInt aError)
  1.1003 +	{
  1.1004 +	iREMessage->Complete(aError);
  1.1005 +	delete iREMessage;
  1.1006 +	iREMessage = NULL;
  1.1007 +	}
  1.1008 +
  1.1009 +void CMMFDevSoundSession::ConvertError(TInt /*aError*/)
  1.1010 +	{
  1.1011 +	}
  1.1012 +void CMMFDevSoundSession::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
  1.1013 +	{
  1.1014 +	}
  1.1015 +
  1.1016 +void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent)
  1.1017 +	{
  1.1018 +	TMMFEventPckg iEventPckg(aEvent);
  1.1019 +	TInt err = MmfMessageUtil::Write(*iSETCMessage, 0, iEventPckg);
  1.1020 +	iSETCMessage->Complete(err);
  1.1021 +	delete iSETCMessage;
  1.1022 +	iSETCMessage = NULL;
  1.1023 +	}
  1.1024 +
  1.1025 +/********************************************************************************
  1.1026 + *				Non Exported public functions begins here						*
  1.1027 + ********************************************************************************/
  1.1028 +
  1.1029 +//
  1.1030 +//				Audio Policy specific implementation begins here				//
  1.1031 +//
  1.1032 +
  1.1033 +/**
  1.1034 + *
  1.1035 + *	Sets Id for this instance of DevSound
  1.1036 + *
  1.1037 + *	@param	"TInt aDevSoundId"
  1.1038 + *			Integer value assigned by Audio Policy Server
  1.1039 + *
  1.1040 + */
  1.1041 +void CMMFDevSoundSessionXtnd::SetDevSoundId(TInt aDevSoundId)
  1.1042 +	{
  1.1043 +	iBody->SetDevSoundId(aDevSoundId);
  1.1044 +	}
  1.1045 +
  1.1046 +/**
  1.1047 + *
  1.1048 + *	Returns information about this DevSound instance.
  1.1049 + *
  1.1050 + *	This method is used by Audio Policy Server to make audio policy decisions.
  1.1051 + *
  1.1052 + *	@return	"TMMFDevSoundinfo"
  1.1053 + *			A reference to TMMFDevSoundinfo object holding the current settings
  1.1054 + *			of this DevSound instance.
  1.1055 + *
  1.1056 + */
  1.1057 +TMMFDevSoundInfo CMMFDevSoundSessionXtnd::DevSoundInfo()
  1.1058 +	{
  1.1059 + 	return iBody->DevSoundInfo();
  1.1060 +	}
  1.1061 +
  1.1062 +/**
  1.1063 + *
  1.1064 + *	Called by Audio Policy Server when a request to play is approved by the 
  1.1065 + *	Audio Policy Server.
  1.1066 + *
  1.1067 + *	Leaves on failure.
  1.1068 + *
  1.1069 + */
  1.1070 +void CMMFDevSoundSessionXtnd::StartPlayDataL()
  1.1071 +	{
  1.1072 +	iBody->StartPlayDataL();
  1.1073 +	}
  1.1074 +
  1.1075 +/**
  1.1076 + *
  1.1077 + *	Called by Audio Policy Server when a request to record is approved by the 
  1.1078 + *	Audio Policy Server.
  1.1079 + *
  1.1080 + *	Leaves on failure.
  1.1081 + *
  1.1082 + */
  1.1083 +void CMMFDevSoundSessionXtnd::StartRecordDataL()
  1.1084 +	{
  1.1085 +	iBody->StartRecordDataL();
  1.1086 +	}
  1.1087 +
  1.1088 +/**
  1.1089 + *
  1.1090 + *	Called by Audio Policy Server when a request to play tone is approved by
  1.1091 + *	the Audio Policy Server.
  1.1092 + *
  1.1093 + *	Leaves on failure.
  1.1094 + *
  1.1095 + */
  1.1096 +void CMMFDevSoundSessionXtnd::StartPlayToneL()
  1.1097 +	{
  1.1098 +	iBody->StartPlayToneL();
  1.1099 +	}
  1.1100 +
  1.1101 +/**
  1.1102 + *
  1.1103 + *	Called by Audio Policy Server when a request to play a dual tone is approved by
  1.1104 + *	the Audio Policy Server.
  1.1105 + *
  1.1106 + */
  1.1107 +void CMMFDevSoundSessionXtnd::StartPlayDualToneL()
  1.1108 +	{
  1.1109 +	iBody->StartPlayDualToneL();
  1.1110 +	}
  1.1111 +
  1.1112 +/**
  1.1113 + *
  1.1114 + *	Called by Audio Policy Server when a request to play DTMF String is approved
  1.1115 + *	by the Audio Policy Server.
  1.1116 + *
  1.1117 + *	Leaves on failure.
  1.1118 + *
  1.1119 + */
  1.1120 +void CMMFDevSoundSessionXtnd::StartPlayDTMFStringL()
  1.1121 +	{
  1.1122 +	iBody->StartPlayDTMFStringL();
  1.1123 +	}
  1.1124 +
  1.1125 +/**
  1.1126 + *
  1.1127 + *	Called by Audio Policy Server when a request to play tone sequence is
  1.1128 + *	approved by the Audio Policy Server.
  1.1129 + *
  1.1130 + *	Leaves on failure.
  1.1131 + *
  1.1132 + */
  1.1133 +void CMMFDevSoundSessionXtnd::StartPlayToneSequenceL()
  1.1134 +	{
  1.1135 +	iBody->StartPlayToneSequenceL();
  1.1136 +	}
  1.1137 +
  1.1138 +/**
  1.1139 + *
  1.1140 + *	Called by Audio Policy Server when the current DevSound instance looses the
  1.1141 + *	policy because of another instance with a higher priority wants the device.
  1.1142 + *
  1.1143 + */
  1.1144 +void CMMFDevSoundSessionXtnd::SendEvent(const TMMFEvent& aEvent)
  1.1145 +	{
  1.1146 +	iBody->SendEventToClient(aEvent);
  1.1147 +	}
  1.1148 +
  1.1149 +
  1.1150 +//
  1.1151 +//				Audio Policy specific implementation begins here				//
  1.1152 +//
  1.1153 +
  1.1154 +/**
  1.1155 + *
  1.1156 + *	Updates the total bytes played.
  1.1157 + *
  1.1158 + */
  1.1159 +void CMMFDevSoundSessionXtnd::UpdateBytesPlayed()
  1.1160 +	{
  1.1161 +	iBody->UpdateBytesPlayed();
  1.1162 +	}
  1.1163 +
  1.1164 +
  1.1165 +
  1.1166 +