os/mm/devsound/a3fdevsound/src/devsoundadaptor/mmfdevsoundadaptationbody.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 MMFDEVSOUNDADAPTATIONBODY_H
sl@0
    21
#define MMFDEVSOUNDADAPTATIONBODY_H
sl@0
    22
sl@0
    23
#include <e32base.h>
sl@0
    24
#include <mmf/server/mmfhwdevice.h>
sl@0
    25
#include <a3f/a3f_trace_utils.h>
sl@0
    26
#include "mmfdevsoundadaptation.h"
sl@0
    27
#include <a3f/tonedata.h>
sl@0
    28
#include <a3f/audioprocessingunittypeuids.h>
sl@0
    29
sl@0
    30
sl@0
    31
class CDevAudio;
sl@0
    32
class CDevAudioControl;
sl@0
    33
class MGlobalProperties;
sl@0
    34
sl@0
    35
// CONSTANTS
sl@0
    36
const TInt KDevsoundDefaultMaxGain = 10;
sl@0
    37
const TUint KDevSoundMaxCaps = 0xFFFFFFFF;
sl@0
    38
sl@0
    39
const TUint KDataForPlay = 0;
sl@0
    40
const TUint KDataForRecord = 1;
sl@0
    41
sl@0
    42
/**
sl@0
    43
 * Class implementing CMMFDevSoundAdaptation behaviour.
sl@0
    44
 *
sl@0
    45
 * @lib mmfdevsoundadaptation.lib
sl@0
    46
 */
sl@0
    47
class CMMFDevSoundAdaptation::CBody : public CBase
sl@0
    48
	{
sl@0
    49
	friend class CMMFDevSoundAdaptation;
sl@0
    50
sl@0
    51
public:
sl@0
    52
sl@0
    53
	static CBody* NewL(MDevSoundAdaptationObserver& aDevSoundObserver,
sl@0
    54
						MGlobalProperties& aGlobalProperties);
sl@0
    55
sl@0
    56
	~CBody();
sl@0
    57
sl@0
    58
public: // New functions
sl@0
    59
sl@0
    60
	/*
sl@0
    61
	* 2nd phase async open operation
sl@0
    62
	*/
sl@0
    63
	void PostOpenL();
sl@0
    64
sl@0
    65
	/**
sl@0
    66
	* Initializes to raw audio data PCM16 and Sampling Rate of 8 KHz.
sl@0
    67
	* On completion of Initialization, calls InitializeComplete() on
sl@0
    68
	* aDevSoundObserver.
sl@0
    69
	* Leaves on failure.
sl@0
    70
	* @since
sl@0
    71
	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
sl@0
    72
	*        Observer instance.
sl@0
    73
	* @param TMMFState aMode Mode for which this object will be used.
sl@0
    74
	* @return void
sl@0
    75
	*/
sl@0
    76
	void InitializeL(TMMFState aMode);
sl@0
    77
sl@0
    78
	/**
sl@0
    79
	* Initializes DevSound object for the mode aMode for processing audio
sl@0
    80
	* data with hardware device aHWDev.
sl@0
    81
	* On completion of Initialization, calls InitializeComplete() on
sl@0
    82
	* aDevSoundObserver.
sl@0
    83
	* Leaves on failure.
sl@0
    84
	* @since
sl@0
    85
	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
sl@0
    86
	*        Observer instance.
sl@0
    87
	* @param TUid aHWDev The CMMFHwDevice implementation identifier.
sl@0
    88
	* @param TMMFState aMode The mode for which this object will be used
sl@0
    89
	* @return void
sl@0
    90
	*/
sl@0
    91
	void InitializeL(TUid aHWDev, TMMFState aMode);
sl@0
    92
sl@0
    93
	/**
sl@0
    94
	* Initializes DevSound object for the mode aMode for processing audio
sl@0
    95
	* data with hardware device supporting FourCC aDesiredFourCC.
sl@0
    96
	* Leaves on failure.
sl@0
    97
	* @since
sl@0
    98
	* @param MDevSoundAdaptationObserver& aDevSoundObserver A reference to DevSound
sl@0
    99
	*        Observer instance.
sl@0
   100
	* @param TFourCC aDesiredFourCC The CMMFHwDevice implementation FourCC
sl@0
   101
	*        code.
sl@0
   102
	* @param TMMFState aMode The mode for which this object will be used
sl@0
   103
	* @return KErrNone if successfull, else corresponding error code
sl@0
   104
	* @return void
sl@0
   105
	*/
sl@0
   106
	void InitializeL(TFourCC aDesiredFourCC,
sl@0
   107
					TMMFState aMode);
sl@0
   108
sl@0
   109
	/**
sl@0
   110
	* Initializes DevSound object with codec format aFormat
sl@0
   111
	* Leaves on failure.
sl@0
   112
	* @since
sl@0
   113
	* @param aDevSoundObserver A reference to DevSound Observer instance.
sl@0
   114
	* @param aFormat codec format
sl@0
   115
	* @param aMode The mode for which this object will be used
sl@0
   116
	*/
sl@0
   117
	void DoInitializeL(TUid aFormat,
sl@0
   118
				TMMFState aMode);
sl@0
   119
sl@0
   120
	/**
sl@0
   121
	* Cancels the initialization of a DevSound object.
sl@0
   122
	* @since
sl@0
   123
	* @return An error code indicating if the function call was successful.
sl@0
   124
	*    	  KErrNone on success,
sl@0
   125
	*		  KerrNotReady if this is called before InitializeL() call or after
sl@0
   126
	*		  the object has been initialized,
sl@0
   127
	*/
sl@0
   128
	TInt CancelInitialize();
sl@0
   129
sl@0
   130
	/**
sl@0
   131
	* Returns the supported Audio settings ie. encoding, sample rates,
sl@0
   132
	* mono/stereo operation, buffer size etc..
sl@0
   133
	* @since
sl@0
   134
	* @return TMMFCapabilities The device settings.
sl@0
   135
	*/
sl@0
   136
	TInt Capabilities(TMMFCapabilities& aCap);
sl@0
   137
sl@0
   138
	/**
sl@0
   139
	* Returns the current device configuration.
sl@0
   140
	* @since
sl@0
   141
	* @return TMMFCapabilities The device settings.
sl@0
   142
	*/
sl@0
   143
	TMMFCapabilities Config() const;
sl@0
   144
sl@0
   145
	/**
sl@0
   146
	* Configure CMMFDevSound object with the settings in aConfig. Use this
sl@0
   147
	* to set sampling rate, encoding and mono/stereo.
sl@0
   148
	* Leaves on failure.
sl@0
   149
	* @since
sl@0
   150
	* @param const TMMFCapabilities& aConfig The attribute values to which
sl@0
   151
	*        CMMFDevSound object will be configured to.
sl@0
   152
	* @return void
sl@0
   153
	*/
sl@0
   154
	void SetConfigL(const TMMFCapabilities& aCaps);
sl@0
   155
sl@0
   156
	/**
sl@0
   157
	* Returns an integer representing the maximum volume device supports.
sl@0
   158
	* This is the maximum value which can be passed to
sl@0
   159
	* CMMFDevSound::SetVolume.
sl@0
   160
	* @since
sl@0
   161
	* @return TInt The maximum volume. This value is platform dependent but
sl@0
   162
	*        is always greater than or equal to one.
sl@0
   163
	*/
sl@0
   164
	TInt MaxVolume();
sl@0
   165
sl@0
   166
	/**
sl@0
   167
	* Returns an integer representing the current volume.
sl@0
   168
	* @since
sl@0
   169
	* @return TInt The current volume level.
sl@0
   170
	*/
sl@0
   171
	TInt Volume();
sl@0
   172
sl@0
   173
	/**
sl@0
   174
	* Changes the current playback volume to a specified value. The volume
sl@0
   175
	* can be changed before or during playback and is effective immediately.
sl@0
   176
	* @since
sl@0
   177
	* @param aVolume The volume setting. This can be any value from 0
sl@0
   178
	*        to the value returned by a call to
sl@0
   179
	*        CMMFDevSound::MaxVolume(). If the volume is not
sl@0
   180
	*        within this range, the volume is automatically set
sl@0
   181
	*        to minimum or maximum value based on the value
sl@0
   182
	*        that is being passed. Setting a zero value mutes
sl@0
   183
	*        the sound. Setting the maximum value results in
sl@0
   184
	*        the loudest possible sound.
sl@0
   185
	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
sl@0
   186
	*        to AsynchronousOperationComplete()
sl@0
   187
	* @return KErrNone if successful, otherwise system-wide error code
sl@0
   188
	*/
sl@0
   189
	TInt SetVolume(TInt aVolume, TBool& aAyncCompletion);
sl@0
   190
sl@0
   191
	/**
sl@0
   192
	* Gets the maximum gain the device supports.
sl@0
   193
	* This is the maximum value which can be passed to CMMFDevSound::SetGain
sl@0
   194
	* @since
sl@0
   195
	* @return error
sl@0
   196
	*/
sl@0
   197
	TInt MaxGain();
sl@0
   198
sl@0
   199
	/**
sl@0
   200
	* Returns an integer representing the current gain.
sl@0
   201
	* @since
sl@0
   202
	* @return TInt The current gain level.
sl@0
   203
	*/
sl@0
   204
	TInt Gain();
sl@0
   205
sl@0
   206
	/**
sl@0
   207
	* Changes the current recording gain to a specified value. The gain can
sl@0
   208
	* be changed before or during recording and is effective immediately.
sl@0
   209
	* @since
sl@0
   210
	* @param TInt aGain The gain setting. This can be any value from zero to
sl@0
   211
	*        the value returned by a call to
sl@0
   212
	*        CMMFDevSound::MaxGain(). If the volume
sl@0
   213
	*        is not within this range, the gain is automatically
sl@0
   214
	*        set to minimum or maximum value based on the value
sl@0
   215
	*        that is being passed. Setting a zero value mutes the
sl@0
   216
	*        sound. Setting the maximum value results in the
sl@0
   217
	*        loudest possible sound.
sl@0
   218
	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
sl@0
   219
	*        to AsynchronousOperationComplete()
sl@0
   220
	* @return void
sl@0
   221
	*/
sl@0
   222
	TInt SetGain(TInt aGain, TBool& aAyncCompletion);
sl@0
   223
sl@0
   224
	/**
sl@0
   225
	* Returns the speaker balance set for playing.
sl@0
   226
	* Leaves on failure.
sl@0
   227
	* @since
sl@0
   228
	* @param TInt &aLeftPercentage On return contains the left speaker
sl@0
   229
	*        volume percentage.
sl@0
   230
	* @param TInt &aRightPercentage On return contains the right speaker
sl@0
   231
	*        volume percentage.
sl@0
   232
	* @return void
sl@0
   233
	*/
sl@0
   234
	void GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
sl@0
   235
sl@0
   236
	/**
sl@0
   237
	* Sets the speaker balance for playing. The speaker balance can be
sl@0
   238
	* changed before or during playback and is effective immediately.
sl@0
   239
	* Leaves on failure.
sl@0
   240
	* @since
sl@0
   241
	* @param TInt aLeftPercentage The left speaker volume percentage. This
sl@0
   242
	*        can be any value from zero to 100. Setting
sl@0
   243
	*        a zero value mutes the sound on left
sl@0
   244
	*        speaker.
sl@0
   245
	* @param TInt aRightPercentage The right speaker volume percentage.
sl@0
   246
	*        This can be any value from zero to 100.
sl@0
   247
	*        Setting a zero value mutes the sound on
sl@0
   248
	*        right speaker.
sl@0
   249
	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
sl@0
   250
	*        to AsynchronousOperationComplete()
sl@0
   251
	* @return void
sl@0
   252
	*/
sl@0
   253
	void SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAsyncCompletion);
sl@0
   254
sl@0
   255
	/**
sl@0
   256
	* Returns the microphone gain balance set for recording.
sl@0
   257
	* Leaves on failure.
sl@0
   258
	* @since
sl@0
   259
	* @param TInt &aLeftPercentage On return contains the left microphone
sl@0
   260
	*        gain percentage.
sl@0
   261
	* @param TInt &aRightPercentage On return contains the right microphone
sl@0
   262
	*        gain percentage.
sl@0
   263
	* @return void
sl@0
   264
	*/
sl@0
   265
	void GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage);
sl@0
   266
sl@0
   267
	/**
sl@0
   268
	* Sets the microphone balance for recording. The microphone balance can
sl@0
   269
	* be changed before or during recording and is effective immediately.
sl@0
   270
	* Leaves on failure.
sl@0
   271
	* @since
sl@0
   272
	* @param TInt aLeftPercentage The left microphone gain percentage. This
sl@0
   273
	*        can be any value from zero to 100. Setting
sl@0
   274
	*        a zero value mutes the sound from left
sl@0
   275
	*        microphone.
sl@0
   276
	* @param TInt aRightPercentage The right microphone gain percentage.
sl@0
   277
	*        This can be any value from zero to 100.
sl@0
   278
	*        Setting a zero value mutes the sound from
sl@0
   279
	*        right microphone.
sl@0
   280
	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
sl@0
   281
	*        to AsynchronousOperationComplete()
sl@0
   282
	* @return void
sl@0
   283
	*/
sl@0
   284
	void SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage, TBool& aAsyncCompletion);
sl@0
   285
sl@0
   286
	/**
sl@0
   287
	* Initializes the audio device and starts the play process. This
sl@0
   288
	* function queries and acquires the audio policy before initializing
sl@0
   289
	* audio device. If there was an error during policy initialization,
sl@0
   290
	* PlayError() function will be called on the observer with error code
sl@0
   291
	* KErrAccessDenied, otherwise BufferToBeFilled() function will be called
sl@0
   292
	* with a buffer reference. After reading data into the buffer reference
sl@0
   293
	* passed, the client should call PlayData() to play data.
sl@0
   294
	* The amount of data that can be played is specified in
sl@0
   295
	* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond
sl@0
   296
	* this size will be ignored.
sl@0
   297
	* Leaves on failure.
sl@0
   298
	* @since
sl@0
   299
	* @return void
sl@0
   300
	*/
sl@0
   301
	void PlayInitL();
sl@0
   302
sl@0
   303
	/**
sl@0
   304
	* Initializes the audio device and starts the record process. This
sl@0
   305
	* function queries and acquires the audio policy before initializing
sl@0
   306
	* audio device. If there was an error during policy initialization,
sl@0
   307
	* RecordError() function will be called on the observer with error code
sl@0
   308
	* KErrAccessDenied, otherwise BufferToBeEmptied() function will be called
sl@0
   309
	* with a buffer reference. This buffer contains recorded or encoded
sl@0
   310
	* data. After processing data in the buffer reference passed, the client
sl@0
   311
	* should call RecordData() to continue recording process.
sl@0
   312
	* The amount of data that is available is specified in
sl@0
   313
	* CMMFBuffer::RequestSize().
sl@0
   314
	* Leaves on failure.
sl@0
   315
	* @since
sl@0
   316
	* @return void
sl@0
   317
	*/
sl@0
   318
	void RecordInitL();
sl@0
   319
sl@0
   320
	/**
sl@0
   321
	* Plays data in the buffer at the current volume.
sl@0
   322
	* The client should fill the buffer with audio data before calling this
sl@0
   323
	* function. The observer gets a reference to the buffer along with the
sl@0
   324
	* callback function BufferToBeFilled(). When playing of the audio sample
sl@0
   325
	* is complete, successfully or otherwise, the function PlayError() on
sl@0
   326
	* the observer is called.
sl@0
   327
	* The last buffer of the audio stream being played should have the last
sl@0
   328
	* buffer flag set using CMMFBuffer::SetLastBuffer(TBool). If a
sl@0
   329
	* subsequent attempt to play the clip is made, this flag will need
sl@0
   330
	* resetting by the client.
sl@0
   331
	* @return void
sl@0
   332
	*/
sl@0
   333
	void PlayData();
sl@0
   334
sl@0
   335
	/**
sl@0
   336
	* Contine the process of recording.
sl@0
   337
	* Once the buffer is filled with recorded data, the Observer gets a
sl@0
   338
	* reference to the buffer along with the callback function
sl@0
   339
	* BufferToBeEmptied(). After processing the buffer (copying over to a
sl@0
   340
	* different buffer or writing to file) the client should call this
sl@0
   341
	* function to continue the recording process.
sl@0
   342
	* @return void
sl@0
   343
	*/
sl@0
   344
	void RecordData();
sl@0
   345
sl@0
   346
	/**
sl@0
   347
	* Stops the ongoing operation (Play, Record, TonePlay).
sl@0
   348
	* @since
sl@0
   349
	* @return KErrNone if successful, system wide error otherwise
sl@0
   350
	*/
sl@0
   351
	TBool Stop();
sl@0
   352
sl@0
   353
	/**
sl@0
   354
	* Temporarily Stops the ongoing operation (Play, Record, TonePlay).
sl@0
   355
	* @since
sl@0
   356
	* @return KErrNone if successful, system wide error otherwise
sl@0
   357
	*/
sl@0
   358
	TInt Pause();
sl@0
   359
sl@0
   360
	/**
sl@0
   361
	* Returns the Sample recorded so far
sl@0
   362
	* @since
sl@0
   363
	* @return TInt Returns the samples recorded.
sl@0
   364
	*/
sl@0
   365
	TInt SamplesRecorded();
sl@0
   366
sl@0
   367
	/**
sl@0
   368
	* Returns the Sample played so far
sl@0
   369
	* @since
sl@0
   370
	* @return TInt Returns the samples played.
sl@0
   371
	*/
sl@0
   372
	TInt SamplesPlayed();
sl@0
   373
sl@0
   374
	/**
sl@0
   375
	* Initializes the audio device and starts playing a tone. The tone is
sl@0
   376
	* played with the frequency and duration specified.
sl@0
   377
	* Leaves on failure.
sl@0
   378
	* @since
sl@0
   379
	* @param TInt aFrequency The frequency at which the tone will be played.
sl@0
   380
	* @param const TTimeIntervalMicroSeconds &aDuration The period over
sl@0
   381
	*        which the tone will be played. A zero value causes the no tone
sl@0
   382
	*        to be played.
sl@0
   383
	* @return void
sl@0
   384
	*/
sl@0
   385
	void PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration);
sl@0
   386
sl@0
   387
	/**
sl@0
   388
	* Initializes audio device and starts playing a dual tone. Dual Tone is
sl@0
   389
	* played with the specified frequencies and for the specified duration.
sl@0
   390
	* Leaves on failure.
sl@0
   391
	* @since
sl@0
   392
	* @param TInt aFrequencyOne The first frequency of dual tone.
sl@0
   393
	* @param TInt aFrequencyTwo The second frequency of dual tone.
sl@0
   394
	* @param const TTimeIntervalMicroSeconds &aDuration The period over
sl@0
   395
	*        which the tone will be played. A zero value causes the no tone
sl@0
   396
	*        to be played.
sl@0
   397
	* @return void
sl@0
   398
	*/
sl@0
   399
	void PlayDualToneL(TInt aFrequencyOne,
sl@0
   400
					TInt aFrequencyTwo,
sl@0
   401
					const TTimeIntervalMicroSeconds& aDuration);
sl@0
   402
sl@0
   403
	/**
sl@0
   404
	* Initializes the audio device and starts playing the DTMF string
sl@0
   405
	* aDTMFString.
sl@0
   406
	* Leaves on failure.
sl@0
   407
	* @since
sl@0
   408
	* @param const TDesC &aDTMFString The DTMF sequence in a descriptor.
sl@0
   409
	* @return void
sl@0
   410
	*/
sl@0
   411
	void PlayDTMFStringL(const TDesC& aDTMFString);
sl@0
   412
sl@0
   413
	/**
sl@0
   414
	* Initializes the audio device and starts playing a tone sequence.
sl@0
   415
	* Leaves on failure.
sl@0
   416
	* @since
sl@0
   417
	* @param const TDesC8 &aData The tone sequence in a descriptor.
sl@0
   418
	* @return void
sl@0
   419
	*/
sl@0
   420
	void PlayToneSequenceL(const TDesC8& aData);
sl@0
   421
sl@0
   422
	/**
sl@0
   423
	* Initializes the audio device and starts playing the specified
sl@0
   424
	* pre-defined tone sequence.
sl@0
   425
	* Leaves on failure.
sl@0
   426
	* @since
sl@0
   427
	* @param TInt aSequenceNumber The index identifying the specific
sl@0
   428
	*        pre-defined tone sequence. Index values are relative to zero.
sl@0
   429
	*        This can be any value from zero to the value returned by a call
sl@0
   430
	*        to FixedSequenceCount() - 1. The function raises a panic if the
sl@0
   431
	*        sequence number is not within this range.
sl@0
   432
	* @return void
sl@0
   433
	*/
sl@0
   434
	void PlayFixedSequenceL(TInt aSequenceNumber);
sl@0
   435
sl@0
   436
	/**
sl@0
   437
	* Defines the number of times the audio is to be repeated during the
sl@0
   438
	* tone playback operation. A period of silence can follow each playing
sl@0
   439
	* of a tone. The tone playing can be repeated indefinitely
sl@0
   440
	* @since
sl@0
   441
	* @param TInt aRepeatCount The number of times the tone, together with
sl@0
   442
	*        the trailing silence, is to be repeated. If this is set to
sl@0
   443
	*        KMdaRepeatForever, then the tone, together with the trailing
sl@0
   444
	*        silence, is repeated indefinitely or until Stop() is called.
sl@0
   445
	*        If this is set to zero, then the tone is not repeated.
sl@0
   446
	* @param const TTimeIntervalMicroSeconds &aRepeatTrailingSilence An
sl@0
   447
	*        interval of silence which will be played after each tone.
sl@0
   448
	*        Supported only during tone playing.
sl@0
   449
	* @return KErrNone if successful, system wide error otherwise
sl@0
   450
	*/
sl@0
   451
	TInt SetToneRepeats(TInt aRepeatCount,
sl@0
   452
						const TTimeIntervalMicroSeconds& aRepeatTrailingSilence);
sl@0
   453
sl@0
   454
	/**
sl@0
   455
	* Defines the duration of tone on, tone off and tone pause to be used
sl@0
   456
	* during the DTMF tone playback operation.
sl@0
   457
	* Supported only during tone playing.
sl@0
   458
	* @since
sl@0
   459
	* @param TTimeIntervalMicroSeconds32 &aToneOnLength The period over
sl@0
   460
	*        which the tone will be played. If this is set to zero, then the
sl@0
   461
	*        tone is not played.
sl@0
   462
	* @param TTimeIntervalMicroSeconds32 &aToneOffLength The period over
sl@0
   463
	*        which the no tone will be played.
sl@0
   464
	* @param TTimeIntervalMicroSeconds32 &aPauseLength The period over which
sl@0
   465
	*        the tone playing will be paused.
sl@0
   466
	* @return KErrNone if successful, system wide error otherwise
sl@0
   467
	*/
sl@0
   468
	TInt SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
sl@0
   469
						TTimeIntervalMicroSeconds32& aToneOffLength,
sl@0
   470
						TTimeIntervalMicroSeconds32& aPauseLength);
sl@0
   471
sl@0
   472
	/**
sl@0
   473
	* Defines the period over which the volume level is to rise smoothly
sl@0
   474
	* from nothing to the normal volume level.
sl@0
   475
	* The function is only available before playing.
sl@0
   476
	* @since
sl@0
   477
	* @param const TTimeIntervalMicroSeconds &aRampDuration The period over
sl@0
   478
	*        which the volume is to rise. A zero value causes the tone
sl@0
   479
	*        sample to be played at the normal level for the full duration
sl@0
   480
	*        of the playback. A value, which is longer than the duration of
sl@0
   481
	*        the tone sample means that the sample never reaches its normal
sl@0
   482
	*        volume level.
sl@0
   483
	* @return KErrNone if successful, system wide error otherwise
sl@0
   484
	*/
sl@0
   485
	TInt SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
sl@0
   486
sl@0
   487
	/**
sl@0
   488
	* Defines the priority settings that should be used for this instance.
sl@0
   489
	* @since
sl@0
   490
	* @param const TMMFPrioritySettings &aPrioritySettings A class type
sl@0
   491
	*        representing the client's priority, priority preference and
sl@0
   492
	*        state
sl@0
   493
	* @return KErrNone if successful, system wide error otherwise
sl@0
   494
	*/
sl@0
   495
	TInt SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
sl@0
   496
sl@0
   497
	/**
sl@0
   498
	* Retrieves a custom interface to the device.
sl@0
   499
	* @since
sl@0
   500
	* @param TUid aInterfaceId The interface UID, defined with the custom
sl@0
   501
	*        interface.
sl@0
   502
	* @return TAny* A pointer to the interface implementation, or NULL if
sl@0
   503
	*        the device does not implement the interface requested. The
sl@0
   504
	*        return value must be cast to the correct type by the user.
sl@0
   505
	*/
sl@0
   506
	TAny* CustomInterface(TUid aInterfaceId);
sl@0
   507
sl@0
   508
	/**
sl@0
   509
	* Returns the number of available pre-defined tone sequences.
sl@0
   510
	* This is the number of fixed sequence supported by DevSound by default.
sl@0
   511
	* @since
sl@0
   512
	* @return TInt  The fixed sequence count. This value is implementation
sl@0
   513
	*        dependent.
sl@0
   514
	*/
sl@0
   515
	TInt FixedSequenceCount();
sl@0
   516
sl@0
   517
	/**
sl@0
   518
	* Returns the name assigned to a specific pre-defined tone sequence.
sl@0
   519
	* This is the number of the fixed sequence supported by DevSound by
sl@0
   520
	* default.
sl@0
   521
	* The function raises a panic if sequence number specified is invalid.
sl@0
   522
	* @since
sl@0
   523
	* @param TInt aSequenceNumber The index identifying the specific
sl@0
   524
	*        pre-defined tone sequence. Index values are relative to zero.
sl@0
   525
	*        This can be any value from zero to the value returned by a call
sl@0
   526
	*        to CMdaAudioPlayerUtility::FixedSequenceCount() - 1. The
sl@0
   527
	*        function raises a panic if sequence number is not within this
sl@0
   528
	*        range.
sl@0
   529
	* @return const TDesC & A reference to a Descriptor containing the fixed
sl@0
   530
	*        sequence name indexed by aSequenceNumber.
sl@0
   531
	*/
sl@0
   532
	const TDesC& FixedSequenceName(TInt aSequenceNumber);
sl@0
   533
sl@0
   534
	/**
sl@0
   535
	* Returns a list of the supported input datatypes that can be sent to
sl@0
   536
	* DevSound for playing audio. The datatypes returned are those that the
sl@0
   537
	* DevSound supports given the priority settings passed in
sl@0
   538
	* aPrioritySettings. Note that if no supported data types are found this
sl@0
   539
	* does not constitute failure, the function will return normally with no
sl@0
   540
	* entries in aSupportedDataTypes.
sl@0
   541
	* Leaves on failure.
sl@0
   542
	* @since
sl@0
   543
	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
sl@0
   544
	*        data types that will be filled in by this function. The
sl@0
   545
	*        supported data types of the DevSound are in the form of an
sl@0
   546
	*        array of TFourCC codes. Any existing entries in the array will
sl@0
   547
	*        be overwritten on calling this function. If no supported data
sl@0
   548
	*        types are found given the priority settings, then the
sl@0
   549
	*        aSupportedDatatypes array will have zero entries.
sl@0
   550
	* @param const TMMFPrioritySettings &aPrioritySettings The priority
sl@0
   551
	*        settings used to determine the supported datatypes. Note this
sl@0
   552
	*        does not set the priority settings. For input datatypes the
sl@0
   553
	*        iState member of the priority settings would be expected to be
sl@0
   554
	*        either EMMFStatePlaying or EMMFStatePlayingRecording. The
sl@0
   555
	*        priority settings may effect the supported datatypes depending
sl@0
   556
	*        on the audio routing.
sl@0
   557
	* @return void
sl@0
   558
	*/
sl@0
   559
	void GetSupportedInputDataTypesL(RArray<TFourCC>& aSupportedDataTypesconst,
sl@0
   560
								const TMMFPrioritySettings& aPrioritySettings) const;
sl@0
   561
sl@0
   562
	/**
sl@0
   563
	* Returns a list of the supported output dataypes that can be received
sl@0
   564
	* from DevSound for recording audio. The datatypes returned are those
sl@0
   565
	* that the DevSound supports given the priority settings passed in
sl@0
   566
	* aPrioritySettings. Note that if no supported data types are found this
sl@0
   567
	* does not constitute failure, the function will return normally with no
sl@0
   568
	* entries in aSupportedDataTypes.
sl@0
   569
	* Leaves on failure.
sl@0
   570
	* @since
sl@0
   571
	* @param RArray< TFourCC > &aSupportedDataTypes The array of supported
sl@0
   572
	*        data types that will be filled in by this function. The
sl@0
   573
	*        supported datatypes of the DevSound are in the form of an array
sl@0
   574
	*        of TFourCC codes. Any existing entries in the array will be
sl@0
   575
	*        overwritten on calling this function. If no supported datatypes
sl@0
   576
	*        are found given the priority settings, then the
sl@0
   577
	*        aSupportedDatatypes array will have zero entries.
sl@0
   578
	* @param const TMMFPrioritySettings &aPrioritySettings The priority
sl@0
   579
	*        settings used to determine the supported data types. Note this
sl@0
   580
	*        does not set the priority settings. For output data types the
sl@0
   581
	*        iState member of the priority settings would expected to be
sl@0
   582
	*        either EMMFStateRecording or EMMFStatePlayingRecording. The
sl@0
   583
	*        priority settings may effect the supported datatypes depending
sl@0
   584
	*        on the audio routing.
sl@0
   585
	* @return void
sl@0
   586
	*/
sl@0
   587
	void GetSupportedOutputDataTypesL(RArray<TFourCC>& aSupportedDataTypes,
sl@0
   588
								const TMMFPrioritySettings& aPrioritySettings) const;
sl@0
   589
sl@0
   590
	/**
sl@0
   591
	* Sets client configuration
sl@0
   592
	* @since
sl@0
   593
	* @param aActualProcessId the effective devsound client (supplied with SetClientThreadInfo)
sl@0
   594
	* @param aProcessId the client of DevSound
sl@0
   595
	* @return KErrNone if successful, system wide error otherwise
sl@0
   596
	*/
sl@0
   597
    TInt SetClientConfig(const TProcessId& aProcessId);
sl@0
   598
    TInt SetClientConfig(const TProcessId& aActualProcessId, const TProcessId& aProcessId);
sl@0
   599
sl@0
   600
	/**
sl@0
   601
	* Return to idle state, preparing for destruction.
sl@0
   602
	* @since
sl@0
   603
	* @return void
sl@0
   604
	*/
sl@0
   605
	TBool CloseDevSound();
sl@0
   606
sl@0
   607
	/**
sl@0
   608
	* Called when a ProcessingFinished callback is received
sl@0
   609
	* @param aAsyncCompletion Returns ETrue to say the call is asynchronous, with result sent
sl@0
   610
	*		to AsynchronousOperationComplete()
sl@0
   611
	* @return an error code KErrNone if successful
sl@0
   612
	*/
sl@0
   613
	TInt ProcessingFinishedReceived(TBool& aAyncCompletion);
sl@0
   614
sl@0
   615
	TInt ProcessingError(TBool& aAyncCompletion);
sl@0
   616
	/**
sl@0
   617
	* Empties the buffers below DevSound without deleting the codec
sl@0
   618
	* @since
sl@0
   619
	* @return KErrNone if successful, otherwise system-wide error code.
sl@0
   620
	*/
sl@0
   621
	TInt EmptyBuffers();
sl@0
   622
	
sl@0
   623
	//provides interface for register a notification event
sl@0
   624
	TInt RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData = KNullDesC8);
sl@0
   625
	//provides interface to cancel the registered notification
sl@0
   626
	TInt CancelRegisterAsClient(TUid aEventType);
sl@0
   627
	//Gets the notification data for client to resume
sl@0
   628
	TInt GetResourceNotificationData(TUid aEventType, TDes8& aNotificationData);
sl@0
   629
	//waits for the client to resume playback even after the timeout expires
sl@0
   630
	TInt WillResumePlay();
sl@0
   631
	
sl@0
   632
	/**
sl@0
   633
	* Gets the current play time from the audio renderer
sl@0
   634
	* @since 
sl@0
   635
	* @param TTimeIntervalMicroSeconds& aTime On return contains the current play time
sl@0
   636
	* @return an error code KErrNone if successful
sl@0
   637
	*/
sl@0
   638
	TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTime);
sl@0
   639
sl@0
   640
	/**
sl@0
   641
	* Queries if the low layers does support resume operation.
sl@0
   642
	* @since
sl@0
   643
	* @return TBool ETrue if Resume is supported
sl@0
   644
	*               EFalse otherwise
sl@0
   645
	*/
sl@0
   646
	TBool IsResumeSupported();
sl@0
   647
	
sl@0
   648
	/**
sl@0
   649
	* Resume the operation (Play, Record, TonePlay) temporarily paused .
sl@0
   650
	* @since
sl@0
   651
	* @return TInt KErrNone if succesful
sl@0
   652
	*              KErrNotSupported if the operation is not supported by this implementation
sl@0
   653
	*/
sl@0
   654
	TInt Resume();
sl@0
   655
	
sl@0
   656
	/*
sl@0
   657
	Used to send a stop call when there is a error in the buffer
sl@0
   658
	*/
sl@0
   659
	void BufferErrorEvent();
sl@0
   660
sl@0
   661
	/**
sl@0
   662
	* Used rollback the adapror active state to the previous state prior a Commit call
sl@0
   663
	* @return void
sl@0
   664
	*/
sl@0
   665
	void RollbackAdaptorActiveStateToBeforeCommit();
sl@0
   666
sl@0
   667
private:
sl@0
   668
sl@0
   669
	CBody(MDevSoundAdaptationObserver& aDevSoundObserver,
sl@0
   670
		MGlobalProperties& aGlobalProperties);
sl@0
   671
sl@0
   672
	void ConstructL(MGlobalProperties& aGlobalProperties);
sl@0
   673
sl@0
   674
private: // data
sl@0
   675
sl@0
   676
	/**
sl@0
   677
	* pointer to devsound framework for callbacks
sl@0
   678
	* Not own.
sl@0
   679
	*/
sl@0
   680
    MDevSoundAdaptationObserver& iDevSoundObserver;
sl@0
   681
sl@0
   682
	/**
sl@0
   683
	* holds mode for which current instance is initialized for
sl@0
   684
	*/
sl@0
   685
	TMMFState iMode;
sl@0
   686
sl@0
   687
	/**
sl@0
   688
	* holds format for which current instance is initialized for
sl@0
   689
	*/
sl@0
   690
	TUid iFormat;
sl@0
   691
sl@0
   692
	/**
sl@0
   693
	* holds information of supported configurations
sl@0
   694
	* (channels, sampling rates, buffersize...)
sl@0
   695
	*/
sl@0
   696
	TMMFCapabilities iMmfCapabilities;
sl@0
   697
sl@0
   698
	/**
sl@0
   699
	* holds information of current device configuration
sl@0
   700
	* (channels, sampling rates, buffersize...)
sl@0
   701
	*/
sl@0
   702
	TMMFCapabilities iMmfConfig;
sl@0
   703
sl@0
   704
	/**
sl@0
   705
	* holds client audio type information
sl@0
   706
	*/
sl@0
   707
	TMMFPrioritySettings iPrioritySettings;
sl@0
   708
sl@0
   709
	/**
sl@0
   710
	* pointer to devaudio
sl@0
   711
	* Own.
sl@0
   712
	*/
sl@0
   713
	CDevAudio  *iDevAudio;
sl@0
   714
sl@0
   715
	TToneData iToneData;
sl@0
   716
sl@0
   717
	// Pointer to global properties
sl@0
   718
	// Not owned.
sl@0
   719
	MGlobalProperties*	iGlobalProperties;
sl@0
   720
	};
sl@0
   721
sl@0
   722
#endif		// MMFDEVSOUNDADAPTATIONBODY_H
sl@0
   723
sl@0
   724
// End of File