os/kernelhwsrv/kernel/eka/include/d32soundsc.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\include\d32soundsc.h
sl@0
    15
// User side class definition for the shared chunk sound driver.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
 @publishedPartner
sl@0
    22
 @prototype
sl@0
    23
*/
sl@0
    24
sl@0
    25
#ifndef __D32SOUNDSC_H__
sl@0
    26
#define __D32SOUNDSC_H__
sl@0
    27
sl@0
    28
#include <e32cmn.h>
sl@0
    29
#include <e32ver.h>
sl@0
    30
#ifndef __KERNEL_MODE__
sl@0
    31
#include <e32std.h>
sl@0
    32
#endif
sl@0
    33
sl@0
    34
_LIT(KDevSoundScName,"SoundSc");
sl@0
    35
sl@0
    36
const TInt KSoundScTxUnit0=0;
sl@0
    37
const TInt KSoundScTxUnit1=1;
sl@0
    38
/**
sl@0
    39
@capability UserEnvironment
sl@0
    40
@ref RSoundSc::Open An RSoundSc may not be opened for record without UserEnvironment
sl@0
    41
*/
sl@0
    42
const TInt KSoundScRxUnit0=4;
sl@0
    43
/**
sl@0
    44
@capability UserEnvironment
sl@0
    45
@ref RSoundSc::Open An RSoundSc may not be opened for record without UserEnvironment
sl@0
    46
*/
sl@0
    47
const TInt KSoundScRxUnit1=5;
sl@0
    48
sl@0
    49
// Note that the implementation in the sound driver LDD to calculate a default audio configuration assumes a 
sl@0
    50
// monotonic ordering of all caps bitfields. If it is necessary to break this ordering then this implementation
sl@0
    51
// will need to be reviewed and possibly changed.
sl@0
    52
sl@0
    53
/**
sl@0
    54
Sound driver capability constants - bitmasks of the audio channel configurations supported
sl@0
    55
by a unit. @see TSoundFormatsSupportedV02.
sl@0
    56
*/
sl@0
    57
/** The unit supports Mono (i.e. a single audio channel). */
sl@0
    58
const TUint KSoundMonoChannel = 0x0001;
sl@0
    59
/** The unit supports Stereo (i.e. two audio channels). */
sl@0
    60
const TUint KSoundStereoChannel = 0x0002;
sl@0
    61
/** The unit supports three audio channels. */
sl@0
    62
const TUint KSoundThreeChannel = 0x0004;
sl@0
    63
/** The unit supports four audio channels. */
sl@0
    64
const TUint KSoundFourChannel = 0x0008;
sl@0
    65
/** The unit supports five audio channels. */
sl@0
    66
const TUint KSoundFiveChannel = 0x0010;
sl@0
    67
/** The unit supports six audio channels. */
sl@0
    68
const TUint KSoundSixChannel = 0x0020;
sl@0
    69
sl@0
    70
/**
sl@0
    71
Sound driver capability constants - bitmasks of supported sample rates. @see TSoundFormatsSupportedV02.
sl@0
    72
*/
sl@0
    73
/** The device supports the 7.35KHz sample rate. */
sl@0
    74
const TUint KSoundRate7350Hz = 0x0001;
sl@0
    75
/** The device supports the 8KHz sample rate. */
sl@0
    76
const TUint KSoundRate8000Hz = 0x0002;
sl@0
    77
/** The device supports the 8.82KHz sample rate. */
sl@0
    78
const TUint KSoundRate8820Hz = 0x0004;
sl@0
    79
/** The device supports the 9.6KHz sample rate. */
sl@0
    80
const TUint KSoundRate9600Hz = 0x0008;
sl@0
    81
/** The device supports the 11.025KHz sample rate. */
sl@0
    82
const TUint KSoundRate11025Hz = 0x0010;
sl@0
    83
/** The device supports the 12KHz sample rate. */
sl@0
    84
const TUint KSoundRate12000Hz = 0x0020;
sl@0
    85
/** The device supports the 14.7KHz sample rate. */
sl@0
    86
const TUint KSoundRate14700Hz = 0x0040;
sl@0
    87
/** The device supports the 16KHz sample rate. */
sl@0
    88
const TUint KSoundRate16000Hz = 0x0080;
sl@0
    89
/** The device supports the 22.05KHz sample rate. */
sl@0
    90
const TUint KSoundRate22050Hz = 0x0100;
sl@0
    91
/** The device supports the 24KHz sample rate. */
sl@0
    92
const TUint KSoundRate24000Hz = 0x0200;
sl@0
    93
/** The device supports the 29.4KHz sample rate. */
sl@0
    94
const TUint KSoundRate29400Hz = 0x0400;
sl@0
    95
/** The device supports the 32KHz sample rate. */
sl@0
    96
const TUint KSoundRate32000Hz = 0x0800;
sl@0
    97
/** The device supports the 44.1KHz sample rate. */
sl@0
    98
const TUint KSoundRate44100Hz = 0x1000;
sl@0
    99
/** The device supports the 48KHz sample rate. */
sl@0
   100
const TUint KSoundRate48000Hz = 0x2000;
sl@0
   101
sl@0
   102
/**
sl@0
   103
Sound driver capability constants - bitmasks of supported encoding formats. @see TSoundFormatsSupportedV02.
sl@0
   104
*/
sl@0
   105
/** The device supports 8bit PCM encoding format. */
sl@0
   106
const TUint KSoundEncoding8BitPCM = 0x0001;
sl@0
   107
/** The device supports 16bit PCM encoding format. */
sl@0
   108
const TUint KSoundEncoding16BitPCM = 0x0002;
sl@0
   109
/** The device supports 24bit PCM encoding format. */
sl@0
   110
const TUint KSoundEncoding24BitPCM = 0x0004;
sl@0
   111
sl@0
   112
/**
sl@0
   113
Sound driver capability constants - bitmasks of the data formats supported
sl@0
   114
by the device. @see TSoundFormatsSupportedV02.
sl@0
   115
*/
sl@0
   116
/** The device supports an interleaved data format (i.e. data for each channel is interleaved throughout
sl@0
   117
each data buffer). */
sl@0
   118
const TUint KSoundDataFormatInterleaved = 0x0001;
sl@0
   119
/** The device supports a non-interleaved data format (i.e. data for each channel is arranged in
sl@0
   120
contiguous regions within each data buffer). */
sl@0
   121
const TUint KSoundDataFormatNonInterleaved = 0x0002;
sl@0
   122
sl@0
   123
/** The maximum setting possible for the record level / volume. */
sl@0
   124
const TInt KSoundMaxVolume = 255;
sl@0
   125
sl@0
   126
/**
sl@0
   127
Enumeration of possible data transfer directions. @see TSoundFormatsSupportedV02.
sl@0
   128
*/
sl@0
   129
enum TSoundDirection
sl@0
   130
	{
sl@0
   131
	/**	A unit for recording data. */
sl@0
   132
	ESoundDirRecord,
sl@0
   133
	/** A unit for playing data. */
sl@0
   134
	ESoundDirPlayback
sl@0
   135
	};
sl@0
   136
sl@0
   137
/**
sl@0
   138
Enumeration of possible sample rates. @see TCurrentSoundFormatV02.
sl@0
   139
*/	
sl@0
   140
enum TSoundRate
sl@0
   141
	{
sl@0
   142
	/** 7.35KHz sample rate. */
sl@0
   143
	ESoundRate7350Hz,
sl@0
   144
	/** 8KHz sample rate. */
sl@0
   145
	ESoundRate8000Hz,
sl@0
   146
	/** 8.82KHz sample rate. */
sl@0
   147
	ESoundRate8820Hz,
sl@0
   148
	/** 9.6KHz sample rate. */
sl@0
   149
	ESoundRate9600Hz,
sl@0
   150
	/** 11.025KHz sample rate. */
sl@0
   151
	ESoundRate11025Hz,
sl@0
   152
	/** 12KHz sample rate. */
sl@0
   153
	ESoundRate12000Hz,
sl@0
   154
	/** 14.7KHz sample rate. */
sl@0
   155
	ESoundRate14700Hz,
sl@0
   156
	/** 16KHz sample rate. */
sl@0
   157
	ESoundRate16000Hz,
sl@0
   158
	/** 22.05KHz sample rate. */
sl@0
   159
	ESoundRate22050Hz,
sl@0
   160
	/** 24KHz sample rate. */
sl@0
   161
	ESoundRate24000Hz,
sl@0
   162
	/** 29.4KHz sample rate. */
sl@0
   163
	ESoundRate29400Hz,
sl@0
   164
	/** 32KHz sample rate. */
sl@0
   165
	ESoundRate32000Hz,
sl@0
   166
	/** 44.1KHz sample rate. */
sl@0
   167
	ESoundRate44100Hz,
sl@0
   168
	/** 48KHz sample rate. */
sl@0
   169
	ESoundRate48000Hz
sl@0
   170
	};
sl@0
   171
sl@0
   172
/**
sl@0
   173
Enumeration of possible sound encoding formats. @see TCurrentSoundFormatV02.
sl@0
   174
*/
sl@0
   175
enum TSoundEncoding
sl@0
   176
	{
sl@0
   177
	/** 8bit PCM encoding format. */
sl@0
   178
	ESoundEncoding8BitPCM,
sl@0
   179
	/** 16bit PCM encoding format. */
sl@0
   180
	ESoundEncoding16BitPCM,
sl@0
   181
	/** 24bit PCM encoding format. */
sl@0
   182
	ESoundEncoding24BitPCM
sl@0
   183
	};
sl@0
   184
	
sl@0
   185
/**
sl@0
   186
Enumeration of possible sound data formats. @see TCurrentSoundFormatV02.
sl@0
   187
*/
sl@0
   188
enum TSoundDataFormat
sl@0
   189
	{
sl@0
   190
	/** The device supports an interleaved data format. */ 
sl@0
   191
	ESoundDataFormatInterleaved,
sl@0
   192
	/** The device supports a non-interleaved data format. */
sl@0
   193
	ESoundDataFormatNonInterleaved
sl@0
   194
	};	
sl@0
   195
	
sl@0
   196
/**
sl@0
   197
The general driver capabilites class - returned by the LDD factory in response to RDevice::GetCaps().
sl@0
   198
*/
sl@0
   199
class TCapsSoundScV01
sl@0
   200
	{
sl@0
   201
public:
sl@0
   202
	TVersion iVersion;
sl@0
   203
	};
sl@0
   204
sl@0
   205
/**
sl@0
   206
The main audio capabilities class. This is used by the LDD to get either the play or record capabilities
sl@0
   207
of a particular sound device once a channel to it has been opened.
sl@0
   208
*/
sl@0
   209
class TSoundFormatsSupportedV02
sl@0
   210
	{
sl@0
   211
public:
sl@0
   212
	/** The data transfer direction for this unit: play or record. @see TSoundDirection. */
sl@0
   213
	TSoundDirection iDirection;
sl@0
   214
	/** The audio channel configurations supported by this unit - a bitfield. */
sl@0
   215
	TUint32 iChannels;
sl@0
   216
	/** The sample rates supported - a bitfield. */
sl@0
   217
	TUint32 iRates;
sl@0
   218
	/** The encoding formats supported - a bitfield. */
sl@0
   219
	TUint32 iEncodings;
sl@0
   220
	/** The data formats supported - a bitfield. */
sl@0
   221
	TUint32 iDataFormats;
sl@0
   222
	/** The minimum request size that the device can support. All requests to play or record data must be of a
sl@0
   223
	length that is a multiple of this value. */
sl@0
   224
	TInt iRequestMinSize;
sl@0
   225
	/** The logarithm to base 2 of the alignment required for request arguments. All requests to play or
sl@0
   226
	record data must specify locations in the shared chunk which conform to this alignment.
sl@0
   227
	For example, iRequestAlignment of 1 is 2 byte aligned (2^1), 2 is 4 byte aligned (2^2) etc. */
sl@0
   228
	TInt iRequestAlignment;
sl@0
   229
	/** Indicates whether this unit is capable of detecting changes in its hardware configuration. */
sl@0
   230
	TBool iHwConfigNotificationSupport;
sl@0
   231
	/** Reserved field. */
sl@0
   232
	TInt iReserved1;
sl@0
   233
	};
sl@0
   234
typedef TPckgBuf<TSoundFormatsSupportedV02> TSoundFormatsSupportedV02Buf;
sl@0
   235
sl@0
   236
/**
sl@0
   237
The sound format configuration class. This is used to get and set the current configuration
sl@0
   238
of the sound device (both for playing and recording).
sl@0
   239
*/
sl@0
   240
class TCurrentSoundFormatV02
sl@0
   241
	{
sl@0
   242
public:
sl@0
   243
	/** The audio channel configuration: 1=Mono, 2=Stereo etc. */ 
sl@0
   244
	TInt iChannels;
sl@0
   245
	/** The sample rate. @see TSoundRate. */
sl@0
   246
	TSoundRate iRate;
sl@0
   247
	/** The encoding format. @see TSoundEncoding. */
sl@0
   248
	TSoundEncoding iEncoding;
sl@0
   249
	/** The data format: interleaved, non-interleaved etc. @see TSoundDataFormat. */
sl@0
   250
	TSoundDataFormat iDataFormat;
sl@0
   251
	/** Reserved field. */
sl@0
   252
	TInt iReserved1;
sl@0
   253
	};
sl@0
   254
typedef TPckgBuf<TCurrentSoundFormatV02> TCurrentSoundFormatV02Buf;
sl@0
   255
sl@0
   256
/**
sl@0
   257
A flag that can be passed via the 'aFlags' argument of the function RSoundSc::PlayData(). This being
sl@0
   258
set signifies that this particular play request is the last one of a series (ie EOF) and therefore an underflow is
sl@0
   259
expected after this request completes.
sl@0
   260
*/
sl@0
   261
const TUint KSndFlagLastSample=0x00000001;
sl@0
   262
sl@0
   263
/** Reserved settings used with CustomConfig(). */
sl@0
   264
const TInt KSndCustomConfigMaxReserved=0x0FFFFFFF;
sl@0
   265
#ifdef _DEBUG
sl@0
   266
const TInt KSndCustom_ForceHwConfigNotifSupported=0x00;
sl@0
   267
const TInt KSndCustom_CompleteChangeOfHwConfig=0x01;
sl@0
   268
const TInt KSndCustom_ForceStartTransferError=0x02;
sl@0
   269
const TInt KSndCustom_ForceTransferDataError=0x03;
sl@0
   270
const TInt KSndCustom_ForceTransferTimeout=0x04;
sl@0
   271
#endif
sl@0
   272
sl@0
   273
/** A structure used to assemble arguments for the function RSoundSc::PlayData() and to pass these to the driver. */
sl@0
   274
struct SRequestPlayDataInfo
sl@0
   275
	{
sl@0
   276
	TInt iBufferOffset;
sl@0
   277
	TInt iLength;
sl@0
   278
	TUint iFlags;
sl@0
   279
	};	
sl@0
   280
sl@0
   281
#ifndef __KERNEL_MODE__
sl@0
   282
typedef TPckgBuf<TTimeIntervalMicroSeconds> TTimeIntervalMicroSecondsBuf;
sl@0
   283
#endif
sl@0
   284
sl@0
   285
class RSoundSc : public RBusLogicalChannel
sl@0
   286
	{
sl@0
   287
private:	
sl@0
   288
	enum TRequest
sl@0
   289
	/**
sl@0
   290
	 Asynchronous request types
sl@0
   291
	 */
sl@0
   292
		{
sl@0
   293
		EMsgRequestPlayData,
sl@0
   294
		ERequestNotifyChangeOfHwConfig,
sl@0
   295
		EMsgRequestMax=3,				// All requests less than this value are handled in the driver DFC thread.
sl@0
   296
		ERequestRecordData,
sl@0
   297
		ENumRequests,
sl@0
   298
		EAllRequests = (1<<ENumRequests)-1
sl@0
   299
		};
sl@0
   300
		
sl@0
   301
	enum TControl
sl@0
   302
	/**
sl@0
   303
	 Synchronous request types
sl@0
   304
	*/
sl@0
   305
		{
sl@0
   306
		EMsgControlSetAudioFormat,
sl@0
   307
		EMsgControlSetBufChunkCreate,
sl@0
   308
		EMsgControlSetBufChunkOpen,
sl@0
   309
		EMsgControlSetVolume,
sl@0
   310
		EMsgControlPause,
sl@0
   311
		EMsgControlResume,
sl@0
   312
		EMsgControlCancelSpecific,
sl@0
   313
		EMsgControlCustomConfig,
sl@0
   314
		EControlTimePlayed,
sl@0
   315
		EControlTimeRecorded,
sl@0
   316
		EMsgControlMax=10,				// All requests less than this value are handled in the driver DFC thread.
sl@0
   317
		EControlGetCaps,
sl@0
   318
		EControlGetAudioFormat,
sl@0
   319
		EControlGetBufConfig,
sl@0
   320
		EControlGetVolume,
sl@0
   321
		EControlBytesTransferred,
sl@0
   322
		EControlResetBytesTransferred,
sl@0
   323
		EControlReleaseBuffer
sl@0
   324
		};
sl@0
   325
	friend class DSoundScLdd;	
sl@0
   326
public:
sl@0
   327
	/**
sl@0
   328
	Get the version number of sound driver interface.
sl@0
   329
    @return The sound driver interface version number.
sl@0
   330
	*/
sl@0
   331
	inline static TVersion VersionRequired();
sl@0
   332
sl@0
   333
#ifndef __KERNEL_MODE__
sl@0
   334
	/**
sl@0
   335
	Open a channel on a specified sound device. This driver allows more than one channel to be opened on each device.
sl@0
   336
	@capability MultimediaDD
sl@0
   337
	@capability Dependent UserEnvironment Is required when opening a record channel.
sl@0
   338
	@param aUnit The unit number of the sound device.
sl@0
   339
	@return KErrNone, if successful; KErrPermissionDenied, if process lacks required capabilities
sl@0
   340
        	otherwise one of the other system-wide error codes. 
sl@0
   341
	*/
sl@0
   342
	inline TInt Open(TInt aUnit=KNullUnit);
sl@0
   343
	
sl@0
   344
	/**
sl@0
   345
	Get the capabilities of the sound device.
sl@0
   346
	@param aCapsBuf A packaged object which will be filled with the capabilities of the device.
sl@0
   347
	@see TSoundFormatsSupportedV02.
sl@0
   348
	*/
sl@0
   349
	inline void Caps(TDes8& aCapsBuf);
sl@0
   350
	
sl@0
   351
	/**
sl@0
   352
  	Get the current audio format configuration.
sl@0
   353
  	@param aFormatBuf A packaged object which will be filled with the audio configuration settings.
sl@0
   354
    @see TCurrentSoundFormatV02.
sl@0
   355
	*/
sl@0
   356
	inline void AudioFormat(TDes8& aFormatBuf);
sl@0
   357
	
sl@0
   358
	/**
sl@0
   359
  	Set the current audio format configuration.
sl@0
   360
  	This can't be changed while the driver is currently playing or recording data.
sl@0
   361
	@param aFormatBuf A packaged object holding the new audio configuration settings to be used.
sl@0
   362
  	@return KErrNone if successful;
sl@0
   363
  			KErrInUse if the playing or recording of data is in progress;
sl@0
   364
          	KErrNotSupported if any configuration values are invalid;
sl@0
   365
		  	otherwise one of the other system-wide error codes.
sl@0
   366
	@see TCurrentSoundFormatV02.
sl@0
   367
	*/
sl@0
   368
	inline TInt SetAudioFormat(const TDesC8& aFormatBuf);
sl@0
   369
	
sl@0
   370
 	/**
sl@0
   371
  	Get the current buffer configuration.
sl@0
   372
	@param aConfigBuf A packaged TSharedChunkBufConfigBase derived object which will be filled with the buffer
sl@0
   373
					  configuration settings.
sl@0
   374
	@see TSharedChunkBufConfigBase.
sl@0
   375
	*/
sl@0
   376
 	inline void GetBufferConfig(TDes8& aConfigBuf);
sl@0
   377
 	
sl@0
   378
 	/**
sl@0
   379
  	Set the current buffer configuration - creating a shared chunk.
sl@0
   380
  	The driver will create a shared chunk according to the buffer specification supplied (and will commit
sl@0
   381
  	memory to it). This will replace any previous shared chunk created by this driver. A handle to
sl@0
   382
  	the chunk will then be created for the client thread which will be assigned to the RChunk object supplied
sl@0
   383
  	by the client.
sl@0
   384
  	The buffer configuration cannot be changed while the driver is currently playing or recording data.
sl@0
   385
  	Note that a minimum of three buffers are required when recording: one being loaded with record data by the driver,
sl@0
   386
  	another also owned by the driver - queued ready for the next transfer and a third owned by the client for processing.
sl@0
   387
  	Note that for record channels, the buffer size specified effectively determines the size of each record request.
sl@0
   388
  	Hence, for record channels the buffer size must be a multiple of the minimum request size as specified in the capabilities 
sl@0
   389
  	class. @see TSoundFormatsSupportedV02. It should also be a multiple of the number of bytes per audio sample (e.g. a multiple 
sl@0
   390
  	of 4 for 2 channels of 16bit PCM).  
sl@0
   391
	@param aConfigBuf A packaged TSharedChunkBufConfigBase derived object which must be set with the new buffer configuration
sl@0
   392
					  settings to be used. Note that this function will ignore any buffer offset information specified by the 
sl@0
   393
					  caller (i.e. setting the flag KScFlagBufOffsetListInUse has no effect).
sl@0
   394
	@param aChunk An RChunk object to which the chunk handle will be assigned. 
sl@0
   395
  	@return KErrNone if successful;
sl@0
   396
  			KErrInUse if the playing or recording of data is in progress;
sl@0
   397
          	KErrArgument if any configuration values are invalid;
sl@0
   398
          	KErrNoMemory if the driver failed to allocate memory for the shared chunk specified;
sl@0
   399
		  	otherwise one of the other system-wide error codes.
sl@0
   400
	@see TSharedChunkBufConfigBase.
sl@0
   401
	*/
sl@0
   402
 	inline TInt SetBufferChunkCreate(const TDesC8& aConfigBuf,RChunk& aChunk);
sl@0
   403
 	
sl@0
   404
 	/**
sl@0
   405
  	Set the current buffer configuration - using an existing shared chunk.
sl@0
   406
  	The client supplies an existing shared chunk which is to be used by the driver as the play or record buffer. 
sl@0
   407
  	Any shared chunk previously created by the driver will be closed by it.
sl@0
   408
  	The buffer configuration cannot be changed while the driver is currently playing or recording data.
sl@0
   409
  	See RSoundSc::SetBufferChunkCreate for details on the buffer configuration setting necessary for playback or record.
sl@0
   410
	@param aConfigBuf A packaged TSharedChunkBufConfigBase derived object which must be set with the buffer configuration
sl@0
   411
					  settings of the chunk supplied. This must include buffer offset information (i.e. the flag 
sl@0
   412
					  KScFlagBufOffsetListInUse must be set).
sl@0
   413
	@param aChunk A handle to the shared chunk which is to be used as the play or record buffer. (This must
sl@0
   414
				  be a valid handle for the calling thread).
sl@0
   415
  	@return KErrNone if successful;
sl@0
   416
  			KErrInUse if the playing or recording of data is in progress;
sl@0
   417
          	KErrArgument if any configuration values are invalid;
sl@0
   418
		  	otherwise one of the other system-wide error codes.
sl@0
   419
	@see TSharedChunkBufConfigBase.
sl@0
   420
	*/
sl@0
   421
 	inline TInt SetBufferChunkOpen(const TDesC8& aConfigBuf,RChunk& aChunk);
sl@0
   422
 	
sl@0
   423
 	/**
sl@0
   424
  	Get the current play volume or record level.
sl@0
   425
	@return The current play volume / record level - a value in the range 0 to 255. The value 255 equates to
sl@0
   426
	the maximum volume and each value below this equates to a 0.5dB step below it.
sl@0
   427
	*/
sl@0
   428
	inline TInt Volume();
sl@0
   429
	
sl@0
   430
	/**
sl@0
   431
	Set the current play volume or record level. The volume can be altered while the driver is in the process
sl@0
   432
	of playing or recording data.
sl@0
   433
	@param aVolume The play volume / record level to be set - a value in the range 0 to 255. The value 255
sl@0
   434
		equates to the maximum volume and each value below this equates to a 0.5dB step below it.
sl@0
   435
    @return KErrNone if successful;
sl@0
   436
          	KErrArgument if the specified volume is out of range;
sl@0
   437
		  	otherwise one of the other system-wide error codes.
sl@0
   438
	*/
sl@0
   439
	inline TInt SetVolume(TInt aVolume);
sl@0
   440
	
sl@0
   441
	/**
sl@0
   442
	Submit a request to play (write data) to the sound device from a buffer.
sl@0
   443
  	The buffer must be contained within the driver's shared chunk. A single play request may not span more than one
sl@0
   444
  	buffer even if two or more buffers are contiguous within the shared chunk.
sl@0
   445
  	The driver will allow more than one play request to be pending at any time. It will
sl@0
   446
  	process requests in FIFO order. This is an asynchronous operation with the driver completing the request and
sl@0
   447
  	returning the request status once all the specified data has been delivered to the sound device. The driver
sl@0
   448
  	will return a request status of KErrUnderflow each time it completes the last pending play request unless this
sl@0
   449
  	request was marked with the KSndFlagLastSample flag. If this flag is set, the driver will return
sl@0
   450
  	KErrNone in this situation. Therefore when it is required to play uninterrupted audio by issuing a series of play
sl@0
   451
  	requests, the client should mark the last play request using this flag.
sl@0
   452
	@param aStatus 		 The request status which is signalled when all of the specified data has been transferred to
sl@0
   453
						 the sound device (or when an error occurs). Possible values:
sl@0
   454
								KErrNone:	   if all the specified data was successfully transferred and no underflow
sl@0
   455
											   occured following this transfer (or if an underflow occurred but the
sl@0
   456
											   request was marked with the KSndFlagLastSample flag);
sl@0
   457
								KErrUnderflow: if data underflow occurred during or immediately following the transfer;
sl@0
   458
								otherwise one of the system-wide error codes.
sl@0
   459
	@param aBufferOffset Offset from the beginning of the shared chunk for the start of data to be played. This must be
sl@0
   460
						 aligned to a value conforming to the iRequestAlignment member of the capabilities structure.
sl@0
   461
						 @see TSoundFormatsSupportedV02.
sl@0
   462
  	@param aLength 		 Number of bytes of data to be played. This must be a multiple of the minimum request size as
sl@0
   463
  						 specified in the capabilities class. @see TSoundFormatsSupportedV02. It should also be a multiple
sl@0
   464
  						 of the number of bytes per audio sample (e.g. a multiple of 4 for 2 channels of 16bit PCM).
sl@0
   465
  	@param aFlags 		 Play request flags. Use KSndFlagLastSample to mark the last play request in a series of play
sl@0
   466
  						 requests.
sl@0
   467
	@pre The buffer must have been previously initialised by a call to SetBufferChunkN().
sl@0
   468
	*/
sl@0
   469
	inline void PlayData(TRequestStatus& aStatus,TInt aBufferOffset,TInt aLength,TUint aFlags=0);
sl@0
   470
	
sl@0
   471
	/**
sl@0
   472
	Get the next available record buffer. More than one request may be pending at any time. This is an asynchronous
sl@0
   473
	operation. If the driver is not already recording then the issuing of this request will start the capturing of
sl@0
   474
	record data from the sound device into a record buffer.
sl@0
   475
	@param aStatus	The request status which is signalled when buffer is available (or an error occurs). If
sl@0
   476
					the request is successful then this result value is set to the offset within the shared chunk
sl@0
   477
					where the buffer resides. Alternatively, if an error occurs, it will be set to one of
sl@0
   478
					the system wide error values. These include:
sl@0
   479
					KErrInUse: if the client needs to free up record buffers;
sl@0
   480
					KErrOverflow: if it was necessary for the driver to over-write unread record data since the
sl@0
   481
								  last record request;
sl@0
   482
					KErrCancel: if the device is paused and there is no un-read record data available.			  
sl@0
   483
					otherwise one of the system-wide error codes.
sl@0
   484
  	@param aLength	On return, this contains the number of record bytes successfully stored in the buffer. 
sl@0
   485
	@pre The record buffer must have been previously initialised by a call to SetBufferChunkN().
sl@0
   486
	*/
sl@0
   487
	inline void RecordData(TRequestStatus& aStatus, TInt& aLength);
sl@0
   488
	
sl@0
   489
	/**
sl@0
   490
	Release a record buffer - making it available again for the driver to record into.
sl@0
   491
	@param aChunkOffset: The chunk offset of the image to be released. This is the value that was returned by the
sl@0
   492
						 RecordData() request when the buffer was claimed by the client.
sl@0
   493
	@return KErrNone: if successful;
sl@0
   494
			KErrNotFound: if the chunk offset is invalid;
sl@0
   495
			otherwise one of the system-wide error codes.
sl@0
   496
	*/
sl@0
   497
	inline TInt ReleaseBuffer(TInt aChunkOffset);
sl@0
   498
	
sl@0
   499
	/**
sl@0
   500
	Cancel all outstanding play requests.
sl@0
   501
	This immediately stops the driver playing data and all outstanding play requests are completed with KErrCancel.
sl@0
   502
	*/
sl@0
   503
	inline void CancelPlayData();
sl@0
   504
	
sl@0
   505
	/**
sl@0
   506
	Cancel all outstanding record requests.
sl@0
   507
	This immediately stops the driver from capturing record data and all outstanding record requests are completed
sl@0
   508
	with KErrCancel.
sl@0
   509
	*/
sl@0
   510
	inline void CancelRecordData();
sl@0
   511
	
sl@0
   512
	/**
sl@0
   513
	Cancel a specific record or play request.
sl@0
   514
	The outstanding request completes with KErrCancel.
sl@0
   515
	@param aStatus The request status object associated with the request to be cancelled.
sl@0
   516
	*/			   
sl@0
   517
	inline void Cancel(const TRequestStatus& aStatus);
sl@0
   518
	
sl@0
   519
	/**
sl@0
   520
	For a play back units, this method returns the number of bytes delivered to the sound device hardware. For
sl@0
   521
	recording units, this method returns the number of bytes read from the sound device hardware. This is the
sl@0
   522
	count since the driver was opened or since the last ResetBytesTransferred() command was issued.	
sl@0
   523
	@return The number of bytes transferred.
sl@0
   524
	@see ResetBytesTransferred()
sl@0
   525
	*/
sl@0
   526
	inline TInt BytesTransferred();
sl@0
   527
	
sl@0
   528
	/**
sl@0
   529
	Reset the count of the number of bytes transferred by the sound device..
sl@0
   530
	@see BytesTransferred().
sl@0
   531
	*/
sl@0
   532
	inline void ResetBytesTransferred();
sl@0
   533
	
sl@0
   534
	/**
sl@0
   535
	Halt the playing or recording of data from the sound device.
sl@0
   536
	Playing or recording can be resumed using Resume().
sl@0
   537
	If an incomplete play request is outstanding when the device is paused, this request does not complete as a 
sl@0
   538
	result. Resuming play operation following a pause will cause the driver to re-commence playing data from the 
sl@0
   539
	next sample following the last one played - even of this is part way through a play buffer.
sl@0
   540
	However, if an incomplete record request is outstanding when recording is paused, this will be completed immediately
sl@0
   541
	as a result. Typically this will be a partially filled record buffer and the number of valid bytes in the buffer are
sl@0
   542
	indicated via the length argument of the RecordData() method. The client should release this buffer in the normal
sl@0
   543
	way in order to make it available again to the driver when recoding is resumed. Any other outstanding record
sl@0
   544
	requests are completed immediately when recording is halted with a return value of KErrCancel. Likewise, record 
sl@0
   545
	requests received after the device has been paused will complete immediately in the same way - either successfully
sl@0
   546
	if un-read data is available or KErrCancel if not. The device must be resumed before it can be primed to capture a
sl@0
   547
	new record buffer. The driver will capture no record data while it is in the paused state. If recording is resumed,
sl@0
   548
	the driver will begin storing the received data from the beginning of its next available record buffer.
sl@0
   549
	@return KErrNone if successful;
sl@0
   550
  			KErrNotReady: if the driver is not currently playing or recording;
sl@0
   551
		  	otherwise one of the other system-wide error codes.
sl@0
   552
	@see Resume()
sl@0
   553
	*/
sl@0
   554
	inline TInt Pause();
sl@0
   555
	
sl@0
   556
	/**
sl@0
   557
	Allow the sound device to resume playing or recording data.
sl@0
   558
	This is used resume the operation of the driver following a earlier Pause() command to pause play or record.
sl@0
   559
	@return KErrNone if successful;
sl@0
   560
  			KErrNotReady: if the driver is not currently paused;
sl@0
   561
		  	otherwise one of the other system-wide error codes.
sl@0
   562
	@see Pause()
sl@0
   563
	*/
sl@0
   564
	inline TInt Resume();
sl@0
   565
	
sl@0
   566
	/**
sl@0
   567
	Register for notification of a change in the hardware configuration of the device.
sl@0
   568
	This is an asynchronous operation. Only one request of this type can be outstanding per driver channel.
sl@0
   569
	@param aStatus The request status which is signalled when a change in hardware configuration occurs. Possible
sl@0
   570
		values returned:
sl@0
   571
			KErrNotSupported: The unit cannot detect changes in configuration;
sl@0
   572
			KErrInUse: A notification request is already outstanding for this driver channel.
sl@0
   573
			KErrNone: A normal change in hardware configuration has occured;
sl@0
   574
			otherwise one of the other system-wide error codes.
sl@0
   575
	@param aHeadsetPresent On return, this is set to ETrue if the unit is connected to a microphone or headset socket and
sl@0
   576
		this is now present. Otherwise it returns EFalse.
sl@0
   577
	*/
sl@0
   578
	inline void NotifyChangeOfHwConfig(TRequestStatus& aStatus,TBool& aHeadsetPresent);
sl@0
   579
sl@0
   580
	/**
sl@0
   581
	Cancel a request for notification of a change in the hardware configuration.
sl@0
   582
	This results in a pending request being completed immediately with KErrCancel.
sl@0
   583
	*/
sl@0
   584
	inline void CancelNotifyChangeOfHwConfig();
sl@0
   585
	
sl@0
   586
	/**
sl@0
   587
	Issue a custom configuration request.
sl@0
   588
	@param aFunction A number identifying the request. (Values below 0x10000000 are reserved).
sl@0
   589
	@param aParam A 32-bit value passed to the driver. Its meaning depends on the request.
sl@0
   590
	@return KErrNone if successful, otherwise one of the other system wide error codes.
sl@0
   591
	*/
sl@0
   592
	inline TInt CustomConfig(TInt aFunction,TAny* aParam=NULL);
sl@0
   593
sl@0
   594
	/**
sl@0
   595
	Calculates and returns the number of microseconds of data played since the start of playback.  If playback ends or
sl@0
   596
	if CancelPlayData() is called, this number will be reset.
sl@0
   597
	@param aTimePlayed A packaged TTimeIntervalMicroSecondsBuf into which to place the number of microseconds played.
sl@0
   598
	@return	KErrNone if successful.
sl@0
   599
			KErrNotSupported if unit is not open for playback.
sl@0
   600
			Otherwise one of the other system wide error codes.
sl@0
   601
	*/
sl@0
   602
	inline TInt TimePlayed(TTimeIntervalMicroSecondsBuf& aTimePlayed);
sl@0
   603
sl@0
   604
	/**
sl@0
   605
	Calculates and returns the number of microseconds of data recorded since the start of record.  If recording ends or
sl@0
   606
	if CancelRecord() is called, this number will be reset.
sl@0
   607
	@param aTimeRecorded A packaged TTimeIntervalMicroSecondsBuf into which to place the number of microseconds played.
sl@0
   608
	@return	KErrNone if successful.
sl@0
   609
			KErrNotSupported if unit is not open for recording.
sl@0
   610
			Otherwise one of the other system wide error codes.
sl@0
   611
	*/
sl@0
   612
	inline TInt TimeRecorded(TTimeIntervalMicroSecondsBuf& aTimeRecorded);
sl@0
   613
sl@0
   614
#endif	// __KERNEL_MODE__
sl@0
   615
	};
sl@0
   616
sl@0
   617
#include <d32soundsc.inl>
sl@0
   618
sl@0
   619
#endif // __D32SOUNDSC_H__
sl@0
   620