1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmdevicefw/mdf/src/audio/mdasoundadapter/mdasoundadapter.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,241 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +
1.20 +#ifndef MDASOUNDADAPTER_H
1.21 +#define MDASOUNDADAPTER_H
1.22 +
1.23 +#include <e32std.h>
1.24 +#include <e32ver.h>
1.25 +
1.26 +
1.27 +#define MDADEVSOUNDNAME _L8("RMdaDevSound")
1.28 +
1.29 +/*
1.30 + Adapter class which routes the calls on RMdaDevSound(old sound driver interface) to RSoundSc(new sound driver interface).
1.31 + The purpose of this class is to use the new sound driver in MDF without changing the calling code. This class
1.32 + does not support any new functionalities supported by the shared chunk sound driver but supports the functionality of the
1.33 + of the old driver with the new driver.
1.34 + */
1.35 +class RMdaDevSound
1.36 + {
1.37 + class CBody;
1.38 +public:
1.39 + /*
1.40 + enum for major, minor and build version of sound device driver.
1.41 + */
1.42 + enum TVer {EMajorVersionNumber=1,EMinorVersionNumber=0,EBuildVersionNumber=KE32BuildVersionNumber};
1.43 + /*
1.44 + enum for sound media device play/record request.
1.45 + */
1.46 + enum TMdaRequest
1.47 + {
1.48 + /* Play data request */
1.49 + EMdaRequestPlayData,
1.50 + /* Play error notification */
1.51 + EMdaRequestPlayErrorNotification,
1.52 + /* Record data request */
1.53 + EMdaRequestRecordData,
1.54 + /* Record error notification */
1.55 + EMdaRequestRecordErrorNotification
1.56 + };
1.57 +
1.58 + /* enum for media device control request */
1.59 + enum TMdaControl
1.60 + {
1.61 + /* play format (capability) supported request */
1.62 + EMdaControlPlayFormatsSupported,
1.63 + /* get the current play format request */
1.64 + EMdaControlGetPlayFormat,
1.65 + /* set the play format request */
1.66 + EMdaControlSetPlayFormat,
1.67 + /* get play volume request */
1.68 + EMdaControlGetPlayVolume,
1.69 + /* set play volume request */
1.70 + EMdaControlSetPlayVolume,
1.71 + /* record format supported request */
1.72 + EMdaControlRecordFormatsSupported,
1.73 + /* get the current record format request */
1.74 + EMdaControlGetRecordFormat,
1.75 + /* set record format request */
1.76 + EMdaControlSetRecordFormat,
1.77 + /* get record volume request */
1.78 + EMdaControlGetRecordLevel,
1.79 + /* set record volume request */
1.80 + EMdaControlSetRecordLevel,
1.81 + /* stop play request */
1.82 + EMdaControlFlushPlayBuffer,
1.83 + /* stop record request */
1.84 + EMdaControlFlushRecordBuffer,
1.85 + /* bytes played request */
1.86 + EMdaControlBytesPlayed,
1.87 + /* set base value for the bytes played */
1.88 + EMdaControlResetBytesPlayed,
1.89 + /* Investigate for sound media driver request */
1.90 + EMdaControlIsMdaSound,
1.91 + /* pause play request */
1.92 + EMdaControlPausePlayBuffer,
1.93 + /* resume play request */
1.94 + EMdaControlResumePlaying
1.95 + };
1.96 +
1.97 + /*
1.98 + This enum corresponds to supported sound encoding schemes
1.99 + */
1.100 + enum TMdaSoundEncoding
1.101 + {
1.102 + /* sound encoding(compression) using 8 bit PCM (pulse code modulation) */
1.103 + EMdaSoundEncoding8BitPCM = 0x00000001,
1.104 + /* sound encoding using 16 bit PCM */
1.105 + EMdaSoundEncoding16BitPCM = 0x00000002,
1.106 + /* sound encoding using 8 bit A law */
1.107 + EMdaSoundEncoding8BitALaw = 0x00000004,
1.108 + /* sound encoding using 8 bit Mu law */
1.109 + EMdaSoundEncoding8BitMuLaw = 0x00000008,
1.110 + };
1.111 +
1.112 + /*
1.113 + This class corresponds to a supported sound format.
1.114 + The format describes the supported audio device's min/max sampling rate, encoding, channels and buffer size of play/record and volume.
1.115 + */
1.116 + class TSoundFormatsSupported
1.117 + {
1.118 + public:
1.119 + /*
1.120 + This corresponds to minimum sample rate supported. This depends on the physical sound device used(example: 8000 hertz).
1.121 + */
1.122 + TInt iMinRate;
1.123 +
1.124 + /*
1.125 + This corresponds to maximum sample rate supported. This depends on the physical sound device used(example: 48000 hertz).
1.126 + */
1.127 + TInt iMaxRate;
1.128 +
1.129 + /*
1.130 + This corresponds to encoding format supported.
1.131 + @see TMdaSoundEncoding
1.132 + */
1.133 + TUint32 iEncodings;
1.134 +
1.135 + /*
1.136 + This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound.
1.137 + Also this depends on the physical device used.
1.138 + */
1.139 + TInt iChannels;
1.140 +
1.141 + /*
1.142 + This corresponds to minimum buffer size. This depends on the physical device used and sampling rate adapted.
1.143 + @see KSoundMinBufferSize
1.144 + */
1.145 + TInt iMinBufferSize;
1.146 +
1.147 + /*
1.148 + This corresponds to maximum buffer size.This depends on the physical device used and sampling rate adapted.
1.149 + @see KSoundPlayBufferSize
1.150 + @see KSoundRecordBufferSize
1.151 + */
1.152 + TInt iMaxBufferSize;
1.153 +
1.154 + /*
1.155 + This corresponds to minimum play/record volume.
1.156 + */
1.157 + TInt iMinVolume;
1.158 +
1.159 + /*
1.160 + This corresponds to maximum play/record volume.
1.161 + */
1.162 + TInt iMaxVolume;
1.163 + };
1.164 +
1.165 + /* A typedef'd packaged RMdaDevSound::TSoundFormatsSupported for passing through a generic API method */
1.166 + typedef TPckgBuf<TSoundFormatsSupported> TSoundFormatsSupportedBuf;
1.167 +
1.168 + /*
1.169 + This class corresponds to current supported sound format.
1.170 + The format describes the supported audio device's sampling rate, encoding, channels and buffer size of play/record.
1.171 + */
1.172 + class TCurrentSoundFormat
1.173 + {
1.174 + public:
1.175 + /*
1.176 + This corresponds to sound sampling rate like (44000 Hertz, 8000 Hertz). The possible values depends on the physical device used.
1.177 + */
1.178 + TInt iRate;
1.179 +
1.180 + /*
1.181 + @see TMdaSoundEncoding
1.182 + */
1.183 + TMdaSoundEncoding iEncoding;
1.184 +
1.185 + /*
1.186 + This corresponds to the number of sound channels supported. Possible values are EMono for a single channel and EStereo for two channel sound.
1.187 + Also this depends on the physical device used.
1.188 + */
1.189 + TInt iChannels;
1.190 +
1.191 + /*
1.192 + Play or Record buffer size. The possible value depends on the physical device used.
1.193 + */
1.194 + TInt iBufferSize;
1.195 + };
1.196 +
1.197 + /* A typedef'd packaged RMdaDevSound::TCurrentSoundFormat for passing through a generic API method */
1.198 + typedef TPckgBuf<TCurrentSoundFormat> TCurrentSoundFormatBuf;
1.199 +public:
1.200 + IMPORT_C RMdaDevSound();
1.201 + IMPORT_C TInt Open(TInt aUnit=KNullUnit);
1.202 + IMPORT_C TVersion VersionRequired() const;
1.203 + IMPORT_C TInt IsMdaSound();
1.204 + IMPORT_C void PlayFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported);
1.205 + IMPORT_C void GetPlayFormat(TCurrentSoundFormatBuf& aFormat);
1.206 + IMPORT_C TInt SetPlayFormat(const TCurrentSoundFormatBuf& aFormat);
1.207 + IMPORT_C TInt PlayVolume();
1.208 + // This function mimics RMdaDevSound interface with linear volume semantics
1.209 + IMPORT_C void SetPlayVolume(TInt aLinearVolume);
1.210 + // This function supports volume change with logarithmic semantics
1.211 + IMPORT_C void SetVolume(TInt aLogarithmicVolume);
1.212 + IMPORT_C void PlayData(TRequestStatus& aStatus,const TDesC8& aData);
1.213 + IMPORT_C void CancelPlayData();
1.214 + IMPORT_C void NotifyPlayError(TRequestStatus& aStatus);
1.215 + IMPORT_C void CancelNotifyPlayError();
1.216 +
1.217 + IMPORT_C void RecordFormatsSupported(TSoundFormatsSupportedBuf& aFormatsSupported);
1.218 + IMPORT_C void GetRecordFormat(TCurrentSoundFormatBuf& aFormat);
1.219 + IMPORT_C TInt SetRecordFormat(const TCurrentSoundFormatBuf& aFormat);
1.220 + IMPORT_C TInt RecordLevel();
1.221 + IMPORT_C void SetRecordLevel(TInt aLevel);
1.222 + IMPORT_C void RecordData(TRequestStatus& aStatus,TDes8& aData);
1.223 + IMPORT_C void CancelRecordData();
1.224 + IMPORT_C void NotifyRecordError(TRequestStatus& aStatus);
1.225 + IMPORT_C void CancelNotifyRecordError();
1.226 +
1.227 + IMPORT_C void FlushPlayBuffer();
1.228 + IMPORT_C void FlushRecordBuffer();
1.229 + IMPORT_C TInt BytesPlayed();
1.230 + IMPORT_C void ResetBytesPlayed();
1.231 + IMPORT_C void PausePlayBuffer();
1.232 + IMPORT_C void ResumePlaying();
1.233 + IMPORT_C void ResumePlaying(TRequestStatus&);
1.234 + IMPORT_C void Close();
1.235 + IMPORT_C TInt Handle();
1.236 + IMPORT_C void PauseRecordBuffer();
1.237 + IMPORT_C void ResumeRecording();
1.238 + IMPORT_C TInt GetTimePlayed(TTimeIntervalMicroSeconds& aTimePlayed);
1.239 +private:
1.240 + CBody* iBody;
1.241 + };
1.242 +
1.243 +#endif
1.244 +