os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptationbody.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
sl@0
    18
sl@0
    19
#include <e32base.h>
sl@0
    20
sl@0
    21
#include "mmfdevsoundadaptationbody.h"
sl@0
    22
#include "cdevaudiocontrol.h"
sl@0
    23
#include "cdevaudio.h"
sl@0
    24
#include "a3ffourcclookup.h"
sl@0
    25
sl@0
    26
#include <a3f/audioformatuids.h>
sl@0
    27
sl@0
    28
#include "mglobalproperties.h"
sl@0
    29
sl@0
    30
const TInt KDefaultOnDTMFLength = 250000;
sl@0
    31
const TInt KDefaultOffDTMFLength = 50000;
sl@0
    32
const TInt KDefaultPauseDTMFLength = 250000;
sl@0
    33
const TInt KDefaultBufferSize = 4096;
sl@0
    34
sl@0
    35
// ============================ MEMBER FUNCTIONS =============================// -----------------------------------------------------------------------------
sl@0
    36
// CMMFDevSoundAdaptation::CBody::CBody
sl@0
    37
// C++ default constructor can NOT contain any code, that
sl@0
    38
// might leave.
sl@0
    39
// -----------------------------------------------------------------------------
sl@0
    40
//
sl@0
    41
CMMFDevSoundAdaptation::CBody::CBody(MDevSoundAdaptationObserver& aDevSoundObserver, 
sl@0
    42
									MGlobalProperties& aGlobalProperties)
sl@0
    43
	:iDevSoundObserver(aDevSoundObserver)
sl@0
    44
	{
sl@0
    45
	TRACE_CREATE();
sl@0
    46
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CBody *CD1*, CtxDevSound, DPLOCAL);
sl@0
    47
	DP_IN();
sl@0
    48
	
sl@0
    49
	iGlobalProperties = &aGlobalProperties;
sl@0
    50
	
sl@0
    51
	iMode = EMMFStateIdle;
sl@0
    52
	// Initialize default config for cases when the DevSound's client query using 
sl@0
    53
	// CMMDevSound::Config() before setting the configuration through 
sl@0
    54
	// CMMDevSound::SetConfigL(TMMFCappabilites aConfig)
sl@0
    55
	iMmfConfig.iRate = EMMFSampleRate8000Hz;
sl@0
    56
	iMmfConfig.iEncoding = EMMFSoundEncoding16BitPCM;
sl@0
    57
	iMmfConfig.iChannels = EMMFMono;
sl@0
    58
	iMmfConfig.iBufferSize = KDefaultBufferSize;
sl@0
    59
sl@0
    60
	DP_OUT();
sl@0
    61
	}
sl@0
    62
sl@0
    63
// -----------------------------------------------------------------------------
sl@0
    64
// CMMFDevSoundAdaptation::CBody::ConstructL
sl@0
    65
// Symbian 2nd phase constructor can leave.
sl@0
    66
// assumes that iParent has already been set up properly
sl@0
    67
// -----------------------------------------------------------------------------
sl@0
    68
//
sl@0
    69
void CMMFDevSoundAdaptation::CBody::ConstructL(MGlobalProperties& aGlobalProperties)
sl@0
    70
	{
sl@0
    71
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ConstructL *CD1*, CtxDevSound, DPLOCAL);
sl@0
    72
	DP_IN();
sl@0
    73
sl@0
    74
	// create DevAudio
sl@0
    75
	iDevAudio = CDevAudio::NewL(iDevSoundObserver, aGlobalProperties);
sl@0
    76
	
sl@0
    77
	//Default values for DTMF tones
sl@0
    78
	iToneData.SetDtmfLengths(KDefaultOnDTMFLength,KDefaultOffDTMFLength,KDefaultPauseDTMFLength);
sl@0
    79
	
sl@0
    80
	DP_OUT();
sl@0
    81
	}
sl@0
    82
sl@0
    83
// -----------------------------------------------------------------------------
sl@0
    84
// CMMFDevSoundAdaptation::CBody::NewL
sl@0
    85
// Two-phased constructor.
sl@0
    86
// -----------------------------------------------------------------------------
sl@0
    87
//
sl@0
    88
CMMFDevSoundAdaptation::CBody* CMMFDevSoundAdaptation::CBody::NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
sl@0
    89
																MGlobalProperties& aGlobalProperties)
sl@0
    90
	{
sl@0
    91
	DP_STATIC_CONTEXT(CMMFDevSoundAdaptation::CBody::NewL *CD0*, CtxDevSound, DPLOCAL);
sl@0
    92
	DP_IN();
sl@0
    93
	CMMFDevSoundAdaptation::CBody* self = new (ELeave) CBody(aDevSoundObserver, aGlobalProperties);
sl@0
    94
	CleanupStack::PushL(self);
sl@0
    95
	self->ConstructL(aGlobalProperties);
sl@0
    96
	CleanupStack::Pop(self);
sl@0
    97
	DP0_RET(self, "0x%x");
sl@0
    98
	}
sl@0
    99
sl@0
   100
// -----------------------------------------------------------------------------
sl@0
   101
// CMMFDevSoundAdaptation::CBody::~CBody
sl@0
   102
// Destructor
sl@0
   103
// -----------------------------------------------------------------------------
sl@0
   104
//
sl@0
   105
CMMFDevSoundAdaptation::CBody::~CBody()
sl@0
   106
	{
sl@0
   107
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::~CBody *CD1*, CtxDevSound, DPLOCAL);
sl@0
   108
	DP_IN();
sl@0
   109
	if(iDevAudio)
sl@0
   110
		{
sl@0
   111
		delete iDevAudio;
sl@0
   112
		}
sl@0
   113
	DP_OUT();
sl@0
   114
	}
sl@0
   115
	
sl@0
   116
// CMMFDevSoundAdaptation:CBody::PostOpenL()
sl@0
   117
// 2nd phase post open - used to setup internal attributes asynchronously
sl@0
   118
//
sl@0
   119
void CMMFDevSoundAdaptation::CBody::PostOpenL()
sl@0
   120
	{
sl@0
   121
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PostOpenL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   122
	DP_IN();
sl@0
   123
	User::LeaveIfError(iDevAudio->PostOpen());
sl@0
   124
	DP_OUT();
sl@0
   125
	}
sl@0
   126
sl@0
   127
// -----------------------------------------------------------------------------
sl@0
   128
// CMMFDevSoundAdaptation::CBody::InitializeL
sl@0
   129
// Initializes CMMFDevSoundProxy object to play and record PCM16 raw audio data
sl@0
   130
// with sampling rate of 8 KHz.
sl@0
   131
// On completion of Initialization, calls InitializeComplete() on
sl@0
   132
// aDevSoundObserver.
sl@0
   133
// Leaves on failure.
sl@0
   134
// (other items were commented in a header).
sl@0
   135
// -----------------------------------------------------------------------------
sl@0
   136
//
sl@0
   137
void CMMFDevSoundAdaptation::CBody::InitializeL(TMMFState aMode)
sl@0
   138
	{
sl@0
   139
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   140
	DP_IN();
sl@0
   141
	if (aMode == EMMFStateTonePlaying)
sl@0
   142
		{
sl@0
   143
		DoInitializeL(KUidFormatTone, aMode); 
sl@0
   144
		}
sl@0
   145
	else
sl@0
   146
		{
sl@0
   147
		DoInitializeL(KUidFormatPCM16, aMode);
sl@0
   148
		}
sl@0
   149
	DP_OUT();
sl@0
   150
	}
sl@0
   151
sl@0
   152
// -----------------------------------------------------------------------------
sl@0
   153
// CMMFDevSoundAdaptation::CBody::InitializeL
sl@0
   154
// Initializes DevSound object for the mode aMode for processing audio data
sl@0
   155
// with hardware device aHWDev.
sl@0
   156
// On completion of Initialization, the observer will be notified via call back
sl@0
   157
// InitializeComplete().
sl@0
   158
// Leaves on failure.
sl@0
   159
// (other items were commented in a header).
sl@0
   160
// -----------------------------------------------------------------------------
sl@0
   161
//
sl@0
   162
void CMMFDevSoundAdaptation::CBody::InitializeL(TUid /*aHWDev*/,
sl@0
   163
								TMMFState /*aMode*/)
sl@0
   164
	{
sl@0
   165
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   166
	DP_IN();
sl@0
   167
	User::LeaveIfError(KErrNotSupported);
sl@0
   168
	DP_OUT();
sl@0
   169
	}
sl@0
   170
sl@0
   171
// -----------------------------------------------------------------------------
sl@0
   172
// CMMFDevSoundAdaptation::CBody::InitializeL
sl@0
   173
// Initializes DevSound object for the mode aMode for processing audio data
sl@0
   174
// with hardware device supporting FourCC aDesiredFourCC.
sl@0
   175
// On completion of Initialization, the observer will be notified via call back
sl@0
   176
// InitializeComplete().
sl@0
   177
// Leaves on failure.
sl@0
   178
// (other items were commented in a header).
sl@0
   179
// -----------------------------------------------------------------------------
sl@0
   180
//
sl@0
   181
void CMMFDevSoundAdaptation::CBody::InitializeL(
sl@0
   182
								TFourCC aDesiredFourCC,
sl@0
   183
								TMMFState aMode)
sl@0
   184
	{
sl@0
   185
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::InitializeL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   186
	DP_IN();
sl@0
   187
	
sl@0
   188
	TUid format = {0};
sl@0
   189
	TInt err = KErrNone;
sl@0
   190
	
sl@0
   191
	err = iGlobalProperties->GetFourCCConvertor().FourCCToFormat(aDesiredFourCC, format);
sl@0
   192
	if(err == KErrNone)
sl@0
   193
		{
sl@0
   194
		DoInitializeL(format, aMode);
sl@0
   195
		}
sl@0
   196
	else
sl@0
   197
		{
sl@0
   198
		User::LeaveIfError(KErrNotSupported);
sl@0
   199
		}
sl@0
   200
	DP_OUT();
sl@0
   201
	}
sl@0
   202
sl@0
   203
// -----------------------------------------------------------------------------
sl@0
   204
// CMMFDevSoundAdaptation::CBody::DoInitializeL
sl@0
   205
// -----------------------------------------------------------------------------
sl@0
   206
//
sl@0
   207
void CMMFDevSoundAdaptation::CBody::DoInitializeL(
sl@0
   208
								TUid aFormat,
sl@0
   209
								TMMFState aMode)
sl@0
   210
	{
sl@0
   211
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::DoInitializeL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   212
	DP2_IN("format=0x%x, mode=%d",aFormat.iUid,aMode);
sl@0
   213
sl@0
   214
sl@0
   215
	ASSERT(iDevAudio);
sl@0
   216
sl@0
   217
	TInt err(KErrNone);
sl@0
   218
sl@0
   219
	if ((aMode == EMMFStatePlaying) || (aMode == EMMFStateRecording)
sl@0
   220
			|| (aMode == EMMFStateTonePlaying))
sl@0
   221
		{
sl@0
   222
		err = iDevAudio->Initialize(aFormat, aMode);
sl@0
   223
		}
sl@0
   224
	else
sl@0
   225
		{
sl@0
   226
		err = KErrNotSupported;
sl@0
   227
		}
sl@0
   228
	User::LeaveIfError(err);
sl@0
   229
sl@0
   230
	iMode = aMode;
sl@0
   231
sl@0
   232
	DP_OUT();
sl@0
   233
	}
sl@0
   234
sl@0
   235
// -----------------------------------------------------------------------------
sl@0
   236
// CMMFDevSoundAdaptation::CBody::CancelInitialize
sl@0
   237
// Cancels the initialization of DevSound object
sl@0
   238
// returns an error code
sl@0
   239
// (other items were commented in a header).
sl@0
   240
// -----------------------------------------------------------------------------
sl@0
   241
//
sl@0
   242
TInt CMMFDevSoundAdaptation::CBody::CancelInitialize()
sl@0
   243
	{
sl@0
   244
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CancelInitialize *CD1*, CtxDevSound, DPLOCAL);
sl@0
   245
	DP_IN();
sl@0
   246
	TInt err=iDevAudio->CancelInitialize();
sl@0
   247
	DP0_RET(err, "%d");
sl@0
   248
	}
sl@0
   249
sl@0
   250
sl@0
   251
// -----------------------------------------------------------------------------
sl@0
   252
// CMMFDevSoundAdaptation::CBody::Capabilities
sl@0
   253
// Returns the supported Audio settings.
sl@0
   254
// (other items were commented in a header).
sl@0
   255
// -----------------------------------------------------------------------------
sl@0
   256
//
sl@0
   257
TInt CMMFDevSoundAdaptation::CBody::Capabilities(TMMFCapabilities& aCap)
sl@0
   258
	{
sl@0
   259
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Capabilities *CD1*, CtxDevSound, DPLOCAL);
sl@0
   260
	DP_IN();
sl@0
   261
	// query real values, on error just return last known (default) values
sl@0
   262
	TInt err = iDevAudio->GetAudioControl()->GetCapabilities(aCap);
sl@0
   263
	DP0_RET(err, "%d");
sl@0
   264
	}
sl@0
   265
sl@0
   266
// -----------------------------------------------------------------------------
sl@0
   267
// CMMFDevSoundAdaptation::CBody::Config()
sl@0
   268
// Returns the current audio settings.
sl@0
   269
// (other items were commented in a header).
sl@0
   270
// -----------------------------------------------------------------------------
sl@0
   271
//
sl@0
   272
TMMFCapabilities CMMFDevSoundAdaptation::CBody::Config() const
sl@0
   273
	{
sl@0
   274
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Config *CD1*, CtxDevSound, DPLOCAL);
sl@0
   275
	DP_IN();
sl@0
   276
	// Query real values, on error just return last known (default) values
sl@0
   277
	TMMFCapabilities config;
sl@0
   278
	TInt err = iDevAudio->GetAudioControl()->GetConfig(config);
sl@0
   279
	// TBD: for now, just return set value for encoding - codec does not give this
sl@0
   280
	config.iEncoding = iMmfConfig.iEncoding;
sl@0
   281
	if ( err == KErrNone )
sl@0
   282
		{
sl@0
   283
		DP0_RET(config, "0");
sl@0
   284
		}
sl@0
   285
	DP0_RET(iMmfConfig, "0");
sl@0
   286
	}
sl@0
   287
sl@0
   288
// -----------------------------------------------------------------------------
sl@0
   289
// CMMFDevSoundAdaptation::CBody::SetConfigL
sl@0
   290
// Configure device for the settings in aConfig.
sl@0
   291
// Use this to set sampling rate, Encoding and Mono/Stereo.
sl@0
   292
//
sl@0
   293
// (other items were commented in a header).
sl@0
   294
// -----------------------------------------------------------------------------
sl@0
   295
//
sl@0
   296
void CMMFDevSoundAdaptation::CBody::SetConfigL(const TMMFCapabilities& aConfig)
sl@0
   297
	{
sl@0
   298
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetConfigL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   299
	DP3_IN("rate 0x%x, channels 0x%x, encoding 0x%x",
sl@0
   300
			aConfig.iRate, aConfig.iChannels, aConfig.iEncoding);
sl@0
   301
	User::LeaveIfError(iDevAudio->GetAudioControl()->SetConfig(aConfig));
sl@0
   302
	// success, update local copy
sl@0
   303
	iMmfConfig.iRate = aConfig.iRate;
sl@0
   304
	iMmfConfig.iChannels = aConfig.iChannels;
sl@0
   305
	iMmfConfig.iEncoding = aConfig.iEncoding;
sl@0
   306
	DP_OUT();
sl@0
   307
	}
sl@0
   308
sl@0
   309
// -----------------------------------------------------------------------------
sl@0
   310
// CMMFDevSoundAdaptation::CBody::MaxVolume
sl@0
   311
// Returns an integer representing the maximum volume.
sl@0
   312
// This is the maximum value which can be passed to CMMFDevSoundProxy::SetVolume
sl@0
   313
// (other items were commented in a header).
sl@0
   314
// -----------------------------------------------------------------------------
sl@0
   315
//
sl@0
   316
TInt CMMFDevSoundAdaptation::CBody::MaxVolume()
sl@0
   317
	{
sl@0
   318
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::MaxVolume *CD1*, CtxDevSound, DPLOCAL);
sl@0
   319
	DP_IN();
sl@0
   320
	DP0_RET(iDevAudio->DevSoundMaxVolume(), "%d");
sl@0
   321
	}
sl@0
   322
sl@0
   323
// -----------------------------------------------------------------------------
sl@0
   324
// CMMFDevSoundAdaptation::CBody::Volume
sl@0
   325
// Returns an integer representing the current volume.
sl@0
   326
// (other items were commented in a header).
sl@0
   327
// -----------------------------------------------------------------------------
sl@0
   328
//
sl@0
   329
TInt CMMFDevSoundAdaptation::CBody::Volume()
sl@0
   330
	{
sl@0
   331
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Volume *CD1*, CtxDevSound, DPLOCAL);
sl@0
   332
	DP_IN();
sl@0
   333
	DP0_RET(iDevAudio->DevSoundVolume(), "%d");
sl@0
   334
	}
sl@0
   335
sl@0
   336
// -----------------------------------------------------------------------------
sl@0
   337
// CMMFDevSoundAdaptation::CBody::SetVolume
sl@0
   338
// Changes the current playback volume to a specified value.
sl@0
   339
// The volume can be changed before or during playback and is effective
sl@0
   340
// immediately.
sl@0
   341
// (other items were commented in a header).
sl@0
   342
// -----------------------------------------------------------------------------
sl@0
   343
//
sl@0
   344
TInt CMMFDevSoundAdaptation::CBody::SetVolume(TInt aVolume, TBool& aAsyncCompletion)
sl@0
   345
	{
sl@0
   346
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetVolume *CD1*, CtxDevSound, DPLOCAL);
sl@0
   347
	DP1_IN("aVolume = %d", aVolume);
sl@0
   348
	TInt error = iDevAudio->SetDevSoundVolume(aVolume, aAsyncCompletion);
sl@0
   349
	DP0_RET(error, "%d");
sl@0
   350
	}
sl@0
   351
sl@0
   352
// -----------------------------------------------------------------------------
sl@0
   353
// CMMFDevSoundAdaptation::CBody::MaxGain
sl@0
   354
// Returns an integer representing the maximum gain.
sl@0
   355
// This is the maximum value which can be passed to CMMFDevSoundProxy::SetGain.
sl@0
   356
// (other items were commented in a header).
sl@0
   357
// -----------------------------------------------------------------------------
sl@0
   358
//
sl@0
   359
TInt CMMFDevSoundAdaptation::CBody::MaxGain()
sl@0
   360
	{
sl@0
   361
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::MaxGain *CD1*, CtxDevSound, DPLOCAL);
sl@0
   362
	DP_IN();
sl@0
   363
	DP0_RET(iDevAudio->DevSoundMaxGain(), "%d");
sl@0
   364
	}
sl@0
   365
sl@0
   366
// -----------------------------------------------------------------------------
sl@0
   367
// CMMFDevSoundAdaptation::CBody::Gain
sl@0
   368
// Returns an integer representing the current gain.
sl@0
   369
// (other items were commented in a header).
sl@0
   370
// -----------------------------------------------------------------------------
sl@0
   371
//
sl@0
   372
TInt CMMFDevSoundAdaptation::CBody::Gain()
sl@0
   373
	{
sl@0
   374
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Gain *CD1*, CtxDevSound, DPLOCAL);
sl@0
   375
	DP_IN();
sl@0
   376
	DP0_RET(iDevAudio->DevSoundGain(), "%d");
sl@0
   377
	}
sl@0
   378
sl@0
   379
// -----------------------------------------------------------------------------
sl@0
   380
// CMMFDevSoundAdaptation::CBody::SetGain
sl@0
   381
// Changes the current recording gain to a specified value.
sl@0
   382
// The gain can be changed before or during recording and is effective
sl@0
   383
// immediately.
sl@0
   384
// (other items were commented in a header).
sl@0
   385
// -----------------------------------------------------------------------------
sl@0
   386
//
sl@0
   387
TInt CMMFDevSoundAdaptation::CBody::SetGain(TInt aGain, TBool& aAsyncCompletion)
sl@0
   388
	{
sl@0
   389
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetGain *CD1*, CtxDevSound, DPLOCAL);
sl@0
   390
	DP1_IN("aGain = %d", aGain);
sl@0
   391
	TInt error = iDevAudio->SetDevSoundGain(aGain, aAsyncCompletion);
sl@0
   392
	DP0_RET(error, "%d");
sl@0
   393
	}
sl@0
   394
sl@0
   395
// -----------------------------------------------------------------------------
sl@0
   396
// CMMFDevSoundAdaptation::CBody::GetPlayBalanceL
sl@0
   397
// Returns the speaker balance set for playing.
sl@0
   398
// Leaves on failure.
sl@0
   399
// (other items were commented in a header).
sl@0
   400
// -----------------------------------------------------------------------------
sl@0
   401
//
sl@0
   402
void CMMFDevSoundAdaptation::CBody::GetPlayBalanceL(TInt& aLeftPercentage,
sl@0
   403
								                    TInt& aRightPercentage)
sl@0
   404
	{
sl@0
   405
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetPlayBalanceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   406
	DP_IN();
sl@0
   407
	iDevAudio->GetDevSoundPlayBalance(aLeftPercentage, aRightPercentage);
sl@0
   408
	DP_OUT();
sl@0
   409
	}
sl@0
   410
sl@0
   411
// -----------------------------------------------------------------------------
sl@0
   412
// CMMFDevSoundAdaptation::CBody::SetPlayBalanceL
sl@0
   413
// Sets the speaker balance for playing.
sl@0
   414
// The speaker balance can be changed before or during playback and is
sl@0
   415
// effective immediately.
sl@0
   416
// (other items were commented in a header).
sl@0
   417
// -----------------------------------------------------------------------------
sl@0
   418
//
sl@0
   419
void CMMFDevSoundAdaptation::CBody::SetPlayBalanceL(TInt aLeftPercentage,
sl@0
   420
													TInt aRightPercentage,
sl@0
   421
													TBool& aAsyncCompletion)
sl@0
   422
	{
sl@0
   423
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetPlayBalanceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   424
	DP2_IN("aLeftPercentage = %d, aRightPercentage=%d", aLeftPercentage, aRightPercentage);
sl@0
   425
sl@0
   426
	User::LeaveIfError(iDevAudio->SetDevSoundPlayBalance(aLeftPercentage, aRightPercentage, aAsyncCompletion));
sl@0
   427
sl@0
   428
	DP_OUT();
sl@0
   429
	}
sl@0
   430
sl@0
   431
// -----------------------------------------------------------------------------
sl@0
   432
// CMMFDevSoundAdaptation::CBody::GetRecordBalanceL
sl@0
   433
// Returns the microphone gain balance set for recording.
sl@0
   434
// Leaves on failure.
sl@0
   435
// (other items were commented in a header).
sl@0
   436
// -----------------------------------------------------------------------------
sl@0
   437
//
sl@0
   438
void CMMFDevSoundAdaptation::CBody::GetRecordBalanceL(TInt& aLeftPercentage,
sl@0
   439
								                      TInt& aRightPercentage)
sl@0
   440
	{
sl@0
   441
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetRecordBalanceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   442
	DP_IN();
sl@0
   443
sl@0
   444
	iDevAudio->GetDevSoundRecordBalance(aLeftPercentage, aRightPercentage);
sl@0
   445
sl@0
   446
	DP_OUT();
sl@0
   447
	}
sl@0
   448
sl@0
   449
// -----------------------------------------------------------------------------
sl@0
   450
// CMMFDevSoundAdaptation::CBody::SetRecordBalanceL
sl@0
   451
// Sets the microphone gain balance for recording.
sl@0
   452
// The microphone gain balance can be changed before or during recording and
sl@0
   453
// is effective immediately.
sl@0
   454
// (other items were commented in a header).
sl@0
   455
// -----------------------------------------------------------------------------
sl@0
   456
//
sl@0
   457
void CMMFDevSoundAdaptation::CBody::SetRecordBalanceL(TInt aLeftPercentage,
sl@0
   458
													  TInt aRightPercentage,
sl@0
   459
													  TBool& aAsyncCompletion)
sl@0
   460
	{
sl@0
   461
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetRecordBalanceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   462
	DP2_IN("aLeftPercentage = %d, aRightPercentage=%d", aLeftPercentage, aRightPercentage);
sl@0
   463
sl@0
   464
	User::LeaveIfError(iDevAudio->SetDevSoundRecordBalance(aLeftPercentage, aRightPercentage,aAsyncCompletion));
sl@0
   465
sl@0
   466
	DP_OUT();
sl@0
   467
	}
sl@0
   468
sl@0
   469
// -----------------------------------------------------------------------------
sl@0
   470
// CMMFDevSoundAdaptation::CBody::PlayInitL
sl@0
   471
// Initializes audio device and start play process. This method queries and
sl@0
   472
// acquires the audio policy before initializing audio device. If there was an
sl@0
   473
// error during policy initialization, PlayError() method will be called on
sl@0
   474
// the observer with error code KErrAccessDenied, otherwise BufferToBeFilled()
sl@0
   475
// method will be called with a buffer reference. After reading data into the
sl@0
   476
// buffer reference passed, the client should call PlayData() to play data.
sl@0
   477
//
sl@0
   478
// The amount of data that can be played is specified in
sl@0
   479
// CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
sl@0
   480
// size will be ignored.
sl@0
   481
//
sl@0
   482
// Leaves on failure.
sl@0
   483
// (other items were commented in a header).
sl@0
   484
// -----------------------------------------------------------------------------
sl@0
   485
//
sl@0
   486
void CMMFDevSoundAdaptation::CBody::PlayInitL()
sl@0
   487
	{
sl@0
   488
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayInitL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   489
	DP_IN();
sl@0
   490
sl@0
   491
	if(iMode==EMMFStatePlaying)
sl@0
   492
		{
sl@0
   493
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   494
		}
sl@0
   495
	else
sl@0
   496
		{
sl@0
   497
		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
sl@0
   498
		User::Leave(KErrNotReady);
sl@0
   499
		}
sl@0
   500
	DP_OUT();
sl@0
   501
	}
sl@0
   502
sl@0
   503
// -----------------------------------------------------------------------------
sl@0
   504
// CMMFDevSoundAdaptation::CBody::RecordInitL
sl@0
   505
// Initializes audio device and start record process. This method queries and
sl@0
   506
// acquires the audio policy before initializing audio device. If there was an
sl@0
   507
// error during policy initialization, RecordError() method will be called on
sl@0
   508
// the observer with error code KErrAccessDenied, otherwise BufferToBeEmptied()
sl@0
   509
// method will be called with a buffer reference. This buffer contains recorded
sl@0
   510
// or encoded data. After processing data in the buffer reference passed, the
sl@0
   511
// client should call RecordData() to continue recording process.
sl@0
   512
//
sl@0
   513
// The amount of data that is available is specified in
sl@0
   514
// CMMFBuffer::RequestSize().
sl@0
   515
//
sl@0
   516
// Leaves on failure.
sl@0
   517
// (other items were commented in a header).
sl@0
   518
// -----------------------------------------------------------------------------
sl@0
   519
//
sl@0
   520
void CMMFDevSoundAdaptation::CBody::RecordInitL()
sl@0
   521
	{
sl@0
   522
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RecordInitL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   523
	DP_IN();
sl@0
   524
	if(iMode==EMMFStateRecording)
sl@0
   525
		{
sl@0
   526
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   527
		}
sl@0
   528
	else
sl@0
   529
		{
sl@0
   530
		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
sl@0
   531
		User::Leave(KErrNotReady);
sl@0
   532
		}
sl@0
   533
	DP_OUT();
sl@0
   534
	}
sl@0
   535
sl@0
   536
// -----------------------------------------------------------------------------
sl@0
   537
// CMMFDevSoundAdaptation::CBody::PlayData
sl@0
   538
// Plays data in the buffer at the current volume. The client should fill
sl@0
   539
// the buffer with audio data before calling this method. The Observer gets
sl@0
   540
// reference to buffer along with callback BufferToBeFilled(). When playing of
sl@0
   541
// the audio sample is complete, successfully or otherwise, the method
sl@0
   542
// PlayError() on observer is called.
sl@0
   543
// (other items were commented in a header).
sl@0
   544
// -----------------------------------------------------------------------------
sl@0
   545
//
sl@0
   546
void CMMFDevSoundAdaptation::CBody::PlayData()
sl@0
   547
	{
sl@0
   548
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayData *CD1*, CtxDevSound, DPLOCAL);
sl@0
   549
	DP_IN();
sl@0
   550
sl@0
   551
	if(iMode==EMMFStatePlaying)
sl@0
   552
		{
sl@0
   553
		iDevAudio->GetAudioControl()->ProcessData();
sl@0
   554
		}
sl@0
   555
	else
sl@0
   556
		{
sl@0
   557
		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
sl@0
   558
		}
sl@0
   559
	DP_OUT();
sl@0
   560
	}
sl@0
   561
sl@0
   562
// -----------------------------------------------------------------------------
sl@0
   563
// CMMFDevSoundAdaptation::CBody::RecordData
sl@0
   564
// Contine the process of recording. Once the buffer is filled with recorded
sl@0
   565
// data, the Observer gets reference to buffer along with callback
sl@0
   566
// BufferToBeEmptied(). After processing the buffer (copying over to a
sl@0
   567
// different buffer or writing to file) the client should call this
sl@0
   568
// method to continue recording process.
sl@0
   569
// (other items were commented in a header).
sl@0
   570
// -----------------------------------------------------------------------------
sl@0
   571
//
sl@0
   572
void CMMFDevSoundAdaptation::CBody::RecordData()
sl@0
   573
	{
sl@0
   574
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RecordData *CD1*, CtxDevSound, DPLOCAL);
sl@0
   575
	DP_IN();
sl@0
   576
	if(iMode==EMMFStateRecording)
sl@0
   577
		{
sl@0
   578
		iDevAudio->GetAudioControl()->ProcessData();
sl@0
   579
		}
sl@0
   580
	else
sl@0
   581
		{
sl@0
   582
		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
sl@0
   583
		}
sl@0
   584
	DP_OUT();
sl@0
   585
	}
sl@0
   586
sl@0
   587
// -----------------------------------------------------------------------------
sl@0
   588
// CMMFDevSoundAdaptation::CBody::Stop
sl@0
   589
// Stops the ongoing operation (Play, Record, TonePlay)
sl@0
   590
// (other items were commented in a header).
sl@0
   591
// -----------------------------------------------------------------------------
sl@0
   592
//
sl@0
   593
TBool CMMFDevSoundAdaptation::CBody::Stop()
sl@0
   594
	{
sl@0
   595
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Stop *CD1*, CtxDevSound, DPLOCAL);
sl@0
   596
	DP_IN();
sl@0
   597
	TBool isCompleted = EFalse;
sl@0
   598
	
sl@0
   599
	// Need for sequences when calling stop and is already stopped
sl@0
   600
	TDevSoundAdaptorState state = iDevAudio->ActiveState();
sl@0
   601
	if( (iMode != EMMFStateIdle) && 
sl@0
   602
		(state == EDevSoundAdaptorActive_Active || 
sl@0
   603
		state == EDevSoundAdaptorPaused_Primed ) )
sl@0
   604
		{
sl@0
   605
		TInt err = iDevAudio->GetAudioControl()->Stop();
sl@0
   606
		if (err != KErrNone)
sl@0
   607
			{
sl@0
   608
			isCompleted = ETrue;
sl@0
   609
			}
sl@0
   610
		}
sl@0
   611
	else
sl@0
   612
		{
sl@0
   613
		isCompleted = ETrue;	
sl@0
   614
		}
sl@0
   615
	DP_OUT();
sl@0
   616
	return isCompleted;
sl@0
   617
	}
sl@0
   618
sl@0
   619
// -----------------------------------------------------------------------------
sl@0
   620
// CMMFDevSoundAdaptation::CBody::Pause
sl@0
   621
// Temporarily Stops the ongoing operation (Play, Record, TonePlay)
sl@0
   622
// (other items were commented in a header).
sl@0
   623
// -----------------------------------------------------------------------------
sl@0
   624
//
sl@0
   625
TInt CMMFDevSoundAdaptation::CBody::Pause()
sl@0
   626
	{
sl@0
   627
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::Pause *CD1*, CtxDevSound, DPLOCAL);
sl@0
   628
	DP_IN();
sl@0
   629
sl@0
   630
	TInt err = iDevAudio->GetAudioControl()->Pause();
sl@0
   631
	DP0_RET(err, "%d");
sl@0
   632
	}
sl@0
   633
sl@0
   634
// -----------------------------------------------------------------------------
sl@0
   635
// CMMFDevSoundAdaptation::CBody::SamplesRecorded
sl@0
   636
// Returns the sample recorded so far.
sl@0
   637
// (other items were commented in a header).
sl@0
   638
// -----------------------------------------------------------------------------
sl@0
   639
//
sl@0
   640
TInt CMMFDevSoundAdaptation::CBody::SamplesRecorded()
sl@0
   641
	{
sl@0
   642
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SamplesRecorded *CD1*, CtxDevSound, DPLOCAL);
sl@0
   643
	DP_IN();
sl@0
   644
sl@0
   645
	if(iMode==EMMFStateRecording)
sl@0
   646
		{
sl@0
   647
		DP_OUT();
sl@0
   648
		return(iDevAudio->GetAudioControl()->GetSamples());
sl@0
   649
		}
sl@0
   650
	else
sl@0
   651
		{
sl@0
   652
		DP1(DLERR,"Current mode is not EMMFStateRecording! (iMode=%d)",iMode);
sl@0
   653
		DP0_RET(0, "%d");
sl@0
   654
		}
sl@0
   655
	}
sl@0
   656
sl@0
   657
// -----------------------------------------------------------------------------
sl@0
   658
// CMMFDevSoundAdaptation::CBody::SamplesPlayed
sl@0
   659
// Returns the sample played so far.
sl@0
   660
// (other items were commented in a header).
sl@0
   661
// -----------------------------------------------------------------------------
sl@0
   662
//
sl@0
   663
TInt CMMFDevSoundAdaptation::CBody::SamplesPlayed()
sl@0
   664
	{
sl@0
   665
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SamplesPlayed *CD1*, CtxDevSound, DPLOCAL);
sl@0
   666
	DP_IN();
sl@0
   667
	if(iMode==EMMFStatePlaying)
sl@0
   668
		{
sl@0
   669
		DP_OUT();
sl@0
   670
		return(iDevAudio->GetAudioControl()->GetSamples());
sl@0
   671
		}
sl@0
   672
	else
sl@0
   673
		{
sl@0
   674
		DP1(DLERR,"Current mode is not EMMFStatePlaying! (iMode=%d)",iMode);
sl@0
   675
		DP0_RET(0, "%d");
sl@0
   676
		}
sl@0
   677
	}
sl@0
   678
sl@0
   679
// -----------------------------------------------------------------------------
sl@0
   680
// CMMFDevSoundAdaptation::CBody::PlayToneL
sl@0
   681
// Initializes audio device and start playing tone. Tone is played with
sl@0
   682
// frequency and for duration specified.
sl@0
   683
// Leaves on failure.
sl@0
   684
// (other items were commented in a header).
sl@0
   685
// -----------------------------------------------------------------------------
sl@0
   686
//
sl@0
   687
void CMMFDevSoundAdaptation::CBody::PlayToneL(
sl@0
   688
								TInt aFrequency,
sl@0
   689
								const TTimeIntervalMicroSeconds& aDuration)
sl@0
   690
	{
sl@0
   691
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayToneL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   692
	DP1_IN("aFrequency = %d", aFrequency);
sl@0
   693
sl@0
   694
	if(iMode==EMMFStateTonePlaying)
sl@0
   695
		{
sl@0
   696
		iToneData.SetType(TToneData::ESimple);
sl@0
   697
		iToneData.SetFrequencyOne(aFrequency);
sl@0
   698
		iToneData.SetDuration(aDuration);
sl@0
   699
		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
sl@0
   700
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   701
		}
sl@0
   702
	else
sl@0
   703
		{
sl@0
   704
		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
sl@0
   705
		User::Leave(KErrNotSupported);
sl@0
   706
		}
sl@0
   707
sl@0
   708
	DP_OUT();
sl@0
   709
	}
sl@0
   710
sl@0
   711
// -----------------------------------------------------------------------------
sl@0
   712
// CMMFDevSoundAdaptation::CBody::PlayDualToneL
sl@0
   713
// Initializes audio device and start playing a dual tone.
sl@0
   714
// The tone consists of two sine waves of different frequencies summed together
sl@0
   715
// Dual Tone is played with specified frequencies and for specified duration.
sl@0
   716
// (other items were commented in a header).
sl@0
   717
// -----------------------------------------------------------------------------
sl@0
   718
//
sl@0
   719
void CMMFDevSoundAdaptation::CBody::PlayDualToneL(
sl@0
   720
								TInt aFrequencyOne,
sl@0
   721
								TInt aFrequencyTwo,
sl@0
   722
								const TTimeIntervalMicroSeconds& aDuration)
sl@0
   723
	{
sl@0
   724
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayDualToneL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   725
	DP2_IN("aFrequencyOne = %d, aFrequencyTwo=%d", aFrequencyOne, aFrequencyTwo);
sl@0
   726
sl@0
   727
	if(iMode==EMMFStateTonePlaying)
sl@0
   728
		{
sl@0
   729
		iToneData.SetType(TToneData::EDual); 
sl@0
   730
		iToneData.SetFrequencyOne(aFrequencyOne);
sl@0
   731
		iToneData.SetFrequencyTwo(aFrequencyTwo);
sl@0
   732
		iToneData.SetDuration(aDuration);
sl@0
   733
		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
sl@0
   734
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   735
		}
sl@0
   736
	else
sl@0
   737
		{
sl@0
   738
		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
sl@0
   739
		User::Leave(KErrNotSupported);
sl@0
   740
		}
sl@0
   741
	DP_OUT();
sl@0
   742
	}
sl@0
   743
sl@0
   744
// -----------------------------------------------------------------------------
sl@0
   745
// CMMFDevSoundAdaptation::CBody::PlayDTMFStringL
sl@0
   746
// Initializes audio device and start playing DTMF string aDTMFString.
sl@0
   747
// Leaves on failure.
sl@0
   748
// (other items were commented in a header).
sl@0
   749
// -----------------------------------------------------------------------------
sl@0
   750
//
sl@0
   751
void CMMFDevSoundAdaptation::CBody::PlayDTMFStringL(const TDesC& aDTMFString)
sl@0
   752
	{
sl@0
   753
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayDTMFStringL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   754
	DP_IN();
sl@0
   755
sl@0
   756
	if(iMode==EMMFStateTonePlaying)
sl@0
   757
		{
sl@0
   758
		iToneData.SetType(TToneData::EDtmfString);
sl@0
   759
		iToneData.SetDTMFString(const_cast<TDesC&>(aDTMFString));
sl@0
   760
		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
sl@0
   761
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   762
		}
sl@0
   763
	else
sl@0
   764
		{
sl@0
   765
		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
sl@0
   766
		User::Leave(KErrNotSupported);
sl@0
   767
		}
sl@0
   768
sl@0
   769
	DP_OUT();
sl@0
   770
	}
sl@0
   771
sl@0
   772
// -----------------------------------------------------------------------------
sl@0
   773
// CMMFDevSoundAdaptation::CBody::PlayToneSequenceL
sl@0
   774
// Initializes audio device and start playing tone sequence.
sl@0
   775
//
sl@0
   776
// Leaves on failure.
sl@0
   777
// (other items were commented in a header).
sl@0
   778
// -----------------------------------------------------------------------------
sl@0
   779
//
sl@0
   780
void CMMFDevSoundAdaptation::CBody::PlayToneSequenceL(const TDesC8& aData)
sl@0
   781
	{
sl@0
   782
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayToneSequenceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   783
	DP_IN();
sl@0
   784
sl@0
   785
	if(iMode==EMMFStateTonePlaying)
sl@0
   786
		{
sl@0
   787
		iToneData.SetType(TToneData::ESequence); 
sl@0
   788
		iToneData.SetSequenceData(const_cast<TDesC8&>(aData));
sl@0
   789
		User::LeaveIfError(iDevAudio->GetAudioControl()->SetToneData(iToneData));
sl@0
   790
		User::LeaveIfError(iDevAudio->GetAudioControl()->ProcessInit());
sl@0
   791
		}
sl@0
   792
	else
sl@0
   793
		{
sl@0
   794
		DP1(DLERR,"Current mode is not EMMFStateTonePlaying! (iMode=%d)",iMode);
sl@0
   795
		User::Leave(KErrNotSupported);
sl@0
   796
		}
sl@0
   797
sl@0
   798
	DP_OUT();
sl@0
   799
	}
sl@0
   800
sl@0
   801
// -----------------------------------------------------------------------------
sl@0
   802
// CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL
sl@0
   803
// Initializes audio device and start playing the specified pre-defined tone
sl@0
   804
// sequence.
sl@0
   805
//
sl@0
   806
// Leaves on failure.
sl@0
   807
// (other items were commented in a header).
sl@0
   808
// -----------------------------------------------------------------------------
sl@0
   809
//
sl@0
   810
void CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL(TInt /*aSequenceNumber*/)
sl@0
   811
	{
sl@0
   812
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::PlayFixedSequenceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   813
	DP_IN();
sl@0
   814
	User::Leave(KErrNotSupported);
sl@0
   815
	DP_OUT();
sl@0
   816
	}
sl@0
   817
sl@0
   818
// -----------------------------------------------------------------------------
sl@0
   819
// CMMFDevSoundAdaptation::CBody::SetToneRepeats
sl@0
   820
// Defines the number of times the audio is to be repeated during the tone
sl@0
   821
// playback operation. A period of silence can follow each playing of tone.
sl@0
   822
// The tone playing can be repeated indefinitely.
sl@0
   823
// Supported only during tone playing.
sl@0
   824
// (other items were commented in a header).
sl@0
   825
// -----------------------------------------------------------------------------
sl@0
   826
//
sl@0
   827
TInt CMMFDevSoundAdaptation::CBody::SetToneRepeats(
sl@0
   828
								TInt aRepeatCount,
sl@0
   829
								const TTimeIntervalMicroSeconds& aRepeatTrailingSilence)
sl@0
   830
	{
sl@0
   831
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetToneRepeats *CD1*, CtxDevSound, DPLOCAL);
sl@0
   832
	DP1_IN("aRepeatCount = %d", aRepeatCount);
sl@0
   833
sl@0
   834
	TInt err = KErrNone;
sl@0
   835
	iToneData.SetRepeatCount(aRepeatCount);
sl@0
   836
	iToneData.SetRepeatTrailingSilence(aRepeatTrailingSilence);
sl@0
   837
		
sl@0
   838
	DP0_RET(err, "%d");
sl@0
   839
	}
sl@0
   840
sl@0
   841
// -----------------------------------------------------------------------------
sl@0
   842
// CMMFDevSoundAdaptation::CBody::SetDTMFLengths
sl@0
   843
// Defines the duration of tone on, tone off and tone pause to be used during
sl@0
   844
// the DTMF tone playback operation.
sl@0
   845
// Supported only during tone playing.
sl@0
   846
// (other items were commented in a header).
sl@0
   847
// -----------------------------------------------------------------------------
sl@0
   848
//
sl@0
   849
TInt CMMFDevSoundAdaptation::CBody::SetDTMFLengths(
sl@0
   850
								TTimeIntervalMicroSeconds32& aToneOnLength,
sl@0
   851
								TTimeIntervalMicroSeconds32& aToneOffLength,
sl@0
   852
								TTimeIntervalMicroSeconds32& aPauseLength)
sl@0
   853
	{
sl@0
   854
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetDTMFLengths *CD1*, CtxDevSound, DPLOCAL);
sl@0
   855
	DP_IN();
sl@0
   856
sl@0
   857
	TInt err = KErrNone;
sl@0
   858
	if (aToneOnLength.Int() < KMdaInfiniteDurationDTMFToneOnLength)
sl@0
   859
		{
sl@0
   860
		aToneOnLength = TTimeIntervalMicroSeconds32(0);
sl@0
   861
		}
sl@0
   862
	if (aToneOffLength.Int() < 0)
sl@0
   863
		{
sl@0
   864
		aToneOffLength = TTimeIntervalMicroSeconds32(0);
sl@0
   865
		}
sl@0
   866
	if (aPauseLength.Int() < 0)
sl@0
   867
		{
sl@0
   868
		aPauseLength = TTimeIntervalMicroSeconds32(0);
sl@0
   869
		}
sl@0
   870
	
sl@0
   871
	iToneData.SetDtmfLengths(aToneOnLength, aToneOffLength, aPauseLength);
sl@0
   872
	
sl@0
   873
	DP0_RET(err, "%d");
sl@0
   874
	}
sl@0
   875
sl@0
   876
// -----------------------------------------------------------------------------
sl@0
   877
// CMMFDevSoundAdaptation::CBody::SetVolumeRamp
sl@0
   878
// Defines the period over which the volume level is to rise smoothly from
sl@0
   879
// nothing to the normal volume level.
sl@0
   880
// (other items were commented in a header).
sl@0
   881
// -----------------------------------------------------------------------------
sl@0
   882
//
sl@0
   883
TInt CMMFDevSoundAdaptation::CBody::SetVolumeRamp(
sl@0
   884
								const TTimeIntervalMicroSeconds& aRampDuration)
sl@0
   885
	{
sl@0
   886
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetVolumeRamp *CD1*, CtxDevSound, DPLOCAL);
sl@0
   887
	DP_IN();
sl@0
   888
sl@0
   889
	TInt err = iDevAudio->SetVolumeRamp(aRampDuration);
sl@0
   890
	DP0_RET(err, "%d");
sl@0
   891
	}
sl@0
   892
sl@0
   893
// -----------------------------------------------------------------------------
sl@0
   894
// CMMFDevSoundAdaptation::CBody::SetPrioritySettings
sl@0
   895
// Defines the priority settings that should be used for this instance.
sl@0
   896
// (other items were commented in a header).
sl@0
   897
// -----------------------------------------------------------------------------
sl@0
   898
//
sl@0
   899
TInt CMMFDevSoundAdaptation::CBody::SetPrioritySettings(
sl@0
   900
								const TMMFPrioritySettings& aPrioritySettings)
sl@0
   901
	{
sl@0
   902
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetPrioritySettings *CD1*, CtxDevSound, DPLOCAL);
sl@0
   903
	DP_IN();
sl@0
   904
sl@0
   905
	TInt err = iDevAudio->SetPrioritySettings(aPrioritySettings);
sl@0
   906
	if (err == KErrNone)
sl@0
   907
		{
sl@0
   908
		iPrioritySettings = aPrioritySettings;
sl@0
   909
		}
sl@0
   910
	DP0_RET(err, "%d");
sl@0
   911
	}
sl@0
   912
sl@0
   913
// -----------------------------------------------------------------------------
sl@0
   914
// CMMFDevSoundAdaptation::CBody::CustomInterface
sl@0
   915
// @see sounddevice.h
sl@0
   916
// (other items were commented in a header).
sl@0
   917
// -----------------------------------------------------------------------------
sl@0
   918
//
sl@0
   919
TAny* CMMFDevSoundAdaptation::CBody::CustomInterface(TUid aInterfaceId)
sl@0
   920
	{
sl@0
   921
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CustomInterface *CD1*, CtxDevSound, DPLOCAL);
sl@0
   922
	DP_IN();
sl@0
   923
	if ( iDevAudio )
sl@0
   924
		{
sl@0
   925
		DP_OUT();
sl@0
   926
		return(iDevAudio->GetAudioControl()->CustomInterface(aInterfaceId));
sl@0
   927
		}
sl@0
   928
	else
sl@0
   929
		{
sl@0
   930
		DP0_RET(NULL, "%d");
sl@0
   931
		}
sl@0
   932
	}
sl@0
   933
sl@0
   934
// -----------------------------------------------------------------------------
sl@0
   935
// CMMFDevSoundAdaptation::CBody::FixedSequenceCount
sl@0
   936
// Returns the number of available pre-defined tone sequences.
sl@0
   937
// This is the number of fixed sequence supported by DevSound by default.
sl@0
   938
// (other items were commented in a header).
sl@0
   939
// -----------------------------------------------------------------------------
sl@0
   940
//
sl@0
   941
TInt CMMFDevSoundAdaptation::CBody::FixedSequenceCount()
sl@0
   942
	{
sl@0
   943
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::FixedSequenceCount *CD1*, CtxDevSound, DPLOCAL);
sl@0
   944
	DP_IN();
sl@0
   945
	DP0_RET(0, "%d");
sl@0
   946
	}
sl@0
   947
sl@0
   948
// -----------------------------------------------------------------------------
sl@0
   949
// CMMFDevSoundAdaptation::CBody::FixedSequenceName
sl@0
   950
// Returns the name assigned to a specific pre-defined tone sequence.
sl@0
   951
// This is the number of fixed sequence supported by DevSound by default.
sl@0
   952
// The function raises a panic if sequence number specified invalid.
sl@0
   953
// (other items were commented in a header).
sl@0
   954
// -----------------------------------------------------------------------------
sl@0
   955
//
sl@0
   956
const TDesC& CMMFDevSoundAdaptation::CBody::FixedSequenceName(
sl@0
   957
								TInt /*aSequenceNumber*/)
sl@0
   958
	{
sl@0
   959
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::FixedSequenceName *CD1*, CtxDevSound, DPLOCAL);
sl@0
   960
	DP_IN();
sl@0
   961
	DP0_RET(KNullDesC, "");
sl@0
   962
	}
sl@0
   963
sl@0
   964
// -----------------------------------------------------------------------------
sl@0
   965
// CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL
sl@0
   966
// @see sounddevice.h
sl@0
   967
// (other items were commented in a header).
sl@0
   968
// -----------------------------------------------------------------------------
sl@0
   969
//
sl@0
   970
void CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL(
sl@0
   971
								RArray<TFourCC>& aSupportedDataTypes,
sl@0
   972
								const TMMFPrioritySettings& /*aPrioritySettings*/) const
sl@0
   973
	{
sl@0
   974
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetSupportedInputDataTypesL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   975
	DP_IN();
sl@0
   976
	//aPrioritySettings not used on ref DevSound
sl@0
   977
	//search for playing datatypes
sl@0
   978
	iDevAudio->DevSoundSupportedDataTypesL(aSupportedDataTypes, KDataForPlay);
sl@0
   979
	DP_OUT();
sl@0
   980
	}
sl@0
   981
sl@0
   982
// -----------------------------------------------------------------------------
sl@0
   983
// CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL
sl@0
   984
// @see sounddevice.h
sl@0
   985
// (other items were commented in a header).
sl@0
   986
// -----------------------------------------------------------------------------
sl@0
   987
//
sl@0
   988
void CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL(
sl@0
   989
								RArray<TFourCC>& aSupportedDataTypes,
sl@0
   990
								const TMMFPrioritySettings& /*aPrioritySettings*/) const
sl@0
   991
	{
sl@0
   992
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetSupportedOutputDataTypesL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   993
	DP_IN();
sl@0
   994
	//aPrioritySettings not used on ref DevSound
sl@0
   995
	// search for recording datatypes
sl@0
   996
	iDevAudio->DevSoundSupportedDataTypesL(aSupportedDataTypes, KDataForRecord);
sl@0
   997
	DP_OUT();
sl@0
   998
	}
sl@0
   999
sl@0
  1000
// -----------------------------------------------------------------------------
sl@0
  1001
// CMMFDevSoundAdaptation::CBody::SetClientConfig
sl@0
  1002
// Sets client capabilities for this instance of DevSound Adaptation.
sl@0
  1003
// (other items were commented in a header).
sl@0
  1004
// -----------------------------------------------------------------------------
sl@0
  1005
//
sl@0
  1006
TInt CMMFDevSoundAdaptation::CBody::SetClientConfig(
sl@0
  1007
                                const TProcessId& aActualProcessId,
sl@0
  1008
                                const TProcessId& aProcessId)
sl@0
  1009
    {
sl@0
  1010
    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetClientConfig *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1011
    DP_IN();
sl@0
  1012
sl@0
  1013
    TInt err = iDevAudio->SetClientConfig(aActualProcessId, aProcessId);
sl@0
  1014
    DP0_RET(err, "%d");
sl@0
  1015
    }
sl@0
  1016
sl@0
  1017
TInt CMMFDevSoundAdaptation::CBody::SetClientConfig(
sl@0
  1018
                                const TProcessId& aProcessId)
sl@0
  1019
    {
sl@0
  1020
    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::SetClientConfig *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1021
    DP_IN();
sl@0
  1022
sl@0
  1023
    TInt err = iDevAudio->SetClientConfig(aProcessId);
sl@0
  1024
    DP0_RET(err, "%d");
sl@0
  1025
    }
sl@0
  1026
sl@0
  1027
TBool CMMFDevSoundAdaptation::CBody::CloseDevSound()
sl@0
  1028
	{
sl@0
  1029
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CloseDevSound *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1030
	DP_IN();
sl@0
  1031
	DP_OUT();
sl@0
  1032
	return iDevAudio->GetAudioControl()->DestroyChain();
sl@0
  1033
	}
sl@0
  1034
sl@0
  1035
// -----------------------------------------------------------------------------
sl@0
  1036
// CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived
sl@0
  1037
// (other items were commented in a header).
sl@0
  1038
// -----------------------------------------------------------------------------
sl@0
  1039
//	
sl@0
  1040
TInt CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived(TBool& asyncOperation)
sl@0
  1041
	{
sl@0
  1042
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1043
	DP_IN();
sl@0
  1044
	DP_OUT();
sl@0
  1045
	return iDevAudio->GetAudioControl()->ProcessingFinishedReceived(asyncOperation);
sl@0
  1046
	}
sl@0
  1047
sl@0
  1048
// -----------------------------------------------------------------------------
sl@0
  1049
// CMMFDevSoundAdaptation::CBody::ProcessingFinishedReceived
sl@0
  1050
// (other items were commented in a header).
sl@0
  1051
// -----------------------------------------------------------------------------
sl@0
  1052
//  
sl@0
  1053
TInt CMMFDevSoundAdaptation::CBody::ProcessingError(TBool& asyncOperation)
sl@0
  1054
    {
sl@0
  1055
    DP_CONTEXT(CMMFDevSoundAdaptation::CBody::ProcessingError *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1056
    DP_IN();
sl@0
  1057
    DP_OUT();
sl@0
  1058
    return iDevAudio->GetAudioControl()->ProcessingError(asyncOperation);
sl@0
  1059
    }
sl@0
  1060
sl@0
  1061
// -----------------------------------------------------------------------------
sl@0
  1062
// CMMFDevSoundAdaptation::CBody::EmptyBuffers
sl@0
  1063
// (other items were commented in a header).
sl@0
  1064
// -----------------------------------------------------------------------------
sl@0
  1065
//
sl@0
  1066
TInt CMMFDevSoundAdaptation::CBody::EmptyBuffers()
sl@0
  1067
	{
sl@0
  1068
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::EmptyBuffers *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1069
	DP_IN();
sl@0
  1070
	TInt err(KErrNone);
sl@0
  1071
	// Empty buffers is only supported on playing
sl@0
  1072
	if (iMode == EMMFStateRecording || iMode == EMMFStateTonePlaying)
sl@0
  1073
		{
sl@0
  1074
		err = KErrNotSupported;
sl@0
  1075
		}
sl@0
  1076
	else if (!iDevAudio)
sl@0
  1077
		{
sl@0
  1078
		err = KErrNotReady;
sl@0
  1079
		}
sl@0
  1080
	else
sl@0
  1081
		{
sl@0
  1082
		TDevSoundAdaptorState state = iDevAudio->ActiveState();
sl@0
  1083
		if (state == EDevSoundAdaptorActive_Active || 
sl@0
  1084
			state == EDevSoundAdaptorPaused_Primed )
sl@0
  1085
			{
sl@0
  1086
			err = iDevAudio->GetAudioControl()->RequestEmptyBuffers();
sl@0
  1087
			}
sl@0
  1088
		else
sl@0
  1089
			{
sl@0
  1090
			err = KErrNotReady;
sl@0
  1091
			}
sl@0
  1092
		}
sl@0
  1093
	DP0_RET(err, "%d");
sl@0
  1094
	}	
sl@0
  1095
sl@0
  1096
sl@0
  1097
sl@0
  1098
sl@0
  1099
// -----------------------------------------------------------------------------
sl@0
  1100
// CMMFDevSoundAdaptation::CBody::RegisterAsClient
sl@0
  1101
// (other items were commented in a header).
sl@0
  1102
// -----------------------------------------------------------------------------
sl@0
  1103
//
sl@0
  1104
TInt CMMFDevSoundAdaptation::CBody::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData)
sl@0
  1105
	{
sl@0
  1106
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1107
	DP_IN();
sl@0
  1108
	TInt err(KErrNone);
sl@0
  1109
	if (iDevAudio)
sl@0
  1110
		{
sl@0
  1111
		err = iDevAudio->RegisterAsClient(aEventType, aNotificationRegistrationData);
sl@0
  1112
		}
sl@0
  1113
	else
sl@0
  1114
		{
sl@0
  1115
		err = KErrNotReady;
sl@0
  1116
		}
sl@0
  1117
	DP0_RET(err, "%d");
sl@0
  1118
	}
sl@0
  1119
	
sl@0
  1120
	
sl@0
  1121
	
sl@0
  1122
	
sl@0
  1123
	
sl@0
  1124
// -----------------------------------------------------------------------------
sl@0
  1125
// CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient
sl@0
  1126
// (other items were commented in a header).
sl@0
  1127
// -----------------------------------------------------------------------------
sl@0
  1128
//
sl@0
  1129
TInt CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient(TUid aEventType)
sl@0
  1130
	{
sl@0
  1131
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::CancelRegisterAsClient *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1132
	DP_IN();
sl@0
  1133
	TInt err(KErrNone);
sl@0
  1134
	if (iDevAudio)
sl@0
  1135
		{
sl@0
  1136
		err = iDevAudio->CancelRegisterAsClient(aEventType);
sl@0
  1137
		}
sl@0
  1138
	else 
sl@0
  1139
		{
sl@0
  1140
		err = KErrNotReady;
sl@0
  1141
		}
sl@0
  1142
	DP0_RET(err, "%d");
sl@0
  1143
	}	
sl@0
  1144
sl@0
  1145
sl@0
  1146
sl@0
  1147
sl@0
  1148
// -----------------------------------------------------------------------------
sl@0
  1149
// CMMFDevSoundAdaptation::CBody::GetResourceNotificationData
sl@0
  1150
// (other items were commented in a header).
sl@0
  1151
// -----------------------------------------------------------------------------
sl@0
  1152
//
sl@0
  1153
TInt CMMFDevSoundAdaptation::CBody::GetResourceNotificationData(TUid /*aEventType*/, TDes8& aNotificationData)
sl@0
  1154
	{
sl@0
  1155
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetResourceNotificationData *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1156
	DP_IN();
sl@0
  1157
	TInt err(KErrNone);
sl@0
  1158
	if (iDevAudio)
sl@0
  1159
		{
sl@0
  1160
		TMMFTimeIntervalMicroSecondsPckg pckg = TTimeIntervalMicroSeconds(SamplesPlayed());
sl@0
  1161
		aNotificationData.Copy(pckg);
sl@0
  1162
		}
sl@0
  1163
	else
sl@0
  1164
		{
sl@0
  1165
		err = KErrNotReady;
sl@0
  1166
		}
sl@0
  1167
	DP0_RET(err, "%d");
sl@0
  1168
	}	
sl@0
  1169
sl@0
  1170
sl@0
  1171
sl@0
  1172
sl@0
  1173
// -----------------------------------------------------------------------------
sl@0
  1174
// CMMFDevSoundAdaptation::CBody::WillResumePlay
sl@0
  1175
// (other items were commented in a header).
sl@0
  1176
// -----------------------------------------------------------------------------
sl@0
  1177
//
sl@0
  1178
TInt CMMFDevSoundAdaptation::CBody::WillResumePlay()
sl@0
  1179
	{
sl@0
  1180
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::WillResumePlay *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1181
	DP_IN();
sl@0
  1182
	TInt err(KErrNone);
sl@0
  1183
	if (iDevAudio)
sl@0
  1184
		{
sl@0
  1185
		err = iDevAudio->WillResumePlay();
sl@0
  1186
		}
sl@0
  1187
	else
sl@0
  1188
		{
sl@0
  1189
		err = KErrNotReady;
sl@0
  1190
		}
sl@0
  1191
	DP0_RET(err, "%d");
sl@0
  1192
	}	
sl@0
  1193
sl@0
  1194
// CMMFDevSoundAdaptation::CBody::GetTimePlayed
sl@0
  1195
// (other items were commented in a header).
sl@0
  1196
// -----------------------------------------------------------------------------
sl@0
  1197
//
sl@0
  1198
TInt CMMFDevSoundAdaptation::CBody::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
sl@0
  1199
	{
sl@0
  1200
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::GetTimePlayed *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1201
	DP_IN();
sl@0
  1202
	
sl@0
  1203
	TInt err = iDevAudio->GetAudioControl()->GetTimePlayed(aTime);
sl@0
  1204
	DP0_RET(err, "%d");
sl@0
  1205
	}
sl@0
  1206
		
sl@0
  1207
// -----------------------------------------------------------------------------
sl@0
  1208
// CMMFDevSoundAdaptation::CBody::IsResumeSupported
sl@0
  1209
// (other items were commented in a header).
sl@0
  1210
// -----------------------------------------------------------------------------
sl@0
  1211
//
sl@0
  1212
TBool CMMFDevSoundAdaptation::CBody::IsResumeSupported()
sl@0
  1213
	{
sl@0
  1214
	DP_CONTEXT(CMMFDevSoundAdaptation::IsResumeSupported *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1215
	DP_IN();
sl@0
  1216
	TBool isSupported = iDevAudio->IsResumeSupported();
sl@0
  1217
	DP0_RET(isSupported, "%d");
sl@0
  1218
	}
sl@0
  1219
sl@0
  1220
// -----------------------------------------------------------------------------
sl@0
  1221
// CMMFDevSoundAdaptation::CBody::Resume
sl@0
  1222
// (other items were commented in a header).
sl@0
  1223
// -----------------------------------------------------------------------------
sl@0
  1224
//
sl@0
  1225
TInt CMMFDevSoundAdaptation::CBody::Resume()
sl@0
  1226
	{
sl@0
  1227
	DP_CONTEXT(CMMFDevSoundAdaptation::Resume *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1228
	DP_IN();
sl@0
  1229
	TInt err = iDevAudio->GetAudioControl()->Resume();
sl@0
  1230
	DP0_RET(err, "%d");
sl@0
  1231
	}
sl@0
  1232
sl@0
  1233
void CMMFDevSoundAdaptation::CBody::BufferErrorEvent()
sl@0
  1234
	{
sl@0
  1235
	ASSERT(iDevAudio);
sl@0
  1236
	iDevAudio->GetAudioControl()->BufferErrorEvent();
sl@0
  1237
	}
sl@0
  1238
sl@0
  1239
void CMMFDevSoundAdaptation::CBody::RollbackAdaptorActiveStateToBeforeCommit()
sl@0
  1240
	{
sl@0
  1241
	DP_CONTEXT(CMMFDevSoundAdaptation::CBody::RollbackAdaptorActiveStateToBeforeCommit *CD1*, CtxDevSound, DPLOCAL);
sl@0
  1242
	DP_IN();
sl@0
  1243
	TDevSoundAdaptorState previousState = iDevAudio->PreviousState();
sl@0
  1244
	// Set previous state to the active state set after state changing Commit call
sl@0
  1245
	iDevAudio->SetPreviousState(iDevAudio->ActiveState());
sl@0
  1246
	// Set active state to the previous state set before state changing Commit call
sl@0
  1247
	iDevAudio->SetActiveState(previousState);
sl@0
  1248
	DP_OUT();
sl@0
  1249
	}