os/mm/mmdevicefw/mdf/src/audio/mdasoundadapter/mdasoundadapter.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) 2007-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 "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
//
sl@0
    15
sl@0
    16
sl@0
    17
#ifndef MDASOUNDADAPTER_H
sl@0
    18
#define MDASOUNDADAPTER_H
sl@0
    19
sl@0
    20
#include <e32std.h>
sl@0
    21
#include <e32ver.h>
sl@0
    22
sl@0
    23
	
sl@0
    24
#define MDADEVSOUNDNAME _L8("RMdaDevSound")
sl@0
    25
sl@0
    26
/*
sl@0
    27
 Adapter class which routes the calls on RMdaDevSound(old sound driver interface) to RSoundSc(new sound driver interface). 
sl@0
    28
 The purpose of this class is to use the new sound driver in MDF without changing the calling code. This class
sl@0
    29
 does not support any new functionalities supported by the shared chunk sound driver but supports the functionality of the 
sl@0
    30
 of the old driver with the new driver.
sl@0
    31
 */
sl@0
    32
class RMdaDevSound
sl@0
    33
	{
sl@0
    34
	class CBody;
sl@0
    35
public:
sl@0
    36
	/*
sl@0
    37
	enum for major, minor and build version of sound device driver.
sl@0
    38
	*/
sl@0
    39
	enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
sl@0
    40
    /*
sl@0
    41
	enum for sound media device play/record request.
sl@0
    42
	*/
sl@0
    43
	enum TMdaRequest
sl@0
    44
		{
sl@0
    45
		/* Play data request */
sl@0
    46
		EMdaRequestPlayData,
sl@0
    47
		/* Play error notification */
sl@0
    48
		EMdaRequestPlayErrorNotification,
sl@0
    49
		/* Record data request */
sl@0
    50
		EMdaRequestRecordData,
sl@0
    51
		/* Record error notification */
sl@0
    52
		EMdaRequestRecordErrorNotification
sl@0
    53
		};
sl@0
    54
	
sl@0
    55
	/* enum for media device control request */
sl@0
    56
	enum TMdaControl
sl@0
    57
		{
sl@0
    58
		/* play format (capability) supported request */
sl@0
    59
		EMdaControlPlayFormatsSupported,
sl@0
    60
		/* get the current play format request */
sl@0
    61
		EMdaControlGetPlayFormat,
sl@0
    62
		/* set the play format request  */
sl@0
    63
		EMdaControlSetPlayFormat,
sl@0
    64
		/* get play volume request */
sl@0
    65
		EMdaControlGetPlayVolume,
sl@0
    66
		/* set play volume request */
sl@0
    67
		EMdaControlSetPlayVolume,
sl@0
    68
		/* record format supported request */
sl@0
    69
		EMdaControlRecordFormatsSupported,
sl@0
    70
		/* get the current record format request */
sl@0
    71
		EMdaControlGetRecordFormat,
sl@0
    72
		/* set record format request */
sl@0
    73
		EMdaControlSetRecordFormat,
sl@0
    74
		/* get record volume request */
sl@0
    75
		EMdaControlGetRecordLevel,
sl@0
    76
		/* set record volume request */
sl@0
    77
		EMdaControlSetRecordLevel,
sl@0
    78
		/* stop play request */
sl@0
    79
		EMdaControlFlushPlayBuffer,
sl@0
    80
		/* stop record request */
sl@0
    81
		EMdaControlFlushRecordBuffer,
sl@0
    82
		/* bytes played request  */
sl@0
    83
		EMdaControlBytesPlayed,
sl@0
    84
		/* set base value for the bytes played */
sl@0
    85
		EMdaControlResetBytesPlayed,
sl@0
    86
		/* Investigate for sound media driver request */
sl@0
    87
		EMdaControlIsMdaSound,
sl@0
    88
		/* pause play request */
sl@0
    89
		EMdaControlPausePlayBuffer,
sl@0
    90
		/* resume play request */
sl@0
    91
		EMdaControlResumePlaying
sl@0
    92
		};
sl@0
    93
		
sl@0
    94
	/*
sl@0
    95
    This enum corresponds to supported sound encoding schemes
sl@0
    96
    */
sl@0
    97
	enum TMdaSoundEncoding
sl@0
    98
		{
sl@0
    99
		/* sound encoding(compression) using 8 bit PCM (pulse code modulation) */
sl@0
   100
		EMdaSoundEncoding8BitPCM		= 0x00000001,
sl@0
   101
		/* sound encoding using 16 bit PCM */
sl@0
   102
		EMdaSoundEncoding16BitPCM		= 0x00000002,
sl@0
   103
		/* sound encoding using 8 bit A law */
sl@0
   104
		EMdaSoundEncoding8BitALaw		= 0x00000004,
sl@0
   105
		/* sound encoding using 8 bit Mu law */
sl@0
   106
		EMdaSoundEncoding8BitMuLaw		= 0x00000008,
sl@0
   107
		};
sl@0
   108
		
sl@0
   109
	/*
sl@0
   110
    This class corresponds to a supported sound format.
sl@0
   111
	The format describes the supported audio device's min/max sampling rate, encoding, channels and buffer size of play/record and volume.
sl@0
   112
    */
sl@0
   113
	class TSoundFormatsSupported
sl@0
   114
		{
sl@0
   115
	public:
sl@0
   116
	/*
sl@0
   117
    This corresponds to minimum sample rate supported. This depends on the physical sound device used(example: 8000 hertz). 
sl@0
   118
    */
sl@0
   119
		TInt iMinRate;
sl@0
   120
		
sl@0
   121
	/*
sl@0
   122
    This corresponds to maximum sample rate supported. This depends on the physical sound device used(example: 48000 hertz).
sl@0
   123
    */
sl@0
   124
		TInt iMaxRate;
sl@0
   125
		
sl@0
   126
	/*
sl@0
   127
    This corresponds to encoding format supported.  
sl@0
   128
	@see  TMdaSoundEncoding
sl@0
   129
    */		
sl@0
   130
		TUint32 iEncodings;
sl@0
   131
		
sl@0
   132
	/*
sl@0
   133
    This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound.
sl@0
   134
	Also this depends on the physical device used.
sl@0
   135
    */
sl@0
   136
		TInt iChannels;
sl@0
   137
		
sl@0
   138
	/*
sl@0
   139
    This corresponds to minimum buffer size. This depends on the physical device used and sampling rate adapted.
sl@0
   140
	@see KSoundMinBufferSize
sl@0
   141
    */
sl@0
   142
		TInt iMinBufferSize;
sl@0
   143
		
sl@0
   144
	/*
sl@0
   145
    This corresponds to maximum buffer size.This depends on the physical device used and sampling rate adapted. 
sl@0
   146
	@see KSoundPlayBufferSize
sl@0
   147
    @see KSoundRecordBufferSize
sl@0
   148
    */
sl@0
   149
		TInt iMaxBufferSize;
sl@0
   150
sl@0
   151
	/*
sl@0
   152
    This corresponds to minimum play/record volume. 
sl@0
   153
    */	
sl@0
   154
		TInt iMinVolume;
sl@0
   155
		
sl@0
   156
	/*
sl@0
   157
    This corresponds to maximum play/record volume. 
sl@0
   158
    */
sl@0
   159
		TInt iMaxVolume;
sl@0
   160
		};
sl@0
   161
sl@0
   162
	/* A typedef'd packaged RMdaDevSound::TSoundFormatsSupported for passing through a generic API method */
sl@0
   163
	typedef TPckgBuf<TSoundFormatsSupported> TSoundFormatsSupportedBuf;
sl@0
   164
sl@0
   165
	/*
sl@0
   166
    This class corresponds to current supported sound format. 
sl@0
   167
	The format describes the supported audio device's sampling rate, encoding, channels and buffer size of play/record.
sl@0
   168
    */
sl@0
   169
	class TCurrentSoundFormat
sl@0
   170
		{
sl@0
   171
	public:
sl@0
   172
	/*
sl@0
   173
    This corresponds to sound sampling rate like (44000 Hertz, 8000 Hertz). The possible values depends on the physical device used.
sl@0
   174
    */
sl@0
   175
		TInt iRate;
sl@0
   176
		
sl@0
   177
	/*
sl@0
   178
    @see TMdaSoundEncoding
sl@0
   179
    */
sl@0
   180
		TMdaSoundEncoding iEncoding;
sl@0
   181
		
sl@0
   182
	/*
sl@0
   183
    This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound.
sl@0
   184
	Also this depends on the physical device used.
sl@0
   185
    */
sl@0
   186
		TInt iChannels;
sl@0
   187
		
sl@0
   188
	/*
sl@0
   189
    Play or Record buffer size. The possible value depends on the physical device used. 
sl@0
   190
    */
sl@0
   191
		TInt iBufferSize;
sl@0
   192
		};
sl@0
   193
sl@0
   194
	/* A typedef'd packaged RMdaDevSound::TCurrentSoundFormat for passing through a generic API method */
sl@0
   195
	typedef TPckgBuf<TCurrentSoundFormat> TCurrentSoundFormatBuf;
sl@0
   196
public:
sl@0
   197
	IMPORT_C RMdaDevSound();
sl@0
   198
	IMPORT_C TInt Open(TInt aUnit=KNullUnit);
sl@0
   199
	IMPORT_C TVersion VersionRequired() const;
sl@0
   200
	IMPORT_C TInt IsMdaSound();
sl@0
   201
	IMPORT_C void PlayFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported);
sl@0
   202
	IMPORT_C void GetPlayFormat(TCurrentSoundFormatBuf& aFormat);
sl@0
   203
	IMPORT_C TInt SetPlayFormat(const TCurrentSoundFormatBuf& aFormat);
sl@0
   204
	IMPORT_C TInt PlayVolume();
sl@0
   205
	// This function mimics RMdaDevSound interface with linear volume semantics
sl@0
   206
	IMPORT_C void SetPlayVolume(TInt aLinearVolume);
sl@0
   207
	// This function supports volume change with logarithmic semantics
sl@0
   208
	IMPORT_C void SetVolume(TInt aLogarithmicVolume);
sl@0
   209
	IMPORT_C void PlayData(TRequestStatus& aStatus,const TDesC8& aData);
sl@0
   210
	IMPORT_C void CancelPlayData();
sl@0
   211
	IMPORT_C void NotifyPlayError(TRequestStatus& aStatus);
sl@0
   212
	IMPORT_C void CancelNotifyPlayError();
sl@0
   213
sl@0
   214
	IMPORT_C void RecordFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported);
sl@0
   215
	IMPORT_C void GetRecordFormat(TCurrentSoundFormatBuf& aFormat);
sl@0
   216
	IMPORT_C TInt SetRecordFormat(const TCurrentSoundFormatBuf& aFormat);
sl@0
   217
	IMPORT_C TInt RecordLevel();
sl@0
   218
	IMPORT_C void SetRecordLevel(TInt aLevel);
sl@0
   219
	IMPORT_C void RecordData(TRequestStatus& aStatus,TDes8& aData);
sl@0
   220
	IMPORT_C void CancelRecordData();
sl@0
   221
	IMPORT_C void NotifyRecordError(TRequestStatus& aStatus);
sl@0
   222
	IMPORT_C void CancelNotifyRecordError();
sl@0
   223
sl@0
   224
	IMPORT_C void FlushPlayBuffer();
sl@0
   225
	IMPORT_C void FlushRecordBuffer();
sl@0
   226
	IMPORT_C TInt BytesPlayed();
sl@0
   227
	IMPORT_C void ResetBytesPlayed();
sl@0
   228
	IMPORT_C void PausePlayBuffer();
sl@0
   229
	IMPORT_C void ResumePlaying();
sl@0
   230
	IMPORT_C void ResumePlaying(TRequestStatus&);
sl@0
   231
	IMPORT_C void Close();
sl@0
   232
	IMPORT_C TInt Handle();
sl@0
   233
	IMPORT_C void PauseRecordBuffer();
sl@0
   234
	IMPORT_C void ResumeRecording();
sl@0
   235
	IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTimePlayed);
sl@0
   236
private:
sl@0
   237
	CBody* iBody;
sl@0
   238
	};
sl@0
   239
	
sl@0
   240
#endif
sl@0
   241