os/mm/devsound/a3fdevsound/src/devsoundadaptor/cdevaudiocontrol.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 #include "cdevaudiocontrol.h"
    19 
    20 #include <a3f/audioprocessingunittypeuids.h>
    21 #include <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh>
    22 #include <a3f/maudiocontext.h>
    23 #include <a3f/maudiostream.h>
    24 #include <a3f/maudiocodec.h>
    25 #include <a3f/maudiogaincontrol.h>
    26 
    27 
    28 const TInt KMicroSecondsInSecond = 1000000;
    29 const TInt KDefaultBufferSize = 4096;
    30 
    31 const TUint KMaxCallbacksExpected = 2;
    32 const TUint KDefaultSampleRate = 8000;
    33 const TUid KDefaultMode = {KA3FModeMonoValue};
    34 
    35 class TSampleRateTableEntry
    36 	{
    37 public:
    38 	TInt		iSampleRateValue;
    39 	TMMFSampleRate iSampleRate;
    40 	};
    41 
    42 const TSampleRateTableEntry KRateTableLookup[] = { 
    43 							{ 8000, EMMFSampleRate8000Hz },
    44 							{ 11025, EMMFSampleRate11025Hz },
    45 							{ 12000, EMMFSampleRate12000Hz },
    46 							{ 16000, EMMFSampleRate16000Hz },
    47 							{ 22050, EMMFSampleRate22050Hz },
    48 							{ 24000, EMMFSampleRate24000Hz },
    49 							{ 32000, EMMFSampleRate32000Hz },
    50 							{ 44100, EMMFSampleRate44100Hz },
    51 							{ 48000, EMMFSampleRate48000Hz },
    52 							{ 64000, EMMFSampleRate64000Hz },
    53 							{ 88200, EMMFSampleRate88200Hz },
    54 							{ 96000, EMMFSampleRate96000Hz },
    55 						};
    56 const TInt KMaxSampleRateIndex = 11; // must agree with length of table
    57 
    58 class TAudioModeTableEntry
    59 	{
    60 public:
    61 	TMMFMonoStereo	iAudioModeValue;
    62 	TUid			iAudioMode;
    63 	};
    64 
    65 const TAudioModeTableEntry KModeTableLookup[] = {
    66 							{ EMMFMono, {KA3FModeMonoValue} },
    67 							{ EMMFStereo, {KA3FModeStereoNonInterleavedValue} },
    68 							};
    69 
    70 const TInt KMaxModeIndex = 1; // must agree with length of table
    71 
    72 // ---------------------------------------------------------------------------
    73 // Default constructor
    74 // ---------------------------------------------------------------------------
    75 //
    76 CDevAudioControl::CDevAudioControl()
    77 	{
    78 	TRACE_CREATE();
    79 	DP_CONTEXT(CDevAudioControl::CDevAudioControl *CD1*, CtxDevSound, DPLOCAL);
    80 	DP_IN();
    81 
    82 	// Local cache default values
    83 	iCurrentSampleRate = KDefaultSampleRate;
    84 	iCurrentMode = KDefaultMode; 
    85 	iOutstandingCallbacks = KMaxCallbacksExpected; //by default we expect 2 callbacks for capabilities.
    86 	iCallbackFromAdaptor = KCallbackNone;
    87 	
    88 	DP_OUT();
    89 	}
    90 
    91 
    92 void CDevAudioControl::ConstructL(CDevAudio* aDevAudio, MDevSoundAdaptationObserver& aDevSoundObserver)
    93 	{
    94 	TRACE_CREATE();
    95 	DP_CONTEXT(CDevAudioControl::ConstructL *CD1*, CtxDevSound, DPLOCAL);
    96 	DP_IN();
    97 	iDevAudio = aDevAudio; 
    98 	iAdaptationObserver = &aDevSoundObserver;
    99 	
   100 	iObserverRegistered = EFalse;
   101 
   102 	TAudioChannelGain left;
   103 	TAudioChannelGain right;
   104 	
   105 	left.iLocation = TAudioChannelGain::ELeft;
   106 	right.iLocation = TAudioChannelGain::ERight;
   107 		
   108 	User::LeaveIfError(iChannelGains.Append(left)); // assumed element 0 in rest of code
   109 	User::LeaveIfError(iChannelGains.Append(right)); // assumed element 1 in rest of code
   110 
   111 	// Note this could be delayed now (volume is internal to adaptor until later in cycle)
   112 	// Needed to allow CMMFDevSound::MaxVolume and similar calls before CMMFDevSound::InitializeL
   113 	TAny* interface(NULL);
   114 	interface = iDevAudio->iGainControl->Interface(KUidAudioGainControl);
   115 	iGainControl = static_cast<MAudioGainControl*>(interface);
   116 	DP_OUT();
   117 	}
   118 
   119 // ---------------------------------------------------------------------------
   120 // Destructor
   121 // ---------------------------------------------------------------------------
   122 //
   123 CDevAudioControl::~CDevAudioControl()
   124 	{
   125 	DP_CONTEXT(CDevAudioControl::~CDevAudioControl *CD1*, CtxDevSound, DPLOCAL);
   126 	DP_IN();
   127 	iChannelGains.Close();
   128 	iSupportedRates.Close();
   129 	iSupportedModes.Close();
   130 	DP_OUT();
   131 	}
   132 	
   133 // -----------------------------------------------------------------------------
   134 // CacheAudioCodecIf
   135 //
   136 TInt CDevAudioControl::CacheAudioCodecIf()
   137 	{
   138 	DP_CONTEXT(CDevAudioControl::CacheAudioCodecIf *CD1*, CtxDevSound, DPLOCAL);
   139 	DP_IN();
   140 	if (iDevAudio->iAudioCodec==NULL)
   141 		{
   142 		DP0_RET(KErrNotReady,"%d");
   143 		}
   144 	TInt err = KErrNone;
   145 	if (iAudioCodecIf==NULL)
   146 		{
   147 		MAudioCodec* codecInterface = static_cast<MAudioCodec*>(iDevAudio->iAudioCodec->Interface(KUidAudioCodec));
   148 		__ASSERT_ALWAYS (codecInterface, CDevAudioControl::Panic(EAudioCodecIsNull));
   149 		iAudioCodecIf = codecInterface; 
   150 		}
   151 	DP0_RET(err,"%d");
   152 	}
   153 
   154 
   155 // -----------------------------------------------------------------------------
   156 // CDevAudioControl::Initialize
   157 // -----------------------------------------------------------------------------
   158 //
   159 TInt CDevAudioControl::Initialize(TUid /*aFormat*/)
   160 	{
   161 	DP_CONTEXT(CDevAudioControl::Initialize *CD1*, CtxDevSound, DPLOCAL);
   162 	DP_IN();
   163 	ASSERT(EFalse);
   164 	iObserverRegistered = EFalse;
   165 	DP0_RET(KErrNone,"%d");
   166 	}
   167 
   168 // -----------------------------------------------------------------------------
   169 // CDevAudioControl::Uninitialize
   170 // -----------------------------------------------------------------------------
   171 //
   172 TInt CDevAudioControl::Uninitialize()
   173 	{
   174 	DP_CONTEXT(CDevAudioControl::Uninitialize *CD1*, CtxDevSound, DPLOCAL);
   175 	DP_IN();
   176 
   177 	// Remove pUnits only allowed when stream is uninitialized
   178 	TInt err = iDevAudio->iAudioStream->Uninitialize();
   179 
   180 	if (err == KErrNone)
   181 		{
   182 		err = iDevAudio->CommitAudioContext();
   183 		}
   184 	if (err == KErrNone)
   185 		{
   186 		iDevAudio->iActiveState = EDevSoundAdaptorUninitialising;
   187 		}
   188 
   189 	DP0_RET(err,"%d");
   190 	}
   191 
   192 // -----------------------------------------------------------------------------
   193 // CDevAudioControl::Unload
   194 // -----------------------------------------------------------------------------
   195 //
   196 TInt CDevAudioControl::Unload()
   197 	{
   198 	DP_CONTEXT(CDevAudioControl::Unload *CD1*, CtxDevSound, DPLOCAL);
   199 	DP_IN();
   200 
   201 	TInt err = iDevAudio->iAudioStream->Unload();
   202 	if (err == KErrNone)
   203 		{
   204 		err = iDevAudio->CommitAudioContext();
   205 		}
   206 	if (err == KErrNone)
   207 		{
   208 		iDevAudio->iActiveState = EDevSoundAdaptorUnloading;
   209 		}
   210 
   211 	DP0_RET(err,"%d");
   212 	}
   213 
   214 // -----------------------------------------------------------------------------
   215 // CDevAudioControl::GetCapabilities
   216 // -----------------------------------------------------------------------------
   217 //
   218 TInt CDevAudioControl::GetCapabilities(TMMFCapabilities& aCap)
   219 	{
   220 	DP_CONTEXT(CDevAudioControl::GetCapabilities *CD1*, CtxDevSound, DPLOCAL);
   221 	DP_IN();
   222 	// At this phase of CAP, we only care about current codec capabilities. 
   223 	// This will be supported as soon as the A3F API changes to support this are ready
   224 	TInt err = KErrNone;
   225 		
   226 	if (iDevAudio->iActiveState != EDevSoundAdaptorCreated_Uninitialised)
   227 		{
   228 		err = CacheAudioCodecIf();
   229 		if (err != KErrNone)
   230 			{
   231 			DP0_RET(err, "%d");			
   232 			}
   233 			
   234 		if (err == KErrNone)
   235 			{
   236 			err = iAudioCodecIf->GetSupportedModes(iSupportedModes);
   237 			if (err == KErrNone)
   238 				{
   239 				aCap.iChannels = GetModes(iSupportedModes);
   240 				err = iAudioCodecIf->GetSupportedSamplesRates(iSupportedRates);
   241 				
   242 				if (err == KErrNone)
   243 					{
   244 					aCap.iRate = GetSampleRates(iSupportedRates);
   245 					}
   246 				else
   247 					{
   248 					//If was a problem getting sampleRates we donīt expect callbacks and return
   249 					iOutstandingCallbacks = 0;
   250 					}
   251 					
   252 				}
   253 			else
   254 				{
   255 				//If was a problem getting modes we donīt expect callbacks and return
   256 				iOutstandingCallbacks = 0;
   257 				}
   258 			}
   259 		}
   260 	else
   261 		{
   262 		err = KErrNotReady;
   263 		}
   264 	DP0_RET(err, "%d");
   265 	}
   266 
   267 // -----------------------------------------------------------------------------
   268 // CDevAudioControl::GetConfig
   269 // -----------------------------------------------------------------------------
   270 //
   271 TInt CDevAudioControl::GetConfig(TMMFCapabilities& aConfig)
   272 	{
   273 	DP_CONTEXT(CDevAudioControl::GetConfig *CD1*, CtxDevSound, DPLOCAL);
   274 	DP_IN();
   275 	TInt err(KErrNone);
   276 
   277 	//TODO add a return error code if the sample rate or the channels are not found
   278 	//We need to transform the local values to a supported value for the client
   279 	aConfig.iRate = static_cast<TMMFSampleRate>(GetSampleRate(iCurrentSampleRate));
   280 	aConfig.iChannels = static_cast<TMMFMonoStereo>(GetMode(iCurrentMode));
   281 	aConfig.iBufferSize = KDefaultBufferSize;
   282 	
   283 	DP2(DLINFO, "rate 0x%x, channels 0x%x", aConfig.iRate, aConfig.iChannels);
   284 
   285 	DP0_RET(err, "%d");
   286 	}
   287 
   288 // -----------------------------------------------------------------------------
   289 // CDevAudioControl::SetConfig
   290 // -----------------------------------------------------------------------------
   291 //
   292 TInt CDevAudioControl::SetConfig(const TMMFCapabilities& aConfig)
   293 	{
   294 	DP_CONTEXT(CDevAudioControl::SetConfig *CD1*, CtxDevSound, DPLOCAL);
   295 	DP_IN();
   296 	
   297 	// TODO need to ensure if iChannels or iSampleRate is outside known values, then
   298 	// the code handles that gracefully and returns the appropriate error code
   299 	
   300 	TInt err(KErrNone);
   301 	TUid mode = KNullUid;
   302 	//Reset the desired values
   303 	iDesiredSampleRate = 0;
   304 	iDesiredMode = KNullUid;
   305 
   306 	err = ResolveMode(aConfig.iChannels, mode);
   307 	if (err != KErrNone)
   308 		{
   309 		DP0_RET(err, "%d");
   310 		}
   311 
   312 	err = ResolveSampleRate(aConfig.iRate, iDesiredSampleRate);
   313 	if (err != KErrNone)
   314 		{
   315 		DP0_RET(err, "%d");
   316 		}
   317 
   318 	// At this phase of CAP, we only care about codec, which checks config against
   319 	// its own capabilities. Verification against stream specific capabilities
   320 	// should be added later on.
   321 	
   322 	err = CacheAudioCodecIf();
   323 	if (err != KErrNone)
   324 		{
   325 		DP0_RET(err, "%d");
   326 		}
   327 	
   328 	err = iAudioCodecIf->SetSampleRate(iDesiredSampleRate);
   329 		
   330 	
   331 	if(err == KErrNone)
   332 		{
   333 		err = iAudioCodecIf->SetMode(mode);
   334 		}
   335 	
   336 	if(err == KErrNone)
   337 		{
   338 		err = iDevAudio->CommitAudioContext();
   339 		if (err == KErrNone)
   340 			{
   341 			iDesiredMode = mode;
   342 			}
   343 		}
   344 
   345 	DP0_RET(err, "%d");
   346 	}
   347 
   348 // -----------------------------------------------------------------------------
   349 // CDevAudioControl::ProcessInit
   350 // -----------------------------------------------------------------------------
   351 //
   352 TInt CDevAudioControl::ProcessInit()
   353 	{
   354 	DP_CONTEXT(CDevAudioControl::ProcessInit *CD1*, CtxDevSound, DPLOCAL);
   355 	DP_IN();
   356 	ASSERT(EFalse);
   357 	DP0_RET(KErrNone,"%d");
   358 	}
   359 
   360 // -----------------------------------------------------------------------------
   361 // CDevAudioControl::ProcessData
   362 // -----------------------------------------------------------------------------
   363 //
   364 void CDevAudioControl::ProcessData()
   365 	{
   366 	DP_CONTEXT(CDevAudioControl::ProcessData *CD1*, CtxDevSound, DPLOCAL);
   367 	DP_IN();
   368 	ASSERT(EFalse);
   369 	DP_OUT();
   370 	}
   371 
   372 // -----------------------------------------------------------------------------
   373 // CDevAudioControl::GetSamples
   374 // -----------------------------------------------------------------------------
   375 //
   376 TInt CDevAudioControl::GetSamples()
   377 	{
   378 	DP_CONTEXT(CDevAudioControl::GetSamples *CD1*, CtxDevSound, DPLOCAL);
   379 	DP_IN();
   380 	TInt err(KErrNone);
   381 	TInt samplesplayed(0);
   382 	
   383 	TTimeIntervalMicroSeconds timeProcessed(0);
   384 	err = iDevAudio->iAudioStream->GetStreamTime(timeProcessed);
   385 
   386 	DP1(DLINFO,"CDevAudioControl::GetSamples iCurrentSampleRate %d",iCurrentSampleRate);
   387 	
   388 	if(err == KErrNone)
   389 		{
   390 		samplesplayed = (timeProcessed.Int64() * iCurrentSampleRate + KMicroSecondsInSecond/2) / TInt64(KMicroSecondsInSecond);
   391 		}
   392 	//TODO manage the error
   393 
   394 	DP0_RET(samplesplayed, "%d");
   395 	}
   396 
   397 // -----------------------------------------------------------------------------
   398 // CDevAudioControl::Stop
   399 // -----------------------------------------------------------------------------
   400 //
   401 TInt CDevAudioControl::Stop()
   402 	{
   403 	DP_CONTEXT(CDevAudioControl::Stop *CD1*, CtxDevSound, DPLOCAL);
   404 	DP_IN();
   405 	ASSERT(EFalse);
   406 	DP0_RET(KErrNone, "%d");
   407 	}
   408 
   409 // -----------------------------------------------------------------------------
   410 // CDevAudioControl::Pause
   411 // -----------------------------------------------------------------------------
   412 //
   413 TInt CDevAudioControl::Pause()
   414 	{
   415 	DP_CONTEXT(CDevAudioControl::Pause *CD1*, CtxDevSound, DPLOCAL);
   416 	DP_IN();
   417 	ASSERT(EFalse);
   418 	DP0_RET(KErrNone, "%d");
   419 	}
   420 
   421 // -----------------------------------------------------------------------------
   422 // CDevAudioControl::CustomInterface
   423 // -----------------------------------------------------------------------------
   424 //
   425 TAny* CDevAudioControl::CustomInterface(TUid aInterfaceId)
   426 	{
   427 	DP_CONTEXT(CDevAudioControl::CustomInterface *CD1*, CtxDevSound, DPLOCAL);
   428 	DP_IN();
   429 	TAny* ciPtr(NULL);
   430 	TInt err = KErrNone;
   431 	if(iDevAudio->iAudioStream)
   432 		{
   433 		TAny* ptr = iDevAudio->iAudioStream->Interface(KUidExtensionInferface);
   434 		if(ptr)
   435 			{
   436 			MCustomInterfaceSupport* ciSupport  = static_cast<MCustomInterfaceSupport*>(ptr);
   437 			if(!iObserverRegistered)
   438 				{
   439 				err = ciSupport->RegisterObserver(*this);
   440 				if(err == KErrNone)
   441 					{
   442 					iObserverRegistered = ETrue;
   443 					}
   444 				}
   445 			err = ciSupport->RequestCustomInterface(aInterfaceId, ciPtr);
   446 			if( err != KErrNone)
   447 				{
   448 				ciPtr = NULL;
   449 				}
   450 			}
   451 		}
   452 	DP0_RET(ciPtr, "0x%x");
   453 	}
   454 
   455 // -----------------------------------------------------------------------------
   456 // CDevAudioControl::SetGain
   457 // -----------------------------------------------------------------------------
   458 TInt CDevAudioControl::SetGains(TInt aDevSoundGain, TInt aDevSoundMaxGain, TInt aBalance[2], const TTimeIntervalMicroSeconds& aRampDuration, TBool aBecomingActive)
   459 	{
   460 	DP_CONTEXT(CDevAudioControl::SetGains *CD1*, CtxDevSound, DPLOCAL);
   461 	DP_IN();
   462 	ASSERT(aDevSoundGain>=0 && aDevSoundGain<=aDevSoundMaxGain); // higher layer assumed to scale
   463 	ASSERT(aBalance[ELeftCh]>=0 && aBalance[ELeftCh]<=100);
   464 	ASSERT(aBalance[ERightCh]>=0 && aBalance[ERightCh]<=100);
   465 	ASSERT(aDevSoundMaxGain>0); // assumed max gain is positive
   466 	TInt a3fMaxGain;
   467 	TInt err = iGainControl->GetMaxGain(a3fMaxGain);
   468 	if (err==KErrNone)
   469 		{
   470 		iLegacyGain = TInt(TReal(aDevSoundGain)*TReal(a3fMaxGain)/TReal(aDevSoundMaxGain)+0.5);
   471 		ASSERT(iLegacyGain>=0 && iLegacyGain<=a3fMaxGain);
   472 		iLegacyLeft = aBalance[ELeftCh];
   473 		iLegacyRight = aBalance[ERightCh];
   474 
   475 		MapGains();
   476 
   477 		// VolumeRamp is only applied when DevSound is becoming active
   478 		if(err == KErrNone)
   479 			{
   480 			if (aRampDuration > 0 && aBecomingActive)
   481 				{
   482 				err = iGainControl->SetGain(iChannelGains, KUidGainSawTooth, aRampDuration);
   483 				}
   484 			else
   485 				{
   486 				err = iGainControl->SetGain(iChannelGains);
   487 				}
   488 			}
   489 
   490 		// This call will result on commit only when we are already active
   491 		// otherwise the changes will be commited by the DevAudioControl 
   492 		// It means we're here due to RequestGainAndBalance call
   493 		if(err == KErrNone && !aBecomingActive)
   494 			{
   495 			err = iDevAudio->CommitAudioContext();
   496 			}		
   497 		}
   498 	DP0_RET(err,"%d");
   499 	}
   500 
   501 
   502 // -----------------------------------------------------------------------------
   503 // CDevAudioControl::MapAndSetGains
   504 // -----------------------------------------------------------------------------
   505 //
   506 void CDevAudioControl::MapGains()
   507 	{
   508 	DP_CONTEXT(CDevAudioControl::MapGains *CD1*, CtxDevSound, DPLOCAL);
   509 	DP_IN();
   510 
   511 	// Map legacy values to CAP channel array.
   512 	if ( iLegacyLeft == iLegacyRight )
   513 		{
   514 		iChannelGains[ELeftCh].iGain = iLegacyGain;
   515 		iChannelGains[ERightCh].iGain = iLegacyGain;
   516 		}
   517 	else if ( iLegacyLeft > iLegacyRight )
   518 		{
   519 		iChannelGains[ELeftCh].iGain = iLegacyGain;
   520 		iChannelGains[ERightCh].iGain =
   521 						static_cast<TUint>((iLegacyGain*iLegacyRight)/iLegacyLeft);
   522 		}
   523 	else
   524 		{
   525 		iChannelGains[ERightCh].iGain = iLegacyGain;
   526 		iChannelGains[ELeftCh].iGain =
   527 						static_cast<TUint>((iLegacyGain*iLegacyLeft)/iLegacyRight);
   528 		}
   529 
   530 	DP_OUT();
   531 	}
   532 
   533 // -----------------------------------------------------------------------------
   534 // CDevAudioControl::DestroyChain
   535 // -----------------------------------------------------------------------------
   536 //
   537 TBool CDevAudioControl::DestroyChain()
   538 	{
   539 	DP_CONTEXT(CDevAudioControl::DestroyChain *CD1*, CtxDevSound, DPLOCAL);
   540 	DP_IN();
   541 
   542 	TInt err = KErrNone;
   543 	TBool readyToDestroy = EFalse;
   544 	switch(iDevAudio->iActiveState)
   545 		{
   546 		case EDevSoundAdaptorActive_Active:
   547 		case EDevSoundAdaptorPaused_Primed:
   548 			{
   549 			err = iDevAudio->iAudioStream->Stop();
   550 			if(err == KErrNone)
   551 				{
   552 				err = iDevAudio->CommitAudioContext();
   553 				}
   554 			if (err == KErrNone)
   555 				{
   556 				iDevAudio->iActiveState = EDevSoundAdaptorStopping;
   557 				}
   558 			}
   559 			break;
   560 		case EDevSoundAdaptorInitialised_Idle:
   561 			{
   562 			err = iDevAudio->iAudioStream->Unload();
   563 			if(err == KErrNone)
   564 				{
   565 				err = iDevAudio->CommitAudioContext();
   566 				}
   567 			if (err == KErrNone)
   568 				{
   569 				iDevAudio->iActiveState = EDevSoundAdaptorUnloading;
   570 				}
   571 			}
   572 			break;
   573 		case EDevSoundAdaptorInitialised_Initialised:
   574 			{
   575 			err = iDevAudio->iAudioStream->Uninitialize();
   576 			if(err == KErrNone)
   577 				{
   578 				err = iDevAudio->CommitAudioContext();
   579 				}
   580 			if (err == KErrNone)
   581 				{
   582 				iDevAudio->iActiveState = EDevSoundAdaptorUninitialising;
   583 				}
   584 			}
   585 			break;
   586 		case EDevSoundAdaptorCreated_Uninitialised:
   587 			readyToDestroy = ETrue;
   588 			break;
   589 		case EDevSoundAdaptorUnitialised_Uninitialised:
   590 			//If following condition is true, then we are here because of a
   591 			//pre-emption clash in last Commit cycle started from
   592 			//CDevCommonControl::ContextEventUpdateWithStateEventNoError.
   593 			if(iDevAudio->iPreviousState == EDevSoundAdaptorRemovingProcessingUnits)
   594 				{
   595 				err = RemoveProcessingUnits();
   596 				break;
   597 				}
   598 		default:
   599 			break;
   600 		}
   601 	
   602 	// Destroy sequence fail!
   603 	if(err != KErrNone)
   604 		{
   605 		DP0(DLINFO, "================ Destroy sequence fail! ================");
   606 		readyToDestroy = ETrue;
   607 		}
   608 	// Set the flag only when needed
   609 	iDevAudio->iClosing = !readyToDestroy;
   610 	DP0_RET(readyToDestroy,"%d");
   611 	}
   612 
   613 
   614 // -----------------------------------------------------------------------------
   615 // CDevAudioControl::RemoveProcessingUnits
   616 // -----------------------------------------------------------------------------
   617 //
   618 TInt CDevAudioControl::RemoveProcessingUnits()
   619 	{
   620 	DP_CONTEXT(CDevAudioControl::RemoveProcessingUnits *CD1*, CtxDevSound, DPLOCAL);
   621 	DP_IN();
   622 
   623 	// Remove pUnits only allowed when stream is uninitialized
   624 	TInt err = iDevAudio->iAudioStream->RemoveProcessingUnit(iDevAudio->iAudioSource);
   625 		
   626 	if(err == KErrNone)
   627 		{
   628 		err = iDevAudio->iAudioStream->RemoveProcessingUnit(iDevAudio->iAudioSink);	
   629 		}
   630 	if(err == KErrNone)
   631 		{
   632 		err = iDevAudio->iAudioStream->RemoveProcessingUnit(iDevAudio->iAudioCodec);
   633 		}
   634 
   635 	if (err == KErrNone)
   636 		{
   637 		err = iDevAudio->CommitAudioContext();
   638 		}
   639 		
   640 	if(err == KErrNone)
   641 		{
   642 		iDevAudio->iActiveState = EDevSoundAdaptorRemovingProcessingUnits;		
   643 		}
   644 	DP0_RET(err,"%d");
   645 	}
   646 
   647 // -----------------------------------------------------------------------------
   648 // From class MAudioStreamObserver
   649 // CDevAudioControl::StateEvent
   650 // -----------------------------------------------------------------------------
   651 //
   652 void CDevAudioControl::StateEvent(MAudioStream& /*aStream*/, 
   653 									TInt /*aReason*/, 
   654 									TAudioState /*aNewState*/)
   655 	{
   656 	DP_CONTEXT(CDevAudio::StateEvent *CD1*, CtxDevSound, DPLOCAL);
   657 	DP_IN();
   658 	ASSERT(EFalse);
   659 	DP_OUT();
   660 	}
   661 
   662 // -----------------------------------------------------------------------------
   663 // From class MAudioStreamObserver
   664 // CDevAudioControl::AddProcessingUnitComplete
   665 // -----------------------------------------------------------------------------
   666 //
   667 void CDevAudioControl::AddProcessingUnitComplete(MAudioStream& /*aStream*/, 
   668 												MAudioProcessingUnit* /*aInstance*/,
   669 												TInt /*aError*/)
   670 	{
   671 	}
   672 
   673 // -----------------------------------------------------------------------------
   674 // From class MAudioStreamObserver
   675 // CDevAudioControl::RemoveProcessingUnitComplete
   676 // -----------------------------------------------------------------------------
   677 //
   678 void CDevAudioControl::RemoveProcessingUnitComplete(MAudioStream& /*aStream*/,
   679 													MAudioProcessingUnit* /*aInstance*/,
   680 													TInt /*aError*/)
   681 	{
   682 	}
   683 
   684 // -----------------------------------------------------------------------------
   685 // From class MAudioStreamObserver
   686 // CDevAudioControl::ProcessingFinished
   687 // -----------------------------------------------------------------------------
   688 //
   689 void CDevAudioControl::ProcessingFinished(MAudioStream& /*aStream*/)
   690 	{
   691 	}
   692 
   693 // -----------------------------------------------------------------------------
   694 // From class MAudioStreamObserver
   695 // CDevAudioControl::FlushComplete
   696 // -----------------------------------------------------------------------------
   697 //
   698 void CDevAudioControl::FlushComplete (MAudioStream& /*aStream*/, TInt aError)
   699 	{
   700 	// no action needed - should complete as part of the ContextEvent.
   701 	// otherwise could callback.
   702 	TInt err = KErrNone;
   703 	
   704 	if(iPauseResumeSequenceDueToEmptyBuffers)
   705 		{
   706 		// Flush operation failed
   707 		if(aError != KErrNone)
   708 			{
   709 			iPauseResumeSequenceDueToEmptyBuffers = EFalse;
   710 			iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, aError);
   711 			}
   712 		// Handle throw-off scenarios, resume is not possible from here
   713 		// 1. ProcessingFinished has occurred
   714 		// 2. Preemption occurred 
   715 		else if(iCallbackFromAdaptor != KCallbackNone || 
   716 			iDevAudio->iActiveState != EDevSoundAdaptorPaused_Primed)
   717 			{
   718 			iPauseResumeSequenceDueToEmptyBuffers = EFalse;
   719 			iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, KErrNone);
   720 			
   721 			}
   722 		else
   723 			{
   724 			err = Resume();
   725 			if(err != KErrNone)
   726 				{
   727 				iPauseResumeSequenceDueToEmptyBuffers = EFalse;
   728 				iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, aError);
   729 				}
   730 			// Once ContextEvent be received 
   731 			// EmptyBuffers can be considered completed
   732 			}
   733 		}
   734 	// EmptyBuffers operation has concluded here
   735 	// we didn't go through pause - resume sequence
   736 	else
   737 		{
   738 		iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, aError);
   739 		}
   740 	}
   741 	
   742 // -----------------------------------------------------------------------------
   743 // From class MAudioGainControlObserver
   744 // CDevAudioControl::MaxRampTimeChanged
   745 // -----------------------------------------------------------------------------
   746 //
   747 void CDevAudioControl::MaxRampTimeChanged(MAudioGainControl& /*aGain*/)
   748 	{
   749 	DP_CONTEXT(CDevAudioControl::MaxRampTimeChanged *CD1*, CtxDevSound, DPLOCAL);
   750 	DP_IN();
   751 	// this is not cached, no actions needed
   752 	DP_OUT();
   753 	}
   754 
   755 // -----------------------------------------------------------------------------
   756 // From class MAudioGainControlObserver
   757 // CDevAudioControl::MaxGainChanged
   758 // -----------------------------------------------------------------------------
   759 //
   760 void CDevAudioControl::MaxGainChanged(MAudioGainControl& /*aGain*/)
   761 	{
   762 	DP_CONTEXT(CDevAudioControl::MaxGainChanged *CD1*, CtxDevSound, DPLOCAL);
   763 	DP_IN();
   764 	// this is not cached, no actions needed
   765 	DP_OUT();
   766 	}
   767 
   768 // -----------------------------------------------------------------------------
   769 // From class MAudioGainControlObserver
   770 // CDevAudioControl::GainChanged
   771 // -----------------------------------------------------------------------------
   772 //
   773 void CDevAudioControl::GainChanged(MAudioGainControl& aGain, TInt aError)
   774 	{
   775 	DP_CONTEXT(CDevAudioControl::GainChanged *CD1*, CtxDevSound, DPLOCAL);
   776 	DP1_IN("aError=%d", aError);
   777 
   778 	if(aError != KErrNone)
   779 		{
   780 		// Either our request failed, or MMRC has forced some values, and we
   781 		// have to update local values.
   782 		aGain.GetGain(iChannelGains);
   783 		ASSERT(iChannelGains.Count()==2);
   784 		// Map CAP channel array to legacy values. 
   785 		// assumption: left%+right%=100
   786 		if ( iChannelGains[ELeftCh].iGain == iChannelGains[ERightCh].iGain )
   787 			{
   788 			iLegacyGain = iChannelGains[ELeftCh].iGain;
   789 			iLegacyLeft = 50;
   790 			iLegacyRight = 50;
   791 			}
   792 		else if ( iChannelGains[ELeftCh].iGain > iChannelGains[ERightCh].iGain )
   793 			{
   794 			iLegacyGain = iChannelGains[ELeftCh].iGain;
   795 			iLegacyLeft = static_cast<TUint>
   796 				((100*iLegacyGain)/(iLegacyGain+iChannelGains[ERightCh].iGain));
   797 			iLegacyRight = 100 - iLegacyLeft;
   798 			//(not that accurate, but sufficient for now)
   799 			}
   800 		else
   801 			{
   802 			iLegacyGain = iChannelGains[ERightCh].iGain;
   803 			iLegacyRight = static_cast<TUint>
   804 				((100*iLegacyGain)/(iLegacyGain+iChannelGains[ELeftCh].iGain));
   805 			iLegacyLeft = 100 - iLegacyRight;
   806 			}
   807 
   808 		DP3(DLINFO,"New values :iLegacyGain %d, iLegacyLeft %d, iLegacyRight %d",
   809 				iLegacyGain,iLegacyLeft,iLegacyRight);
   810 		}
   811 	else
   812 		{
   813 		// our request completed succesfully, no need to update cached values
   814 		// just print values in debug version
   815 		#ifdef _DEBUG
   816 		RArray<TAudioChannelGain> gains;
   817 		TUint left;
   818 		TUint right;
   819 		TUint gain;
   820 		aGain.GetGain(gains);
   821 		ASSERT(gains.Count()==2);
   822 		if ( iChannelGains[ELeftCh].iGain == iChannelGains[ERightCh].iGain )
   823 			{
   824 			gain = iChannelGains[ELeftCh].iGain;
   825 			left = 50;
   826 			right = 50;
   827 			}
   828 		else if ( iChannelGains[ELeftCh].iGain > iChannelGains[ERightCh].iGain )
   829 			{
   830 			gain = iChannelGains[ELeftCh].iGain;
   831 			left = 
   832 				static_cast<TUint>((100*gain)/(gain+iChannelGains[ERightCh].iGain));
   833 			right = 100 - left;
   834 			}
   835 		else
   836 			{
   837 			gain = iChannelGains[ERightCh].iGain;
   838 			right = 
   839 				static_cast<TUint>((100*gain)/(gain+iChannelGains[ELeftCh].iGain));
   840 			left = 100 - right;
   841 			}
   842 		gains.Close();
   843 		DP3(DLINFO,"KErrNone (gain %d, left %d, right %d)", gain,left,right);
   844 		#endif
   845 		}
   846 
   847 	DP_OUT();
   848 	}
   849 
   850 // -----------------------------------------------------------------------------
   851 // From class MAudioCodecObserver
   852 // CDevAudioControl::SampleRateSet
   853 // -----------------------------------------------------------------------------
   854 void CDevAudioControl::SampleRateSet(TInt aError)
   855 	{
   856 	if(aError==KErrNone)
   857 		{
   858 		//Review if we call SetConfig or is only the first time that we load the codec
   859 		if (iDesiredSampleRate > 0)
   860 			{
   861 			iCurrentSampleRate = iDesiredSampleRate;
   862 			}
   863 		}
   864 	else
   865 	    {
   866         iAdaptationObserver->NotifyError(aError);
   867 	    }
   868     iDesiredSampleRate = 0;
   869 	}
   870 
   871 // -----------------------------------------------------------------------------
   872 // From class MAudioCodecObserver
   873 // CDevAudioControl::ModeSet
   874 // -----------------------------------------------------------------------------
   875 void CDevAudioControl::ModeSet(TInt aError)
   876 	{
   877 	if(aError==KErrNone)
   878 		{
   879 		//Review if we call SetConfig or is only the first time that we load the codec
   880 		if (iDesiredMode != KNullUid)
   881 			{
   882 			iCurrentMode = iDesiredMode;
   883 			}
   884 		}
   885     else
   886         {
   887         iAdaptationObserver->NotifyError(aError);
   888         }
   889     iDesiredMode = KNullUid;
   890 	}
   891 
   892 // -----------------------------------------------------------------------------
   893 // From class MAudioCodecObserver
   894 // CDevAudioControl::GetSupportedSampleRatesComplete
   895 // -----------------------------------------------------------------------------
   896 void CDevAudioControl::GetSupportedSampleRatesComplete(TInt aError)
   897 	{
   898 	iSupportedRates.Reset();
   899 	CompleteMessageCap(aError);
   900 	}
   901 
   902 // -----------------------------------------------------------------------------
   903 // From class MAudioCodecObserver
   904 // CDevAudioControl::GetSupportedModesComplete
   905 // -----------------------------------------------------------------------------
   906 void CDevAudioControl::GetSupportedModesComplete(TInt aError)
   907 	{
   908 	iSupportedModes.Reset();
   909 	CompleteMessageCap(aError);
   910 	}
   911 
   912 // -----------------------------------------------------------------------------
   913 // CDevAudioControl::CompleteMessageCap
   914 // -----------------------------------------------------------------------------
   915 void CDevAudioControl::CompleteMessageCap(TInt aError)
   916 	{
   917 	if (iOutstandingCallbacks > 1) //waiting until the 2 outstanding callbacks arrival.
   918 		{
   919 		iOutstandingCallbacks--;
   920 		iError = aError; //keeping the error.
   921 		}
   922 	else
   923 		{
   924 		if (iError == KErrNone)
   925 			{
   926 			iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue);
   927 			}
   928 		else
   929 			{
   930 			iAdaptationObserver->AsynchronousOperationComplete(iError, ETrue);
   931 			}
   932 		iError = KErrNone;
   933 		iOutstandingCallbacks = KMaxCallbacksExpected;
   934 		}
   935 	}
   936 
   937 // -----------------------------------------------------------------------------
   938 // CDevAudioControl::SetToneData
   939 // -----------------------------------------------------------------------------
   940 //
   941 TInt CDevAudioControl::SetToneData(TToneData& /*aToneData*/)
   942 	{
   943 	DP_CONTEXT(CDevAudioControl::SetToneData *CD1*, CtxDevSound, DPLOCAL);
   944 	DP_IN();
   945 	DP0_RET(KErrNotSupported, "%d");
   946 	}
   947 
   948 
   949 // -----------------------------------------------------------------------------
   950 // From class MAudioContextObserver
   951 // CDevAudio::ContextEvent
   952 // -----------------------------------------------------------------------------
   953 //
   954 void CDevAudioControl::ContextEvent(TUid aEvent, TInt aError)
   955 	{
   956 	DP_CONTEXT(CDevAudioControl::ContextEvent *CD1*, CtxDevSound, DPLOCAL);
   957 	DP_IN();
   958 
   959     if(!(iAdaptationObserver->AdaptorControlsContext()))
   960         {
   961         iIgnoreAsyncOpComplete = ETrue;
   962         }
   963     
   964 	if (aEvent == KUidA3FContextUpdateComplete)
   965 		{
   966 	    if(iIgnoreAsyncOpComplete)
   967 			{
   968             iAdaptationObserver->PreemptionFinishedCallbackReceived(ETrue);
   969 		    iIgnoreAsyncOpComplete = EFalse;
   970    	    	}
   971         else
   972             {
   973             iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue);
   974            	}
   975 		}
   976 	else if(aEvent == KUidA3FContextPreEmption)
   977 		{
   978 		//If we are in a normal pre-emption cycle, we should not be in a mid-state.
   979 		__ASSERT_DEBUG(!iDevAudio->IsMidState(iDevAudio->iActiveState), Panic(EInvalidStateDuringPreemptionCycle));
   980 		iIgnoreAsyncOpComplete = ETrue;
   981 		iAdaptationObserver->PreemptionStartedCallbackReceived();
   982 		}
   983 	//In a clashing pre-emption cycle we must be in a commit cycle, so do nothing here - CDevCommonControl deals
   984 	//with this case.
   985 	DP_OUT();
   986 	}
   987 
   988 
   989 // -----------------------------------------------------------------------------
   990 // From class MCustomInterfaceSupportObserver
   991 // CDevAudio::CustomInterfaceRemoval
   992 // -----------------------------------------------------------------------------
   993 //
   994 void CDevAudioControl::CustomInterfaceRemoval(TUid aUid, TAny* /*aPtr*/)
   995 	{
   996 	DP_CONTEXT(CDevAudioControl::CustomInterfaceRemoval *CD1*, CtxDevSound, DPLOCAL);
   997 	DP_IN();
   998 	// TODO: Review this functionality
   999 	iAdaptationObserver->InterfaceDeleted(aUid);
  1000 	DP_OUT();
  1001 	}
  1002 
  1003 // ---------------------------------------------------------------------------
  1004 // CDevAudioControl::ResolveSampleRate
  1005 // ---------------------------------------------------------------------------
  1006 TInt CDevAudioControl::ResolveSampleRate(TInt aSampleRate, TInt& aSampleRateValue)
  1007 	{
  1008 	DP_CONTEXT(CDevAudioControl::ResolveSampleRate, CtxDevSound, DPLOCAL);
  1009 	DP_IN();
  1010 	TInt err(KErrArgument);
  1011 
  1012 	for (TUint i=0; i<=KMaxSampleRateIndex; i++)
  1013 		{
  1014 		if(KRateTableLookup[i].iSampleRate == aSampleRate)
  1015 			{
  1016 			aSampleRateValue = KRateTableLookup[i].iSampleRateValue;
  1017 			err = KErrNone;
  1018 			break;
  1019 			}
  1020 		}
  1021 
  1022 	//To avoid the value return a non desired value.
  1023 	if (err != KErrNone)
  1024 		{
  1025 		aSampleRateValue = 0;
  1026 		}
  1027 
  1028 	DP0_RET(err, "%d");
  1029 	}
  1030 
  1031 
  1032 // ---------------------------------------------------------------------------
  1033 // CDevAudioControl::ResolveMode
  1034 // ---------------------------------------------------------------------------
  1035 TInt CDevAudioControl::ResolveMode(TUint aModeValue, TUid& aMode)
  1036 	{
  1037 	DP_CONTEXT(CDevAudioControl::ResolveMode *CD1*, CtxDevSound, DPLOCAL);
  1038 	DP_IN();
  1039 	TInt err(KErrArgument);
  1040 
  1041 	
  1042 	for (TInt i=0; i<=KMaxModeIndex; i++)
  1043 		{
  1044 		const TAudioModeTableEntry& entry = KModeTableLookup[i];
  1045 		if (entry.iAudioModeValue == aModeValue)
  1046 			{
  1047 			aMode = entry.iAudioMode;
  1048 			err = KErrNone;
  1049 			break;
  1050 			}
  1051 		}
  1052 	
  1053 	DP0_RET(err,"%d");
  1054 	}
  1055 
  1056 // ---------------------------------------------------------------------------
  1057 // CDevAudioControl::GetModes
  1058 // ---------------------------------------------------------------------------
  1059 TUint CDevAudioControl::GetModes(const RArray<TUid>& aMode)
  1060 	{
  1061 	DP_CONTEXT(CDevAudioControl::GetModes *CD1*, CtxDevSound, DPLOCAL);
  1062 	DP_IN();
  1063 
  1064 	TUint result = 0;
  1065 	TInt count = aMode.Count();
  1066 
  1067 	for (TInt i=0; i<count; i++)
  1068 		{
  1069 		result |= GetMode(aMode[i]);
  1070 		}
  1071 	DP0_RET(result,"%d");
  1072 	}
  1073 
  1074 
  1075 // ---------------------------------------------------------------------------
  1076 // CDevAudioControl::GetMode
  1077 // ---------------------------------------------------------------------------
  1078 TUint CDevAudioControl::GetMode(TUid aMode)
  1079 	{
  1080 	DP_CONTEXT(CDevAudioControl::GetMode *CD1*, CtxDevSound, DPLOCAL);
  1081 	DP_IN();
  1082 	
  1083 	TUint result = 0;
  1084 	
  1085 	for (TInt e=0; e<=KMaxModeIndex; e++)
  1086 		{
  1087 		if(KModeTableLookup[e].iAudioMode == aMode)
  1088 			{
  1089 			result = KModeTableLookup[e].iAudioModeValue;
  1090 			break;
  1091 			}
  1092 		}
  1093 	DP0_RET(result,"%d");
  1094 	}
  1095 
  1096 // ---------------------------------------------------------------------------
  1097 // CDevAudioControl::GetSampleRates
  1098 // ---------------------------------------------------------------------------
  1099 TUint CDevAudioControl::GetSampleRates(const RArray<TInt>& aSampleRates)
  1100 	{
  1101 	DP_CONTEXT(CDevAudioControl::GetSampleRates *CD1*, CtxDevSound, DPLOCAL);
  1102 	DP_IN();
  1103 	
  1104 	TUint result = 0;
  1105 	TInt count = aSampleRates.Count();
  1106 	
  1107 	for (TInt i=0; i<count; i++)
  1108 		{
  1109 		result |= GetSampleRate(aSampleRates[i]);
  1110 		}
  1111 	DP0_RET(result,"%d");
  1112 	}
  1113 
  1114 // ---------------------------------------------------------------------------
  1115 // CDevAudioControl::GetSampleRate
  1116 // ---------------------------------------------------------------------------
  1117 TUint CDevAudioControl::GetSampleRate(TInt aSampleRates)
  1118 	{
  1119 	DP_CONTEXT(CDevAudioControl::GetSampleRate *CD1*, CtxDevSound, DPLOCAL);
  1120 	DP_IN();
  1121 
  1122 	TUint result = 0;
  1123 	TInt position = 0;
  1124 	TInt lowerbound = 0;
  1125 	TInt upperbound = KMaxSampleRateIndex;
  1126 
  1127 	if ((aSampleRates < KRateTableLookup[lowerbound].iSampleRateValue) || (aSampleRates > KRateTableLookup[upperbound].iSampleRateValue)) 
  1128 		{
  1129 		//value request not found in the array.
  1130 		DP0_RET(result,"%d");
  1131 		}
  1132 
  1133 	//Binary Search
  1134 	position = ( lowerbound + upperbound) / 2;
  1135 
  1136 	while((KRateTableLookup[position].iSampleRateValue != aSampleRates) && (lowerbound <= upperbound))
  1137 		{
  1138 		if (KRateTableLookup[position].iSampleRateValue > aSampleRates)
  1139 			{
  1140 			upperbound = position - 1;
  1141 			}
  1142 		else
  1143 			{
  1144 			lowerbound = position + 1;
  1145 			}
  1146 		position = (lowerbound + upperbound) / 2;
  1147 		}
  1148 
  1149 	result = KRateTableLookup[position].iSampleRate;
  1150 
  1151 	DP0_RET(result,"%d");
  1152 	}
  1153 
  1154 // ---------------------------------------------------------------------------
  1155 // CDevAudioControl::ProcessingFinishedReceived
  1156 // ---------------------------------------------------------------------------
  1157 TInt CDevAudioControl::ProcessingFinishedReceived(TBool& /*aAyncOperation*/)
  1158 	{
  1159 	return KErrNone;
  1160 	}
  1161 	
  1162 // ---------------------------------------------------------------------------
  1163 // CDevAudioControl::ProcessingError
  1164 // ---------------------------------------------------------------------------
  1165 TInt CDevAudioControl::ProcessingError(TBool& /*aAyncOperation*/)
  1166     {
  1167     return KErrNone;
  1168     }
  1169 
  1170 // ---------------------------------------------------------------------------
  1171 // CDevAudioControl::RequestEmptyBuffers
  1172 // ---------------------------------------------------------------------------	
  1173 TInt CDevAudioControl::RequestEmptyBuffers()
  1174 	{
  1175 	DP_CONTEXT(CDevAudioControl::RequestEmptyBuffers *CD1*, CtxDevSound, DPLOCAL);
  1176 	DP_IN();
  1177 
  1178 	TInt err(KErrNotReady);
  1179 
  1180 	if(iDevAudio)
  1181 		{
  1182 		if(iDevAudio->iActiveState == EDevSoundAdaptorPaused_Primed)
  1183 			{
  1184 			err = iDevAudio->iAudioStream->Flush();
  1185 			}
  1186 		else if (iDevAudio->iActiveState == EDevSoundAdaptorActive_Active)
  1187 			{
  1188 			err = Pause();
  1189 			if(err == KErrNone)
  1190 				{
  1191 				iPauseResumeSequenceDueToEmptyBuffers = ETrue;
  1192 				}
  1193 			
  1194 			}
  1195 		}
  1196 	DP0_RET(err,"%d");
  1197 	};
  1198 
  1199 void CDevAudioControl::Panic(TDevSoundAdaptorPanicCode aCode)
  1200 	{
  1201 	_LIT(KMMFDevSoundAdaptorPanicCategory, "DevSoundAdaptor");
  1202 	User::Panic(KMMFDevSoundAdaptorPanicCategory, aCode);
  1203 	}
  1204 
  1205 // ---------------------------------------------------------------------------
  1206 // CDevAudioControl::GetTimePlayed
  1207 // ---------------------------------------------------------------------------
  1208 TInt CDevAudioControl::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
  1209 	{
  1210 	DP_CONTEXT(CDevAudioControl::GetTimePlayed *CD1*, CtxDevSound, DPLOCAL);
  1211 	DP_IN();
  1212 	TInt err = iDevAudio->iAudioStream->GetStreamTime(aTime);
  1213 	DP0_RET(err,"%d");
  1214 	}
  1215 
  1216 // ---------------------------------------------------------------------------
  1217 // CDevAudioControl::Resume
  1218 // ---------------------------------------------------------------------------
  1219 TBool CDevAudioControl::Resume()
  1220 	{
  1221 	DP_CONTEXT(CDevAudioControl::Stop *CD1*, CtxDevSound, DPLOCAL);
  1222 	DP_IN();
  1223 	ASSERT(EFalse);
  1224 	DP0_RET(KErrNone, "%d");
  1225 	}
  1226 
  1227 // -----------------------------------------------------------------------------
  1228 // CDevAudioControl::BufferErrorEvent
  1229 // -----------------------------------------------------------------------------
  1230 //
  1231 void CDevAudioControl::BufferErrorEvent()
  1232 	{
  1233 	ASSERT(EFalse); //This should never happen
  1234 	}
  1235 // End of file