devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptation.h
changeset 0 40261b775718
child 8 bc06d8566074
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MMFDEVSOUNDADAPTATION_H
       
    21 #define MMFDEVSOUNDADAPTATION_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <mmf/server/sounddevice.h>
       
    25 #include <a3f/a3f_trace_utils.h>
       
    26 
       
    27 // CLASS FORWARD
       
    28 class MGlobalProperties;
       
    29 
       
    30 const TInt KCallbackNone 				= 0;
       
    31 const TInt KCallbackProcessingFinished	= 1;
       
    32 const TInt KCallbackProcessingUnitError	= 2;
       
    33 const TInt KCallbackRecordPauseComplete	= 3;
       
    34 const TInt KCallbackAutoPauseResume 	= 4; 
       
    35 const TInt KCallbackFlushComplete		= 5;
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /**
       
    40 @publishedAll
       
    41 @released
       
    42 
       
    43 An interface to a set of DevSound adaptation observer callback functions.
       
    44 
       
    45 This serves as the method of communication between the client and the
       
    46 DevSound.
       
    47 
       
    48 The class is a mixin and is intended to be inherited by the client class
       
    49 that is interested in observing the DevSound operation. The functions
       
    50 encapsulated by this class are called when specific events occur in the
       
    51 process of initializing and playing/recording an audio sample or playing
       
    52 tones.
       
    53 */
       
    54 class MDevSoundAdaptationObserver
       
    55 	{
       
    56 	public:
       
    57 	/**
       
    58 	Handles initialization completion event.
       
    59 
       
    60 	A derived class must provide an implementation to handle the initialization
       
    61 	request.
       
    62 
       
    63 	CMMFDevSound object calls this function when its InitializeL() function
       
    64 	completes.
       
    65 
       
    66 	@param  aError
       
    67 			Error code. KErrNone if successful. Other values are possible
       
    68 			indicating a problem initializing CMMFDevSound object.
       
    69 	*/
       
    70 	virtual void InitializeComplete(TInt aError)=0;
       
    71 
       
    72 	/**
       
    73 	Handles tone play completion event.
       
    74 
       
    75 	A derived class must provide an implementation to handle the tone play
       
    76 	completion request.
       
    77 
       
    78 	CMMFDevSound object calls this function when an attempt to play tone has
       
    79 	completed, successfully or otherwise.
       
    80 
       
    81 	The following are the play tone functions; PlayToneL(), PlayDMTFStringL(),
       
    82 	PlayToneSequenceL(), and PlayFixedSequenceL().
       
    83 
       
    84 	@param  aError
       
    85 			Error code. The status of tone playback. KErrUnderflow playing of
       
    86 			the tone is complete. KErrAccessDenied the sound device is in use by
       
    87 			another higher priority client. KErrCancel playing of the audio
       
    88 			sample is stopped by DevSound client another higher priority client.
       
    89 	*/
       
    90 	virtual void ToneFinished(TInt aError)=0;
       
    91 
       
    92 	/**
       
    93 	Handles CMMFDevSound object's data request event.
       
    94 
       
    95 	A derived class must provide an implementation to supply CMMFDevSound
       
    96 	object the data that it needs to play.
       
    97 
       
    98 	CMMFDevSound object calls this function when and where it needs data for
       
    99 	playing. The observer should notify CMMFDevSound object as
       
   100 	quickly as possible after the data is read into buffer, aBuffer by calling
       
   101 	PlayData(), otherwise the implementation might callback function PlayError()
       
   102 	on derived class object with error code KErrUnderflow.
       
   103 	This does not apply to the very first call to PlayData(), however.
       
   104 	It is possible for a user of DevSound to hold the first buffer sent in
       
   105 	BufferToBeFilled() until ready to play.
       
   106 	The use case for this is if a low latency audio response
       
   107 	is required, as at this point all the resources used to play audio are open.
       
   108 	If used in this way then it is important to be aware that when when the
       
   109 	resources for audio are ready at the BufferToBeFilled() callback, a Devsound
       
   110 	on a real device will be running at increased power consumption as the audio
       
   111 	hw and any required DSPs will be powered up etc.
       
   112 
       
   113 	@param  aBuffer
       
   114 			Buffer into which data should be read. The amount of data that is
       
   115 			needed is specified in CMMFBuffer::RequestSize().
       
   116 	*/
       
   117 	virtual void BufferToBeFilled(CMMFBuffer* aBuffer)=0;
       
   118 
       
   119 	/**
       
   120 	Handles play completion or cancel event.
       
   121 
       
   122 	A derived class must provide an implementation to handle the play
       
   123 	completion or cancel request.
       
   124 
       
   125 	CMMFDevSound object calls this function when an attempt to play audio sample
       
   126 	has completed, successfully or otherwise.
       
   127 
       
   128 	@param  aError
       
   129 			Error code. The status of playback. KErrUnderflow playing of the
       
   130 			audio sample is complete. KErrAccessDenied the sound device is in
       
   131 			use by another higher priority client.
       
   132 	*/
       
   133 	virtual void PlayError(TInt aError)=0;
       
   134 
       
   135 	/**
       
   136 	Handles CMMFDevSound object's data request event.
       
   137 
       
   138 	A derived class must provide an implementation to process the data
       
   139 	supplied by CMMFDevSound object while recording.
       
   140 
       
   141 	CMMFDevSound object calls this function when the buffer, aBuffer gets filled
       
   142 	while recording. The observer should notify CMMFDevSound
       
   143 	object as quickly as possible after data in the buffer is processed by
       
   144 	calling RecordData(), otherwise the implementation might callback
       
   145 	the function RecordError() on derived class object with error code KErrOverflow.
       
   146 
       
   147 	@param  aBuffer
       
   148 			Buffer containing processed (recorded) data. The amount
       
   149 			of data that is available is specified in CMMFBuffer::RequestSize().
       
   150 	*/
       
   151 	virtual void BufferToBeEmptied(CMMFBuffer* aBuffer)=0;
       
   152 
       
   153 	/**
       
   154 	Handles record completion or cancel event.
       
   155 
       
   156 	A derived class must provide an implementation to handle the record
       
   157 	completion or cancel request.
       
   158 
       
   159 	CMMFDevSound object calls this function when an attempt to record audio sample
       
   160 	has completed, successfully or otherwise.
       
   161 
       
   162 	@param  aError
       
   163 			Error code. The status of recording. KErrOverflow audio devices
       
   164 			runs out of internal buffer. KErrAccessDenied the sound device is
       
   165 			in use by another higher priority client.
       
   166 	*/
       
   167 	virtual void RecordError(TInt aError)=0;
       
   168 
       
   169 	/**
       
   170 	Handles device event.
       
   171 
       
   172 	A derived class must provide an implementtion to handle the messages from
       
   173 	audio hardware device.
       
   174 
       
   175 	CMMFDevSound object calls this function when a message is received from the
       
   176 	audio hardware device.
       
   177 
       
   178 	@param  aMessageType
       
   179 			Defines the type of message. Used to determine how to
       
   180 			interpret the contents of aMsg.
       
   181 	@param  aMsg
       
   182 			Message that is packed in the Descriptor format.
       
   183 	*/
       
   184 	virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg)=0;
       
   185 
       
   186 	/**
       
   187 	A derived class must provide an implementation to handle the low layer operation completion
       
   188 	@param	aError	The status of operation in progress
       
   189 	@param	aCanStartNewOperation	If EFalse indicates that the operation has more than a cycle
       
   190 	*/
       
   191 	virtual void AsynchronousOperationComplete(TInt aError, TBool aCanStartNewOperation) = 0;
       
   192 
       
   193 
       
   194 	/**
       
   195 	Underlying interface has been (or is about to be) deleted.
       
   196 	Implementations will generally cancel outstanding messages
       
   197 
       
   198 	@param	aInterfaceId	Uid of the Interface which has been deleted
       
   199 	*/
       
   200 	virtual void InterfaceDeleted(TUid aInterfaceId) = 0;
       
   201 
       
   202 	/*
       
   203 	Underlying physical adaptation has sent a callback that will result either on a commit
       
   204 	and need to scheduled or in the case of RecordPauseComplete, completes the message.
       
   205 
       
   206 	@param aType the callback type
       
   207 	@param aError KErrNone if successful, else corresponding error
       
   208 		code
       
   209 	*/
       
   210 	virtual void CallbackFromAdaptorReceived(TInt aType, TInt aError) = 0;
       
   211 	
       
   212 	/*
       
   213 	Underlying physical adaptation has sent a callback indicating that a preemption process 
       
   214  	has started, any incomming commands will be queued during the preemption.  
       
   215 	*/
       
   216 	virtual void PreemptionStartedCallbackReceived() = 0;
       
   217 
       
   218 	/*
       
   219 	Underlying physical adaptation has sent a callback indicating that a preemption process
       
   220 	has finished. Queued commands during preemption can now be processed. 
       
   221 
       
   222 	@param	aCanStartNewOperation	If EFalse indicates that the operation has more than a cycle
       
   223 	*/
       
   224 	virtual void PreemptionFinishedCallbackReceived(TBool aCanStartNewOperation) = 0;
       
   225 
       
   226 	
       
   227 
       
   228 	};
       
   229 
       
   230 
       
   231 /**
       
   232 @publishedAll
       
   233 @released
       
   234 *  A class representing client application information.
       
   235 *
       
   236 *  @lib MmfDevSoundAdaptation.lib
       
   237 *  @since
       
   238 */
       
   239 class TMMFClientConfig
       
   240 	{
       
   241 	public:
       
   242 		TProcessId                  iProcessId; //<<< Application Process Id
       
   243 	};
       
   244 
       
   245 // CLASS DECLARATION
       
   246 
       
   247 /**
       
   248 @publishedAll
       
   249 @released
       
   250 * This class implements DevSound behavior in a hardware independent way.
       
   251 *
       
   252 *  @lib MmfDevSoundAdaptation.lib
       
   253 *  @since
       
   254 */
       
   255 class CMMFDevSoundAdaptation : public CBase
       
   256 {
       
   257 
       
   258 public:  // Constructors and destructor
       
   259 
       
   260 	/**
       
   261 	* Constructs, and returns a pointer to, a new CMMFDevSoundAdaptation
       
   262 	* object.
       
   263 	* Leaves on failure..
       
   264 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
       
   265 	*        Observer instance.
       
   266 	* @param MGlobalPrpoerties a reference to Audio Server global properties
       
   267 	* @return CMMFDevSoundAdaptation* A pointer to newly created object.
       
   268 	*/
       
   269 	IMPORT_C static CMMFDevSoundAdaptation* NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
       
   270 														MGlobalProperties& aGlobalProperties);
       
   271 
       
   272 	/**
       
   273 	* Destructor.
       
   274 	*/
       
   275 	IMPORT_C virtual ~CMMFDevSoundAdaptation();
       
   276 
       
   277 public: // New functions
       
   278 
       
   279 	/*
       
   280 	2nd phase open.
       
   281 	Async open - if returns successfully, then will result in AsynchronousOperationComplete()
       
   282 	*/
       
   283 	IMPORT_C void PostOpenL();
       
   284 
       
   285 	/**
       
   286 	* Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz.
       
   287 	* On completion of Initialization, calls InitializeComplete() on
       
   288 	* aDevSoundObserver.
       
   289 	* Leaves on failure.
       
   290 	* @since
       
   291 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
       
   292 	*        Observer instance.
       
   293 	* @param TMMFState aMode Mode for which this object will be used.
       
   294 	* @return void
       
   295 	*/
       
   296 	IMPORT_C void InitializeL(TMMFState aMode);
       
   297 
       
   298 	/**
       
   299 	* Initializes DevSound object for the mode aMode for processing audio
       
   300 	* data with hardware device aHWDev.
       
   301 	* On completion of Initialization, calls InitializeComplete() on
       
   302 	* aDevSoundObserver.
       
   303 	* Leaves on failure.
       
   304 	* @since
       
   305 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
       
   306 	*        Observer instance.
       
   307 	* @param TUid aHWDev The CMMFHwDevice implementation identifier.
       
   308 	* @param TMMFState aMode The mode for which this object will be used
       
   309 	* @return void
       
   310 	*/
       
   311 	IMPORT_C void InitializeL(TUid aHWDev,
       
   312 							  TMMFState aMode);
       
   313 
       
   314 	/**
       
   315 	* Initializes DevSound object for the mode aMode for processing audio
       
   316 	* data with hardware device supporting FourCC aDesiredFourCC.
       
   317 	* Leaves on failure.
       
   318 	* @since
       
   319 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
       
   320 	*        Observer instance.
       
   321 	* @param TFourCC aDesiredFourCC The CMMFHwDevice implementation FourCC
       
   322 	*        code.
       
   323 	* @param TMMFState aMode The mode for which this object will be used
       
   324 	* @return KErrNone if successfull, else corresponding error code
       
   325 	* @return void
       
   326 	*/
       
   327 	IMPORT_C void InitializeL(TFourCC aDesiredFourCC,
       
   328 							  TMMFState aMode);
       
   329 
       
   330 	/**
       
   331 	* Cancels the initialization of a DevSound object.
       
   332 	* @since
       
   333 	* @return An error code indicating if the function call was successful.
       
   334 	*   	  KErrNone on success,
       
   335 	*		  KerrNotReady if this is called before InitializeL() call or after
       
   336 	*		  the object has been initialized,
       
   337 	*/
       
   338 	IMPORT_C TInt CancelInitialize();
       
   339 
       
   340 	/**
       
   341 	* Returns the supported Audio settings ie. encoding, sample rates,
       
   342 	* mono/stereo operation, buffer size etc..
       
   343 	* @since
       
   344 	* @return TMMFCapabilities The device settings.
       
   345 	*/
       
   346 	IMPORT_C TInt Capabilities(TMMFCapabilities& aCap);
       
   347 
       
   348 	/**
       
   349 	* Returns the current device configuration.
       
   350 	* @since
       
   351 	* @return TMMFCapabilities The device settings.
       
   352 	*/
       
   353 	IMPORT_C TMMFCapabilities Config() const;
       
   354 
       
   355 	/**
       
   356 	* Configure CMMFDevSound object with the settings in aConfig. Use this
       
   357 	* to set sampling rate, encoding and mono/stereo.
       
   358 	* Leaves on failure.
       
   359 	* @since
       
   360 	* @param const TMMFCapabilities& aConfig The attribute values to which
       
   361 	*        CMMFDevSound object will be configured to.
       
   362 	* @return void
       
   363 	*/
       
   364 	IMPORT_C void SetConfigL(const TMMFCapabilities& aCaps);
       
   365 
       
   366 	/**
       
   367 	* Returns an integer representing the maximum volume device supports.
       
   368 	* This is the maximum value which can be passed to
       
   369 	* CMMFDevSound::SetVolume.
       
   370 	* @since
       
   371 	* @return TInt The maximum volume. This value is platform dependent but
       
   372 	*        is always greater than or equal to one.
       
   373 	*/
       
   374 	IMPORT_C TInt MaxVolume();
       
   375 
       
   376 	/**
       
   377 	* Returns an integer representing the current volume.
       
   378 	* @since
       
   379 	* @return TInt The current volume level.
       
   380 	*/
       
   381 	IMPORT_C TInt Volume();
       
   382 
       
   383 	/**
       
   384 	* Changes the current playback volume to a specified value. The volume
       
   385 	* can be changed before or during playback and is effective immediately.
       
   386 	* @since
       
   387 	* @param TInt aVolume The volume setting. This can be any value from 0
       
   388 	*        to the value returned by a call to
       
   389 	*        CMMFDevSound::MaxVolume(). If the volume is not
       
   390 	*        within this range, the volume is automatically set
       
   391 	*        to minimum or maximum value based on the value
       
   392 	*        that is being passed. Setting a zero value mutes
       
   393 	*        the sound. Setting the maximum value results in
       
   394 	*        the loudest possible sound.
       
   395 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
       
   396 	*        to AsynchronousOperationComplete()
       
   397 	* @return KErrNone if successful, otherwise system-wide error code
       
   398 	*/
       
   399 	IMPORT_C TInt SetVolume(TInt aVolume, TBool& aAyncCompletion);
       
   400 
       
   401 	/**
       
   402 	* Returns an integer representing the maximum gain the device supports.
       
   403 	* This is the maximum value which can be passed to CMMFDevSound::SetGain
       
   404 	* @since
       
   405 	* @return TInt The maximum gain. This value is platform dependent but is
       
   406 	*        always greater than or equal to one.
       
   407 	*/
       
   408 	IMPORT_C TInt MaxGain();
       
   409 
       
   410 	/**
       
   411 	* Returns an integer representing the current gain.
       
   412 	* @since
       
   413 	* @return TInt The current gain level.
       
   414 	*/
       
   415 	IMPORT_C TInt Gain();
       
   416 
       
   417 	/**
       
   418 	* Changes the current recording gain to a specified value. The gain can
       
   419 	* be changed before or during recording and is effective immediately.
       
   420 	* @since
       
   421 	* @param TInt aGain The gain setting. This can be any value from zero to
       
   422 	*        the value returned by a call to
       
   423 	*        CMMFDevSound::MaxGain(). If the volume
       
   424 	*        is not within this range, the gain is automatically
       
   425 	*        set to minimum or maximum value based on the value
       
   426 	*        that is being passed. Setting a zero value mutes the
       
   427 	*        sound. Setting the maximum value results in the
       
   428 	*        loudest possible sound.
       
   429 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
       
   430 	*        to AsynchronousOperationComplete()
       
   431 	* @return KErrNone if successful, otherwise system-wide error code
       
   432 	*/
       
   433 	IMPORT_C TInt SetGain(TInt aGain, TBool& aAyncCompletion);
       
   434 
       
   435 	/**
       
   436 	* Returns the speaker balance set for playing.
       
   437 	* Leaves on failure.
       
   438 	* @since
       
   439 	* @param TInt &aLeftPercentage On return contains the left speaker
       
   440 	*        volume percentage.
       
   441 	* @param TInt &aRightPercentage On return contains the right speaker
       
   442 	*        volume percentage.
       
   443 	* @return void
       
   444 	*/
       
   445 	IMPORT_C void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
       
   446 
       
   447 	/**
       
   448 	* Sets the speaker balance for playing. The speaker balance can be
       
   449 	* changed before or during playback and is effective immediately.
       
   450 	* Leaves on failure.
       
   451 	* @since
       
   452 	* @param TInt aLeftPercentage The left speaker volume percentage. This
       
   453 	*        can be any value from zero to 100. Setting
       
   454 	*        a zero value mutes the sound on left
       
   455 	*        speaker.
       
   456 	* @param TInt aRightPercentage The right speaker volume percentage.
       
   457 	*        This can be any value from zero to 100.
       
   458 	*        Setting a zero value mutes the sound on
       
   459 	*        right speaker.
       
   460 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
       
   461 	*        to AsynchronousOperationComplete()
       
   462 	* @return void
       
   463 	*/
       
   464 	IMPORT_C void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
       
   465 
       
   466 	/**
       
   467 	* Returns the microphone gain balance set for recording.
       
   468 	* Leaves on failure.
       
   469 	* @since
       
   470 	* @param TInt &aLeftPercentage On return contains the left microphone
       
   471 	*        gain percentage.
       
   472 	* @param TInt &aRightPercentage On return contains the right microphone
       
   473 	*        gain percentage.
       
   474 	* @return void
       
   475 	*/
       
   476 	IMPORT_C void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
       
   477 
       
   478 	/**
       
   479 	* Sets the microphone balance for recording. The microphone balance can
       
   480 	* be changed before or during recording and is effective immediately.
       
   481 	* Leaves on failure.
       
   482 	* @since
       
   483 	* @param TInt aLeftPercentage The left microphone gain percentage. This
       
   484 	*        can be any value from zero to 100. Setting
       
   485 	*        a zero value mutes the sound from left
       
   486 	*        microphone.
       
   487 	* @param TInt aRightPercentage The right microphone gain percentage.
       
   488 	*        This can be any value from zero to 100.
       
   489 	*        Setting a zero value mutes the sound from
       
   490 	*        right microphone.
       
   491 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
       
   492 	*        to AsynchronousOperationComplete()
       
   493 	* @return void
       
   494 	*/
       
   495 	IMPORT_C void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
       
   496 
       
   497 	/**
       
   498 	* Initializes the audio device and starts the play process. This
       
   499 	* function queries and acquires the audio policy before initializing
       
   500 	* audio device. If there was an error during policy initialization,
       
   501 	* PlayError() function will be called on the observer with error code
       
   502 	* KErrAccessDenied, otherwise BufferToBeFilled() function will be called
       
   503 	* with a buffer reference. After reading data into the buffer reference
       
   504 	* passed, the client should call PlayData() to play data.
       
   505 	* The amount of data that can be played is specified in
       
   506 	* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
       
   507 	* this size will be ignored.
       
   508 	* Leaves on failure.
       
   509 	* @since
       
   510 	* @return void
       
   511 	*/
       
   512 	IMPORT_C void PlayInitL();
       
   513 
       
   514 	/**
       
   515 	* Initializes the audio device and starts the record process. This
       
   516 	* function queries and acquires the audio policy before initializing
       
   517 	* audio device. If there was an error during policy initialization,
       
   518 	* RecordError() function will be called on the observer with error code
       
   519 	* KErrAccessDenied, otherwise BufferToBeEmptied() function will be called
       
   520 	* with a buffer reference. This buffer contains recorded or encoded
       
   521 	* data. After processing data in the buffer reference passed, the client
       
   522 	* should call RecordData() to continue recording process.
       
   523 	* The amount of data that is available is specified in
       
   524 	* CMMFBuffer::RequestSize().
       
   525 	* Leaves on failure.
       
   526 	* @since
       
   527 	* @return void
       
   528 	*/
       
   529 	IMPORT_C void RecordInitL();
       
   530 
       
   531 	/**
       
   532 	* Plays data in the buffer at the current volume.
       
   533 	* The client should fill the buffer with audio data before calling this
       
   534 	* function. The observer gets a reference to the buffer along with the
       
   535 	* callback function BufferToBeFilled(). When playing of the audio sample
       
   536 	* is complete, successfully or otherwise, the function PlayError() on
       
   537 	* the observer is called.
       
   538 	* The last buffer of the audio stream being played should have the last
       
   539 	* buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
       
   540 	* subsequent attempt to play the clip is made, this flag will need
       
   541 	* resetting by the client.
       
   542 	* @return void
       
   543 	*/
       
   544 	IMPORT_C void PlayData();
       
   545 
       
   546 	/**
       
   547 	* Contine the process of recording.
       
   548 	* Once the buffer is filled with recorded data, the Observer gets a
       
   549 	* reference to the buffer along with the callback function
       
   550 	* BufferToBeEmptied(). After processing the buffer (copying over to a
       
   551 	* different buffer or writing to file) the client should call this
       
   552 	* function to continue the recording process.
       
   553 	* @return void
       
   554 	*/
       
   555 	IMPORT_C void RecordData();
       
   556 
       
   557 	/**
       
   558 	* Stops the ongoing operation (Play, Record, TonePlay).
       
   559 	* @since
       
   560 	* @return KErrNone if successful, system wide error otherwise
       
   561 	*/
       
   562 	IMPORT_C TBool Stop();
       
   563 
       
   564 	/**
       
   565 	* Temporarily Stops the ongoing operation (Play, Record, TonePlay).
       
   566 	* @since
       
   567 	* @return KErrNone if successful, system wide error otherwise
       
   568 	*/
       
   569 	IMPORT_C TInt Pause();
       
   570 
       
   571 	/**
       
   572 	* Returns the Sample recorded so far
       
   573 	* @since
       
   574 	* @return TInt Returns the samples recorded.
       
   575 	*/
       
   576 	IMPORT_C TInt SamplesRecorded();
       
   577 
       
   578 	/**
       
   579 	* Returns the Sample played so far
       
   580 	* @since
       
   581 	* @return TInt Returns the samples played.
       
   582 	*/
       
   583 	IMPORT_C TInt SamplesPlayed();
       
   584 
       
   585 	/**
       
   586 	* Initializes the audio device and starts playing a tone. The tone is
       
   587 	* played with the frequency and duration specified.
       
   588 	* Leaves on failure.
       
   589 	* @since
       
   590 	* @param TInt aFrequency The frequency at which the tone will be played.
       
   591 	* @param const TTimeIntervalMicroSeconds &aDuration The period over
       
   592 	*        which the tone will be played. A zero value causes the no tone
       
   593 	*        to be played.
       
   594 	* @return void
       
   595 	*/
       
   596 	IMPORT_C void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
       
   597 
       
   598 	/**
       
   599 	* Initializes audio device and starts playing a dual tone. Dual Tone is
       
   600 	* played with the specified frequencies and for the specified duration.
       
   601 	* Leaves on failure.
       
   602 	* @since
       
   603 	* @param TInt aFrequencyOne The first frequency of dual tone.
       
   604 	* @param TInt aFrequencyTwo The second frequency of dual tone.
       
   605 	* @param const TTimeIntervalMicroSeconds &aDuration The period over
       
   606 	*        which the tone will be played. A zero value causes the no tone
       
   607 	*        to be played.
       
   608 	* @return void
       
   609 	*/
       
   610 	IMPORT_C void PlayDualToneL(TInt aFrequencyOne,
       
   611 								TInt aFrequencyTwo,
       
   612 								const TTimeIntervalMicroSeconds& aDuration);
       
   613 
       
   614 	/**
       
   615 	* Initializes the audio device and starts playing the DTMF string
       
   616 	* aDTMFString.
       
   617 	* Leaves on failure.
       
   618 	* @since
       
   619 	* @param const TDesC &aDTMFString The DTMF sequence in a descriptor.
       
   620 	* @return void
       
   621 	*/
       
   622 	IMPORT_C void PlayDTMFStringL(const TDesC& aDTMFString);
       
   623 
       
   624 	/**
       
   625 	* Initializes the audio device and starts playing a tone sequence.
       
   626 	* Leaves on failure.
       
   627 	* @since
       
   628 	* @param const TDesC8 &aData The tone sequence in a descriptor.
       
   629 	* @return void
       
   630 	*/
       
   631 	IMPORT_C void PlayToneSequenceL(const TDesC8& aData);
       
   632 
       
   633 	/**
       
   634 	* Initializes the audio device and starts playing the specified
       
   635 	* pre-defined tone sequence.
       
   636 	* Leaves on failure.
       
   637 	* @since
       
   638 	* @param TInt aSequenceNumber The index identifying the specific
       
   639 	*        pre-defined tone sequence. Index values are relative to zero.
       
   640 	*        This can be any value from zero to the value returned by a call
       
   641 	*        to FixedSequenceCount() - 1. The function raises a panic if the
       
   642 	*        sequence number is not within this range.
       
   643 	* @return void
       
   644 	*/
       
   645 	IMPORT_C void PlayFixedSequenceL(TInt aSequenceNumber);
       
   646 
       
   647 	/**
       
   648 	* Defines the number of times the audio is to be repeated during the
       
   649 	* tone playback operation. A period of silence can follow each playing
       
   650 	* of a tone. The tone playing can be repeated indefinitely
       
   651 	* @since
       
   652 	* @param TInt aRepeatCount The number of times the tone, together with
       
   653 	*        the trailing silence, is to be repeated. If this is set to
       
   654 	*        KMdaRepeatForever, then the tone, together with the trailing
       
   655 	*        silence, is repeated indefinitely or until Stop() is called.
       
   656 	*        If this is set to zero, then the tone is not repeated.
       
   657 	* @param const TTimeIntervalMicroSeconds &aRepeatTrailingSilence An
       
   658 	*        interval of silence which will be played after each tone.
       
   659 	*        Supported only during tone playing.
       
   660 	* @return KErrNone if successful, system wide error otherwise
       
   661 	*/
       
   662 	IMPORT_C TInt SetToneRepeats(TInt aRepeatCount,
       
   663 				  const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
       
   664 
       
   665 	/**
       
   666 	* Defines the duration of tone on, tone off and tone pause to be used
       
   667 	* during the DTMF tone playback operation.
       
   668 	* Supported only during tone playing.
       
   669 	* @since
       
   670 	* @param TTimeIntervalMicroSeconds32 &aToneOnLength The period over
       
   671 	*        which the tone will be played. If this is set to zero, then the
       
   672 	*        tone is not played.
       
   673 	* @param TTimeIntervalMicroSeconds32 &aToneOffLength The period over
       
   674 	*        which the no tone will be played.
       
   675 	* @param TTimeIntervalMicroSeconds32 &aPauseLength The period over which
       
   676 	*        the tone playing will be paused.
       
   677 	* @return KErrNone if successful, system wide error otherwise
       
   678 	*/
       
   679 	IMPORT_C TInt SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
       
   680 								 TTimeIntervalMicroSeconds32& aToneOffLength,
       
   681 								 TTimeIntervalMicroSeconds32& aPauseLength);
       
   682 
       
   683 	/**
       
   684 	* Defines the period over which the volume level is to rise smoothly
       
   685 	* from nothing to the normal volume level.
       
   686 	* The function is only available before playing.
       
   687 	* @since
       
   688 	* @param const TTimeIntervalMicroSeconds &aRampDuration The period over
       
   689 	*        which the volume is to rise. A zero value causes the tone
       
   690 	*        sample to be played at the normal level for the full duration
       
   691 	*        of the playback. A value, which is longer than the duration of
       
   692 	*        the tone sample means that the sample never reaches its normal
       
   693 	*        volume level.
       
   694 	* @return KErrNone if successful, system wide error otherwise
       
   695 	*/
       
   696 	IMPORT_C TInt SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
       
   697 
       
   698 	/**
       
   699 	* Defines the priority settings that should be used for this instance.
       
   700 	* @since
       
   701 	* @param const TMMFPrioritySettings &aPrioritySettings A class type
       
   702 	*        representing the client's priority, priority preference and
       
   703 	*        state
       
   704 	* @return KErrNone if successful, system wide error otherwise
       
   705 	*/
       
   706 	IMPORT_C TInt SetPrioritySettings(
       
   707 				  const TMMFPrioritySettings& aPrioritySettings);
       
   708 
       
   709 	/**
       
   710 	* Retrieves a custom interface to the device.
       
   711 	* @since
       
   712 	* @param TUid aInterfaceId The interface UID, defined with the custom
       
   713 	*        interface.
       
   714 	* @return TAny* A pointer to the interface implementation, or NULL if
       
   715 	*        the device does not implement the interface requested. The
       
   716 	*        return value must be cast to the correct type by the user.
       
   717 	*/
       
   718 	IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
       
   719 
       
   720 	/**
       
   721 	* Returns the number of available pre-defined tone sequences.
       
   722 	* This is the number of fixed sequence supported by DevSound by default.
       
   723 	* @since
       
   724 	* @return TInt  The fixed sequence count. This value is implementation
       
   725 	*        dependent.
       
   726 	*/
       
   727 	IMPORT_C TInt FixedSequenceCount();
       
   728 
       
   729 	/**
       
   730 	* Returns the name assigned to a specific pre-defined tone sequence.
       
   731 	* This is the number of the fixed sequence supported by DevSound by
       
   732 	* default.
       
   733 	* The function raises a panic if sequence number specified is invalid.
       
   734 	* @since
       
   735 	* @param TInt aSequenceNumber The index identifying the specific
       
   736 	*        pre-defined tone sequence. Index values are relative to zero.
       
   737 	*        This can be any value from zero to the value returned by a call
       
   738 	*        to CMdaAudioPlayerUtility::FixedSequenceCount() - 1. The
       
   739 	*        function raises a panic if sequence number is not within this
       
   740 	*        range.
       
   741 	* @return const TDesC & A reference to a Descriptor containing the fixed
       
   742 	*        sequence name indexed by aSequenceNumber.
       
   743 	*/
       
   744 	IMPORT_C const TDesC& FixedSequenceName(TInt aSequenceNumber);
       
   745 
       
   746 	/**
       
   747 	* Returns a list of the supported input datatypes that can be sent to
       
   748 	* DevSound for playing audio. The datatypes returned are those that the
       
   749 	* DevSound supports given the priority settings passed in
       
   750 	* aPrioritySettings. Note that if no supported data types are found this
       
   751 	* does not constitute failure, the function will return normally with no
       
   752 	* entries in aSupportedDataTypes.
       
   753 	* @since
       
   754 	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
       
   755 	*        data types that will be filled in by this function. The
       
   756 	*        supported data types of the DevSound are in the form of an
       
   757 	*        array of TFourCC codes. Any existing entries in the array will
       
   758 	*        be overwritten on calling this function. If no supported data
       
   759 	*        types are found given the priority settings, then the
       
   760 	*        aSupportedDatatypes array will have zero entries.
       
   761 	* @param const TMMFPrioritySettings &aPrioritySettings The priority
       
   762 	*        settings used to determine the supported datatypes. Note this
       
   763 	*        does not set the priority settings. For input datatypes the
       
   764 	*        iState member of the priority settings would be expected to be
       
   765 	*        either EMMFStatePlaying or EMMFStatePlayingRecording. The
       
   766 	*        priority settings may effect the supported datatypes depending
       
   767 	*        on the audio routing.
       
   768 	* @return void
       
   769 	*/
       
   770 	IMPORT_C void GetSupportedInputDataTypesL(
       
   771 				  RArray<TFourCC>& aSupportedDataTypesconst,
       
   772 				  const TMMFPrioritySettings& aPrioritySettings) const;
       
   773 
       
   774 	/**
       
   775 	* Returns a list of the supported output dataypes that can be received
       
   776 	* from DevSound for recording audio. The datatypes returned are those
       
   777 	* that the DevSound supports given the priority settings passed in
       
   778 	* aPrioritySettings. Note that if no supported data types are found this
       
   779 	* does not constitute failure, the function will return normally with no
       
   780 	* entries in aSupportedDataTypes.
       
   781 	* @since
       
   782 	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
       
   783 	*        data types that will be filled in by this function. The
       
   784 	*        supported datatypes of the DevSound are in the form of an array
       
   785 	*        of TFourCC codes. Any existing entries in the array will be
       
   786 	*        overwritten on calling this function. If no supported datatypes
       
   787 	*        are found given the priority settings, then the
       
   788 	*        aSupportedDatatypes array will have zero entries.
       
   789 	* @param const TMMFPrioritySettings &aPrioritySettings The priority
       
   790 	*        settings used to determine the supported data types. Note this
       
   791 	*        does not set the priority settings. For output data types the
       
   792 	*        iState member of the priority settings would expected to be
       
   793 	*        either EMMFStateRecording or EMMFStatePlayingRecording. The
       
   794 	*        priority settings may effect the supported datatypes depending
       
   795 	*        on the audio routing.
       
   796 	* @return void
       
   797 	*/
       
   798 	IMPORT_C void GetSupportedOutputDataTypesL(
       
   799 				  RArray<TFourCC>& aSupportedDataTypes,
       
   800 				  const TMMFPrioritySettings& aPrioritySettings) const;
       
   801 
       
   802 	/**
       
   803 	* Sets client configuration
       
   804 	* @since
       
   805 	* @param TMMFClientConfig& aClientConfig A reference to client
       
   806 	*        configuration object.
       
   807 	* @return KErrNone if successful, system wide error otherwise
       
   808 	*/
       
   809 	IMPORT_C TInt SetClientConfig(const TMMFClientConfig& aClientConfig);
       
   810 
       
   811 	/**
       
   812 	* Returns client configuration
       
   813 	* @since
       
   814 	* @return void
       
   815 	*/
       
   816 	IMPORT_C const TMMFClientConfig& ClientConfig() const;
       
   817 
       
   818 	/**
       
   819 	* Empties the buffers below DevSound without deleting the codec.
       
   820 	* @since
       
   821 	* @return KErrNone if successful, otherwise system-wide error code.
       
   822 	*/
       
   823 	IMPORT_C TInt EmptyBuffers();
       
   824 
       
   825 	/*
       
   826 	* Make sure any deletions is commited
       
   827 	* @since
       
   828 	* @
       
   829 	*
       
   830 	*/
       
   831 	IMPORT_C TBool CloseDevSound();
       
   832 
       
   833 	/**
       
   834 	* Called when a ProcessingFinished callback is received
       
   835 	* @since
       
   836 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
       
   837 	*			to AsynchronousOperationComplete()
       
   838 	* @return an error code KErrNone if successful
       
   839 	*/
       
   840 	IMPORT_C TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
       
   841 	
       
   842 	IMPORT_C TInt ProcessingError(TBool& aAyncCompletion);
       
   843 	
       
   844 	//provides interface for register a notification event
       
   845 	IMPORT_C TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
       
   846 	//provides interface to cancel the registered notification
       
   847 	IMPORT_C TInt CancelRegisterAsClient(TUid aEventType);
       
   848 	//Gets the notification data for client to resume
       
   849 	IMPORT_C TInt GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData);
       
   850 	//waits for the client to resume playback even after the timeout expires
       
   851 	IMPORT_C TInt WillResumePlay();
       
   852 
       
   853 	/**
       
   854 	* Gets the current play time from the audio renderer
       
   855 	* @since 
       
   856 	* @param TTimeIntervalMicroSeconds& aTime On return contains the current play time
       
   857 	* @return an error code KErrNone if successful
       
   858 	*/
       
   859 	IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
       
   860 
       
   861 	/**
       
   862 	* Queries if the low layers does support resume operation.
       
   863 	* @since
       
   864 	* @return TBool ETrue if Resume is supported
       
   865 	*               EFalse otherwise
       
   866 	*/
       
   867 	IMPORT_C TBool IsResumeSupported();
       
   868 	
       
   869 	/**
       
   870 	* Resume the operation (Play, Record, TonePlay) temporarily paused .
       
   871 	* @since
       
   872 	* @return TInt KErrNone if succesful
       
   873 	*              KErrNotSupported if the operation is not supported by this implementation
       
   874 	*/
       
   875 	IMPORT_C TInt Resume();
       
   876 
       
   877 	/*
       
   878 	Used to send a stop call when error in buffer
       
   879 	*/
       
   880 	IMPORT_C void BufferErrorEvent();
       
   881 	
       
   882 protected:
       
   883 
       
   884 	// So that nobody can extend
       
   885 	CMMFDevSoundAdaptation();
       
   886 
       
   887 	// Second phase constructor
       
   888 	void ConstructL(MDevSoundAdaptationObserver& aDevSoundObserver,
       
   889 				MGlobalProperties& aGlobalProperties);
       
   890 
       
   891 protected:  // Data
       
   892 	// Actual implementation class.
       
   893 	class CBody;
       
   894 
       
   895 	//DevSoundAdaptation body implementation
       
   896 	CBody* iBody;
       
   897 	};
       
   898 
       
   899 #endif      // MMFDEVSOUNDADAPTATION
       
   900 
       
   901 // End of File