78
|
1 |
|
|
2 |
#ifndef DEVSOUNDSTUB_H
|
|
3 |
#define DEVSOUNDSTUB_H
|
|
4 |
|
|
5 |
// Define tone & sample players, so the original headers won't get included afterwards.
|
|
6 |
#define __MDAAUDIOTONEPLAYER_H__
|
|
7 |
|
|
8 |
#define __MDAAUDIOSAMPLEPLAYER_H
|
|
9 |
|
|
10 |
|
|
11 |
#include <e32base.h>
|
|
12 |
#include <e32std.h>
|
|
13 |
|
|
14 |
|
|
15 |
// Priority from devsound
|
|
16 |
enum TMdaPriority
|
|
17 |
{
|
|
18 |
EMdaPriorityMin = -100,
|
|
19 |
EMdaPriorityNormal = 0,
|
|
20 |
EMdaPriorityMax = 100
|
|
21 |
};
|
|
22 |
|
|
23 |
|
|
24 |
// Preference from devsound
|
|
25 |
enum TMdaPriorityPreference
|
|
26 |
{
|
|
27 |
EMdaPriorityPreferenceNone = 0,
|
|
28 |
EMdaPriorityPreferenceTime = 1,
|
|
29 |
EMdaPriorityPreferenceQuality = 2,
|
|
30 |
EMdaPriorityPreferenceTimeAndQuality = 3
|
|
31 |
};
|
|
32 |
|
|
33 |
// Mda server stub definition.
|
|
34 |
class CMdaServer : public CBase
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
static CMdaServer* NewL();
|
|
38 |
~CMdaServer();
|
|
39 |
};
|
|
40 |
|
|
41 |
// Function call test data. These objects should be compared to define the test result. Devsound stub registers function call data in these objects.
|
|
42 |
class CTestFunctionCallData : public CBase
|
|
43 |
{
|
|
44 |
public:
|
|
45 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, HBufC* aString, TInt aInt1, TInt aInt2 );
|
|
46 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, TInt aInt1, TInt aInt2 );
|
|
47 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, TInt aInt1 = 0 );
|
|
48 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, TInt aInt1, TTimeIntervalMicroSeconds aSeconds );
|
|
49 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, TTimeIntervalMicroSeconds aSeconds );
|
|
50 |
static CTestFunctionCallData* NewL( TInt aFunctionIndex, HBufC8* aString );
|
|
51 |
|
|
52 |
~CTestFunctionCallData();
|
|
53 |
|
|
54 |
CTestFunctionCallData( TInt aFunctionIndex, HBufC* aPtr1, TInt aInt1, TInt aInt2, TTimeIntervalMicroSeconds aSeconds );
|
|
55 |
|
|
56 |
CTestFunctionCallData( TInt aFunctionIndex, HBufC8* aString );
|
|
57 |
|
|
58 |
HBufC* DesC1();
|
|
59 |
HBufC8* DesC2();
|
|
60 |
TInt Int1();
|
|
61 |
TInt Int2();
|
|
62 |
TTimeIntervalMicroSeconds Seconds();
|
|
63 |
|
|
64 |
TInt FunctionIndex();
|
|
65 |
|
|
66 |
TBool operator ==( CTestFunctionCallData& aData );
|
|
67 |
|
|
68 |
private:
|
|
69 |
|
|
70 |
TInt iFunctionIndex;
|
|
71 |
HBufC* iP1;
|
|
72 |
TInt iP2;
|
|
73 |
TInt iP3;
|
|
74 |
TTimeIntervalMicroSeconds iP4;
|
|
75 |
HBufC8* iP5;
|
|
76 |
|
|
77 |
};
|
|
78 |
|
|
79 |
|
|
80 |
// M-interface from devsound for callbacks.
|
|
81 |
class MMdaAudioToneObserver
|
|
82 |
{
|
|
83 |
public:
|
|
84 |
virtual void MatoPrepareComplete(TInt aError) = 0;
|
|
85 |
virtual void MatoPlayComplete(TInt aError) = 0;
|
|
86 |
};
|
|
87 |
|
|
88 |
|
|
89 |
// M-interface from devsound for callbacks.
|
|
90 |
class MMdaAudioPlayerCallback
|
|
91 |
{
|
|
92 |
public:
|
|
93 |
virtual void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) = 0;
|
|
94 |
virtual void MapcPlayComplete(TInt aError) = 0;
|
|
95 |
};
|
|
96 |
|
|
97 |
|
|
98 |
// Audio player utility stub. All imperative function calls are stored into iTestData static pointer array.
|
|
99 |
class CMdaAudioPlayerUtility : public CActive
|
|
100 |
{
|
|
101 |
public:
|
|
102 |
|
|
103 |
// function call index.
|
|
104 |
enum TFunctionCall
|
|
105 |
{
|
|
106 |
ENewFilePlayerL,
|
|
107 |
ENewL,
|
|
108 |
ESetVolume,
|
|
109 |
ESetRepeats,
|
|
110 |
ESetVolumeRamp,
|
|
111 |
EMaxVolume,
|
|
112 |
EGetVolume,
|
|
113 |
EOpenDesL,
|
|
114 |
EPlay,
|
|
115 |
EStop
|
|
116 |
};
|
|
117 |
|
|
118 |
static CMdaAudioPlayerUtility* NewFilePlayerL(const TDesC& aFileName,
|
|
119 |
MMdaAudioPlayerCallback& aCallback,
|
|
120 |
TInt aPriority = EMdaPriorityNormal,
|
|
121 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality,
|
|
122 |
CMdaServer* aServer = NULL );
|
|
123 |
static CMdaAudioPlayerUtility* NewL( MMdaAudioPlayerCallback& aCallback,
|
|
124 |
TInt aPriority = EMdaPriorityNormal,
|
|
125 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality );
|
|
126 |
CMdaAudioPlayerUtility(MMdaAudioPlayerCallback& aObserver, TInt aPriority, TInt aPref, CMdaServer* aServer );
|
|
127 |
~CMdaAudioPlayerUtility();
|
|
128 |
TInt SetVolume(TInt aVolume );
|
|
129 |
void SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence);
|
|
130 |
void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration);
|
|
131 |
TInt MaxVolume();
|
|
132 |
TInt GetVolume(TInt& aVolume);
|
|
133 |
void OpenDesL(const TDesC8& aDescriptor);
|
|
134 |
|
|
135 |
void DoCancel();
|
|
136 |
void RunL();
|
|
137 |
|
|
138 |
void Play();
|
|
139 |
void Stop();
|
|
140 |
void Close();
|
|
141 |
|
|
142 |
|
|
143 |
// Static access to test data. If used, stub object must be allocated from the same memory space as the client.
|
|
144 |
static RPointerArray< CTestFunctionCallData >& TestData();
|
|
145 |
static void DelayAudioLoading();
|
|
146 |
static void SimulateErrorInAudioLoading();
|
|
147 |
static void ResetTestData();
|
|
148 |
|
|
149 |
private:
|
|
150 |
|
|
151 |
void ConstructL( const TDesC& aFileName );
|
|
152 |
|
|
153 |
void ConstructL( const TDesC8& aFileName );
|
|
154 |
private:
|
|
155 |
|
|
156 |
MMdaAudioPlayerCallback& iObserver;
|
|
157 |
TInt iVolume;
|
|
158 |
TInt iMaxVolume;
|
|
159 |
TInt iPriority;
|
|
160 |
TInt iPref;
|
|
161 |
CMdaServer* iServer;
|
|
162 |
HBufC* iFile;
|
|
163 |
HBufC8* iFile8;
|
|
164 |
|
|
165 |
RTimer iTimer;
|
|
166 |
|
|
167 |
static RPointerArray< CTestFunctionCallData > iStaticTestData;
|
|
168 |
static bool iDelayedAudioLoading;
|
|
169 |
static bool iErrorInAudioLoading;
|
|
170 |
|
|
171 |
};
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
// The state of the audio tone utility.
|
|
176 |
|
|
177 |
enum TMdaAudioToneUtilityState
|
|
178 |
{
|
|
179 |
/** The audio tone utility has not been prepared to play a tone.
|
|
180 |
*/
|
|
181 |
EMdaAudioToneUtilityNotReady=0,
|
|
182 |
/** The audio tone utility has been prepared to play a tone and is ready.
|
|
183 |
*/
|
|
184 |
EMdaAudioToneUtilityPrepared,
|
|
185 |
/** The audio tone utility is currently playing a tone.
|
|
186 |
*/
|
|
187 |
EMdaAudioToneUtilityPlaying,
|
|
188 |
/** The audio tone utility is currently paused.
|
|
189 |
This state is only reached if underlying DevSound implementations supports resume.
|
|
190 |
*/
|
|
191 |
EMdaAudioToneUtilityPaused
|
|
192 |
};
|
|
193 |
|
|
194 |
// Audio tone player utility stub. All imperative function calls are stored into iTestData static pointer array.
|
|
195 |
class CMdaAudioToneUtility : public CActive
|
|
196 |
{
|
|
197 |
public:
|
|
198 |
|
|
199 |
|
|
200 |
// function call index.
|
|
201 |
enum TFunctionCall
|
|
202 |
{
|
|
203 |
ENewL,
|
|
204 |
EMaxVolume,
|
|
205 |
EVolume,
|
|
206 |
ESetVolume,
|
|
207 |
ESetRepeats,
|
|
208 |
ESetVolumeRamp,
|
|
209 |
EFixedSequenceCount,
|
|
210 |
EFixedSequenceName,
|
|
211 |
EPrepareToPlayTone,
|
|
212 |
EPrepareToPlayDTMFString,
|
|
213 |
EPrepareToPlayDesSequence,
|
|
214 |
EPrepareToPlayFileSequence,
|
|
215 |
EPrepareToPlayFixedSequence,
|
|
216 |
ECancelPrepare,
|
|
217 |
ECancelPlay,
|
|
218 |
EPlay,
|
|
219 |
EStop
|
|
220 |
};
|
|
221 |
|
|
222 |
static CMdaAudioToneUtility* NewL( MMdaAudioToneObserver& aObserver,
|
|
223 |
CMdaServer* aServer = NULL,
|
|
224 |
TInt aPriority = EMdaPriorityNormal,
|
|
225 |
TInt aPref = EMdaPriorityPreferenceTimeAndQuality );
|
|
226 |
|
|
227 |
|
|
228 |
CMdaAudioToneUtility( MMdaAudioToneObserver& aObserver,
|
|
229 |
TInt aPriority, TInt aPref, CMdaServer* aServer );
|
|
230 |
~CMdaAudioToneUtility();
|
|
231 |
virtual TInt MaxVolume();
|
|
232 |
virtual TInt Volume();
|
|
233 |
virtual void SetVolume(TInt aVolume );
|
|
234 |
virtual void SetRepeats(TInt aRepeatNumberOfTimes,
|
|
235 |
const TTimeIntervalMicroSeconds& aTrailingSilence );
|
|
236 |
virtual void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration );
|
|
237 |
virtual TInt FixedSequenceCount();
|
|
238 |
virtual const TDesC& FixedSequenceName(TInt aSequenceNumber );
|
|
239 |
virtual void PrepareToPlayTone(TInt aFrequency,
|
|
240 |
const TTimeIntervalMicroSeconds& aDuration );
|
|
241 |
virtual void PrepareToPlayDTMFString(const TDesC& aDTMF);
|
|
242 |
virtual void PrepareToPlayDesSequence(const TDesC8& aSequence);
|
|
243 |
virtual void PrepareToPlayFileSequence(const TDesC& aFileName);
|
|
244 |
virtual void PrepareToPlayFixedSequence(TInt aSequenceNumber);
|
|
245 |
virtual void CancelPrepare();
|
|
246 |
virtual void Play();
|
|
247 |
virtual TMdaAudioToneUtilityState State();
|
|
248 |
virtual void CancelPlay();
|
|
249 |
|
|
250 |
// Static access to test data. If used, stub object must be allocated from the same memory space as the client.
|
|
251 |
static RPointerArray< CTestFunctionCallData >& TestData();
|
|
252 |
static void DelayAudioLoading();
|
|
253 |
static void SimulateErrorInAudioLoading();
|
|
254 |
static void ResetTestData();
|
|
255 |
|
|
256 |
|
|
257 |
void DoCancel();
|
|
258 |
|
|
259 |
void RunL();
|
|
260 |
|
|
261 |
void Stop();
|
|
262 |
|
|
263 |
|
|
264 |
private:
|
|
265 |
|
|
266 |
void ConstructL();
|
|
267 |
|
|
268 |
private:
|
|
269 |
|
|
270 |
MMdaAudioToneObserver& iObserver;
|
|
271 |
TInt iVolume;
|
|
272 |
TInt iMaxVolume;
|
|
273 |
TInt iPriority;
|
|
274 |
TInt iPref;
|
|
275 |
CMdaServer* iServer;
|
|
276 |
HBufC8* iFile8;
|
|
277 |
|
|
278 |
|
|
279 |
RTimer iTimer;
|
|
280 |
|
|
281 |
|
|
282 |
static RPointerArray< CTestFunctionCallData > iStaticTestData;
|
|
283 |
static bool iDelayedAudioLoading;
|
|
284 |
static bool iErrorInAudioLoading;
|
|
285 |
|
|
286 |
};
|
|
287 |
|
|
288 |
#endif // DEVSOUNDSTUB_H
|
|
289 |
|
|
290 |
// End of file
|