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