os/mm/devsound/sounddevbt/PlatSec/src/SoundDevice/BtSoundDeviceBody.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2001-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 // SoundDeviceBody.inl
    15 // Initializes DevSound object for the mode aMode for processing audio data
    16 // with hardware device aHWDev.
    17 // On completion of Initialization, the observer will be notified via call back
    18 // InitializeComplete().
    19 // Leaves on failure.
    20 // @param	"MDevSoundObserver& aDevSoundObserver"
    21 // A reference to DevSound Observer instance.
    22 // @param	"TUid aHWDev"
    23 // CMMFHwDevice implementation identifier.
    24 // @param	"TMMFState aMode"
    25 // Mode for which this object will be used.
    26 // 
    27 //
    28 
    29 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode)
    30 	{
    31 	TInt initError = KErrNone;
    32 	iDevSoundObserver = &aDevSoundObserver;
    33 
    34 	// Need to set up an init complete event and message handler
    35 	// prior to calling InitializeL()
    36 	if (iICHandler)
    37 		{
    38 		iICHandler->CancelReceiveEvents();
    39 		}
    40 	else
    41 		{
    42 		iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
    43 		}
    44 	iICHandler->ReceiveEvents();
    45 
    46 	initError = iDevSoundProxy->InitializeL(aHWDev, aMode);
    47 
    48  	if (initError)
    49 		{
    50 		iDevSoundObserver->InitializeComplete(initError); 		
    51 		User::Leave(initError);
    52 		}
    53 
    54     if(iBTBFHandler)
    55 		{
    56 		iBTBFHandler->CancelReceiveEvents();
    57 		}
    58 	else
    59 		{
    60 		iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
    61 		}
    62 	iBTBFHandler->ReceiveEvents();
    63 
    64 
    65     if(iPEHandler)
    66 		{
    67 		iPEHandler->CancelReceiveEvents();
    68 		}
    69 	else
    70 		{
    71 		iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
    72 		}
    73 	iPEHandler->ReceiveEvents();
    74 
    75 
    76     if(iREHandler)
    77 		{
    78 		iREHandler->CancelReceiveEvents();
    79 		}
    80 	else
    81 		{
    82 		iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
    83 		}
    84 	iREHandler->ReceiveEvents();
    85 
    86 
    87     if(iTFHandler)
    88 		{
    89 		iTFHandler->CancelReceiveEvents();
    90 		}
    91 	else
    92 		{
    93 		iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
    94 		}
    95 	iTFHandler->ReceiveEvents();
    96 
    97 
    98     if(iBTBEHandler)
    99 		{
   100 		iBTBEHandler->CancelReceiveEvents();
   101 		}
   102 	else
   103 		{
   104 		iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   105 		}
   106 	iBTBEHandler->ReceiveEvents();
   107 
   108 
   109     if(iSETCHandler)
   110 		{
   111 		iSETCHandler->CancelReceiveEvents();
   112 		}
   113 	else
   114 		{
   115 		iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   116 		}
   117 	iSETCHandler->ReceiveEvents();
   118 	}
   119 
   120 
   121 
   122 /*
   123  *
   124  *	Initializes DevSound object for the mode aMode for processing audio data
   125  *	using an array of Hardware devices identified by aHWDevArray identifier
   126  *	array. The hardware devices are chained together with data flow starting
   127  *	with first array element.
   128  *
   129  *	On completion of Initialization, the observer will be notified via call back
   130  *	InitializeComplete().
   131  *
   132  *	Leaves on failure.
   133  *  
   134  *	@param	"MDevSoundObserver& aDevSoundObserver"
   135  *			A reference to DevSound Observer instance.
   136  *
   137  *	@param	"CArrayPtr<TUid> aHWDevArray"
   138  *			Array of CMMFHwDevice implementation identifiers.
   139  *
   140  *	@param	"TMMFState aMode"
   141  *			Mode for which this object will be used.
   142  *
   143  */
   144 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& /*aDevSoundObserver*/, 
   145 										  CArrayPtr<TUid> /*aHWDevArray*/, TMMFState /*aMode*/)
   146 	{
   147 	User::Leave(KErrNotSupported);
   148 	}
   149 
   150 /*
   151  *
   152  *	Initializes DevSound object for the mode aMode for processing audio data
   153  *	with hardware device supporting FourCC aDesiredFourCC.
   154  *
   155  *	On completion of Initialization, the observer will be notified via call back
   156  *	InitializeComplete().
   157  *
   158  *	Leaves on failure.
   159  *  
   160  *	@param	"MDevSoundObserver& aDevSoundObserver"
   161  *			A reference to DevSound Observer instance.
   162  *
   163  *	@param	"TFourCC aDesiredFourCC"
   164  *			CMMFHwDevice implementation FourCC.
   165  *
   166  *	@param	"TMMFState aMode"
   167  *			Mode for which this object will be used.
   168  *
   169  */
   170 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, 
   171 										  TFourCC aDesiredFourCC, TMMFState aMode)
   172 	{
   173 	TInt initError = KErrNone;
   174 	iDevSoundObserver = &aDevSoundObserver;
   175 
   176 	// Need to set up an init complete event and message handler
   177 	// prior to calling InitializeL()
   178 	if (iICHandler)
   179 		{
   180 		iICHandler->CancelReceiveEvents();
   181 		}
   182 	else
   183 		{
   184 		iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   185 		}
   186 	iICHandler->ReceiveEvents();
   187 
   188 	initError = iDevSoundProxy->InitializeL(aDesiredFourCC, aMode);
   189 
   190 	if (initError)
   191 		{
   192 		iDevSoundObserver->InitializeComplete(initError);
   193 		User::Leave(initError);
   194 		}
   195 			
   196     if(iBTBFHandler)
   197 		{
   198 		iBTBFHandler->CancelReceiveEvents();
   199 		}
   200 	else
   201 		{
   202 		iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   203 		}
   204 	iBTBFHandler->ReceiveEvents();
   205 
   206 
   207     if(iPEHandler)
   208 		{
   209 		iPEHandler->CancelReceiveEvents();
   210 		}
   211 	else
   212 		{
   213 		iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   214 		}
   215 	iPEHandler->ReceiveEvents();
   216 
   217 
   218     if(iREHandler)
   219 		{
   220 		iREHandler->CancelReceiveEvents();
   221 		}
   222 	else
   223 		{
   224 		iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   225 		}
   226 	iREHandler->ReceiveEvents();
   227 
   228 
   229     if(iTFHandler)
   230 		{
   231 		iTFHandler->CancelReceiveEvents();
   232 		}
   233 	else
   234 		{
   235 		iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   236 		}
   237 	iTFHandler->ReceiveEvents();
   238 
   239 
   240     if(iBTBEHandler)
   241 		{
   242 		iBTBEHandler->CancelReceiveEvents();
   243 		}
   244 	else
   245 		{
   246 		iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   247 		}
   248 	iBTBEHandler->ReceiveEvents();
   249 
   250 
   251     if(iSETCHandler)
   252 		{
   253 		iSETCHandler->CancelReceiveEvents();
   254 		}
   255 	else
   256 		{
   257 		iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
   258 		}
   259 	iSETCHandler->ReceiveEvents();
   260 
   261 	}
   262 
   263 /*
   264  *
   265  *	Returns the supported Audio settings.
   266  *  
   267  *	@return	"TMMFCapabilities"
   268  *			Device settings.
   269  *
   270  */
   271 inline TMMFCapabilities CMMFDevSoundClientImp::Capabilities()
   272 	{
   273 	return iDevSoundProxy->Capabilities();
   274 	}
   275 
   276 /*
   277  *
   278  *	Returns the current audio settings.
   279  *  
   280  *	@return	"TMMFCapabilities"
   281  *			Device settings.
   282  *
   283  */
   284 inline TMMFCapabilities CMMFDevSoundClientImp::Config() const
   285 	{
   286 	return iDevSoundProxy->Config();
   287 	}
   288 
   289 /*
   290  *
   291  *	Returns an integer representing the maximum volume.
   292  *
   293  *	This is the maximum value which can be passed to CMMFDevSound::SetVolume.
   294  *  
   295  *	@return	"TInt"
   296  *			The maximum volume. This value is platform dependent but is always
   297  *			greater than or equal to one.
   298  *
   299  */
   300 inline TInt CMMFDevSoundClientImp::MaxVolume()
   301 	{
   302 	return iDevSoundProxy->MaxVolume();
   303 	}
   304 
   305 /*
   306  *
   307  *	Returns an integer representing the current volume.
   308  * 
   309  *	@return	"TInt"
   310  *			The current volume level.
   311  *
   312  */
   313 inline TInt CMMFDevSoundClientImp::Volume()
   314 	{
   315 	return iDevSoundProxy->Volume();
   316 	}
   317 
   318 /*
   319  *
   320  *	Returns an integer representing the maximum gain.
   321  *
   322  *	This is the maximum value which can be passed to CMMFDevSound::SetGain.
   323  * 
   324  *	@return	"TInt"
   325  *			The maximum gain. This value is platform dependent but is always
   326  *			greater than or equal to one.
   327  *
   328  */
   329 inline TInt CMMFDevSoundClientImp::MaxGain()
   330 	{
   331 	return iDevSoundProxy->MaxGain();
   332 	}
   333 
   334 /*
   335  *
   336  *	Returns an integer representing the current gain.
   337  *
   338  *	@return	"TInt"
   339  *			The current gain level.
   340  *
   341  */
   342 inline TInt CMMFDevSoundClientImp::Gain()
   343 	{
   344 	return iDevSoundProxy->Gain();
   345 	}
   346 
   347 /*
   348  *
   349  *	Returns the speaker balance set for playing.
   350  *
   351  *	Leaves on failure.
   352  *
   353  *	@param	"TInt& aLeftPercentage"
   354  *			On return contains the left speaker volume percentage.
   355  *
   356  *	@param	"TInt& aRightPercentage"
   357  *			On return contains the right speaker volume percentage.
   358  *
   359  */
   360 inline void CMMFDevSoundClientImp::GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
   361 	{
   362 	iDevSoundProxy->GetPlayBalanceL(aLeftPercentage, aRightPercentage);
   363 	}
   364 
   365 /*
   366  *
   367  *	Returns the microphone gain balance set for recording.
   368  *
   369  *	Leaves on failure.
   370  *
   371  *	@param	"TInt& aLeftPercentage"
   372  *			On return contains the left microphone gain percentage.
   373  *
   374  *	@param	"TInt& aRightPercentage"
   375  *			On return contains the right microphone gain percentage.
   376  *
   377  */
   378 inline void CMMFDevSoundClientImp::GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
   379 	{
   380 	iDevSoundProxy->GetRecordBalanceL(aLeftPercentage, aRightPercentage);
   381 	}
   382 
   383 /*
   384  *
   385  *	Contine the process of recording. Once the buffer is filled with recorded
   386  *	data, the Observer gets reference to buffer along with callback
   387  *	BufferToBeEmptied(). After processing the buffer (copying over to a
   388  *	different buffer or writing to file) the client should call this
   389  *	method to continue recording process.
   390  *
   391  */
   392 inline void CMMFDevSoundClientImp::RecordData()
   393 	{
   394 	ASSERT(iDevSoundObserver);
   395 	iDevSoundProxy->RecordData();
   396 	}
   397 
   398 /*
   399  *
   400  *	Defines the number of times the audio is to be repeated during the tone
   401  *	playback operation.
   402  *
   403  *	A period of silence can follow each playing of tone. The tone playing can
   404  *	be repeated indefinitely.
   405  *
   406  *	@param	"TInt aRepeatCount"
   407  *			The number of times the tone, together with the trailing silence,
   408  *			is to be repeated. If this is set to KMdaRepeatForever, then the
   409  *			tone, together with the trailing silence, is repeated indefinitely
   410  *			or until Stop() is called. If this is set to zero, then the tone is
   411  *			not repeated.
   412  *
   413  *			Supported only during tone playing.
   414  *
   415  */
   416 inline void CMMFDevSoundClientImp::SetToneRepeats(TInt aRepeatCount,
   417 				const TTimeIntervalMicroSeconds& aRepeatTrailingSilence)
   418 	{
   419 	iDevSoundProxy->SetToneRepeats(aRepeatCount, aRepeatTrailingSilence);
   420 	}
   421 
   422 /*
   423  *
   424  *	Defines the priority settings that should be used for this instance.
   425  *
   426  *	@param	"const TMMFPrioritySettings& aPrioritySettings"
   427  *			An class type representing the client's priority, priority 
   428  *			preference and state.
   429  *
   430  */
   431 inline void CMMFDevSoundClientImp::SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
   432 	{
   433 	iDevSoundProxy->SetPrioritySettings(aPrioritySettings);
   434 	}
   435 
   436 /*
   437  *
   438  *	Initializes and starts conversion process. Once the process is initiated,
   439  *	observer's call back method BufferToBeFilled() is called with reference to
   440  *	the buffer into which source format data is to be read.
   441  *
   442  *	The maximum size of data (in bytes) that can be converted is specified in
   443  *	CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
   444  *	size will be ignored.
   445  *
   446  *	Leaves on failure.
   447  *  @prototype
   448  */
   449 inline void CMMFDevSoundClientImp::ConvertInitL()
   450 	{
   451 	iDevSoundProxy->ConvertInitL();
   452 	}
   453 
   454 /*
   455  *
   456  *	Converts the data in the buffer from source format to destination format.
   457  *	After the data is converted to destination format, a reference to the buffer
   458  *	containing data in destination format is passed in the observer call back
   459  *	method BufferToBeEmptied().
   460  *
   461  *	The amount of data contained in buffer is specified in
   462  *	CMMFBuffer::RequestSize().
   463  *  @prototype
   464  */
   465 inline void CMMFDevSoundClientImp::ConvertData()
   466 	{
   467 	iDevSoundProxy->ConvertData();
   468 	}
   469 
   470 // No custom interfaces are supported sp return NULL.
   471 inline TAny* CMMFDevSoundClientImp::CustomInterface(TUid aInterfaceId)
   472 	{
   473 	if(aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
   474 		{
   475 		MAutoPauseResumeSupport* result = this; 
   476 		return result;
   477 		}
   478 	if(aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
   479 		{
   480 		MAudioClientThreadInfo* result = this; 
   481 		return result;
   482 		}
   483 	return iDevSoundProxy->CustomInterface(aInterfaceId);
   484 	}
   485 
   486 /*
   487  *
   488  *	Returns the number of available pre-defined tone sequences.
   489  *
   490  *	This is the number of fixed sequence supported by DevSound by default.
   491  *
   492  *	@return	"TInt"
   493  *			The fixed sequence count. This value is implementation dependent
   494  *			but is always greater than or equal to zero.
   495  *
   496  */
   497 inline TInt CMMFDevSoundClientImp::FixedSequenceCount()
   498 	{
   499 
   500 	return iDevSoundProxy->FixedSequenceCount();
   501 	}
   502 
   503 /*
   504  *
   505  *	Returns the name assigned to a specific pre-defined tone sequence.
   506  *
   507  *	This is the number of fixed sequence supported by DevSound by default.
   508  *
   509  *	The function raises a panic if sequence number specified invalid.
   510  *
   511  *	@return	"TDesC&"
   512  *			A reference to a Descriptor containing the fixed sequence
   513  *			name indexed by aSequenceNumber.
   514  *
   515  *	@param	"TInt aSequenceNumber"
   516  *			The index identifying the specific pre-defined tone sequence. Index
   517  *			values are relative to zero.
   518  *			This can be any value from zero to the value returned by a call to
   519  *			CMdaAudioPlayerUtility::FixedSequenceCount() - 1.
   520  *			The function raises a panic if sequence number is not within this
   521  *			range.
   522  *
   523  */
   524 inline const TDesC& CMMFDevSoundClientImp::FixedSequenceName(TInt aSequenceNumber)
   525 	{
   526 	return iDevSoundProxy->FixedSequenceName(aSequenceNumber);
   527 	}
   528