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