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