os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptationbody.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptationbody.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1249 @@
     1.4 +// Copyright (c) 2006-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 +
    1.20 +
    1.21 +
    1.22 +#include <e32base.h>
    1.23 +
    1.24 +#include "mmfdevsoundadaptationbody.h"
    1.25 +#include "cdevaudiocontrol.h"
    1.26 +#include "cdevaudio.h"
    1.27 +#include "a3ffourcclookup.h"
    1.28 +
    1.29 +#include <a3f/audioformatuids.h>
    1.30 +
    1.31 +#include "mglobalproperties.h"
    1.32 +
    1.33 +const TInt KDefaultOnDTMFLength = 250000;
    1.34 +const TInt KDefaultOffDTMFLength = 50000;
    1.35 +const TInt KDefaultPauseDTMFLength = 250000;
    1.36 +const TInt KDefaultBufferSize = 4096;
    1.37 +
    1.38 +// ============================ MEMBER FUNCTIONS =============================// -----------------------------------------------------------------------------
    1.39 +// CMMFDevSoundAdaptation::CBody::CBody
    1.40 +// C++ default constructor can NOT contain any code, that
    1.41 +// might leave.
    1.42 +// -----------------------------------------------------------------------------
    1.43 +//
    1.44 +CMMFDevSoundAdaptation::CBody::CBody(MDevSoundAdaptationObserver& aDevSoundObserver, 
    1.45 +									MGlobalProperties& aGlobalProperties)
    1.46 +	:iDevSoundObserver(aDevSoundObserver)
    1.47 +	{
    1.48 +	TRACE_CREATE();
    1.49 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CBody *CD1*, CtxDevSound, DPLOCAL);
    1.50 +	DP_IN();
    1.51 +	
    1.52 +	iGlobalProperties = &aGlobalProperties;
    1.53 +	
    1.54 +	iMode = EMMFStateIdle;
    1.55 +	// Initialize default config for cases when the DevSound's client query using 
    1.56 +	// CMMDevSound::Config() before setting the configuration through 
    1.57 +	// CMMDevSound::SetConfigL(TMMFCappabilites aConfig)
    1.58 +	iMmfConfig.iRate = EMMFSampleRate8000Hz;
    1.59 +	iMmfConfig.iEncoding = EMMFSoundEncoding16BitPCM;
    1.60 +	iMmfConfig.iChannels = EMMFMono;
    1.61 +	iMmfConfig.iBufferSize = KDefaultBufferSize;
    1.62 +
    1.63 +	DP_OUT();
    1.64 +	}
    1.65 +
    1.66 +// -----------------------------------------------------------------------------
    1.67 +// CMMFDevSoundAdaptation::CBody::ConstructL
    1.68 +// Symbian 2nd phase constructor can leave.
    1.69 +// assumes that iParent has already been set up properly
    1.70 +// -----------------------------------------------------------------------------
    1.71 +//
    1.72 +void CMMFDevSoundAdaptation::CBody::ConstructL(MGlobalProperties& aGlobalProperties)
    1.73 +	{
    1.74 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ConstructL *CD1*, CtxDevSound, DPLOCAL);
    1.75 +	DP_IN();
    1.76 +
    1.77 +	// create DevAudio
    1.78 +	iDevAudio = CDevAudio::NewL(iDevSoundObserver, aGlobalProperties);
    1.79 +	
    1.80 +	//Default values for DTMF tones
    1.81 +	iToneData.SetDtmfLengths(KDefaultOnDTMFLength,KDefaultOffDTMFLength,KDefaultPauseDTMFLength);
    1.82 +	
    1.83 +	DP_OUT();
    1.84 +	}
    1.85 +
    1.86 +// -----------------------------------------------------------------------------
    1.87 +// CMMFDevSoundAdaptation::CBody::NewL
    1.88 +// Two-phased constructor.
    1.89 +// -----------------------------------------------------------------------------
    1.90 +//
    1.91 +CMMFDevSoundAdaptation::CBody* CMMFDevSoundAdaptation::CBody::NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
    1.92 +																MGlobalProperties& aGlobalProperties)
    1.93 +	{
    1.94 +	DP_STATIC_CONTEXT(CMMFDevSoundAdaptation::CBody::NewL *CD0*, CtxDevSound, DPLOCAL);
    1.95 +	DP_IN();
    1.96 +	CMMFDevSoundAdaptation::CBody* self = new (ELeave) CBody(aDevSoundObserver, aGlobalProperties);
    1.97 +	CleanupStack::PushL(self);
    1.98 +	self->ConstructL(aGlobalProperties);
    1.99 +	CleanupStack::Pop(self);
   1.100 +	DP0_RET(self, "0x%x");
   1.101 +	}
   1.102 +
   1.103 +// -----------------------------------------------------------------------------
   1.104 +// CMMFDevSoundAdaptation::CBody::~CBody
   1.105 +// Destructor
   1.106 +// -----------------------------------------------------------------------------
   1.107 +//
   1.108 +CMMFDevSoundAdaptation::CBody::~CBody()
   1.109 +	{
   1.110 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::~CBody *CD1*, CtxDevSound, DPLOCAL);
   1.111 +	DP_IN();
   1.112 +	if(iDevAudio)
   1.113 +		{
   1.114 +		delete iDevAudio;
   1.115 +		}
   1.116 +	DP_OUT();
   1.117 +	}
   1.118 +	
   1.119 +// CMMFDevSoundAdaptation:CBody::PostOpenL()
   1.120 +// 2nd phase post open - used to setup internal attributes asynchronously
   1.121 +//
   1.122 +void CMMFDevSoundAdaptation::CBody::PostOpenL()
   1.123 +	{
   1.124 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PostOpenL *CD1*, CtxDevSound, DPLOCAL);
   1.125 +	DP_IN();
   1.126 +	User::LeaveIfError(iDevAudio->PostOpen());
   1.127 +	DP_OUT();
   1.128 +	}
   1.129 +
   1.130 +// -----------------------------------------------------------------------------
   1.131 +// CMMFDevSoundAdaptation::CBody::InitializeL
   1.132 +// Initializes CMMFDevSoundProxy object to play and record PCM16 raw audio data
   1.133 +// with sampling rate of 8 KHz.
   1.134 +// On completion of Initialization, calls InitializeComplete() on
   1.135 +// aDevSoundObserver.
   1.136 +// Leaves on failure.
   1.137 +// (other items were commented in a header).
   1.138 +// -----------------------------------------------------------------------------
   1.139 +//
   1.140 +void CMMFDevSoundAdaptation::CBody::InitializeL(TMMFState aMode)
   1.141 +	{
   1.142 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
   1.143 +	DP_IN();
   1.144 +	if (aMode == EMMFStateTonePlaying)
   1.145 +		{
   1.146 +		DoInitializeL(KUidFormatTone, aMode); 
   1.147 +		}
   1.148 +	else
   1.149 +		{
   1.150 +		DoInitializeL(KUidFormatPCM16, aMode);
   1.151 +		}
   1.152 +	DP_OUT();
   1.153 +	}
   1.154 +
   1.155 +// -----------------------------------------------------------------------------
   1.156 +// CMMFDevSoundAdaptation::CBody::InitializeL
   1.157 +// Initializes DevSound object for the mode aMode for processing audio data
   1.158 +// with hardware device aHWDev.
   1.159 +// On completion of Initialization, the observer will be notified via call back
   1.160 +// InitializeComplete().
   1.161 +// Leaves on failure.
   1.162 +// (other items were commented in a header).
   1.163 +// -----------------------------------------------------------------------------
   1.164 +//
   1.165 +void CMMFDevSoundAdaptation::CBody::InitializeL(TUid /*aHWDev*/,
   1.166 +								TMMFState /*aMode*/)
   1.167 +	{
   1.168 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
   1.169 +	DP_IN();
   1.170 +	User::LeaveIfError(KErrNotSupported);
   1.171 +	DP_OUT();
   1.172 +	}
   1.173 +
   1.174 +// -----------------------------------------------------------------------------
   1.175 +// CMMFDevSoundAdaptation::CBody::InitializeL
   1.176 +// Initializes DevSound object for the mode aMode for processing audio data
   1.177 +// with hardware device supporting FourCC aDesiredFourCC.
   1.178 +// On completion of Initialization, the observer will be notified via call back
   1.179 +// InitializeComplete().
   1.180 +// Leaves on failure.
   1.181 +// (other items were commented in a header).
   1.182 +// -----------------------------------------------------------------------------
   1.183 +//
   1.184 +void CMMFDevSoundAdaptation::CBody::InitializeL(
   1.185 +								TFourCC aDesiredFourCC,
   1.186 +								TMMFState aMode)
   1.187 +	{
   1.188 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
   1.189 +	DP_IN();
   1.190 +	
   1.191 +	TUid format = {0};
   1.192 +	TInt err = KErrNone;
   1.193 +	
   1.194 +	err = iGlobalProperties->GetFourCCConvertor().FourCCToFormat(aDesiredFourCC, format);
   1.195 +	if(err == KErrNone)
   1.196 +		{
   1.197 +		DoInitializeL(format, aMode);
   1.198 +		}
   1.199 +	else
   1.200 +		{
   1.201 +		User::LeaveIfError(KErrNotSupported);
   1.202 +		}
   1.203 +	DP_OUT();
   1.204 +	}
   1.205 +
   1.206 +// -----------------------------------------------------------------------------
   1.207 +// CMMFDevSoundAdaptation::CBody::DoInitializeL
   1.208 +// -----------------------------------------------------------------------------
   1.209 +//
   1.210 +void CMMFDevSoundAdaptation::CBody::DoInitializeL(
   1.211 +								TUid aFormat,
   1.212 +								TMMFState aMode)
   1.213 +	{
   1.214 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::DoInitializeL *CD1*, CtxDevSound, DPLOCAL);
   1.215 +	DP2_IN("format=0x%x, mode=%d",aFormat.iUid,aMode);
   1.216 +
   1.217 +
   1.218 +	ASSERT(iDevAudio);
   1.219 +
   1.220 +	TInt err(KErrNone);
   1.221 +
   1.222 +	if ((aMode == EMMFStatePlaying) || (aMode == EMMFStateRecording)
   1.223 +			|| (aMode == EMMFStateTonePlaying))
   1.224 +		{
   1.225 +		err = iDevAudio->Initialize(aFormat, aMode);
   1.226 +		}
   1.227 +	else
   1.228 +		{
   1.229 +		err = KErrNotSupported;
   1.230 +		}
   1.231 +	User::LeaveIfError(err);
   1.232 +
   1.233 +	iMode = aMode;
   1.234 +
   1.235 +	DP_OUT();
   1.236 +	}
   1.237 +
   1.238 +// -----------------------------------------------------------------------------
   1.239 +// CMMFDevSoundAdaptation::CBody::CancelInitialize
   1.240 +// Cancels the initialization of DevSound object
   1.241 +// returns an error code
   1.242 +// (other items were commented in a header).
   1.243 +// -----------------------------------------------------------------------------
   1.244 +//
   1.245 +TInt CMMFDevSoundAdaptation::CBody::CancelInitialize()
   1.246 +	{
   1.247 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CancelInitialize *CD1*, CtxDevSound, DPLOCAL);
   1.248 +	DP_IN();
   1.249 +	TInt err=iDevAudio->CancelInitialize();
   1.250 +	DP0_RET(err, "%d");
   1.251 +	}
   1.252 +
   1.253 +
   1.254 +// -----------------------------------------------------------------------------
   1.255 +// CMMFDevSoundAdaptation::CBody::Capabilities
   1.256 +// Returns the supported Audio settings.
   1.257 +// (other items were commented in a header).
   1.258 +// -----------------------------------------------------------------------------
   1.259 +//
   1.260 +TInt CMMFDevSoundAdaptation::CBody::Capabilities(TMMFCapabilities& aCap)
   1.261 +	{
   1.262 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Capabilities *CD1*, CtxDevSound, DPLOCAL);
   1.263 +	DP_IN();
   1.264 +	// query real values, on error just return last known (default) values
   1.265 +	TInt err = iDevAudio->GetAudioControl()->GetCapabilities(aCap);
   1.266 +	DP0_RET(err, "%d");
   1.267 +	}
   1.268 +
   1.269 +// -----------------------------------------------------------------------------
   1.270 +// CMMFDevSoundAdaptation::CBody::Config()
   1.271 +// Returns the current audio settings.
   1.272 +// (other items were commented in a header).
   1.273 +// -----------------------------------------------------------------------------
   1.274 +//
   1.275 +TMMFCapabilities CMMFDevSoundAdaptation::CBody::Config() const
   1.276 +	{
   1.277 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Config *CD1*, CtxDevSound, DPLOCAL);
   1.278 +	DP_IN();
   1.279 +	// Query real values, on error just return last known (default) values
   1.280 +	TMMFCapabilities config;
   1.281 +	TInt err = iDevAudio->GetAudioControl()->GetConfig(config);
   1.282 +	// TBD: for now, just return set value for encoding - codec does not give this
   1.283 +	config.iEncoding = iMmfConfig.iEncoding;
   1.284 +	if ( err == KErrNone )
   1.285 +		{
   1.286 +		DP0_RET(config, "0");
   1.287 +		}
   1.288 +	DP0_RET(iMmfConfig, "0");
   1.289 +	}
   1.290 +
   1.291 +// -----------------------------------------------------------------------------
   1.292 +// CMMFDevSoundAdaptation::CBody::SetConfigL
   1.293 +// Configure device for the settings in aConfig.
   1.294 +// Use this to set sampling rate, Encoding and Mono/Stereo.
   1.295 +//
   1.296 +// (other items were commented in a header).
   1.297 +// -----------------------------------------------------------------------------
   1.298 +//
   1.299 +void CMMFDevSoundAdaptation::CBody::SetConfigL(const TMMFCapabilities& aConfig)
   1.300 +	{
   1.301 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetConfigL *CD1*, CtxDevSound, DPLOCAL);
   1.302 +	DP3_IN("rate 0x%x, channels 0x%x, encoding 0x%x",
   1.303 +			aConfig.iRate, aConfig.iChannels, aConfig.iEncoding);
   1.304 +	User::LeaveIfError(iDevAudio->GetAudioControl()->SetConfig(aConfig));
   1.305 +	// success, update local copy
   1.306 +	iMmfConfig.iRate = aConfig.iRate;
   1.307 +	iMmfConfig.iChannels = aConfig.iChannels;
   1.308 +	iMmfConfig.iEncoding = aConfig.iEncoding;
   1.309 +	DP_OUT();
   1.310 +	}
   1.311 +
   1.312 +// -----------------------------------------------------------------------------
   1.313 +// CMMFDevSoundAdaptation::CBody::MaxVolume
   1.314 +// Returns an integer representing the maximum volume.
   1.315 +// This is the maximum value which can be passed to CMMFDevSoundProxy::SetVolume
   1.316 +// (other items were commented in a header).
   1.317 +// -----------------------------------------------------------------------------
   1.318 +//
   1.319 +TInt CMMFDevSoundAdaptation::CBody::MaxVolume()
   1.320 +	{
   1.321 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::MaxVolume *CD1*, CtxDevSound, DPLOCAL);
   1.322 +	DP_IN();
   1.323 +	DP0_RET(iDevAudio->DevSoundMaxVolume(), "%d");
   1.324 +	}
   1.325 +
   1.326 +// -----------------------------------------------------------------------------
   1.327 +// CMMFDevSoundAdaptation::CBody::Volume
   1.328 +// Returns an integer representing the current volume.
   1.329 +// (other items were commented in a header).
   1.330 +// -----------------------------------------------------------------------------
   1.331 +//
   1.332 +TInt CMMFDevSoundAdaptation::CBody::Volume()
   1.333 +	{
   1.334 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Volume *CD1*, CtxDevSound, DPLOCAL);
   1.335 +	DP_IN();
   1.336 +	DP0_RET(iDevAudio->DevSoundVolume(), "%d");
   1.337 +	}
   1.338 +
   1.339 +// -----------------------------------------------------------------------------
   1.340 +// CMMFDevSoundAdaptation::CBody::SetVolume
   1.341 +// Changes the current playback volume to a specified value.
   1.342 +// The volume can be changed before or during playback and is effective
   1.343 +// immediately.
   1.344 +// (other items were commented in a header).
   1.345 +// -----------------------------------------------------------------------------
   1.346 +//
   1.347 +TInt CMMFDevSoundAdaptation::CBody::SetVolume(TInt aVolume, TBool& aAsyncCompletion)
   1.348 +	{
   1.349 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetVolume *CD1*, CtxDevSound, DPLOCAL);
   1.350 +	DP1_IN("aVolume = %d", aVolume);
   1.351 +	TInt error = iDevAudio->SetDevSoundVolume(aVolume, aAsyncCompletion);
   1.352 +	DP0_RET(error, "%d");
   1.353 +	}
   1.354 +
   1.355 +// -----------------------------------------------------------------------------
   1.356 +// CMMFDevSoundAdaptation::CBody::MaxGain
   1.357 +// Returns an integer representing the maximum gain.
   1.358 +// This is the maximum value which can be passed to CMMFDevSoundProxy::SetGain.
   1.359 +// (other items were commented in a header).
   1.360 +// -----------------------------------------------------------------------------
   1.361 +//
   1.362 +TInt CMMFDevSoundAdaptation::CBody::MaxGain()
   1.363 +	{
   1.364 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::MaxGain *CD1*, CtxDevSound, DPLOCAL);
   1.365 +	DP_IN();
   1.366 +	DP0_RET(iDevAudio->DevSoundMaxGain(), "%d");
   1.367 +	}
   1.368 +
   1.369 +// -----------------------------------------------------------------------------
   1.370 +// CMMFDevSoundAdaptation::CBody::Gain
   1.371 +// Returns an integer representing the current gain.
   1.372 +// (other items were commented in a header).
   1.373 +// -----------------------------------------------------------------------------
   1.374 +//
   1.375 +TInt CMMFDevSoundAdaptation::CBody::Gain()
   1.376 +	{
   1.377 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Gain *CD1*, CtxDevSound, DPLOCAL);
   1.378 +	DP_IN();
   1.379 +	DP0_RET(iDevAudio->DevSoundGain(), "%d");
   1.380 +	}
   1.381 +
   1.382 +// -----------------------------------------------------------------------------
   1.383 +// CMMFDevSoundAdaptation::CBody::SetGain
   1.384 +// Changes the current recording gain to a specified value.
   1.385 +// The gain can be changed before or during recording and is effective
   1.386 +// immediately.
   1.387 +// (other items were commented in a header).
   1.388 +// -----------------------------------------------------------------------------
   1.389 +//
   1.390 +TInt CMMFDevSoundAdaptation::CBody::SetGain(TInt aGain, TBool& aAsyncCompletion)
   1.391 +	{
   1.392 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetGain *CD1*, CtxDevSound, DPLOCAL);
   1.393 +	DP1_IN("aGain = %d", aGain);
   1.394 +	TInt error = iDevAudio->SetDevSoundGain(aGain, aAsyncCompletion);
   1.395 +	DP0_RET(error, "%d");
   1.396 +	}
   1.397 +
   1.398 +// -----------------------------------------------------------------------------
   1.399 +// CMMFDevSoundAdaptation::CBody::GetPlayBalanceL
   1.400 +// Returns the speaker balance set for playing.
   1.401 +// Leaves on failure.
   1.402 +// (other items were commented in a header).
   1.403 +// -----------------------------------------------------------------------------
   1.404 +//
   1.405 +void CMMFDevSoundAdaptation::CBody::GetPlayBalanceL(TInt& aLeftPercentage,
   1.406 +								                    TInt& aRightPercentage)
   1.407 +	{
   1.408 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetPlayBalanceL *CD1*, CtxDevSound, DPLOCAL);
   1.409 +	DP_IN();
   1.410 +	iDevAudio->GetDevSoundPlayBalance(aLeftPercentage, aRightPercentage);
   1.411 +	DP_OUT();
   1.412 +	}
   1.413 +
   1.414 +// -----------------------------------------------------------------------------
   1.415 +// CMMFDevSoundAdaptation::CBody::SetPlayBalanceL
   1.416 +// Sets the speaker balance for playing.
   1.417 +// The speaker balance can be changed before or during playback and is
   1.418 +// effective immediately.
   1.419 +// (other items were commented in a header).
   1.420 +// -----------------------------------------------------------------------------
   1.421 +//
   1.422 +void CMMFDevSoundAdaptation::CBody::SetPlayBalanceL(TInt aLeftPercentage,
   1.423 +													TInt aRightPercentage,
   1.424 +													TBool& aAsyncCompletion)
   1.425 +	{
   1.426 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetPlayBalanceL *CD1*, CtxDevSound, DPLOCAL);
   1.427 +	DP2_IN("aLeftPercentage = %d, aRightPercentage=%d", aLeftPercentage, aRightPercentage);
   1.428 +
   1.429 +	User::LeaveIfError(iDevAudio->SetDevSoundPlayBalance(aLeftPercentage, aRightPercentage, aAsyncCompletion));
   1.430 +
   1.431 +	DP_OUT();
   1.432 +	}
   1.433 +
   1.434 +// -----------------------------------------------------------------------------
   1.435 +// CMMFDevSoundAdaptation::CBody::GetRecordBalanceL
   1.436 +// Returns the microphone gain balance set for recording.
   1.437 +// Leaves on failure.
   1.438 +// (other items were commented in a header).
   1.439 +// -----------------------------------------------------------------------------
   1.440 +//
   1.441 +void CMMFDevSoundAdaptation::CBody::GetRecordBalanceL(TInt& aLeftPercentage,
   1.442 +								                      TInt& aRightPercentage)
   1.443 +	{
   1.444 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetRecordBalanceL *CD1*, CtxDevSound, DPLOCAL);
   1.445 +	DP_IN();
   1.446 +
   1.447 +	iDevAudio->GetDevSoundRecordBalance(aLeftPercentage, aRightPercentage);
   1.448 +
   1.449 +	DP_OUT();
   1.450 +	}
   1.451 +
   1.452 +// -----------------------------------------------------------------------------
   1.453 +// CMMFDevSoundAdaptation::CBody::SetRecordBalanceL
   1.454 +// Sets the microphone gain balance for recording.
   1.455 +// The microphone gain balance can be changed before or during recording and
   1.456 +// is effective immediately.
   1.457 +// (other items were commented in a header).
   1.458 +// -----------------------------------------------------------------------------
   1.459 +//
   1.460 +void CMMFDevSoundAdaptation::CBody::SetRecordBalanceL(TInt aLeftPercentage,
   1.461 +													  TInt aRightPercentage,
   1.462 +													  TBool& aAsyncCompletion)
   1.463 +	{
   1.464 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetRecordBalanceL *CD1*, CtxDevSound, DPLOCAL);
   1.465 +	DP2_IN("aLeftPercentage = %d, aRightPercentage=%d", aLeftPercentage, aRightPercentage);
   1.466 +
   1.467 +	User::LeaveIfError(iDevAudio->SetDevSoundRecordBalance(aLeftPercentage, aRightPercentage,aAsyncCompletion));
   1.468 +
   1.469 +	DP_OUT();
   1.470 +	}
   1.471 +
   1.472 +// -----------------------------------------------------------------------------
   1.473 +// CMMFDevSoundAdaptation::CBody::PlayInitL
   1.474 +// Initializes audio device and start play process. This method queries and
   1.475 +// acquires the audio policy before initializing audio device. If there was an
   1.476 +// error during policy initialization, PlayError() method will be called on
   1.477 +// the observer with error code KErrAccessDenied, otherwise BufferToBeFilled()
   1.478 +// method will be called with a buffer reference. After reading data into the
   1.479 +// buffer reference passed, the client should call PlayData() to play data.
   1.480 +//
   1.481 +// The amount of data that can be played is specified in
   1.482 +// CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
   1.483 +// size will be ignored.
   1.484 +//
   1.485 +// Leaves on failure.
   1.486 +// (other items were commented in a header).
   1.487 +// -----------------------------------------------------------------------------
   1.488 +//
   1.489 +void CMMFDevSoundAdaptation::CBody::PlayInitL()
   1.490 +	{
   1.491 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayInitL *CD1*, CtxDevSound, DPLOCAL);
   1.492 +	DP_IN();
   1.493 +
   1.494 +	if(iMode==EMMFStatePlaying)
   1.495 +		{
   1.496 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.497 +		}
   1.498 +	else
   1.499 +		{
   1.500 +		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
   1.501 +		User::Leave(KErrNotReady);
   1.502 +		}
   1.503 +	DP_OUT();
   1.504 +	}
   1.505 +
   1.506 +// -----------------------------------------------------------------------------
   1.507 +// CMMFDevSoundAdaptation::CBody::RecordInitL
   1.508 +// Initializes audio device and start record process. This method queries and
   1.509 +// acquires the audio policy before initializing audio device. If there was an
   1.510 +// error during policy initialization, RecordError() method will be called on
   1.511 +// the observer with error code KErrAccessDenied, otherwise BufferToBeEmptied()
   1.512 +// method will be called with a buffer reference. This buffer contains recorded
   1.513 +// or encoded data. After processing data in the buffer reference passed, the
   1.514 +// client should call RecordData() to continue recording process.
   1.515 +//
   1.516 +// The amount of data that is available is specified in
   1.517 +// CMMFBuffer::RequestSize().
   1.518 +//
   1.519 +// Leaves on failure.
   1.520 +// (other items were commented in a header).
   1.521 +// -----------------------------------------------------------------------------
   1.522 +//
   1.523 +void CMMFDevSoundAdaptation::CBody::RecordInitL()
   1.524 +	{
   1.525 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RecordInitL *CD1*, CtxDevSound, DPLOCAL);
   1.526 +	DP_IN();
   1.527 +	if(iMode==EMMFStateRecording)
   1.528 +		{
   1.529 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.530 +		}
   1.531 +	else
   1.532 +		{
   1.533 +		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
   1.534 +		User::Leave(KErrNotReady);
   1.535 +		}
   1.536 +	DP_OUT();
   1.537 +	}
   1.538 +
   1.539 +// -----------------------------------------------------------------------------
   1.540 +// CMMFDevSoundAdaptation::CBody::PlayData
   1.541 +// Plays data in the buffer at the current volume. The client should fill
   1.542 +// the buffer with audio data before calling this method. The Observer gets
   1.543 +// reference to buffer along with callback BufferToBeFilled(). When playing of
   1.544 +// the audio sample is complete, successfully or otherwise, the method
   1.545 +// PlayError() on observer is called.
   1.546 +// (other items were commented in a header).
   1.547 +// -----------------------------------------------------------------------------
   1.548 +//
   1.549 +void CMMFDevSoundAdaptation::CBody::PlayData()
   1.550 +	{
   1.551 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayData *CD1*, CtxDevSound, DPLOCAL);
   1.552 +	DP_IN();
   1.553 +
   1.554 +	if(iMode==EMMFStatePlaying)
   1.555 +		{
   1.556 +		iDevAudio->GetAudioControl()->ProcessData();
   1.557 +		}
   1.558 +	else
   1.559 +		{
   1.560 +		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
   1.561 +		}
   1.562 +	DP_OUT();
   1.563 +	}
   1.564 +
   1.565 +// -----------------------------------------------------------------------------
   1.566 +// CMMFDevSoundAdaptation::CBody::RecordData
   1.567 +// Contine the process of recording. Once the buffer is filled with recorded
   1.568 +// data, the Observer gets reference to buffer along with callback
   1.569 +// BufferToBeEmptied(). After processing the buffer (copying over to a
   1.570 +// different buffer or writing to file) the client should call this
   1.571 +// method to continue recording process.
   1.572 +// (other items were commented in a header).
   1.573 +// -----------------------------------------------------------------------------
   1.574 +//
   1.575 +void CMMFDevSoundAdaptation::CBody::RecordData()
   1.576 +	{
   1.577 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RecordData *CD1*, CtxDevSound, DPLOCAL);
   1.578 +	DP_IN();
   1.579 +	if(iMode==EMMFStateRecording)
   1.580 +		{
   1.581 +		iDevAudio->GetAudioControl()->ProcessData();
   1.582 +		}
   1.583 +	else
   1.584 +		{
   1.585 +		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
   1.586 +		}
   1.587 +	DP_OUT();
   1.588 +	}
   1.589 +
   1.590 +// -----------------------------------------------------------------------------
   1.591 +// CMMFDevSoundAdaptation::CBody::Stop
   1.592 +// Stops the ongoing operation (Play, Record, TonePlay)
   1.593 +// (other items were commented in a header).
   1.594 +// -----------------------------------------------------------------------------
   1.595 +//
   1.596 +TBool CMMFDevSoundAdaptation::CBody::Stop()
   1.597 +	{
   1.598 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Stop *CD1*, CtxDevSound, DPLOCAL);
   1.599 +	DP_IN();
   1.600 +	TBool isCompleted = EFalse;
   1.601 +	
   1.602 +	// Need for sequences when calling stop and is already stopped
   1.603 +	TDevSoundAdaptorState state = iDevAudio->ActiveState();
   1.604 +	if( (iMode != EMMFStateIdle) && 
   1.605 +		(state == EDevSoundAdaptorActive_Active || 
   1.606 +		state == EDevSoundAdaptorPaused_Primed ) )
   1.607 +		{
   1.608 +		TInt err = iDevAudio->GetAudioControl()->Stop();
   1.609 +		if (err != KErrNone)
   1.610 +			{
   1.611 +			isCompleted = ETrue;
   1.612 +			}
   1.613 +		}
   1.614 +	else
   1.615 +		{
   1.616 +		isCompleted = ETrue;	
   1.617 +		}
   1.618 +	DP_OUT();
   1.619 +	return isCompleted;
   1.620 +	}
   1.621 +
   1.622 +// -----------------------------------------------------------------------------
   1.623 +// CMMFDevSoundAdaptation::CBody::Pause
   1.624 +// Temporarily Stops the ongoing operation (Play, Record, TonePlay)
   1.625 +// (other items were commented in a header).
   1.626 +// -----------------------------------------------------------------------------
   1.627 +//
   1.628 +TInt CMMFDevSoundAdaptation::CBody::Pause()
   1.629 +	{
   1.630 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Pause *CD1*, CtxDevSound, DPLOCAL);
   1.631 +	DP_IN();
   1.632 +
   1.633 +	TInt err = iDevAudio->GetAudioControl()->Pause();
   1.634 +	DP0_RET(err, "%d");
   1.635 +	}
   1.636 +
   1.637 +// -----------------------------------------------------------------------------
   1.638 +// CMMFDevSoundAdaptation::CBody::SamplesRecorded
   1.639 +// Returns the sample recorded so far.
   1.640 +// (other items were commented in a header).
   1.641 +// -----------------------------------------------------------------------------
   1.642 +//
   1.643 +TInt CMMFDevSoundAdaptation::CBody::SamplesRecorded()
   1.644 +	{
   1.645 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SamplesRecorded *CD1*, CtxDevSound, DPLOCAL);
   1.646 +	DP_IN();
   1.647 +
   1.648 +	if(iMode==EMMFStateRecording)
   1.649 +		{
   1.650 +		DP_OUT();
   1.651 +		return(iDevAudio->GetAudioControl()->GetSamples());
   1.652 +		}
   1.653 +	else
   1.654 +		{
   1.655 +		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
   1.656 +		DP0_RET(0, "%d");
   1.657 +		}
   1.658 +	}
   1.659 +
   1.660 +// -----------------------------------------------------------------------------
   1.661 +// CMMFDevSoundAdaptation::CBody::SamplesPlayed
   1.662 +// Returns the sample played so far.
   1.663 +// (other items were commented in a header).
   1.664 +// -----------------------------------------------------------------------------
   1.665 +//
   1.666 +TInt CMMFDevSoundAdaptation::CBody::SamplesPlayed()
   1.667 +	{
   1.668 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SamplesPlayed *CD1*, CtxDevSound, DPLOCAL);
   1.669 +	DP_IN();
   1.670 +	if(iMode==EMMFStatePlaying)
   1.671 +		{
   1.672 +		DP_OUT();
   1.673 +		return(iDevAudio->GetAudioControl()->GetSamples());
   1.674 +		}
   1.675 +	else
   1.676 +		{
   1.677 +		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
   1.678 +		DP0_RET(0, "%d");
   1.679 +		}
   1.680 +	}
   1.681 +
   1.682 +// -----------------------------------------------------------------------------
   1.683 +// CMMFDevSoundAdaptation::CBody::PlayToneL
   1.684 +// Initializes audio device and start playing tone. Tone is played with
   1.685 +// frequency and for duration specified.
   1.686 +// Leaves on failure.
   1.687 +// (other items were commented in a header).
   1.688 +// -----------------------------------------------------------------------------
   1.689 +//
   1.690 +void CMMFDevSoundAdaptation::CBody::PlayToneL(
   1.691 +								TInt aFrequency,
   1.692 +								const TTimeIntervalMicroSeconds& aDuration)
   1.693 +	{
   1.694 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayToneL *CD1*, CtxDevSound, DPLOCAL);
   1.695 +	DP1_IN("aFrequency = %d", aFrequency);
   1.696 +
   1.697 +	if(iMode==EMMFStateTonePlaying)
   1.698 +		{
   1.699 +		iToneData.SetType(TToneData::ESimple);
   1.700 +		iToneData.SetFrequencyOne(aFrequency);
   1.701 +		iToneData.SetDuration(aDuration);
   1.702 +		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
   1.703 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.704 +		}
   1.705 +	else
   1.706 +		{
   1.707 +		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
   1.708 +		User::Leave(KErrNotSupported);
   1.709 +		}
   1.710 +
   1.711 +	DP_OUT();
   1.712 +	}
   1.713 +
   1.714 +// -----------------------------------------------------------------------------
   1.715 +// CMMFDevSoundAdaptation::CBody::PlayDualToneL
   1.716 +// Initializes audio device and start playing a dual tone.
   1.717 +// The tone consists of two sine waves of different frequencies summed together
   1.718 +// Dual Tone is played with specified frequencies and for specified duration.
   1.719 +// (other items were commented in a header).
   1.720 +// -----------------------------------------------------------------------------
   1.721 +//
   1.722 +void CMMFDevSoundAdaptation::CBody::PlayDualToneL(
   1.723 +								TInt aFrequencyOne,
   1.724 +								TInt aFrequencyTwo,
   1.725 +								const TTimeIntervalMicroSeconds& aDuration)
   1.726 +	{
   1.727 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayDualToneL *CD1*, CtxDevSound, DPLOCAL);
   1.728 +	DP2_IN("aFrequencyOne = %d, aFrequencyTwo=%d", aFrequencyOne, aFrequencyTwo);
   1.729 +
   1.730 +	if(iMode==EMMFStateTonePlaying)
   1.731 +		{
   1.732 +		iToneData.SetType(TToneData::EDual); 
   1.733 +		iToneData.SetFrequencyOne(aFrequencyOne);
   1.734 +		iToneData.SetFrequencyTwo(aFrequencyTwo);
   1.735 +		iToneData.SetDuration(aDuration);
   1.736 +		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
   1.737 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.738 +		}
   1.739 +	else
   1.740 +		{
   1.741 +		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
   1.742 +		User::Leave(KErrNotSupported);
   1.743 +		}
   1.744 +	DP_OUT();
   1.745 +	}
   1.746 +
   1.747 +// -----------------------------------------------------------------------------
   1.748 +// CMMFDevSoundAdaptation::CBody::PlayDTMFStringL
   1.749 +// Initializes audio device and start playing DTMF string aDTMFString.
   1.750 +// Leaves on failure.
   1.751 +// (other items were commented in a header).
   1.752 +// -----------------------------------------------------------------------------
   1.753 +//
   1.754 +void CMMFDevSoundAdaptation::CBody::PlayDTMFStringL(const TDesC& aDTMFString)
   1.755 +	{
   1.756 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayDTMFStringL *CD1*, CtxDevSound, DPLOCAL);
   1.757 +	DP_IN();
   1.758 +
   1.759 +	if(iMode==EMMFStateTonePlaying)
   1.760 +		{
   1.761 +		iToneData.SetType(TToneData::EDtmfString);
   1.762 +		iToneData.SetDTMFString(const_cast<TDesC&>(aDTMFString));
   1.763 +		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
   1.764 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.765 +		}
   1.766 +	else
   1.767 +		{
   1.768 +		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
   1.769 +		User::Leave(KErrNotSupported);
   1.770 +		}
   1.771 +
   1.772 +	DP_OUT();
   1.773 +	}
   1.774 +
   1.775 +// -----------------------------------------------------------------------------
   1.776 +// CMMFDevSoundAdaptation::CBody::PlayToneSequenceL
   1.777 +// Initializes audio device and start playing tone sequence.
   1.778 +//
   1.779 +// Leaves on failure.
   1.780 +// (other items were commented in a header).
   1.781 +// -----------------------------------------------------------------------------
   1.782 +//
   1.783 +void CMMFDevSoundAdaptation::CBody::PlayToneSequenceL(const TDesC8& aData)
   1.784 +	{
   1.785 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayToneSequenceL *CD1*, CtxDevSound, DPLOCAL);
   1.786 +	DP_IN();
   1.787 +
   1.788 +	if(iMode==EMMFStateTonePlaying)
   1.789 +		{
   1.790 +		iToneData.SetType(TToneData::ESequence); 
   1.791 +		iToneData.SetSequenceData(const_cast<TDesC8&>(aData));
   1.792 +		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
   1.793 +		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
   1.794 +		}
   1.795 +	else
   1.796 +		{
   1.797 +		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
   1.798 +		User::Leave(KErrNotSupported);
   1.799 +		}
   1.800 +
   1.801 +	DP_OUT();
   1.802 +	}
   1.803 +
   1.804 +// -----------------------------------------------------------------------------
   1.805 +// CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL
   1.806 +// Initializes audio device and start playing the specified pre-defined tone
   1.807 +// sequence.
   1.808 +//
   1.809 +// Leaves on failure.
   1.810 +// (other items were commented in a header).
   1.811 +// -----------------------------------------------------------------------------
   1.812 +//
   1.813 +void CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL(TInt /*aSequenceNumber*/)
   1.814 +	{
   1.815 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL *CD1*, CtxDevSound, DPLOCAL);
   1.816 +	DP_IN();
   1.817 +	User::Leave(KErrNotSupported);
   1.818 +	DP_OUT();
   1.819 +	}
   1.820 +
   1.821 +// -----------------------------------------------------------------------------
   1.822 +// CMMFDevSoundAdaptation::CBody::SetToneRepeats
   1.823 +// Defines the number of times the audio is to be repeated during the tone
   1.824 +// playback operation. A period of silence can follow each playing of tone.
   1.825 +// The tone playing can be repeated indefinitely.
   1.826 +// Supported only during tone playing.
   1.827 +// (other items were commented in a header).
   1.828 +// -----------------------------------------------------------------------------
   1.829 +//
   1.830 +TInt CMMFDevSoundAdaptation::CBody::SetToneRepeats(
   1.831 +								TInt aRepeatCount,
   1.832 +								const TTimeIntervalMicroSeconds& aRepeatTrailingSilence)
   1.833 +	{
   1.834 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetToneRepeats *CD1*, CtxDevSound, DPLOCAL);
   1.835 +	DP1_IN("aRepeatCount = %d", aRepeatCount);
   1.836 +
   1.837 +	TInt err = KErrNone;
   1.838 +	iToneData.SetRepeatCount(aRepeatCount);
   1.839 +	iToneData.SetRepeatTrailingSilence(aRepeatTrailingSilence);
   1.840 +		
   1.841 +	DP0_RET(err, "%d");
   1.842 +	}
   1.843 +
   1.844 +// -----------------------------------------------------------------------------
   1.845 +// CMMFDevSoundAdaptation::CBody::SetDTMFLengths
   1.846 +// Defines the duration of tone on, tone off and tone pause to be used during
   1.847 +// the DTMF tone playback operation.
   1.848 +// Supported only during tone playing.
   1.849 +// (other items were commented in a header).
   1.850 +// -----------------------------------------------------------------------------
   1.851 +//
   1.852 +TInt CMMFDevSoundAdaptation::CBody::SetDTMFLengths(
   1.853 +								TTimeIntervalMicroSeconds32& aToneOnLength,
   1.854 +								TTimeIntervalMicroSeconds32& aToneOffLength,
   1.855 +								TTimeIntervalMicroSeconds32& aPauseLength)
   1.856 +	{
   1.857 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetDTMFLengths *CD1*, CtxDevSound, DPLOCAL);
   1.858 +	DP_IN();
   1.859 +
   1.860 +	TInt err = KErrNone;
   1.861 +	if (aToneOnLength.Int() < KMdaInfiniteDurationDTMFToneOnLength)
   1.862 +		{
   1.863 +		aToneOnLength = TTimeIntervalMicroSeconds32(0);
   1.864 +		}
   1.865 +	if (aToneOffLength.Int() < 0)
   1.866 +		{
   1.867 +		aToneOffLength = TTimeIntervalMicroSeconds32(0);
   1.868 +		}
   1.869 +	if (aPauseLength.Int() < 0)
   1.870 +		{
   1.871 +		aPauseLength = TTimeIntervalMicroSeconds32(0);
   1.872 +		}
   1.873 +	
   1.874 +	iToneData.SetDtmfLengths(aToneOnLength, aToneOffLength, aPauseLength);
   1.875 +	
   1.876 +	DP0_RET(err, "%d");
   1.877 +	}
   1.878 +
   1.879 +// -----------------------------------------------------------------------------
   1.880 +// CMMFDevSoundAdaptation::CBody::SetVolumeRamp
   1.881 +// Defines the period over which the volume level is to rise smoothly from
   1.882 +// nothing to the normal volume level.
   1.883 +// (other items were commented in a header).
   1.884 +// -----------------------------------------------------------------------------
   1.885 +//
   1.886 +TInt CMMFDevSoundAdaptation::CBody::SetVolumeRamp(
   1.887 +								const TTimeIntervalMicroSeconds& aRampDuration)
   1.888 +	{
   1.889 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetVolumeRamp *CD1*, CtxDevSound, DPLOCAL);
   1.890 +	DP_IN();
   1.891 +
   1.892 +	TInt err = iDevAudio->SetVolumeRamp(aRampDuration);
   1.893 +	DP0_RET(err, "%d");
   1.894 +	}
   1.895 +
   1.896 +// -----------------------------------------------------------------------------
   1.897 +// CMMFDevSoundAdaptation::CBody::SetPrioritySettings
   1.898 +// Defines the priority settings that should be used for this instance.
   1.899 +// (other items were commented in a header).
   1.900 +// -----------------------------------------------------------------------------
   1.901 +//
   1.902 +TInt CMMFDevSoundAdaptation::CBody::SetPrioritySettings(
   1.903 +								const TMMFPrioritySettings& aPrioritySettings)
   1.904 +	{
   1.905 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetPrioritySettings *CD1*, CtxDevSound, DPLOCAL);
   1.906 +	DP_IN();
   1.907 +
   1.908 +	TInt err = iDevAudio->SetPrioritySettings(aPrioritySettings);
   1.909 +	if (err == KErrNone)
   1.910 +		{
   1.911 +		iPrioritySettings = aPrioritySettings;
   1.912 +		}
   1.913 +	DP0_RET(err, "%d");
   1.914 +	}
   1.915 +
   1.916 +// -----------------------------------------------------------------------------
   1.917 +// CMMFDevSoundAdaptation::CBody::CustomInterface
   1.918 +// @see sounddevice.h
   1.919 +// (other items were commented in a header).
   1.920 +// -----------------------------------------------------------------------------
   1.921 +//
   1.922 +TAny* CMMFDevSoundAdaptation::CBody::CustomInterface(TUid aInterfaceId)
   1.923 +	{
   1.924 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CustomInterface *CD1*, CtxDevSound, DPLOCAL);
   1.925 +	DP_IN();
   1.926 +	if ( iDevAudio )
   1.927 +		{
   1.928 +		DP_OUT();
   1.929 +		return(iDevAudio->GetAudioControl()->CustomInterface(aInterfaceId));
   1.930 +		}
   1.931 +	else
   1.932 +		{
   1.933 +		DP0_RET(NULL, "%d");
   1.934 +		}
   1.935 +	}
   1.936 +
   1.937 +// -----------------------------------------------------------------------------
   1.938 +// CMMFDevSoundAdaptation::CBody::FixedSequenceCount
   1.939 +// Returns the number of available pre-defined tone sequences.
   1.940 +// This is the number of fixed sequence supported by DevSound by default.
   1.941 +// (other items were commented in a header).
   1.942 +// -----------------------------------------------------------------------------
   1.943 +//
   1.944 +TInt CMMFDevSoundAdaptation::CBody::FixedSequenceCount()
   1.945 +	{
   1.946 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::FixedSequenceCount *CD1*, CtxDevSound, DPLOCAL);
   1.947 +	DP_IN();
   1.948 +	DP0_RET(0, "%d");
   1.949 +	}
   1.950 +
   1.951 +// -----------------------------------------------------------------------------
   1.952 +// CMMFDevSoundAdaptation::CBody::FixedSequenceName
   1.953 +// Returns the name assigned to a specific pre-defined tone sequence.
   1.954 +// This is the number of fixed sequence supported by DevSound by default.
   1.955 +// The function raises a panic if sequence number specified invalid.
   1.956 +// (other items were commented in a header).
   1.957 +// -----------------------------------------------------------------------------
   1.958 +//
   1.959 +const TDesC& CMMFDevSoundAdaptation::CBody::FixedSequenceName(
   1.960 +								TInt /*aSequenceNumber*/)
   1.961 +	{
   1.962 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::FixedSequenceName *CD1*, CtxDevSound, DPLOCAL);
   1.963 +	DP_IN();
   1.964 +	DP0_RET(KNullDesC, "");
   1.965 +	}
   1.966 +
   1.967 +// -----------------------------------------------------------------------------
   1.968 +// CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL
   1.969 +// @see sounddevice.h
   1.970 +// (other items were commented in a header).
   1.971 +// -----------------------------------------------------------------------------
   1.972 +//
   1.973 +void CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL(
   1.974 +								RArray<TFourCC>& aSupportedDataTypes,
   1.975 +								const TMMFPrioritySettings& /*aPrioritySettings*/) const
   1.976 +	{
   1.977 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL *CD1*, CtxDevSound, DPLOCAL);
   1.978 +	DP_IN();
   1.979 +	//aPrioritySettings not used on ref DevSound
   1.980 +	//search for playing datatypes
   1.981 +	iDevAudio->DevSoundSupportedDataTypesL(aSupportedDataTypes, KDataForPlay);
   1.982 +	DP_OUT();
   1.983 +	}
   1.984 +
   1.985 +// -----------------------------------------------------------------------------
   1.986 +// CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL
   1.987 +// @see sounddevice.h
   1.988 +// (other items were commented in a header).
   1.989 +// -----------------------------------------------------------------------------
   1.990 +//
   1.991 +void CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL(
   1.992 +								RArray<TFourCC>& aSupportedDataTypes,
   1.993 +								const TMMFPrioritySettings& /*aPrioritySettings*/) const
   1.994 +	{
   1.995 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL *CD1*, CtxDevSound, DPLOCAL);
   1.996 +	DP_IN();
   1.997 +	//aPrioritySettings not used on ref DevSound
   1.998 +	// search for recording datatypes
   1.999 +	iDevAudio->DevSoundSupportedDataTypesL(aSupportedDataTypes, KDataForRecord);
  1.1000 +	DP_OUT();
  1.1001 +	}
  1.1002 +
  1.1003 +// -----------------------------------------------------------------------------
  1.1004 +// CMMFDevSoundAdaptation::CBody::SetClientConfig
  1.1005 +// Sets client capabilities for this instance of DevSound Adaptation.
  1.1006 +// (other items were commented in a header).
  1.1007 +// -----------------------------------------------------------------------------
  1.1008 +//
  1.1009 +TInt CMMFDevSoundAdaptation::CBody::SetClientConfig(
  1.1010 +                                const TProcessId& aActualProcessId,
  1.1011 +                                const TProcessId& aProcessId)
  1.1012 +    {
  1.1013 +    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetClientConfig *CD1*, CtxDevSound, DPLOCAL);
  1.1014 +    DP_IN();
  1.1015 +
  1.1016 +    TInt err = iDevAudio->SetClientConfig(aActualProcessId, aProcessId);
  1.1017 +    DP0_RET(err, "%d");
  1.1018 +    }
  1.1019 +
  1.1020 +TInt CMMFDevSoundAdaptation::CBody::SetClientConfig(
  1.1021 +                                const TProcessId& aProcessId)
  1.1022 +    {
  1.1023 +    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetClientConfig *CD1*, CtxDevSound, DPLOCAL);
  1.1024 +    DP_IN();
  1.1025 +
  1.1026 +    TInt err = iDevAudio->SetClientConfig(aProcessId);
  1.1027 +    DP0_RET(err, "%d");
  1.1028 +    }
  1.1029 +
  1.1030 +TBool CMMFDevSoundAdaptation::CBody::CloseDevSound()
  1.1031 +	{
  1.1032 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CloseDevSound *CD1*, CtxDevSound, DPLOCAL);
  1.1033 +	DP_IN();
  1.1034 +	DP_OUT();
  1.1035 +	return iDevAudio->GetAudioControl()->DestroyChain();
  1.1036 +	}
  1.1037 +
  1.1038 +// -----------------------------------------------------------------------------
  1.1039 +// CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived
  1.1040 +// (other items were commented in a header).
  1.1041 +// -----------------------------------------------------------------------------
  1.1042 +//	
  1.1043 +TInt CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived(TBool& asyncOperation)
  1.1044 +	{
  1.1045 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived *CD1*, CtxDevSound, DPLOCAL);
  1.1046 +	DP_IN();
  1.1047 +	DP_OUT();
  1.1048 +	return iDevAudio->GetAudioControl()->ProcessingFinishedReceived(asyncOperation);
  1.1049 +	}
  1.1050 +
  1.1051 +// -----------------------------------------------------------------------------
  1.1052 +// CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived
  1.1053 +// (other items were commented in a header).
  1.1054 +// -----------------------------------------------------------------------------
  1.1055 +//  
  1.1056 +TInt CMMFDevSoundAdaptation::CBody::ProcessingError(TBool& asyncOperation)
  1.1057 +    {
  1.1058 +    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ProcessingError *CD1*, CtxDevSound, DPLOCAL);
  1.1059 +    DP_IN();
  1.1060 +    DP_OUT();
  1.1061 +    return iDevAudio->GetAudioControl()->ProcessingError(asyncOperation);
  1.1062 +    }
  1.1063 +
  1.1064 +// -----------------------------------------------------------------------------
  1.1065 +// CMMFDevSoundAdaptation::CBody::EmptyBuffers
  1.1066 +// (other items were commented in a header).
  1.1067 +// -----------------------------------------------------------------------------
  1.1068 +//
  1.1069 +TInt CMMFDevSoundAdaptation::CBody::EmptyBuffers()
  1.1070 +	{
  1.1071 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::EmptyBuffers *CD1*, CtxDevSound, DPLOCAL);
  1.1072 +	DP_IN();
  1.1073 +	TInt err(KErrNone);
  1.1074 +	// Empty buffers is only supported on playing
  1.1075 +	if (iMode == EMMFStateRecording || iMode == EMMFStateTonePlaying)
  1.1076 +		{
  1.1077 +		err = KErrNotSupported;
  1.1078 +		}
  1.1079 +	else if (!iDevAudio)
  1.1080 +		{
  1.1081 +		err = KErrNotReady;
  1.1082 +		}
  1.1083 +	else
  1.1084 +		{
  1.1085 +		TDevSoundAdaptorState state = iDevAudio->ActiveState();
  1.1086 +		if (state == EDevSoundAdaptorActive_Active || 
  1.1087 +			state == EDevSoundAdaptorPaused_Primed )
  1.1088 +			{
  1.1089 +			err = iDevAudio->GetAudioControl()->RequestEmptyBuffers();
  1.1090 +			}
  1.1091 +		else
  1.1092 +			{
  1.1093 +			err = KErrNotReady;
  1.1094 +			}
  1.1095 +		}
  1.1096 +	DP0_RET(err, "%d");
  1.1097 +	}	
  1.1098 +
  1.1099 +
  1.1100 +
  1.1101 +
  1.1102 +// -----------------------------------------------------------------------------
  1.1103 +// CMMFDevSoundAdaptation::CBody::RegisterAsClient
  1.1104 +// (other items were commented in a header).
  1.1105 +// -----------------------------------------------------------------------------
  1.1106 +//
  1.1107 +TInt CMMFDevSoundAdaptation::CBody::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData)
  1.1108 +	{
  1.1109 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
  1.1110 +	DP_IN();
  1.1111 +	TInt err(KErrNone);
  1.1112 +	if (iDevAudio)
  1.1113 +		{
  1.1114 +		err = iDevAudio->RegisterAsClient(aEventType, aNotificationRegistrationData);
  1.1115 +		}
  1.1116 +	else
  1.1117 +		{
  1.1118 +		err = KErrNotReady;
  1.1119 +		}
  1.1120 +	DP0_RET(err, "%d");
  1.1121 +	}
  1.1122 +	
  1.1123 +	
  1.1124 +	
  1.1125 +	
  1.1126 +	
  1.1127 +// -----------------------------------------------------------------------------
  1.1128 +// CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient
  1.1129 +// (other items were commented in a header).
  1.1130 +// -----------------------------------------------------------------------------
  1.1131 +//
  1.1132 +TInt CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient(TUid aEventType)
  1.1133 +	{
  1.1134 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
  1.1135 +	DP_IN();
  1.1136 +	TInt err(KErrNone);
  1.1137 +	if (iDevAudio)
  1.1138 +		{
  1.1139 +		err = iDevAudio->CancelRegisterAsClient(aEventType);
  1.1140 +		}
  1.1141 +	else 
  1.1142 +		{
  1.1143 +		err = KErrNotReady;
  1.1144 +		}
  1.1145 +	DP0_RET(err, "%d");
  1.1146 +	}	
  1.1147 +
  1.1148 +
  1.1149 +
  1.1150 +
  1.1151 +// -----------------------------------------------------------------------------
  1.1152 +// CMMFDevSoundAdaptation::CBody::GetResourceNotificationData
  1.1153 +// (other items were commented in a header).
  1.1154 +// -----------------------------------------------------------------------------
  1.1155 +//
  1.1156 +TInt CMMFDevSoundAdaptation::CBody::GetResourceNotificationData(TUid /*aEventType*/, TDes8& aNotificationData)
  1.1157 +	{
  1.1158 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetResourceNotificationData *CD1*, CtxDevSound, DPLOCAL);
  1.1159 +	DP_IN();
  1.1160 +	TInt err(KErrNone);
  1.1161 +	if (iDevAudio)
  1.1162 +		{
  1.1163 +		TMMFTimeIntervalMicroSecondsPckg pckg = TTimeIntervalMicroSeconds(SamplesPlayed());
  1.1164 +		aNotificationData.Copy(pckg);
  1.1165 +		}
  1.1166 +	else
  1.1167 +		{
  1.1168 +		err = KErrNotReady;
  1.1169 +		}
  1.1170 +	DP0_RET(err, "%d");
  1.1171 +	}	
  1.1172 +
  1.1173 +
  1.1174 +
  1.1175 +
  1.1176 +// -----------------------------------------------------------------------------
  1.1177 +// CMMFDevSoundAdaptation::CBody::WillResumePlay
  1.1178 +// (other items were commented in a header).
  1.1179 +// -----------------------------------------------------------------------------
  1.1180 +//
  1.1181 +TInt CMMFDevSoundAdaptation::CBody::WillResumePlay()
  1.1182 +	{
  1.1183 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::WillResumePlay *CD1*, CtxDevSound, DPLOCAL);
  1.1184 +	DP_IN();
  1.1185 +	TInt err(KErrNone);
  1.1186 +	if (iDevAudio)
  1.1187 +		{
  1.1188 +		err = iDevAudio->WillResumePlay();
  1.1189 +		}
  1.1190 +	else
  1.1191 +		{
  1.1192 +		err = KErrNotReady;
  1.1193 +		}
  1.1194 +	DP0_RET(err, "%d");
  1.1195 +	}	
  1.1196 +
  1.1197 +// CMMFDevSoundAdaptation::CBody::GetTimePlayed
  1.1198 +// (other items were commented in a header).
  1.1199 +// -----------------------------------------------------------------------------
  1.1200 +//
  1.1201 +TInt CMMFDevSoundAdaptation::CBody::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
  1.1202 +	{
  1.1203 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetTimePlayed *CD1*, CtxDevSound, DPLOCAL);
  1.1204 +	DP_IN();
  1.1205 +	
  1.1206 +	TInt err = iDevAudio->GetAudioControl()->GetTimePlayed(aTime);
  1.1207 +	DP0_RET(err, "%d");
  1.1208 +	}
  1.1209 +		
  1.1210 +// -----------------------------------------------------------------------------
  1.1211 +// CMMFDevSoundAdaptation::CBody::IsResumeSupported
  1.1212 +// (other items were commented in a header).
  1.1213 +// -----------------------------------------------------------------------------
  1.1214 +//
  1.1215 +TBool CMMFDevSoundAdaptation::CBody::IsResumeSupported()
  1.1216 +	{
  1.1217 +	DP_CONTEXT(CMMFDevSoundAdaptation::IsResumeSupported *CD1*, CtxDevSound, DPLOCAL);
  1.1218 +	DP_IN();
  1.1219 +	TBool isSupported = iDevAudio->IsResumeSupported();
  1.1220 +	DP0_RET(isSupported, "%d");
  1.1221 +	}
  1.1222 +
  1.1223 +// -----------------------------------------------------------------------------
  1.1224 +// CMMFDevSoundAdaptation::CBody::Resume
  1.1225 +// (other items were commented in a header).
  1.1226 +// -----------------------------------------------------------------------------
  1.1227 +//
  1.1228 +TInt CMMFDevSoundAdaptation::CBody::Resume()
  1.1229 +	{
  1.1230 +	DP_CONTEXT(CMMFDevSoundAdaptation::Resume *CD1*, CtxDevSound, DPLOCAL);
  1.1231 +	DP_IN();
  1.1232 +	TInt err = iDevAudio->GetAudioControl()->Resume();
  1.1233 +	DP0_RET(err, "%d");
  1.1234 +	}
  1.1235 +
  1.1236 +void CMMFDevSoundAdaptation::CBody::BufferErrorEvent()
  1.1237 +	{
  1.1238 +	ASSERT(iDevAudio);
  1.1239 +	iDevAudio->GetAudioControl()->BufferErrorEvent();
  1.1240 +	}
  1.1241 +
  1.1242 +void CMMFDevSoundAdaptation::CBody::RollbackAdaptorActiveStateToBeforeCommit()
  1.1243 +	{
  1.1244 +	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RollbackAdaptorActiveStateToBeforeCommit *CD1*, CtxDevSound, DPLOCAL);
  1.1245 +	DP_IN();
  1.1246 +	TDevSoundAdaptorState previousState = iDevAudio->PreviousState();
  1.1247 +	// Set previous state to the active state set after state changing Commit call
  1.1248 +	iDevAudio->SetPreviousState(iDevAudio->ActiveState());
  1.1249 +	// Set active state to the previous state set before state changing Commit call
  1.1250 +	iDevAudio->SetActiveState(previousState);
  1.1251 +	DP_OUT();
  1.1252 +	}