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