os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptation.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptation.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,911 @@
     1.4 +/*
     1.5 +* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#ifndef MMFDEVSOUNDADAPTATION_H
    1.24 +#define MMFDEVSOUNDADAPTATION_H
    1.25 +
    1.26 +//  INCLUDES
    1.27 +#include <mmf/server/sounddevice.h>
    1.28 +#include <a3f/a3f_trace_utils.h>
    1.29 +
    1.30 +// CLASS FORWARD
    1.31 +class MGlobalProperties;
    1.32 +
    1.33 +const TInt KCallbackNone 				= 0;
    1.34 +const TInt KCallbackProcessingFinished	= 1;
    1.35 +const TInt KCallbackProcessingUnitError	= 2;
    1.36 +const TInt KCallbackRecordPauseComplete	= 3;
    1.37 +const TInt KCallbackAutoPauseResume 	= 4; 
    1.38 +const TInt KCallbackFlushComplete		= 5;
    1.39 +
    1.40 +// CLASS DECLARATION
    1.41 +
    1.42 +/**
    1.43 +@publishedAll
    1.44 +@released
    1.45 +
    1.46 +An interface to a set of DevSound adaptation observer callback functions.
    1.47 +
    1.48 +This serves as the method of communication between the client and the
    1.49 +DevSound.
    1.50 +
    1.51 +The class is a mixin and is intended to be inherited by the client class
    1.52 +that is interested in observing the DevSound operation. The functions
    1.53 +encapsulated by this class are called when specific events occur in the
    1.54 +process of initializing and playing/recording an audio sample or playing
    1.55 +tones.
    1.56 +*/
    1.57 +class MDevSoundAdaptationObserver
    1.58 +	{
    1.59 +	public:
    1.60 +	/**
    1.61 +	Handles initialization completion event.
    1.62 +
    1.63 +	A derived class must provide an implementation to handle the initialization
    1.64 +	request.
    1.65 +
    1.66 +	CMMFDevSound object calls this function when its InitializeL() function
    1.67 +	completes.
    1.68 +
    1.69 +	@param  aError
    1.70 +			Error code. KErrNone if successful. Other values are possible
    1.71 +			indicating a problem initializing CMMFDevSound object.
    1.72 +	*/
    1.73 +	virtual void InitializeComplete(TInt aError)=0;
    1.74 +
    1.75 +	/**
    1.76 +	Handles tone play completion event.
    1.77 +
    1.78 +	A derived class must provide an implementation to handle the tone play
    1.79 +	completion request.
    1.80 +
    1.81 +	CMMFDevSound object calls this function when an attempt to play tone has
    1.82 +	completed, successfully or otherwise.
    1.83 +
    1.84 +	The following are the play tone functions; PlayToneL(), PlayDMTFStringL(),
    1.85 +	PlayToneSequenceL(), and PlayFixedSequenceL().
    1.86 +
    1.87 +	@param  aError
    1.88 +			Error code. The status of tone playback. KErrUnderflow playing of
    1.89 +			the tone is complete. KErrAccessDenied the sound device is in use by
    1.90 +			another higher priority client. KErrCancel playing of the audio
    1.91 +			sample is stopped by DevSound client another higher priority client.
    1.92 +	*/
    1.93 +	virtual void ToneFinished(TInt aError)=0;
    1.94 +
    1.95 +	/**
    1.96 +	Handles CMMFDevSound object's data request event.
    1.97 +
    1.98 +	A derived class must provide an implementation to supply CMMFDevSound
    1.99 +	object the data that it needs to play.
   1.100 +
   1.101 +	CMMFDevSound object calls this function when and where it needs data for
   1.102 +	playing. The observer should notify CMMFDevSound object as
   1.103 +	quickly as possible after the data is read into buffer, aBuffer by calling
   1.104 +	PlayData(), otherwise the implementation might callback function PlayError()
   1.105 +	on derived class object with error code KErrUnderflow.
   1.106 +	This does not apply to the very first call to PlayData(), however.
   1.107 +	It is possible for a user of DevSound to hold the first buffer sent in
   1.108 +	BufferToBeFilled() until ready to play.
   1.109 +	The use case for this is if a low latency audio response
   1.110 +	is required, as at this point all the resources used to play audio are open.
   1.111 +	If used in this way then it is important to be aware that when when the
   1.112 +	resources for audio are ready at the BufferToBeFilled() callback, a Devsound
   1.113 +	on a real device will be running at increased power consumption as the audio
   1.114 +	hw and any required DSPs will be powered up etc.
   1.115 +
   1.116 +	@param  aBuffer
   1.117 +			Buffer into which data should be read. The amount of data that is
   1.118 +			needed is specified in CMMFBuffer::RequestSize().
   1.119 +	*/
   1.120 +	virtual void BufferToBeFilled(CMMFBuffer* aBuffer)=0;
   1.121 +
   1.122 +	/**
   1.123 +	Handles play completion or cancel event.
   1.124 +
   1.125 +	A derived class must provide an implementation to handle the play
   1.126 +	completion or cancel request.
   1.127 +
   1.128 +	CMMFDevSound object calls this function when an attempt to play audio sample
   1.129 +	has completed, successfully or otherwise.
   1.130 +
   1.131 +	@param  aError
   1.132 +			Error code. The status of playback. KErrUnderflow playing of the
   1.133 +			audio sample is complete. KErrAccessDenied the sound device is in
   1.134 +			use by another higher priority client.
   1.135 +	*/
   1.136 +	virtual void PlayError(TInt aError)=0;
   1.137 +
   1.138 +	/**
   1.139 +	Handles CMMFDevSound object's data request event.
   1.140 +
   1.141 +	A derived class must provide an implementation to process the data
   1.142 +	supplied by CMMFDevSound object while recording.
   1.143 +
   1.144 +	CMMFDevSound object calls this function when the buffer, aBuffer gets filled
   1.145 +	while recording. The observer should notify CMMFDevSound
   1.146 +	object as quickly as possible after data in the buffer is processed by
   1.147 +	calling RecordData(), otherwise the implementation might callback
   1.148 +	the function RecordError() on derived class object with error code KErrOverflow.
   1.149 +
   1.150 +	@param  aBuffer
   1.151 +			Buffer containing processed (recorded) data. The amount
   1.152 +			of data that is available is specified in CMMFBuffer::RequestSize().
   1.153 +	*/
   1.154 +	virtual void BufferToBeEmptied(CMMFBuffer* aBuffer)=0;
   1.155 +
   1.156 +	/**
   1.157 +	Handles record completion or cancel event.
   1.158 +
   1.159 +	A derived class must provide an implementation to handle the record
   1.160 +	completion or cancel request.
   1.161 +
   1.162 +	CMMFDevSound object calls this function when an attempt to record audio sample
   1.163 +	has completed, successfully or otherwise.
   1.164 +
   1.165 +	@param  aError
   1.166 +			Error code. The status of recording. KErrOverflow audio devices
   1.167 +			runs out of internal buffer. KErrAccessDenied the sound device is
   1.168 +			in use by another higher priority client.
   1.169 +	*/
   1.170 +	virtual void RecordError(TInt aError)=0;
   1.171 +
   1.172 +	/**
   1.173 +	Handles device event.
   1.174 +
   1.175 +	A derived class must provide an implementtion to handle the messages from
   1.176 +	audio hardware device.
   1.177 +
   1.178 +	CMMFDevSound object calls this function when a message is received from the
   1.179 +	audio hardware device.
   1.180 +
   1.181 +	@param  aMessageType
   1.182 +			Defines the type of message. Used to determine how to
   1.183 +			interpret the contents of aMsg.
   1.184 +	@param  aMsg
   1.185 +			Message that is packed in the Descriptor format.
   1.186 +	*/
   1.187 +	virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg)=0;
   1.188 +
   1.189 +	/**
   1.190 +	A derived class must provide an implementation to handle the low layer operation completion
   1.191 +	@param	aError	The status of operation in progress
   1.192 +	@param	aCanStartNewOperation	If EFalse indicates that the operation has more than a cycle
   1.193 +	*/
   1.194 +	virtual void AsynchronousOperationComplete(TInt aError, TBool aCanStartNewOperation) = 0;
   1.195 +
   1.196 +
   1.197 +	/**
   1.198 +	Underlying interface has been (or is about to be) deleted.
   1.199 +	Implementations will generally cancel outstanding messages
   1.200 +
   1.201 +	@param	aInterfaceId	Uid of the Interface which has been deleted
   1.202 +	*/
   1.203 +	virtual void InterfaceDeleted(TUid aInterfaceId) = 0;
   1.204 +
   1.205 +	/*
   1.206 +	Underlying physical adaptation has sent a callback that will result either on a commit
   1.207 +	and need to scheduled or in the case of RecordPauseComplete, completes the message.
   1.208 +
   1.209 +	@param aType the callback type
   1.210 +	@param aError KErrNone if successful, else corresponding error
   1.211 +		code
   1.212 +	*/
   1.213 +	virtual void CallbackFromAdaptorReceived(TInt aType, TInt aError) = 0;
   1.214 +	
   1.215 +	/*
   1.216 +	Underlying physical adaptation has sent a callback indicating that a preemption process 
   1.217 + 	has started, any incomming commands will be queued during the preemption.  
   1.218 +	*/
   1.219 +	virtual void PreemptionStartedCallbackReceived() = 0;
   1.220 +
   1.221 +	/*
   1.222 +	Underlying physical adaptation has sent a callback indicating that a preemption process
   1.223 +	has finished. Queued commands during preemption can now be processed. 
   1.224 +
   1.225 +	@param	aCanStartNewOperation	If EFalse indicates that the operation has more than a cycle
   1.226 +	*/
   1.227 +	virtual void PreemptionFinishedCallbackReceived(TBool aCanStartNewOperation) = 0;
   1.228 +
   1.229 +	/*
   1.230 +	 * The adaptor has control of the context.
   1.231 +	 * @return returns True if the adaptor is the entity responsible for calling Commit()
   1.232 +	 */
   1.233 +	virtual TBool AdaptorControlsContext() const = 0;
   1.234 +
   1.235 +	/*
   1.236 +	 * Callback indicating that a clash with pre-emption has occurred during the commit cycle
   1.237 +	 * and to push the current request that was being processed onto front of queue.
   1.238 +	 */
   1.239 +
   1.240 +	virtual void PreemptionClash() = 0;
   1.241 +
   1.242 +	/*
   1.243 +	 * Callback indicating the clash with pre-emption during the commit cycle was with state change,
   1.244 +	 * so the current request that was previously pushed onto the front of queue should be removed
   1.245 +	 * without processing.
   1.246 +	 */
   1.247 +
   1.248 +	virtual void PreemptionClashWithStateChange() = 0;
   1.249 +
   1.250 +	/*
   1.251 +	 * Callback to indicate an error has been noticed. This is to be cached until subsequent
   1.252 +	 * AsynchronousOperationComplete(), and handled then if needs.
   1.253 +	 */
   1.254 +	virtual void NotifyError(TInt aError) = 0;
   1.255 +
   1.256 +	};
   1.257 +
   1.258 +// CLASS DECLARATION
   1.259 +
   1.260 +/**
   1.261 +@publishedAll
   1.262 +@released
   1.263 +* This class implements DevSound behavior in a hardware independent way.
   1.264 +*
   1.265 +*  @lib MmfDevSoundAdaptation.lib
   1.266 +*  @since
   1.267 +*/
   1.268 +class CMMFDevSoundAdaptation : public CBase
   1.269 +{
   1.270 +
   1.271 +public:  // Constructors and destructor
   1.272 +
   1.273 +	/**
   1.274 +	* Constructs, and returns a pointer to, a new CMMFDevSoundAdaptation
   1.275 +	* object.
   1.276 +	* Leaves on failure..
   1.277 +	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   1.278 +	*        Observer instance.
   1.279 +	* @param MGlobalPrpoerties a reference to Audio Server global properties
   1.280 +	* @return CMMFDevSoundAdaptation* A pointer to newly created object.
   1.281 +	*/
   1.282 +	IMPORT_C static CMMFDevSoundAdaptation* NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
   1.283 +														MGlobalProperties& aGlobalProperties);
   1.284 +
   1.285 +	/**
   1.286 +	* Destructor.
   1.287 +	*/
   1.288 +	IMPORT_C virtual ~CMMFDevSoundAdaptation();
   1.289 +
   1.290 +public: // New functions
   1.291 +
   1.292 +	/*
   1.293 +	2nd phase open.
   1.294 +	Async open - if returns successfully, then will result in AsynchronousOperationComplete()
   1.295 +	*/
   1.296 +	IMPORT_C void PostOpenL();
   1.297 +
   1.298 +	/**
   1.299 +	* Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz.
   1.300 +	* On completion of Initialization, calls InitializeComplete() on
   1.301 +	* aDevSoundObserver.
   1.302 +	* Leaves on failure.
   1.303 +	* @since
   1.304 +	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   1.305 +	*        Observer instance.
   1.306 +	* @param TMMFState aMode Mode for which this object will be used.
   1.307 +	* @return void
   1.308 +	*/
   1.309 +	IMPORT_C void InitializeL(TMMFState aMode);
   1.310 +
   1.311 +	/**
   1.312 +	* Initializes DevSound object for the mode aMode for processing audio
   1.313 +	* data with hardware device aHWDev.
   1.314 +	* On completion of Initialization, calls InitializeComplete() on
   1.315 +	* aDevSoundObserver.
   1.316 +	* Leaves on failure.
   1.317 +	* @since
   1.318 +	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   1.319 +	*        Observer instance.
   1.320 +	* @param TUid aHWDev The CMMFHwDevice implementation identifier.
   1.321 +	* @param TMMFState aMode The mode for which this object will be used
   1.322 +	* @return void
   1.323 +	*/
   1.324 +	IMPORT_C void InitializeL(TUid aHWDev,
   1.325 +							  TMMFState aMode);
   1.326 +
   1.327 +	/**
   1.328 +	* Initializes DevSound object for the mode aMode for processing audio
   1.329 +	* data with hardware device supporting FourCC aDesiredFourCC.
   1.330 +	* Leaves on failure.
   1.331 +	* @since
   1.332 +	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
   1.333 +	*        Observer instance.
   1.334 +	* @param TFourCC aDesiredFourCC The CMMFHwDevice implementation FourCC
   1.335 +	*        code.
   1.336 +	* @param TMMFState aMode The mode for which this object will be used
   1.337 +	* @return KErrNone if successfull, else corresponding error code
   1.338 +	* @return void
   1.339 +	*/
   1.340 +	IMPORT_C void InitializeL(TFourCC aDesiredFourCC,
   1.341 +							  TMMFState aMode);
   1.342 +
   1.343 +	/**
   1.344 +	* Cancels the initialization of a DevSound object.
   1.345 +	* @since
   1.346 +	* @return An error code indicating if the function call was successful.
   1.347 +	*   	  KErrNone on success,
   1.348 +	*		  KerrNotReady if this is called before InitializeL() call or after
   1.349 +	*		  the object has been initialized,
   1.350 +	*/
   1.351 +	IMPORT_C TInt CancelInitialize();
   1.352 +
   1.353 +	/**
   1.354 +	* Returns the supported Audio settings ie. encoding, sample rates,
   1.355 +	* mono/stereo operation, buffer size etc..
   1.356 +	* @since
   1.357 +	* @return TMMFCapabilities The device settings.
   1.358 +	*/
   1.359 +	IMPORT_C TInt Capabilities(TMMFCapabilities& aCap);
   1.360 +
   1.361 +	/**
   1.362 +	* Returns the current device configuration.
   1.363 +	* @since
   1.364 +	* @return TMMFCapabilities The device settings.
   1.365 +	*/
   1.366 +	IMPORT_C TMMFCapabilities Config() const;
   1.367 +
   1.368 +	/**
   1.369 +	* Configure CMMFDevSound object with the settings in aConfig. Use this
   1.370 +	* to set sampling rate, encoding and mono/stereo.
   1.371 +	* Leaves on failure.
   1.372 +	* @since
   1.373 +	* @param const TMMFCapabilities& aConfig The attribute values to which
   1.374 +	*        CMMFDevSound object will be configured to.
   1.375 +	* @return void
   1.376 +	*/
   1.377 +	IMPORT_C void SetConfigL(const TMMFCapabilities& aCaps);
   1.378 +
   1.379 +	/**
   1.380 +	* Returns an integer representing the maximum volume device supports.
   1.381 +	* This is the maximum value which can be passed to
   1.382 +	* CMMFDevSound::SetVolume.
   1.383 +	* @since
   1.384 +	* @return TInt The maximum volume. This value is platform dependent but
   1.385 +	*        is always greater than or equal to one.
   1.386 +	*/
   1.387 +	IMPORT_C TInt MaxVolume();
   1.388 +
   1.389 +	/**
   1.390 +	* Returns an integer representing the current volume.
   1.391 +	* @since
   1.392 +	* @return TInt The current volume level.
   1.393 +	*/
   1.394 +	IMPORT_C TInt Volume();
   1.395 +
   1.396 +	/**
   1.397 +	* Changes the current playback volume to a specified value. The volume
   1.398 +	* can be changed before or during playback and is effective immediately.
   1.399 +	* @since
   1.400 +	* @param TInt aVolume The volume setting. This can be any value from 0
   1.401 +	*        to the value returned by a call to
   1.402 +	*        CMMFDevSound::MaxVolume(). If the volume is not
   1.403 +	*        within this range, the volume is automatically set
   1.404 +	*        to minimum or maximum value based on the value
   1.405 +	*        that is being passed. Setting a zero value mutes
   1.406 +	*        the sound. Setting the maximum value results in
   1.407 +	*        the loudest possible sound.
   1.408 +	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   1.409 +	*        to AsynchronousOperationComplete()
   1.410 +	* @return KErrNone if successful, otherwise system-wide error code
   1.411 +	*/
   1.412 +	IMPORT_C TInt SetVolume(TInt aVolume, TBool& aAyncCompletion);
   1.413 +
   1.414 +	/**
   1.415 +	* Returns an integer representing the maximum gain the device supports.
   1.416 +	* This is the maximum value which can be passed to CMMFDevSound::SetGain
   1.417 +	* @since
   1.418 +	* @return TInt The maximum gain. This value is platform dependent but is
   1.419 +	*        always greater than or equal to one.
   1.420 +	*/
   1.421 +	IMPORT_C TInt MaxGain();
   1.422 +
   1.423 +	/**
   1.424 +	* Returns an integer representing the current gain.
   1.425 +	* @since
   1.426 +	* @return TInt The current gain level.
   1.427 +	*/
   1.428 +	IMPORT_C TInt Gain();
   1.429 +
   1.430 +	/**
   1.431 +	* Changes the current recording gain to a specified value. The gain can
   1.432 +	* be changed before or during recording and is effective immediately.
   1.433 +	* @since
   1.434 +	* @param TInt aGain The gain setting. This can be any value from zero to
   1.435 +	*        the value returned by a call to
   1.436 +	*        CMMFDevSound::MaxGain(). If the volume
   1.437 +	*        is not within this range, the gain is automatically
   1.438 +	*        set to minimum or maximum value based on the value
   1.439 +	*        that is being passed. Setting a zero value mutes the
   1.440 +	*        sound. Setting the maximum value results in the
   1.441 +	*        loudest possible sound.
   1.442 +	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   1.443 +	*        to AsynchronousOperationComplete()
   1.444 +	* @return KErrNone if successful, otherwise system-wide error code
   1.445 +	*/
   1.446 +	IMPORT_C TInt SetGain(TInt aGain, TBool& aAyncCompletion);
   1.447 +
   1.448 +	/**
   1.449 +	* Returns the speaker balance set for playing.
   1.450 +	* Leaves on failure.
   1.451 +	* @since
   1.452 +	* @param TInt &aLeftPercentage On return contains the left speaker
   1.453 +	*        volume percentage.
   1.454 +	* @param TInt &aRightPercentage On return contains the right speaker
   1.455 +	*        volume percentage.
   1.456 +	* @return void
   1.457 +	*/
   1.458 +	IMPORT_C void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
   1.459 +
   1.460 +	/**
   1.461 +	* Sets the speaker balance for playing. The speaker balance can be
   1.462 +	* changed before or during playback and is effective immediately.
   1.463 +	* Leaves on failure.
   1.464 +	* @since
   1.465 +	* @param TInt aLeftPercentage The left speaker volume percentage. This
   1.466 +	*        can be any value from zero to 100. Setting
   1.467 +	*        a zero value mutes the sound on left
   1.468 +	*        speaker.
   1.469 +	* @param TInt aRightPercentage The right speaker volume percentage.
   1.470 +	*        This can be any value from zero to 100.
   1.471 +	*        Setting a zero value mutes the sound on
   1.472 +	*        right speaker.
   1.473 +	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   1.474 +	*        to AsynchronousOperationComplete()
   1.475 +	* @return void
   1.476 +	*/
   1.477 +	IMPORT_C void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
   1.478 +
   1.479 +	/**
   1.480 +	* Returns the microphone gain balance set for recording.
   1.481 +	* Leaves on failure.
   1.482 +	* @since
   1.483 +	* @param TInt &aLeftPercentage On return contains the left microphone
   1.484 +	*        gain percentage.
   1.485 +	* @param TInt &aRightPercentage On return contains the right microphone
   1.486 +	*        gain percentage.
   1.487 +	* @return void
   1.488 +	*/
   1.489 +	IMPORT_C void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
   1.490 +
   1.491 +	/**
   1.492 +	* Sets the microphone balance for recording. The microphone balance can
   1.493 +	* be changed before or during recording and is effective immediately.
   1.494 +	* Leaves on failure.
   1.495 +	* @since
   1.496 +	* @param TInt aLeftPercentage The left microphone gain percentage. This
   1.497 +	*        can be any value from zero to 100. Setting
   1.498 +	*        a zero value mutes the sound from left
   1.499 +	*        microphone.
   1.500 +	* @param TInt aRightPercentage The right microphone gain percentage.
   1.501 +	*        This can be any value from zero to 100.
   1.502 +	*        Setting a zero value mutes the sound from
   1.503 +	*        right microphone.
   1.504 +	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   1.505 +	*        to AsynchronousOperationComplete()
   1.506 +	* @return void
   1.507 +	*/
   1.508 +	IMPORT_C void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAyncCompletion);
   1.509 +
   1.510 +	/**
   1.511 +	* Initializes the audio device and starts the play process. This
   1.512 +	* function queries and acquires the audio policy before initializing
   1.513 +	* audio device. If there was an error during policy initialization,
   1.514 +	* PlayError() function will be called on the observer with error code
   1.515 +	* KErrAccessDenied, otherwise BufferToBeFilled() function will be called
   1.516 +	* with a buffer reference. After reading data into the buffer reference
   1.517 +	* passed, the client should call PlayData() to play data.
   1.518 +	* The amount of data that can be played is specified in
   1.519 +	* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
   1.520 +	* this size will be ignored.
   1.521 +	* Leaves on failure.
   1.522 +	* @since
   1.523 +	* @return void
   1.524 +	*/
   1.525 +	IMPORT_C void PlayInitL();
   1.526 +
   1.527 +	/**
   1.528 +	* Initializes the audio device and starts the record process. This
   1.529 +	* function queries and acquires the audio policy before initializing
   1.530 +	* audio device. If there was an error during policy initialization,
   1.531 +	* RecordError() function will be called on the observer with error code
   1.532 +	* KErrAccessDenied, otherwise BufferToBeEmptied() function will be called
   1.533 +	* with a buffer reference. This buffer contains recorded or encoded
   1.534 +	* data. After processing data in the buffer reference passed, the client
   1.535 +	* should call RecordData() to continue recording process.
   1.536 +	* The amount of data that is available is specified in
   1.537 +	* CMMFBuffer::RequestSize().
   1.538 +	* Leaves on failure.
   1.539 +	* @since
   1.540 +	* @return void
   1.541 +	*/
   1.542 +	IMPORT_C void RecordInitL();
   1.543 +
   1.544 +	/**
   1.545 +	* Plays data in the buffer at the current volume.
   1.546 +	* The client should fill the buffer with audio data before calling this
   1.547 +	* function. The observer gets a reference to the buffer along with the
   1.548 +	* callback function BufferToBeFilled(). When playing of the audio sample
   1.549 +	* is complete, successfully or otherwise, the function PlayError() on
   1.550 +	* the observer is called.
   1.551 +	* The last buffer of the audio stream being played should have the last
   1.552 +	* buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
   1.553 +	* subsequent attempt to play the clip is made, this flag will need
   1.554 +	* resetting by the client.
   1.555 +	* @return void
   1.556 +	*/
   1.557 +	IMPORT_C void PlayData();
   1.558 +
   1.559 +	/**
   1.560 +	* Contine the process of recording.
   1.561 +	* Once the buffer is filled with recorded data, the Observer gets a
   1.562 +	* reference to the buffer along with the callback function
   1.563 +	* BufferToBeEmptied(). After processing the buffer (copying over to a
   1.564 +	* different buffer or writing to file) the client should call this
   1.565 +	* function to continue the recording process.
   1.566 +	* @return void
   1.567 +	*/
   1.568 +	IMPORT_C void RecordData();
   1.569 +
   1.570 +	/**
   1.571 +	* Stops the ongoing operation (Play, Record, TonePlay).
   1.572 +	* @since
   1.573 +	* @return KErrNone if successful, system wide error otherwise
   1.574 +	*/
   1.575 +	IMPORT_C TBool Stop();
   1.576 +
   1.577 +	/**
   1.578 +	* Temporarily Stops the ongoing operation (Play, Record, TonePlay).
   1.579 +	* @since
   1.580 +	* @return KErrNone if successful, system wide error otherwise
   1.581 +	*/
   1.582 +	IMPORT_C TInt Pause();
   1.583 +
   1.584 +	/**
   1.585 +	* Returns the Sample recorded so far
   1.586 +	* @since
   1.587 +	* @return TInt Returns the samples recorded.
   1.588 +	*/
   1.589 +	IMPORT_C TInt SamplesRecorded();
   1.590 +
   1.591 +	/**
   1.592 +	* Returns the Sample played so far
   1.593 +	* @since
   1.594 +	* @return TInt Returns the samples played.
   1.595 +	*/
   1.596 +	IMPORT_C TInt SamplesPlayed();
   1.597 +
   1.598 +	/**
   1.599 +	* Initializes the audio device and starts playing a tone. The tone is
   1.600 +	* played with the frequency and duration specified.
   1.601 +	* Leaves on failure.
   1.602 +	* @since
   1.603 +	* @param TInt aFrequency The frequency at which the tone will be played.
   1.604 +	* @param const TTimeIntervalMicroSeconds &aDuration The period over
   1.605 +	*        which the tone will be played. A zero value causes the no tone
   1.606 +	*        to be played.
   1.607 +	* @return void
   1.608 +	*/
   1.609 +	IMPORT_C void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
   1.610 +
   1.611 +	/**
   1.612 +	* Initializes audio device and starts playing a dual tone. Dual Tone is
   1.613 +	* played with the specified frequencies and for the specified duration.
   1.614 +	* Leaves on failure.
   1.615 +	* @since
   1.616 +	* @param TInt aFrequencyOne The first frequency of dual tone.
   1.617 +	* @param TInt aFrequencyTwo The second frequency of dual tone.
   1.618 +	* @param const TTimeIntervalMicroSeconds &aDuration The period over
   1.619 +	*        which the tone will be played. A zero value causes the no tone
   1.620 +	*        to be played.
   1.621 +	* @return void
   1.622 +	*/
   1.623 +	IMPORT_C void PlayDualToneL(TInt aFrequencyOne,
   1.624 +								TInt aFrequencyTwo,
   1.625 +								const TTimeIntervalMicroSeconds& aDuration);
   1.626 +
   1.627 +	/**
   1.628 +	* Initializes the audio device and starts playing the DTMF string
   1.629 +	* aDTMFString.
   1.630 +	* Leaves on failure.
   1.631 +	* @since
   1.632 +	* @param const TDesC &aDTMFString The DTMF sequence in a descriptor.
   1.633 +	* @return void
   1.634 +	*/
   1.635 +	IMPORT_C void PlayDTMFStringL(const TDesC& aDTMFString);
   1.636 +
   1.637 +	/**
   1.638 +	* Initializes the audio device and starts playing a tone sequence.
   1.639 +	* Leaves on failure.
   1.640 +	* @since
   1.641 +	* @param const TDesC8 &aData The tone sequence in a descriptor.
   1.642 +	* @return void
   1.643 +	*/
   1.644 +	IMPORT_C void PlayToneSequenceL(const TDesC8& aData);
   1.645 +
   1.646 +	/**
   1.647 +	* Initializes the audio device and starts playing the specified
   1.648 +	* pre-defined tone sequence.
   1.649 +	* Leaves on failure.
   1.650 +	* @since
   1.651 +	* @param TInt aSequenceNumber The index identifying the specific
   1.652 +	*        pre-defined tone sequence. Index values are relative to zero.
   1.653 +	*        This can be any value from zero to the value returned by a call
   1.654 +	*        to FixedSequenceCount() - 1. The function raises a panic if the
   1.655 +	*        sequence number is not within this range.
   1.656 +	* @return void
   1.657 +	*/
   1.658 +	IMPORT_C void PlayFixedSequenceL(TInt aSequenceNumber);
   1.659 +
   1.660 +	/**
   1.661 +	* Defines the number of times the audio is to be repeated during the
   1.662 +	* tone playback operation. A period of silence can follow each playing
   1.663 +	* of a tone. The tone playing can be repeated indefinitely
   1.664 +	* @since
   1.665 +	* @param TInt aRepeatCount The number of times the tone, together with
   1.666 +	*        the trailing silence, is to be repeated. If this is set to
   1.667 +	*        KMdaRepeatForever, then the tone, together with the trailing
   1.668 +	*        silence, is repeated indefinitely or until Stop() is called.
   1.669 +	*        If this is set to zero, then the tone is not repeated.
   1.670 +	* @param const TTimeIntervalMicroSeconds &aRepeatTrailingSilence An
   1.671 +	*        interval of silence which will be played after each tone.
   1.672 +	*        Supported only during tone playing.
   1.673 +	* @return KErrNone if successful, system wide error otherwise
   1.674 +	*/
   1.675 +	IMPORT_C TInt SetToneRepeats(TInt aRepeatCount,
   1.676 +				  const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
   1.677 +
   1.678 +	/**
   1.679 +	* Defines the duration of tone on, tone off and tone pause to be used
   1.680 +	* during the DTMF tone playback operation.
   1.681 +	* Supported only during tone playing.
   1.682 +	* @since
   1.683 +	* @param TTimeIntervalMicroSeconds32 &aToneOnLength The period over
   1.684 +	*        which the tone will be played. If this is set to zero, then the
   1.685 +	*        tone is not played.
   1.686 +	* @param TTimeIntervalMicroSeconds32 &aToneOffLength The period over
   1.687 +	*        which the no tone will be played.
   1.688 +	* @param TTimeIntervalMicroSeconds32 &aPauseLength The period over which
   1.689 +	*        the tone playing will be paused.
   1.690 +	* @return KErrNone if successful, system wide error otherwise
   1.691 +	*/
   1.692 +	IMPORT_C TInt SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
   1.693 +								 TTimeIntervalMicroSeconds32& aToneOffLength,
   1.694 +								 TTimeIntervalMicroSeconds32& aPauseLength);
   1.695 +
   1.696 +	/**
   1.697 +	* Defines the period over which the volume level is to rise smoothly
   1.698 +	* from nothing to the normal volume level.
   1.699 +	* The function is only available before playing.
   1.700 +	* @since
   1.701 +	* @param const TTimeIntervalMicroSeconds &aRampDuration The period over
   1.702 +	*        which the volume is to rise. A zero value causes the tone
   1.703 +	*        sample to be played at the normal level for the full duration
   1.704 +	*        of the playback. A value, which is longer than the duration of
   1.705 +	*        the tone sample means that the sample never reaches its normal
   1.706 +	*        volume level.
   1.707 +	* @return KErrNone if successful, system wide error otherwise
   1.708 +	*/
   1.709 +	IMPORT_C TInt SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
   1.710 +
   1.711 +	/**
   1.712 +	* Defines the priority settings that should be used for this instance.
   1.713 +	* @since
   1.714 +	* @param const TMMFPrioritySettings &aPrioritySettings A class type
   1.715 +	*        representing the client's priority, priority preference and
   1.716 +	*        state
   1.717 +	* @return KErrNone if successful, system wide error otherwise
   1.718 +	*/
   1.719 +	IMPORT_C TInt SetPrioritySettings(
   1.720 +				  const TMMFPrioritySettings& aPrioritySettings);
   1.721 +
   1.722 +	/**
   1.723 +	* Retrieves a custom interface to the device.
   1.724 +	* @since
   1.725 +	* @param TUid aInterfaceId The interface UID, defined with the custom
   1.726 +	*        interface.
   1.727 +	* @return TAny* A pointer to the interface implementation, or NULL if
   1.728 +	*        the device does not implement the interface requested. The
   1.729 +	*        return value must be cast to the correct type by the user.
   1.730 +	*/
   1.731 +	IMPORT_C TAny* CustomInterface(TUid aInterfaceId);
   1.732 +
   1.733 +	/**
   1.734 +	* Returns the number of available pre-defined tone sequences.
   1.735 +	* This is the number of fixed sequence supported by DevSound by default.
   1.736 +	* @since
   1.737 +	* @return TInt  The fixed sequence count. This value is implementation
   1.738 +	*        dependent.
   1.739 +	*/
   1.740 +	IMPORT_C TInt FixedSequenceCount();
   1.741 +
   1.742 +	/**
   1.743 +	* Returns the name assigned to a specific pre-defined tone sequence.
   1.744 +	* This is the number of the fixed sequence supported by DevSound by
   1.745 +	* default.
   1.746 +	* The function raises a panic if sequence number specified is invalid.
   1.747 +	* @since
   1.748 +	* @param TInt aSequenceNumber The index identifying the specific
   1.749 +	*        pre-defined tone sequence. Index values are relative to zero.
   1.750 +	*        This can be any value from zero to the value returned by a call
   1.751 +	*        to CMdaAudioPlayerUtility::FixedSequenceCount() - 1. The
   1.752 +	*        function raises a panic if sequence number is not within this
   1.753 +	*        range.
   1.754 +	* @return const TDesC & A reference to a Descriptor containing the fixed
   1.755 +	*        sequence name indexed by aSequenceNumber.
   1.756 +	*/
   1.757 +	IMPORT_C const TDesC& FixedSequenceName(TInt aSequenceNumber);
   1.758 +
   1.759 +	/**
   1.760 +	* Returns a list of the supported input datatypes that can be sent to
   1.761 +	* DevSound for playing audio. The datatypes returned are those that the
   1.762 +	* DevSound supports given the priority settings passed in
   1.763 +	* aPrioritySettings. Note that if no supported data types are found this
   1.764 +	* does not constitute failure, the function will return normally with no
   1.765 +	* entries in aSupportedDataTypes.
   1.766 +	* @since
   1.767 +	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
   1.768 +	*        data types that will be filled in by this function. The
   1.769 +	*        supported data types of the DevSound are in the form of an
   1.770 +	*        array of TFourCC codes. Any existing entries in the array will
   1.771 +	*        be overwritten on calling this function. If no supported data
   1.772 +	*        types are found given the priority settings, then the
   1.773 +	*        aSupportedDatatypes array will have zero entries.
   1.774 +	* @param const TMMFPrioritySettings &aPrioritySettings The priority
   1.775 +	*        settings used to determine the supported datatypes. Note this
   1.776 +	*        does not set the priority settings. For input datatypes the
   1.777 +	*        iState member of the priority settings would be expected to be
   1.778 +	*        either EMMFStatePlaying or EMMFStatePlayingRecording. The
   1.779 +	*        priority settings may effect the supported datatypes depending
   1.780 +	*        on the audio routing.
   1.781 +	* @return void
   1.782 +	*/
   1.783 +	IMPORT_C void GetSupportedInputDataTypesL(
   1.784 +				  RArray<TFourCC>& aSupportedDataTypesconst,
   1.785 +				  const TMMFPrioritySettings& aPrioritySettings) const;
   1.786 +
   1.787 +	/**
   1.788 +	* Returns a list of the supported output dataypes that can be received
   1.789 +	* from DevSound for recording audio. The datatypes returned are those
   1.790 +	* that the DevSound supports given the priority settings passed in
   1.791 +	* aPrioritySettings. Note that if no supported data types are found this
   1.792 +	* does not constitute failure, the function will return normally with no
   1.793 +	* entries in aSupportedDataTypes.
   1.794 +	* @since
   1.795 +	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
   1.796 +	*        data types that will be filled in by this function. The
   1.797 +	*        supported datatypes of the DevSound are in the form of an array
   1.798 +	*        of TFourCC codes. Any existing entries in the array will be
   1.799 +	*        overwritten on calling this function. If no supported datatypes
   1.800 +	*        are found given the priority settings, then the
   1.801 +	*        aSupportedDatatypes array will have zero entries.
   1.802 +	* @param const TMMFPrioritySettings &aPrioritySettings The priority
   1.803 +	*        settings used to determine the supported data types. Note this
   1.804 +	*        does not set the priority settings. For output data types the
   1.805 +	*        iState member of the priority settings would expected to be
   1.806 +	*        either EMMFStateRecording or EMMFStatePlayingRecording. The
   1.807 +	*        priority settings may effect the supported datatypes depending
   1.808 +	*        on the audio routing.
   1.809 +	* @return void
   1.810 +	*/
   1.811 +	IMPORT_C void GetSupportedOutputDataTypesL(
   1.812 +				  RArray<TFourCC>& aSupportedDataTypes,
   1.813 +				  const TMMFPrioritySettings& aPrioritySettings) const;
   1.814 +
   1.815 +	/**
   1.816 +	* Sets client configuration
   1.817 +	* @since
   1.818 +    * @param aActualProcessId the effective devsound client (supplied with SetClientThreadInfo)
   1.819 +    * @param aProcessId the client of DevSound
   1.820 +	* @return KErrNone if successful, system wide error otherwise
   1.821 +	*/
   1.822 +    IMPORT_C TInt SetClientConfig(const TProcessId& aProcessId);
   1.823 +    IMPORT_C TInt SetClientConfig(const TProcessId& aActualProcessId, const TProcessId& aProcessId);
   1.824 +
   1.825 +	/**
   1.826 +	* Empties the buffers below DevSound without deleting the codec.
   1.827 +	* @since
   1.828 +	* @return KErrNone if successful, otherwise system-wide error code.
   1.829 +	*/
   1.830 +	IMPORT_C TInt EmptyBuffers();
   1.831 +
   1.832 +	/*
   1.833 +	* Make sure any deletions is commited
   1.834 +	* @since
   1.835 +	* @
   1.836 +	*
   1.837 +	*/
   1.838 +	IMPORT_C TBool CloseDevSound();
   1.839 +
   1.840 +	/**
   1.841 +	* Called when a ProcessingFinished callback is received
   1.842 +	* @since
   1.843 +	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
   1.844 +	*			to AsynchronousOperationComplete()
   1.845 +	* @return an error code KErrNone if successful
   1.846 +	*/
   1.847 +	IMPORT_C TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
   1.848 +	
   1.849 +	IMPORT_C TInt ProcessingError(TBool& aAyncCompletion);
   1.850 +	
   1.851 +	//provides interface for register a notification event
   1.852 +	IMPORT_C TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
   1.853 +	//provides interface to cancel the registered notification
   1.854 +	IMPORT_C TInt CancelRegisterAsClient(TUid aEventType);
   1.855 +	//Gets the notification data for client to resume
   1.856 +	IMPORT_C TInt GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData);
   1.857 +	//waits for the client to resume playback even after the timeout expires
   1.858 +	IMPORT_C TInt WillResumePlay();
   1.859 +
   1.860 +	/**
   1.861 +	* Gets the current play time from the audio renderer
   1.862 +	* @since 
   1.863 +	* @param TTimeIntervalMicroSeconds& aTime On return contains the current play time
   1.864 +	* @return an error code KErrNone if successful
   1.865 +	*/
   1.866 +	IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
   1.867 +
   1.868 +	/**
   1.869 +	* Queries if the low layers does support resume operation.
   1.870 +	* @since
   1.871 +	* @return TBool ETrue if Resume is supported
   1.872 +	*               EFalse otherwise
   1.873 +	*/
   1.874 +	IMPORT_C TBool IsResumeSupported();
   1.875 +	
   1.876 +	/**
   1.877 +	* Resume the operation (Play, Record, TonePlay) temporarily paused .
   1.878 +	* @since
   1.879 +	* @return TInt KErrNone if succesful
   1.880 +	*              KErrNotSupported if the operation is not supported by this implementation
   1.881 +	*/
   1.882 +	IMPORT_C TInt Resume();
   1.883 +
   1.884 +	/*
   1.885 +	Used to send a stop call when error in buffer
   1.886 +	*/
   1.887 +	IMPORT_C void BufferErrorEvent();
   1.888 +	
   1.889 +	/**
   1.890 +	* Used rollback the adapror active state to the previous state prior a Commit call
   1.891 +	* @return void
   1.892 +	*/
   1.893 +	IMPORT_C void RollbackAdaptorActiveStateToBeforeCommit();
   1.894 +
   1.895 +protected:
   1.896 +
   1.897 +	// So that nobody can extend
   1.898 +	CMMFDevSoundAdaptation();
   1.899 +
   1.900 +	// Second phase constructor
   1.901 +	void ConstructL(MDevSoundAdaptationObserver& aDevSoundObserver,
   1.902 +				MGlobalProperties& aGlobalProperties);
   1.903 +
   1.904 +protected:  // Data
   1.905 +	// Actual implementation class.
   1.906 +	class CBody;
   1.907 +
   1.908 +	//DevSoundAdaptation body implementation
   1.909 +	CBody* iBody;
   1.910 +	};
   1.911 +
   1.912 +#endif      // MMFDEVSOUNDADAPTATION
   1.913 +
   1.914 +// End of File