os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptation.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 	 * The adaptor has control of the context.
   228 	 * @return returns True if the adaptor is the entity responsible for calling Commit()
   229 	 */
   230 	virtual TBool AdaptorControlsContext() const = 0;
   231 
   232 	/*
   233 	 * Callback indicating that a clash with pre-emption has occurred during the commit cycle
   234 	 * and to push the current request that was being processed onto front of queue.
   235 	 */
   236 
   237 	virtual void PreemptionClash() = 0;
   238 
   239 	/*
   240 	 * Callback indicating the clash with pre-emption during the commit cycle was with state change,
   241 	 * so the current request that was previously pushed onto the front of queue should be removed
   242 	 * without processing.
   243 	 */
   244 
   245 	virtual void PreemptionClashWithStateChange() = 0;
   246 
   247 	/*
   248 	 * Callback to indicate an error has been noticed. This is to be cached until subsequent
   249 	 * AsynchronousOperationComplete(), and handled then if needs.
   250 	 */
   251 	virtual void NotifyError(TInt aError) = 0;
   252 
   253 	};
   254 
   255 // CLASS DECLARATION
   256 
   257 /**
   258 @publishedAll
   259 @released
   260 * This class implements DevSound behavior in a hardware independent way.
   261 *
   262 *  @lib MmfDevSoundAdaptation.lib
   263 *  @since
   264 */
   265 class CMMFDevSoundAdaptation : public CBase
   266 {
   267 
   268 public:  // Constructors and destructor
   269 
   270 	/**
   271 	* Constructs, and returns a pointer to, a new CMMFDevSoundAdaptation
   272 	* object.
   273 	* Leaves on failure..
   274 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   275 	*        Observer instance.
   276 	* @param MGlobalPrpoerties a reference to Audio Server global properties
   277 	* @return CMMFDevSoundAdaptation* A pointer to newly created object.
   278 	*/
   279 	IMPORT_C static CMMFDevSoundAdaptation* NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
   280 														MGlobalProperties& aGlobalProperties);
   281 
   282 	/**
   283 	* Destructor.
   284 	*/
   285 	IMPORT_C virtual ~CMMFDevSoundAdaptation();
   286 
   287 public: // New functions
   288 
   289 	/*
   290 	2nd phase open.
   291 	Async open - if returns successfully, then will result in AsynchronousOperationComplete()
   292 	*/
   293 	IMPORT_C void PostOpenL();
   294 
   295 	/**
   296 	* Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz.
   297 	* On completion of Initialization, calls InitializeComplete() on
   298 	* aDevSoundObserver.
   299 	* Leaves on failure.
   300 	* @since
   301 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   302 	*        Observer instance.
   303 	* @param TMMFState aMode Mode for which this object will be used.
   304 	* @return void
   305 	*/
   306 	IMPORT_C void InitializeL(TMMFState aMode);
   307 
   308 	/**
   309 	* Initializes DevSound object for the mode aMode for processing audio
   310 	* data with hardware device aHWDev.
   311 	* On completion of Initialization, calls InitializeComplete() on
   312 	* aDevSoundObserver.
   313 	* Leaves on failure.
   314 	* @since
   315 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   316 	*        Observer instance.
   317 	* @param TUid aHWDev The CMMFHwDevice implementation identifier.
   318 	* @param TMMFState aMode The mode for which this object will be used
   319 	* @return void
   320 	*/
   321 	IMPORT_C void InitializeL(TUid aHWDev,
   322 							  TMMFState aMode);
   323 
   324 	/**
   325 	* Initializes DevSound object for the mode aMode for processing audio
   326 	* data with hardware device supporting FourCC aDesiredFourCC.
   327 	* Leaves on failure.
   328 	* @since
   329 	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   330 	*        Observer instance.
   331 	* @param TFourCC aDesiredFourCC The CMMFHwDevice implementation FourCC
   332 	*        code.
   333 	* @param TMMFState aMode The mode for which this object will be used
   334 	* @return KErrNone if successfull, else corresponding error code
   335 	* @return void
   336 	*/
   337 	IMPORT_C void InitializeL(TFourCC aDesiredFourCC,
   338 							  TMMFState aMode);
   339 
   340 	/**
   341 	* Cancels the initialization of a DevSound object.
   342 	* @since
   343 	* @return An error code indicating if the function call was successful.
   344 	*   	  KErrNone on success,
   345 	*		  KerrNotReady if this is called before InitializeL() call or after
   346 	*		  the object has been initialized,
   347 	*/
   348 	IMPORT_C TInt CancelInitialize();
   349 
   350 	/**
   351 	* Returns the supported Audio settings ie. encoding, sample rates,
   352 	* mono/stereo operation, buffer size etc..
   353 	* @since
   354 	* @return TMMFCapabilities The device settings.
   355 	*/
   356 	IMPORT_C TInt Capabilities(TMMFCapabilities& aCap);
   357 
   358 	/**
   359 	* Returns the current device configuration.
   360 	* @since
   361 	* @return TMMFCapabilities The device settings.
   362 	*/
   363 	IMPORT_C TMMFCapabilities Config() const;
   364 
   365 	/**
   366 	* Configure CMMFDevSound object with the settings in aConfig. Use this
   367 	* to set sampling rate, encoding and mono/stereo.
   368 	* Leaves on failure.
   369 	* @since
   370 	* @param const TMMFCapabilities& aConfig The attribute values to which
   371 	*        CMMFDevSound object will be configured to.
   372 	* @return void
   373 	*/
   374 	IMPORT_C void SetConfigL(const TMMFCapabilities& aCaps);
   375 
   376 	/**
   377 	* Returns an integer representing the maximum volume device supports.
   378 	* This is the maximum value which can be passed to
   379 	* CMMFDevSound::SetVolume.
   380 	* @since
   381 	* @return TInt The maximum volume. This value is platform dependent but
   382 	*        is always greater than or equal to one.
   383 	*/
   384 	IMPORT_C TInt MaxVolume();
   385 
   386 	/**
   387 	* Returns an integer representing the current volume.
   388 	* @since
   389 	* @return TInt The current volume level.
   390 	*/
   391 	IMPORT_C TInt Volume();
   392 
   393 	/**
   394 	* Changes the current playback volume to a specified value. The volume
   395 	* can be changed before or during playback and is effective immediately.
   396 	* @since
   397 	* @param TInt aVolume The volume setting. This can be any value from 0
   398 	*        to the value returned by a call to
   399 	*        CMMFDevSound::MaxVolume(). If the volume is not
   400 	*        within this range, the volume is automatically set
   401 	*        to minimum or maximum value based on the value
   402 	*        that is being passed. Setting a zero value mutes
   403 	*        the sound. Setting the maximum value results in
   404 	*        the loudest possible sound.
   405 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   406 	*        to AsynchronousOperationComplete()
   407 	* @return KErrNone if successful, otherwise system-wide error code
   408 	*/
   409 	IMPORT_C TInt SetVolume(TInt aVolume, TBool& aAyncCompletion);
   410 
   411 	/**
   412 	* Returns an integer representing the maximum gain the device supports.
   413 	* This is the maximum value which can be passed to CMMFDevSound::SetGain
   414 	* @since
   415 	* @return TInt The maximum gain. This value is platform dependent but is
   416 	*        always greater than or equal to one.
   417 	*/
   418 	IMPORT_C TInt MaxGain();
   419 
   420 	/**
   421 	* Returns an integer representing the current gain.
   422 	* @since
   423 	* @return TInt The current gain level.
   424 	*/
   425 	IMPORT_C TInt Gain();
   426 
   427 	/**
   428 	* Changes the current recording gain to a specified value. The gain can
   429 	* be changed before or during recording and is effective immediately.
   430 	* @since
   431 	* @param TInt aGain The gain setting. This can be any value from zero to
   432 	*        the value returned by a call to
   433 	*        CMMFDevSound::MaxGain(). If the volume
   434 	*        is not within this range, the gain is automatically
   435 	*        set to minimum or maximum value based on the value
   436 	*        that is being passed. Setting a zero value mutes the
   437 	*        sound. Setting the maximum value results in the
   438 	*        loudest possible sound.
   439 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   440 	*        to AsynchronousOperationComplete()
   441 	* @return KErrNone if successful, otherwise system-wide error code
   442 	*/
   443 	IMPORT_C TInt SetGain(TInt aGain, TBool& aAyncCompletion);
   444 
   445 	/**
   446 	* Returns the speaker balance set for playing.
   447 	* Leaves on failure.
   448 	* @since
   449 	* @param TInt &aLeftPercentage On return contains the left speaker
   450 	*        volume percentage.
   451 	* @param TInt &aRightPercentage On return contains the right speaker
   452 	*        volume percentage.
   453 	* @return void
   454 	*/
   455 	IMPORT_C void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
   456 
   457 	/**
   458 	* Sets the speaker balance for playing. The speaker balance can be
   459 	* changed before or during playback and is effective immediately.
   460 	* Leaves on failure.
   461 	* @since
   462 	* @param TInt aLeftPercentage The left speaker volume percentage. This
   463 	*        can be any value from zero to 100. Setting
   464 	*        a zero value mutes the sound on left
   465 	*        speaker.
   466 	* @param TInt aRightPercentage The right speaker volume percentage.
   467 	*        This can be any value from zero to 100.
   468 	*        Setting a zero value mutes the sound on
   469 	*        right speaker.
   470 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   471 	*        to AsynchronousOperationComplete()
   472 	* @return void
   473 	*/
   474 	IMPORT_C void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
   475 
   476 	/**
   477 	* Returns the microphone gain balance set for recording.
   478 	* Leaves on failure.
   479 	* @since
   480 	* @param TInt &aLeftPercentage On return contains the left microphone
   481 	*        gain percentage.
   482 	* @param TInt &aRightPercentage On return contains the right microphone
   483 	*        gain percentage.
   484 	* @return void
   485 	*/
   486 	IMPORT_C void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
   487 
   488 	/**
   489 	* Sets the microphone balance for recording. The microphone balance can
   490 	* be changed before or during recording and is effective immediately.
   491 	* Leaves on failure.
   492 	* @since
   493 	* @param TInt aLeftPercentage The left microphone gain percentage. This
   494 	*        can be any value from zero to 100. Setting
   495 	*        a zero value mutes the sound from left
   496 	*        microphone.
   497 	* @param TInt aRightPercentage The right microphone gain percentage.
   498 	*        This can be any value from zero to 100.
   499 	*        Setting a zero value mutes the sound from
   500 	*        right microphone.
   501 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   502 	*        to AsynchronousOperationComplete()
   503 	* @return void
   504 	*/
   505 	IMPORT_C void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
   506 
   507 	/**
   508 	* Initializes the audio device and starts the play process. This
   509 	* function queries and acquires the audio policy before initializing
   510 	* audio device. If there was an error during policy initialization,
   511 	* PlayError() function will be called on the observer with error code
   512 	* KErrAccessDenied, otherwise BufferToBeFilled() function will be called
   513 	* with a buffer reference. After reading data into the buffer reference
   514 	* passed, the client should call PlayData() to play data.
   515 	* The amount of data that can be played is specified in
   516 	* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
   517 	* this size will be ignored.
   518 	* Leaves on failure.
   519 	* @since
   520 	* @return void
   521 	*/
   522 	IMPORT_C void PlayInitL();
   523 
   524 	/**
   525 	* Initializes the audio device and starts the record process. This
   526 	* function queries and acquires the audio policy before initializing
   527 	* audio device. If there was an error during policy initialization,
   528 	* RecordError() function will be called on the observer with error code
   529 	* KErrAccessDenied, otherwise BufferToBeEmptied() function will be called
   530 	* with a buffer reference. This buffer contains recorded or encoded
   531 	* data. After processing data in the buffer reference passed, the client
   532 	* should call RecordData() to continue recording process.
   533 	* The amount of data that is available is specified in
   534 	* CMMFBuffer::RequestSize().
   535 	* Leaves on failure.
   536 	* @since
   537 	* @return void
   538 	*/
   539 	IMPORT_C void RecordInitL();
   540 
   541 	/**
   542 	* Plays data in the buffer at the current volume.
   543 	* The client should fill the buffer with audio data before calling this
   544 	* function. The observer gets a reference to the buffer along with the
   545 	* callback function BufferToBeFilled(). When playing of the audio sample
   546 	* is complete, successfully or otherwise, the function PlayError() on
   547 	* the observer is called.
   548 	* The last buffer of the audio stream being played should have the last
   549 	* buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
   550 	* subsequent attempt to play the clip is made, this flag will need
   551 	* resetting by the client.
   552 	* @return void
   553 	*/
   554 	IMPORT_C void PlayData();
   555 
   556 	/**
   557 	* Contine the process of recording.
   558 	* Once the buffer is filled with recorded data, the Observer gets a
   559 	* reference to the buffer along with the callback function
   560 	* BufferToBeEmptied(). After processing the buffer (copying over to a
   561 	* different buffer or writing to file) the client should call this
   562 	* function to continue the recording process.
   563 	* @return void
   564 	*/
   565 	IMPORT_C void RecordData();
   566 
   567 	/**
   568 	* Stops the ongoing operation (Play, Record, TonePlay).
   569 	* @since
   570 	* @return KErrNone if successful, system wide error otherwise
   571 	*/
   572 	IMPORT_C TBool Stop();
   573 
   574 	/**
   575 	* Temporarily Stops the ongoing operation (Play, Record, TonePlay).
   576 	* @since
   577 	* @return KErrNone if successful, system wide error otherwise
   578 	*/
   579 	IMPORT_C TInt Pause();
   580 
   581 	/**
   582 	* Returns the Sample recorded so far
   583 	* @since
   584 	* @return TInt Returns the samples recorded.
   585 	*/
   586 	IMPORT_C TInt SamplesRecorded();
   587 
   588 	/**
   589 	* Returns the Sample played so far
   590 	* @since
   591 	* @return TInt Returns the samples played.
   592 	*/
   593 	IMPORT_C TInt SamplesPlayed();
   594 
   595 	/**
   596 	* Initializes the audio device and starts playing a tone. The tone is
   597 	* played with the frequency and duration specified.
   598 	* Leaves on failure.
   599 	* @since
   600 	* @param TInt aFrequency The frequency at which the tone will be played.
   601 	* @param const TTimeIntervalMicroSeconds &aDuration The period over
   602 	*        which the tone will be played. A zero value causes the no tone
   603 	*        to be played.
   604 	* @return void
   605 	*/
   606 	IMPORT_C void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
   607 
   608 	/**
   609 	* Initializes audio device and starts playing a dual tone. Dual Tone is
   610 	* played with the specified frequencies and for the specified duration.
   611 	* Leaves on failure.
   612 	* @since
   613 	* @param TInt aFrequencyOne The first frequency of dual tone.
   614 	* @param TInt aFrequencyTwo The second frequency of dual tone.
   615 	* @param const TTimeIntervalMicroSeconds &aDuration The period over
   616 	*        which the tone will be played. A zero value causes the no tone
   617 	*        to be played.
   618 	* @return void
   619 	*/
   620 	IMPORT_C void PlayDualToneL(TInt aFrequencyOne,
   621 								TInt aFrequencyTwo,
   622 								const TTimeIntervalMicroSeconds& aDuration);
   623 
   624 	/**
   625 	* Initializes the audio device and starts playing the DTMF string
   626 	* aDTMFString.
   627 	* Leaves on failure.
   628 	* @since
   629 	* @param const TDesC &aDTMFString The DTMF sequence in a descriptor.
   630 	* @return void
   631 	*/
   632 	IMPORT_C void PlayDTMFStringL(const TDesC& aDTMFString);
   633 
   634 	/**
   635 	* Initializes the audio device and starts playing a tone sequence.
   636 	* Leaves on failure.
   637 	* @since
   638 	* @param const TDesC8 &aData The tone sequence in a descriptor.
   639 	* @return void
   640 	*/
   641 	IMPORT_C void PlayToneSequenceL(const TDesC8& aData);
   642 
   643 	/**
   644 	* Initializes the audio device and starts playing the specified
   645 	* pre-defined tone sequence.
   646 	* Leaves on failure.
   647 	* @since
   648 	* @param TInt aSequenceNumber The index identifying the specific
   649 	*        pre-defined tone sequence. Index values are relative to zero.
   650 	*        This can be any value from zero to the value returned by a call
   651 	*        to FixedSequenceCount() - 1. The function raises a panic if the
   652 	*        sequence number is not within this range.
   653 	* @return void
   654 	*/
   655 	IMPORT_C void PlayFixedSequenceL(TInt aSequenceNumber);
   656 
   657 	/**
   658 	* Defines the number of times the audio is to be repeated during the
   659 	* tone playback operation. A period of silence can follow each playing
   660 	* of a tone. The tone playing can be repeated indefinitely
   661 	* @since
   662 	* @param TInt aRepeatCount The number of times the tone, together with
   663 	*        the trailing silence, is to be repeated. If this is set to
   664 	*        KMdaRepeatForever, then the tone, together with the trailing
   665 	*        silence, is repeated indefinitely or until Stop() is called.
   666 	*        If this is set to zero, then the tone is not repeated.
   667 	* @param const TTimeIntervalMicroSeconds &aRepeatTrailingSilence An
   668 	*        interval of silence which will be played after each tone.
   669 	*        Supported only during tone playing.
   670 	* @return KErrNone if successful, system wide error otherwise
   671 	*/
   672 	IMPORT_C TInt SetToneRepeats(TInt aRepeatCount,
   673 				  const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
   674 
   675 	/**
   676 	* Defines the duration of tone on, tone off and tone pause to be used
   677 	* during the DTMF tone playback operation.
   678 	* Supported only during tone playing.
   679 	* @since
   680 	* @param TTimeIntervalMicroSeconds32 &aToneOnLength The period over
   681 	*        which the tone will be played. If this is set to zero, then the
   682 	*        tone is not played.
   683 	* @param TTimeIntervalMicroSeconds32 &aToneOffLength The period over
   684 	*        which the no tone will be played.
   685 	* @param TTimeIntervalMicroSeconds32 &aPauseLength The period over which
   686 	*        the tone playing will be paused.
   687 	* @return KErrNone if successful, system wide error otherwise
   688 	*/
   689 	IMPORT_C TInt SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
   690 								 TTimeIntervalMicroSeconds32& aToneOffLength,
   691 								 TTimeIntervalMicroSeconds32& aPauseLength);
   692 
   693 	/**
   694 	* Defines the period over which the volume level is to rise smoothly
   695 	* from nothing to the normal volume level.
   696 	* The function is only available before playing.
   697 	* @since
   698 	* @param const TTimeIntervalMicroSeconds &aRampDuration The period over
   699 	*        which the volume is to rise. A zero value causes the tone
   700 	*        sample to be played at the normal level for the full duration
   701 	*        of the playback. A value, which is longer than the duration of
   702 	*        the tone sample means that the sample never reaches its normal
   703 	*        volume level.
   704 	* @return KErrNone if successful, system wide error otherwise
   705 	*/
   706 	IMPORT_C TInt SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
   707 
   708 	/**
   709 	* Defines the priority settings that should be used for this instance.
   710 	* @since
   711 	* @param const TMMFPrioritySettings &aPrioritySettings A class type
   712 	*        representing the client's priority, priority preference and
   713 	*        state
   714 	* @return KErrNone if successful, system wide error otherwise
   715 	*/
   716 	IMPORT_C TInt SetPrioritySettings(
   717 				  const TMMFPrioritySettings& aPrioritySettings);
   718 
   719 	/**
   720 	* Retrieves a custom interface to the device.
   721 	* @since
   722 	* @param TUid aInterfaceId The interface UID, defined with the custom
   723 	*        interface.
   724 	* @return TAny* A pointer to the interface implementation, or NULL if
   725 	*        the device does not implement the interface requested. The
   726 	*        return value must be cast to the correct type by the user.
   727 	*/
   728 	IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
   729 
   730 	/**
   731 	* Returns the number of available pre-defined tone sequences.
   732 	* This is the number of fixed sequence supported by DevSound by default.
   733 	* @since
   734 	* @return TInt  The fixed sequence count. This value is implementation
   735 	*        dependent.
   736 	*/
   737 	IMPORT_C TInt FixedSequenceCount();
   738 
   739 	/**
   740 	* Returns the name assigned to a specific pre-defined tone sequence.
   741 	* This is the number of the fixed sequence supported by DevSound by
   742 	* default.
   743 	* The function raises a panic if sequence number specified is invalid.
   744 	* @since
   745 	* @param TInt aSequenceNumber The index identifying the specific
   746 	*        pre-defined tone sequence. Index values are relative to zero.
   747 	*        This can be any value from zero to the value returned by a call
   748 	*        to CMdaAudioPlayerUtility::FixedSequenceCount() - 1. The
   749 	*        function raises a panic if sequence number is not within this
   750 	*        range.
   751 	* @return const TDesC & A reference to a Descriptor containing the fixed
   752 	*        sequence name indexed by aSequenceNumber.
   753 	*/
   754 	IMPORT_C const TDesC& FixedSequenceName(TInt aSequenceNumber);
   755 
   756 	/**
   757 	* Returns a list of the supported input datatypes that can be sent to
   758 	* DevSound for playing audio. The datatypes returned are those that the
   759 	* DevSound supports given the priority settings passed in
   760 	* aPrioritySettings. Note that if no supported data types are found this
   761 	* does not constitute failure, the function will return normally with no
   762 	* entries in aSupportedDataTypes.
   763 	* @since
   764 	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
   765 	*        data types that will be filled in by this function. The
   766 	*        supported data types of the DevSound are in the form of an
   767 	*        array of TFourCC codes. Any existing entries in the array will
   768 	*        be overwritten on calling this function. If no supported data
   769 	*        types are found given the priority settings, then the
   770 	*        aSupportedDatatypes array will have zero entries.
   771 	* @param const TMMFPrioritySettings &aPrioritySettings The priority
   772 	*        settings used to determine the supported datatypes. Note this
   773 	*        does not set the priority settings. For input datatypes the
   774 	*        iState member of the priority settings would be expected to be
   775 	*        either EMMFStatePlaying or EMMFStatePlayingRecording. The
   776 	*        priority settings may effect the supported datatypes depending
   777 	*        on the audio routing.
   778 	* @return void
   779 	*/
   780 	IMPORT_C void GetSupportedInputDataTypesL(
   781 				  RArray<TFourCC>& aSupportedDataTypesconst,
   782 				  const TMMFPrioritySettings& aPrioritySettings) const;
   783 
   784 	/**
   785 	* Returns a list of the supported output dataypes that can be received
   786 	* from DevSound for recording audio. The datatypes returned are those
   787 	* that the DevSound supports given the priority settings passed in
   788 	* aPrioritySettings. Note that if no supported data types are found this
   789 	* does not constitute failure, the function will return normally with no
   790 	* entries in aSupportedDataTypes.
   791 	* @since
   792 	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
   793 	*        data types that will be filled in by this function. The
   794 	*        supported datatypes of the DevSound are in the form of an array
   795 	*        of TFourCC codes. Any existing entries in the array will be
   796 	*        overwritten on calling this function. If no supported datatypes
   797 	*        are found given the priority settings, then the
   798 	*        aSupportedDatatypes array will have zero entries.
   799 	* @param const TMMFPrioritySettings &aPrioritySettings The priority
   800 	*        settings used to determine the supported data types. Note this
   801 	*        does not set the priority settings. For output data types the
   802 	*        iState member of the priority settings would expected to be
   803 	*        either EMMFStateRecording or EMMFStatePlayingRecording. The
   804 	*        priority settings may effect the supported datatypes depending
   805 	*        on the audio routing.
   806 	* @return void
   807 	*/
   808 	IMPORT_C void GetSupportedOutputDataTypesL(
   809 				  RArray<TFourCC>& aSupportedDataTypes,
   810 				  const TMMFPrioritySettings& aPrioritySettings) const;
   811 
   812 	/**
   813 	* Sets client configuration
   814 	* @since
   815     * @param aActualProcessId the effective devsound client (supplied with SetClientThreadInfo)
   816     * @param aProcessId the client of DevSound
   817 	* @return KErrNone if successful, system wide error otherwise
   818 	*/
   819     IMPORT_C TInt SetClientConfig(const TProcessId& aProcessId);
   820     IMPORT_C TInt SetClientConfig(const TProcessId& aActualProcessId, const TProcessId& aProcessId);
   821 
   822 	/**
   823 	* Empties the buffers below DevSound without deleting the codec.
   824 	* @since
   825 	* @return KErrNone if successful, otherwise system-wide error code.
   826 	*/
   827 	IMPORT_C TInt EmptyBuffers();
   828 
   829 	/*
   830 	* Make sure any deletions is commited
   831 	* @since
   832 	* @
   833 	*
   834 	*/
   835 	IMPORT_C TBool CloseDevSound();
   836 
   837 	/**
   838 	* Called when a ProcessingFinished callback is received
   839 	* @since
   840 	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   841 	*			to AsynchronousOperationComplete()
   842 	* @return an error code KErrNone if successful
   843 	*/
   844 	IMPORT_C TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
   845 	
   846 	IMPORT_C TInt ProcessingError(TBool& aAyncCompletion);
   847 	
   848 	//provides interface for register a notification event
   849 	IMPORT_C TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
   850 	//provides interface to cancel the registered notification
   851 	IMPORT_C TInt CancelRegisterAsClient(TUid aEventType);
   852 	//Gets the notification data for client to resume
   853 	IMPORT_C TInt GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData);
   854 	//waits for the client to resume playback even after the timeout expires
   855 	IMPORT_C TInt WillResumePlay();
   856 
   857 	/**
   858 	* Gets the current play time from the audio renderer
   859 	* @since 
   860 	* @param TTimeIntervalMicroSeconds& aTime On return contains the current play time
   861 	* @return an error code KErrNone if successful
   862 	*/
   863 	IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
   864 
   865 	/**
   866 	* Queries if the low layers does support resume operation.
   867 	* @since
   868 	* @return TBool ETrue if Resume is supported
   869 	*               EFalse otherwise
   870 	*/
   871 	IMPORT_C TBool IsResumeSupported();
   872 	
   873 	/**
   874 	* Resume the operation (Play, Record, TonePlay) temporarily paused .
   875 	* @since
   876 	* @return TInt KErrNone if succesful
   877 	*              KErrNotSupported if the operation is not supported by this implementation
   878 	*/
   879 	IMPORT_C TInt Resume();
   880 
   881 	/*
   882 	Used to send a stop call when error in buffer
   883 	*/
   884 	IMPORT_C void BufferErrorEvent();
   885 	
   886 	/**
   887 	* Used rollback the adapror active state to the previous state prior a Commit call
   888 	* @return void
   889 	*/
   890 	IMPORT_C void RollbackAdaptorActiveStateToBeforeCommit();
   891 
   892 protected:
   893 
   894 	// So that nobody can extend
   895 	CMMFDevSoundAdaptation();
   896 
   897 	// Second phase constructor
   898 	void ConstructL(MDevSoundAdaptationObserver& aDevSoundObserver,
   899 				MGlobalProperties& aGlobalProperties);
   900 
   901 protected:  // Data
   902 	// Actual implementation class.
   903 	class CBody;
   904 
   905 	//DevSoundAdaptation body implementation
   906 	CBody* iBody;
   907 	};
   908 
   909 #endif      // MMFDEVSOUNDADAPTATION
   910 
   911 // End of File