|
1 // Copyright (c) 2006-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 the License "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 // e32test\multimedia\t_sound_api.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file Shared chunk sound driver API test code. |
|
20 */ |
|
21 |
|
22 #include <e32test.h> |
|
23 #include <f32file.h> |
|
24 #include "t_soundutils.h" |
|
25 |
|
26 #define CHECK(aValue) {Test(aValue);} |
|
27 #define CHECK_NOERROR(aValue) { TInt v=(aValue); if(v) { Test.Printf(_L("Error value = %d\n"),v); Test(EFalse,__LINE__); }} |
|
28 #define CHECK_EQUAL(aValue1,aValue2) { TInt v1=(aValue1); TInt v2=(aValue2); if(v1!=v2) { Test.Printf(_L("Error value = %d\n"),v1); Test(EFalse,__LINE__); }} |
|
29 |
|
30 _LIT(KSndLddFileName,"ESOUNDSC.LDD"); |
|
31 _LIT(KSndPddFileName,"SOUNDSC.PDD"); |
|
32 |
|
33 RTest Test(_L("T_SOUND_API")); |
|
34 RSoundSc TxSoundDevice; |
|
35 RSoundSc RxSoundDevice; |
|
36 |
|
37 TSoundFormatsSupportedV02Buf RecordCapsBuf; |
|
38 TSoundFormatsSupportedV02Buf PlayCapsBuf; |
|
39 TCurrentSoundFormatV02Buf PlayFormatBuf; |
|
40 TCurrentSoundFormatV02Buf RecordFormatBuf; |
|
41 |
|
42 LOCAL_C TInt Load() |
|
43 { |
|
44 TInt r; |
|
45 |
|
46 /** @SYMTestCaseID PBASE-T_SOUND_API-219 |
|
47 @SYMTestCaseDesc Installing the PDD |
|
48 @SYMTestPriority Critical |
|
49 @SYMTestActions 1) Attempt to install the PDD (using User::LoadPhysicalDevice()). |
|
50 2) Without un-installing it, attempt to install it a second time. |
|
51 @SYMTestExpectedResults 1) KErrNone - PDD loads successfully. |
|
52 2) Should fail with KErrAlreadyExists. |
|
53 @SYMREQ PREQ1073.4 */ |
|
54 |
|
55 Test.Start(_L("Load sound PDD")); |
|
56 r=User::LoadPhysicalDevice(KSndPddFileName); |
|
57 if (r==KErrNotFound) |
|
58 { |
|
59 Test.End(); |
|
60 return(r); |
|
61 } |
|
62 CHECK(r==KErrNone || r==KErrAlreadyExists); |
|
63 r=User::LoadPhysicalDevice(KSndPddFileName); |
|
64 CHECK(r==KErrAlreadyExists); |
|
65 |
|
66 /** @SYMTestCaseID PBASE-T_SOUND_API-220 |
|
67 @SYMTestCaseDesc Installing the LDD |
|
68 @SYMTestPriority Critical |
|
69 @SYMTestActions 1) Attempt to install the LDD (using User::LoadLogicalDevice()). |
|
70 2) Without un-installing it, attempt to install it a second time. |
|
71 @SYMTestExpectedResults 1) KErrNone - LDD loads successfully. |
|
72 2) Should fail with KErrAlreadyExists. |
|
73 @SYMREQ PREQ1073.4 */ |
|
74 |
|
75 Test.Next(_L("Load sound LDD")); |
|
76 r=User::LoadLogicalDevice(KSndLddFileName); |
|
77 CHECK(r==KErrNone || r==KErrAlreadyExists); |
|
78 r=User::LoadPhysicalDevice(KSndPddFileName); |
|
79 CHECK(r==KErrAlreadyExists); |
|
80 |
|
81 Test.End(); |
|
82 return(KErrNone); |
|
83 } |
|
84 |
|
85 LOCAL_C void TestSetAudioFormat() |
|
86 { |
|
87 TInt r; |
|
88 Test.Printf(_L("Testing setting the audio format\r\n")); |
|
89 |
|
90 /** @SYMTestCaseID PBASE-T_SOUND_API-227 |
|
91 @SYMTestCaseDesc Setting the audio configuration - channel configuration. |
|
92 @SYMTestPriority Critical |
|
93 @SYMTestActions Read the audio capabilities of the playback channel. For each of the possible 6 channel |
|
94 configurations, issue a request on the playback channel to set this audio configuration. |
|
95 @SYMTestExpectedResults Either KErrNone if the playback channel supports the channel configuration, or |
|
96 KErrNotSupported if the playback channel does not support the channel configuration. |
|
97 @SYMREQ PREQ1073.4 */ |
|
98 |
|
99 Test.Next(_L("Try to set every possible audio channel configuration")); |
|
100 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
101 TInt i; |
|
102 for (i=0 ; i < 6 ; i++) |
|
103 { |
|
104 PlayFormatBuf().iChannels = (i+1); |
|
105 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
106 if (PlayCapsBuf().iChannels & (1<<i)) |
|
107 { |
|
108 CHECK_NOERROR(r); // Caps reports it is supported |
|
109 } |
|
110 else |
|
111 { |
|
112 CHECK(r==KErrNotSupported); // Caps reports it is not supported |
|
113 } |
|
114 } |
|
115 |
|
116 /** @SYMTestCaseID PBASE-T_SOUND_API-228 |
|
117 @SYMTestCaseDesc Setting the audio configuration - sample rate. |
|
118 @SYMTestPriority Critical |
|
119 @SYMTestActions Read the audio capabilities of the playback channel. For each of the possible 14 sample |
|
120 rates, issue a request on the playback channel to set this audio configuration. |
|
121 @SYMTestExpectedResults Either KErrNone if the playback channel supports the sample rate, or |
|
122 KErrNotSupported if the playback channel does not support the sample rate. |
|
123 @SYMREQ PREQ1073.4 */ |
|
124 |
|
125 Test.Next(_L("Try to set every possible sample rate")); |
|
126 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
127 for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++) |
|
128 { |
|
129 PlayFormatBuf().iRate = (TSoundRate)i; |
|
130 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
131 if (PlayCapsBuf().iRates & (1<<i)) |
|
132 { |
|
133 CHECK_NOERROR(r); // Caps reports it is supported |
|
134 } |
|
135 else |
|
136 { |
|
137 CHECK(r==KErrNotSupported); // Caps reports it is not supported |
|
138 } |
|
139 } |
|
140 |
|
141 /** @SYMTestCaseID PBASE-T_SOUND_API-229 |
|
142 @SYMTestCaseDesc Setting the audio configuration - audio encoding. |
|
143 @SYMTestPriority Critical |
|
144 @SYMTestActions Read the audio capabilities of the playback channel. For each of the possible 3 audio |
|
145 encodings, issue a request on the playback channel to set this audio configuration. |
|
146 @SYMTestExpectedResults Either KErrNone if the playback channel supports the audio encoding, or |
|
147 KErrNotSupported if the playback channel does not support the audio encoding. |
|
148 @SYMREQ PREQ1073.4 */ |
|
149 |
|
150 Test.Next(_L("Try to set every possible encoding")); |
|
151 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
152 for (i=0 ; i <= (TInt)ESoundEncoding24BitPCM ; i++) |
|
153 { |
|
154 PlayFormatBuf().iEncoding = (TSoundEncoding)i; |
|
155 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
156 if (PlayCapsBuf().iEncodings & (1<<i)) |
|
157 { |
|
158 CHECK_NOERROR(r); // Caps reports it is supported |
|
159 } |
|
160 else |
|
161 { |
|
162 CHECK(r==KErrNotSupported); // Caps reports it is not supported |
|
163 } |
|
164 } |
|
165 |
|
166 /** @SYMTestCaseID PBASE-T_SOUND_API-230 |
|
167 @SYMTestCaseDesc Setting the audio configuration - audio data format. |
|
168 @SYMTestPriority Critical |
|
169 @SYMTestActions Read the audio capabilities of the playback channel. For each of the possible 2 audio data |
|
170 formats, issue a request on the playback channel to set this audio configuration. |
|
171 @SYMTestExpectedResults Either KErrNone if the playback channel supports the audio data format, or |
|
172 KErrNotSupported if the playback channel does not support the audio data format. |
|
173 @SYMREQ PREQ1073.4 */ |
|
174 |
|
175 Test.Next(_L("Try to set every possible data format")); |
|
176 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
177 for (i=0 ; i <= (TInt)ESoundDataFormatNonInterleaved ; i++) |
|
178 { |
|
179 PlayFormatBuf().iDataFormat = (TSoundDataFormat)i; |
|
180 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
181 if (PlayCapsBuf().iDataFormats & (1<<i)) |
|
182 { |
|
183 CHECK_NOERROR(r); // Caps reports it is supported |
|
184 } |
|
185 else |
|
186 { |
|
187 CHECK(r==KErrNotSupported); // Caps reports it is not supported |
|
188 } |
|
189 } |
|
190 |
|
191 /** @SYMTestCaseID PBASE-T_SOUND_API-231 |
|
192 @SYMTestCaseDesc Setting the audio configuration - altering the configuration while transferring data. |
|
193 @SYMTestPriority Critical |
|
194 @SYMTestActions 1) Read the audio capabilities of the playback channel and apply a playback audio |
|
195 configuration that is supported by channel. Set the play buffer configuration and |
|
196 then start playing data from one of the buffers. While still playing, attempt to alter |
|
197 the audio configuration of the playback channel. |
|
198 2) Read the audio capabilities of the record channel and apply an audio record |
|
199 configuration that is supported by channel. Set the record buffer configuration and |
|
200 then start recording data into one of the buffers. While still recording, attempt |
|
201 to alter the audio configuration of the record channel. |
|
202 @SYMTestExpectedResults 1) Altering the audio configuration should fail with KErrInUse. |
|
203 2) Altering the audio configuration should fail with KErrInUse. |
|
204 @SYMREQ PREQ1073.4 */ |
|
205 |
|
206 Test.Next(_L("Try to alter the audio format while playing")); |
|
207 |
|
208 // Set the audio configuration of the playback channel ready to start playing |
|
209 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
210 if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM) |
|
211 PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM; |
|
212 |
|
213 PlayFormatBuf().iChannels = 2; |
|
214 |
|
215 // find first supported rate and set the the audio configuration to use it |
|
216 TxSoundDevice.AudioFormat(PlayFormatBuf); // Read back the current setting which must be valid. |
|
217 for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++) |
|
218 { |
|
219 PlayFormatBuf().iRate = (TSoundRate)i; |
|
220 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
221 if (PlayCapsBuf().iRates & (1<<i)) |
|
222 { |
|
223 CHECK_NOERROR(r); // Caps reports it is supported |
|
224 break; |
|
225 } |
|
226 } |
|
227 |
|
228 PrintConfig(PlayFormatBuf(),Test); |
|
229 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
230 CHECK_NOERROR(r); |
|
231 |
|
232 // Set the play buffer configuration. |
|
233 RChunk chunk; |
|
234 TInt bufSize=BytesPerSecond(PlayFormatBuf()); // Large enough to hold 1 second of data. |
|
235 bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver. |
|
236 TTestSharedChunkBufConfig bufferConfig; |
|
237 bufferConfig.iNumBuffers=3; |
|
238 bufferConfig.iBufferSizeInBytes=bufSize; |
|
239 bufferConfig.iFlags=0; |
|
240 TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig); |
|
241 r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
242 CHECK_NOERROR(r); |
|
243 TxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
244 PrintBufferConf(bufferConfig,Test); |
|
245 CHECK(bufferConfig.iBufferSizeInBytes==bufSize); |
|
246 |
|
247 // Start playing |
|
248 r=MakeSineTable(PlayFormatBuf()); |
|
249 CHECK_NOERROR(r); |
|
250 r=SetToneFrequency(660,PlayFormatBuf()); |
|
251 CHECK_NOERROR(r); |
|
252 TPtr8 ptr(chunk.Base()+bufferConfig.iBufferOffsetList[0],bufSize); |
|
253 WriteTone(ptr,PlayFormatBuf()); |
|
254 TRequestStatus stat; |
|
255 TxSoundDevice.PlayData(stat,bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample); |
|
256 |
|
257 // Check that altering the audio format while playing - fails |
|
258 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
259 CHECK(r==KErrInUse); |
|
260 |
|
261 User::WaitForRequest(stat); |
|
262 CHECK_EQUAL(stat.Int(),KErrNone); |
|
263 |
|
264 Test.Next(_L("Try to alter the audio format while recording")); |
|
265 |
|
266 // Set the audio configuration of the record channel ready to start recording |
|
267 RxSoundDevice.AudioFormat(RecordFormatBuf); // Read back the current setting which must be valid. |
|
268 if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM) |
|
269 RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM; |
|
270 RecordFormatBuf().iChannels = 2; |
|
271 |
|
272 // find first supported rate and set the the audio configuration to use it |
|
273 for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++) |
|
274 { |
|
275 RecordFormatBuf().iRate = (TSoundRate)i; |
|
276 r=TxSoundDevice.SetAudioFormat(RecordFormatBuf); |
|
277 if (RecordCapsBuf().iRates & (1<<i)) |
|
278 { |
|
279 CHECK_NOERROR(r); // Caps reports it is supported |
|
280 break; |
|
281 } |
|
282 } |
|
283 |
|
284 // Use the same shared chunk for recording |
|
285 r=RxSoundDevice.SetBufferChunkOpen(bufferConfigBuf,chunk); |
|
286 CHECK_NOERROR(r); |
|
287 |
|
288 // Start recording |
|
289 TInt length; |
|
290 RxSoundDevice.RecordData(stat,length); |
|
291 |
|
292 // Check that altering the audio format while recording - fails |
|
293 r=RxSoundDevice.SetAudioFormat(RecordFormatBuf); |
|
294 CHECK(r==KErrInUse); |
|
295 |
|
296 User::WaitForRequest(stat); |
|
297 TInt retOffset=stat.Int(); |
|
298 CHECK(retOffset>=0); |
|
299 CHECK(length>0); |
|
300 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
301 CHECK_NOERROR(r); |
|
302 |
|
303 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
|
304 chunk.Close(); |
|
305 } |
|
306 |
|
307 LOCAL_C void TestSetBufferConfig(TInt aBufferConfigFlags) |
|
308 { |
|
309 |
|
310 Test.Printf(_L("Testing setting the buffer configuration\r\n")); |
|
311 |
|
312 /** @SYMTestCaseID PBASE-T_SOUND_API-232 |
|
313 @SYMTestCaseDesc Setting the buffer configuration - varying the number of buffers. |
|
314 @SYMTestPriority Critical |
|
315 @SYMTestActions Issue a request on the playback channel to create a shared chunk (i.e. using |
|
316 SetBufferChunkCreate()) with a buffer configuration containing a single buffer. Attempt |
|
317 to open the same shared chunk on the record channel (i.e. using SetBufferChunkOpen()). |
|
318 Then close the chunk. |
|
319 Repeat this same sequence using buffer configurations containing 2 - 8 buffers. |
|
320 @SYMTestExpectedResults In every case the attempt to create and open the shared chunk should return KErrNone. |
|
321 @SYMREQ PREQ1073.4 */ |
|
322 |
|
323 Test.Next(_L("Test creating/opening a chunk, varying the number of buffers ")); |
|
324 TInt r; |
|
325 RChunk chunk; |
|
326 TTestSharedChunkBufConfig bufferConfig; |
|
327 bufferConfig.iBufferSizeInBytes=0x7FE0; // 32K - 32 bytes |
|
328 if (PlayCapsBuf().iRequestMinSize) |
|
329 bufferConfig.iBufferSizeInBytes&=~(PlayCapsBuf().iRequestMinSize-1); // Assumes iRequestMinSize is same for play and record |
|
330 TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig); |
|
331 |
|
332 TInt i; |
|
333 for (i=1 ; i<=8 ; i++) |
|
334 { |
|
335 bufferConfig.iFlags=aBufferConfigFlags; |
|
336 bufferConfig.iNumBuffers=i; |
|
337 |
|
338 // Create the shared chunk on the play channel |
|
339 r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
340 CHECK_NOERROR(r); |
|
341 TxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
342 PrintBufferConf(bufferConfig,Test); |
|
343 |
|
344 // Open the same shared chunk on the record channel |
|
345 r=RxSoundDevice.SetBufferChunkOpen(bufferConfigBuf,chunk); |
|
346 CHECK_NOERROR(r); |
|
347 |
|
348 chunk.Close(); |
|
349 } |
|
350 |
|
351 /** @SYMTestCaseID PBASE-T_SOUND_API-233 |
|
352 @SYMTestCaseDesc Setting the buffer configuration - varying the size of the buffers. |
|
353 @SYMTestPriority Critical |
|
354 @SYMTestActions Issue a request on the playback channel to create a shared chunk (i.e. using |
|
355 SetBufferChunkCreate()) with a buffer configuration containing multiple buffers |
|
356 each of size 32K bytes. Attempt to open the same shared chunk on the record channel |
|
357 (i.e. using SetBufferChunkOpen()). Then close the chunk. Repeat this same sequence |
|
358 using buffer configurations containing buffers of size 16K, 8K and 4K bytes. |
|
359 @SYMTestExpectedResults In every case the attempt to create and open the shared chunk should return KErrNone. |
|
360 @SYMREQ PREQ1073.4 */ |
|
361 |
|
362 Test.Next(_L("Test creating/opening a chunk, varying the size of the buffers ")); |
|
363 bufferConfig.iNumBuffers=4; |
|
364 |
|
365 for (i=1 ; i<=8 ; i*=2) |
|
366 { |
|
367 bufferConfig.iFlags=aBufferConfigFlags; |
|
368 bufferConfig.iBufferSizeInBytes=(0x8000/i); |
|
369 |
|
370 // Create the shared chunk on the play channel |
|
371 r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
372 CHECK_NOERROR(r); |
|
373 TxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
374 PrintBufferConf(bufferConfig,Test); |
|
375 |
|
376 // Open the same shared chunk on the record channel |
|
377 r=RxSoundDevice.SetBufferChunkOpen(bufferConfigBuf,chunk); |
|
378 CHECK_NOERROR(r); |
|
379 |
|
380 chunk.Close(); |
|
381 } |
|
382 |
|
383 // Try creating a shared chunk for the record channel specifying an illegal buffer size. |
|
384 if (RecordCapsBuf().iRequestMinSize) |
|
385 { |
|
386 Test.Next(_L("Test creating a chunk, with an illegal buffer size")); |
|
387 bufferConfig.iNumBuffers=1; |
|
388 bufferConfig.iBufferSizeInBytes=0x1001; // 4K + 1byte |
|
389 bufferConfig.iFlags=aBufferConfigFlags; |
|
390 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
391 CHECK(r==KErrArgument); |
|
392 chunk.Close(); |
|
393 } |
|
394 |
|
395 /** @SYMTestCaseID PBASE-T_SOUND_API-234 |
|
396 @SYMTestCaseDesc Setting the buffer configuration - specifying the buffer offsets. |
|
397 @SYMTestPriority Critical |
|
398 @SYMTestActions Issue a request on the record channel to create a shared chunk (i.e. |
|
399 using SetBufferChunkCreate()) with an buffer configuration containing multiple buffers |
|
400 where the offset of each buffer is specified by the client. Perform this test repeatedly |
|
401 with buffer offsets specified as follows:- |
|
402 1) Valid buffer offsets |
|
403 2) Offsets resulting on overlapping buffers |
|
404 3) Offsets which aren't aligned with the request alignment restrictions for the device (if it has any). |
|
405 @SYMTestExpectedResults 1) Setting the buffer configuration should return KErrNone. |
|
406 2) Setting the buffer configuration should fail with KErrArgument. |
|
407 3) Setting the buffer configuration should fail with KErrArgument. |
|
408 @SYMREQ PREQ1073.4 */ |
|
409 /* |
|
410 // ***** Setting the buffer configuration - specifying the buffer offsets is not supported. ***** |
|
411 |
|
412 Test.Next(_L("Test creating a chunk, specifying the buffer offsets")); |
|
413 TInt bufSize=0x2000; |
|
414 bufferConfig.iNumBuffers=8; |
|
415 bufferConfig.iBufferSizeInBytes=bufSize; |
|
416 bufferConfig.iBufferOffsetList[0]=0; |
|
417 bufferConfig.iBufferOffsetList[1]=bufSize; |
|
418 bufferConfig.iBufferOffsetList[2]=bufSize*4; |
|
419 bufferConfig.iBufferOffsetList[3]=bufSize*6; |
|
420 bufferConfig.iBufferOffsetList[4]=bufSize*7; |
|
421 bufferConfig.iBufferOffsetList[5]=bufSize*9; |
|
422 bufferConfig.iBufferOffsetList[6]=bufSize*10; |
|
423 bufferConfig.iBufferOffsetList[7]=bufSize*12; |
|
424 bufferConfig.iFlags=(aBufferConfigFlags|KScFlagBufOffsetListInUse); |
|
425 bufferConfigBuf.SetLength(sizeof(bufferConfig)); // Otherwise set shorter by previous GetBufferConfig(). |
|
426 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
427 CHECK_NOERROR(r); |
|
428 RxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
429 PrintBufferConf(bufferConfig,Test); |
|
430 chunk.Close(); |
|
431 |
|
432 Test.Next(_L("Test creating a chunk, with invalid buffer offsets specified")); |
|
433 |
|
434 // Firstly with 2nd buffer overlapping the 1st |
|
435 bufSize=0x2000; |
|
436 bufferConfig.iNumBuffers=3; |
|
437 bufferConfig.iBufferSizeInBytes=bufSize; |
|
438 bufferConfig.iBufferOffsetList[0]=0; |
|
439 bufferConfig.iBufferOffsetList[1]=bufSize/2; |
|
440 bufferConfig.iBufferOffsetList[2]=bufSize*2; |
|
441 bufferConfig.iFlags=(aBufferConfigFlags|KScFlagBufOffsetListInUse); |
|
442 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
443 CHECK(r==KErrArgument); |
|
444 chunk.Close(); |
|
445 |
|
446 // Now with offset of 3rd buffer not on a page boundary |
|
447 if (RecordCapsBuf().iRequestAlignment) |
|
448 { |
|
449 bufSize=0x2000; |
|
450 bufferConfig.iNumBuffers=3; |
|
451 bufferConfig.iBufferSizeInBytes=bufSize; |
|
452 bufferConfig.iBufferOffsetList[0]=0; |
|
453 bufferConfig.iBufferOffsetList[1]=bufSize; |
|
454 bufferConfig.iBufferOffsetList[2]=(bufSize*2)+1; |
|
455 bufferConfig.iFlags=(aBufferConfigFlags|KScFlagBufOffsetListInUse); |
|
456 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
457 CHECK(r==KErrArgument); |
|
458 chunk.Close(); |
|
459 } |
|
460 */ |
|
461 } |
|
462 |
|
463 LOCAL_C void TestPlay() |
|
464 { |
|
465 |
|
466 Test.Printf(_L("Testing play operation\r\n")); |
|
467 |
|
468 // Close and re-open the playback channel to reset the driver. |
|
469 TxSoundDevice.Close(); |
|
470 TInt r = TxSoundDevice.Open(KSoundScTxUnit0); |
|
471 CHECK_NOERROR(r); |
|
472 |
|
473 /** @SYMTestCaseID PBASE-T_SOUND_API-235 |
|
474 @SYMTestCaseDesc Play operation - playing without having set the buffer configuration. |
|
475 @SYMTestPriority Critical |
|
476 @SYMTestActions Issue a request on the playback channel to play some audio data before having set-up |
|
477 the buffer configuration. |
|
478 @SYMTestExpectedResults The play request should fail with KErrNotReady. |
|
479 @SYMREQ PREQ1073.4 */ |
|
480 |
|
481 Test.Next(_L("Test playing without setting buffer config")); |
|
482 TRequestStatus stat[2]; |
|
483 TxSoundDevice.PlayData(stat[0],0,0x2000); // 8K |
|
484 User::WaitForRequest(stat[0]); |
|
485 CHECK_EQUAL(stat[0].Int(),KErrNotReady); |
|
486 |
|
487 /** @SYMTestCaseID PBASE-T_SOUND_API-236 |
|
488 @SYMTestCaseDesc Play operation - playing without having set the audio configuration. |
|
489 @SYMTestPriority Critical |
|
490 @SYMTestActions Setup the buffer configuration on the playback channel and then issue a request to |
|
491 play audio data before having set-up the audio configuration |
|
492 @SYMTestExpectedResults The play request should complete with KErrNone - with the driver using its default |
|
493 audio configuration for the transfer. |
|
494 @SYMREQ PREQ1073.4 */ |
|
495 |
|
496 Test.Next(_L("Test playing without setting audio config")); |
|
497 |
|
498 // Read back the default play configuration |
|
499 TxSoundDevice.AudioFormat(PlayFormatBuf); |
|
500 TCurrentSoundFormatV02 playFormat=PlayFormatBuf(); |
|
501 PrintConfig(playFormat,Test); |
|
502 |
|
503 // Set the play buffer configuration. |
|
504 RChunk chunk; |
|
505 TInt bufSize=BytesPerSecond(PlayFormatBuf()); // Large enough to hold 1 second of data. |
|
506 bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver. |
|
507 TTestSharedChunkBufConfig bufferConfig; |
|
508 bufferConfig.iNumBuffers=1; |
|
509 bufferConfig.iBufferSizeInBytes=bufSize; |
|
510 bufferConfig.iFlags=0; |
|
511 TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig); |
|
512 r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
513 CHECK_NOERROR(r); |
|
514 TxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
515 PrintBufferConf(bufferConfig,Test); |
|
516 CHECK(bufferConfig.iBufferSizeInBytes==bufSize); |
|
517 |
|
518 // Start playing |
|
519 r=MakeSineTable(PlayFormatBuf()); |
|
520 CHECK_NOERROR(r); |
|
521 r=SetToneFrequency(660,PlayFormatBuf()); |
|
522 CHECK_NOERROR(r); |
|
523 TPtr8 ptr(chunk.Base()+bufferConfig.iBufferOffsetList[0],bufSize); |
|
524 WriteTone(ptr,PlayFormatBuf()); |
|
525 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample); |
|
526 User::WaitForRequest(stat[0]); |
|
527 CHECK_NOERROR(stat[0].Int()); |
|
528 |
|
529 /** @SYMTestCaseID PBASE-T_SOUND_API-239 |
|
530 @SYMTestCaseDesc Play operation - with invalid arguments. |
|
531 @SYMTestPriority Critical |
|
532 @SYMTestActions Setup the playback channel to commence playing audio data using a buffer configuration |
|
533 containing multiple buffers. Now issue a series of transfer requests to play data where the |
|
534 requests contain invalid request arguments as follows:- |
|
535 1) A request with a buffer offset before the start of the first buffer. |
|
536 2) A request with a buffer offset between buffers. |
|
537 3) A request with a length too large for a buffer. |
|
538 4) A request with a buffer offset that doesn't comply with the offset restrictions of |
|
539 the driver (i.e. TSoundFormatsSupportedV02:: iRequestAlignment). |
|
540 5) A request with a length that doesn't comply with the length restrictions of |
|
541 the driver (i.e. TSoundFormatsSupportedV02::iRequestMinSize). |
|
542 @SYMTestExpectedResults 1) The play request should fail with KErrArgument. |
|
543 2) The play request should fail with KErrArgument. |
|
544 3) The play request should fail with KErrArgument. |
|
545 4) The play request should fail with KErrArgument. |
|
546 5) The play request should fail with KErrArgument |
|
547 @SYMREQ PREQ1073.4 */ |
|
548 |
|
549 Test.Next(_L("Test playing with invalid arguments")); |
|
550 |
|
551 // With a buffer offset before the start of the buffer. |
|
552 TxSoundDevice.PlayData(stat[0],(bufferConfig.iBufferOffsetList[0]-0x100),bufSize,KSndFlagLastSample); |
|
553 User::WaitForRequest(stat[0]); |
|
554 CHECK_EQUAL(stat[0].Int(),KErrArgument); |
|
555 |
|
556 // With a buffer offset beyond the end of the buffer |
|
557 TxSoundDevice.PlayData(stat[0],(bufferConfig.iBufferOffsetList[0]+bufSize+0x100),bufSize,KSndFlagLastSample); |
|
558 User::WaitForRequest(stat[0]); |
|
559 CHECK_EQUAL(stat[0].Int(),KErrArgument); |
|
560 |
|
561 // With a length too large for the buffer |
|
562 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],(bufSize+0x100),KSndFlagLastSample); |
|
563 User::WaitForRequest(stat[0]); |
|
564 CHECK_EQUAL(stat[0].Int(),KErrArgument); |
|
565 |
|
566 // With a length that doesn't comply with the length restrictions of the driver |
|
567 if (PlayCapsBuf().iRequestMinSize) |
|
568 { |
|
569 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],(bufSize-1),KSndFlagLastSample); |
|
570 User::WaitForRequest(stat[0]); |
|
571 CHECK_EQUAL(stat[0].Int(),KErrArgument); |
|
572 } |
|
573 |
|
574 // With an offset that doesn't comply with the offset restrictions of the driver |
|
575 if (PlayCapsBuf().iRequestAlignment) |
|
576 { |
|
577 TInt ln=bufSize/2; |
|
578 if (PlayCapsBuf().iRequestMinSize) |
|
579 ln&=~(PlayCapsBuf().iRequestMinSize-1); // Keep the buffer length valid for the driver. |
|
580 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0]+1,ln,KSndFlagLastSample); |
|
581 User::WaitForRequest(stat[0]); |
|
582 CHECK_EQUAL(stat[0].Int(),KErrArgument); |
|
583 } |
|
584 |
|
585 /** @SYMTestCaseID PBASE-T_SOUND_API-242 |
|
586 @SYMTestCaseDesc Play operation - play underflow detection. |
|
587 @SYMTestPriority Critical |
|
588 @SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer |
|
589 configuration. Issue a single request to play audio data from one of the buffers |
|
590 (without supplying the KSndFlagLastSample flag) and wait for the request to complete. |
|
591 @SYMTestExpectedResults The driver should successfully play the audio data supplied but the request should |
|
592 return the error value: KErrUnderflow. |
|
593 @SYMREQ PREQ1073.4 */ |
|
594 |
|
595 Test.Next(_L("Test play underflow detection")); |
|
596 |
|
597 // Now set the audio configuration to a known state. |
|
598 if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM) |
|
599 PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM; |
|
600 if (PlayCapsBuf().iRates&KSoundRate16000Hz) |
|
601 PlayFormatBuf().iRate = ESoundRate16000Hz; |
|
602 if (PlayCapsBuf().iChannels&KSoundStereoChannel) |
|
603 PlayFormatBuf().iChannels = 2; |
|
604 PrintConfig(PlayFormatBuf(),Test); |
|
605 r=TxSoundDevice.SetAudioFormat(PlayFormatBuf); |
|
606 CHECK_NOERROR(r); |
|
607 |
|
608 // Reset the play buffer configuration to correspond to the audio configuration. |
|
609 bufSize=BytesPerSecond(PlayFormatBuf()); // Large enough to hold 1 second of data (64K) |
|
610 bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver. |
|
611 bufferConfig.iNumBuffers=1; |
|
612 bufferConfig.iBufferSizeInBytes=bufSize; |
|
613 bufferConfig.iFlags=0; |
|
614 r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
615 CHECK_NOERROR(r); |
|
616 TxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
617 PrintBufferConf(bufferConfig,Test); |
|
618 CHECK(bufferConfig.iBufferSizeInBytes==bufSize); |
|
619 |
|
620 // Start playing |
|
621 r=MakeSineTable(PlayFormatBuf()); |
|
622 CHECK_NOERROR(r); |
|
623 r=SetToneFrequency(660,PlayFormatBuf()); |
|
624 CHECK_NOERROR(r); |
|
625 ptr.Set(chunk.Base()+bufferConfig.iBufferOffsetList[0],bufSize,bufSize); |
|
626 WriteTone(ptr,PlayFormatBuf()); |
|
627 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize); |
|
628 User::WaitForRequest(stat[0]); |
|
629 CHECK_EQUAL(stat[0].Int(),KErrUnderflow); |
|
630 |
|
631 /** @SYMTestCaseID PBASE-T_SOUND_API-243 |
|
632 @SYMTestCaseDesc Play operation - playing multiple transfers from a single buffer. |
|
633 @SYMTestPriority Critical |
|
634 @SYMTestActions Setup the audio configuration on the playback channel and setup the buffer configuration |
|
635 so the shared chunk contains just a single large buffer. Issue a pair of requests to play |
|
636 audio data from the buffer (marking the last with the KSndFlagLastSample flag) and wait |
|
637 for the requests to complete. |
|
638 @SYMTestExpectedResults The driver should successfully play the audio data supplied and both requests should |
|
639 complete with KErrNone. |
|
640 @SYMREQ PREQ1073.4 */ |
|
641 |
|
642 Test.Next(_L("Test playing multiple transfers from a single buffer")); |
|
643 |
|
644 // Start playing |
|
645 TInt len=bufSize/2; |
|
646 if (PlayCapsBuf().iRequestMinSize) |
|
647 len&=~(PlayCapsBuf().iRequestMinSize-1); // Keep the buffer length valid for the driver. |
|
648 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],len); |
|
649 TxSoundDevice.PlayData(stat[1],(bufferConfig.iBufferOffsetList[0]+len),len,KSndFlagLastSample); |
|
650 User::WaitForRequest(stat[0]); |
|
651 CHECK_NOERROR(stat[0].Int()); |
|
652 User::WaitForRequest(stat[1]); |
|
653 CHECK_NOERROR(stat[1].Int()); |
|
654 |
|
655 /** @SYMTestCaseID PBASE-T_SOUND_API-244 |
|
656 @SYMTestCaseDesc Play operation - tracking the count of bytes transferred. |
|
657 @SYMTestPriority Critical |
|
658 @SYMTestActions Setup the playback channel for playing audio data. |
|
659 1) Reset the channel's count of bytes transferred and read back the count. |
|
660 2) Issue a play request of known length and wait for it to complete. Now read the |
|
661 count of bytes transferred. |
|
662 3) Reset the channel's count of bytes transferred and read back the count. |
|
663 @SYMTestExpectedResults 1) The count of bytes transferred should equal zero. |
|
664 2) The count of bytes transferred should equal the length of the play request. |
|
665 3) The count of bytes transferred should equal zero. |
|
666 @SYMREQ PREQ1073.4 */ |
|
667 |
|
668 Test.Next(_L("Test tracking the number of bytes played")); |
|
669 TxSoundDevice.ResetBytesTransferred(); |
|
670 TInt bytesPlayed=TxSoundDevice.BytesTransferred(); |
|
671 CHECK(bytesPlayed==0); |
|
672 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],len,KSndFlagLastSample); |
|
673 User::WaitForRequest(stat[0]); |
|
674 CHECK_NOERROR(stat[0].Int()); |
|
675 bytesPlayed=TxSoundDevice.BytesTransferred(); |
|
676 CHECK(bytesPlayed==len); |
|
677 TxSoundDevice.ResetBytesTransferred(); |
|
678 bytesPlayed=TxSoundDevice.BytesTransferred(); |
|
679 CHECK(bytesPlayed==0); |
|
680 |
|
681 /** @SYMTestCaseID PBASE-T_SOUND_API-246 |
|
682 @SYMTestCaseDesc Play operation - testing the driver's handling of PDD play errors. |
|
683 @SYMTestPriority Critical |
|
684 @SYMTestActions Setup the playback channel for playing audio data. Using the CustomConfig() test mode |
|
685 supported by the driver, induce the following errors returned from the driver PDD back |
|
686 to the LDD:- |
|
687 1) Induce a KErrTimedOut error at the start of the transfer and then issue a play request. |
|
688 2) Induce a KErrTimedOut error once transfer has commenced and then issue a play request. |
|
689 Once this completes, issue a further play request. |
|
690 @SYMTestExpectedResults 1) The play request should fail immediately with KErrTimedOut (with no audible output being |
|
691 heard). |
|
692 2) The driver should output a short section of audible data before the first play request |
|
693 fails with KErrTimedOut. However, the driver should recover from this and the second |
|
694 play request should complete with KErrNone. |
|
695 @SYMREQ PREQ1073.4 */ |
|
696 |
|
697 #ifdef _DEBUG |
|
698 Test.Next(_L("Test the driver's handling of PDD play errors")); |
|
699 |
|
700 // First induce an error at the start of the transfer |
|
701 // Use an LDD test mode which induces KErrTimedOut at the start of the transfer. |
|
702 r=TxSoundDevice.CustomConfig(KSndCustom_ForceStartTransferError); |
|
703 CHECK_NOERROR(r); |
|
704 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample); |
|
705 User::WaitForRequest(stat[0]); |
|
706 CHECK_EQUAL(stat[0].Int(),KErrTimedOut); |
|
707 |
|
708 // Now induce an error once transfer has commenced |
|
709 // Use an LDD test mode which induces KErrTimedOut once transfer has commenced. |
|
710 r=TxSoundDevice.CustomConfig(KSndCustom_ForceTransferDataError); |
|
711 CHECK_NOERROR(r); |
|
712 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample); |
|
713 User::WaitForRequest(stat[0]); |
|
714 CHECK_EQUAL(stat[0].Int(),KErrTimedOut); |
|
715 |
|
716 // Check that the driver recovers |
|
717 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample); |
|
718 User::WaitForRequest(stat[0]); |
|
719 CHECK_NOERROR(stat[0].Int()); |
|
720 #endif |
|
721 |
|
722 /** @SYMTestCaseID PBASE-T_SOUND_API-247 |
|
723 @SYMTestCaseDesc Play operation - closing the channel cancels any play requests. |
|
724 @SYMTestPriority Critical |
|
725 @SYMTestActions Setup the playback channel for playing audio data. Issue a play request and |
|
726 while this is outstanding, close the playback channel. |
|
727 @SYMTestExpectedResults The outstanding request should complete with KErrCancel. |
|
728 @SYMREQ PREQ1073.4 */ |
|
729 |
|
730 Test.Next(_L("Test that closing the channel cancels a play request")); |
|
731 TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],len,KSndFlagLastSample); |
|
732 CHECK(stat[0]==KRequestPending); |
|
733 TxSoundDevice.Close(); |
|
734 User::WaitForRequest(stat[0]); |
|
735 CHECK(stat[0]==KErrCancel); |
|
736 |
|
737 Test.Next(_L("Re-open the channel")); |
|
738 r = TxSoundDevice.Open(KSoundScTxUnit0); |
|
739 CHECK_NOERROR(r); |
|
740 |
|
741 chunk.Close(); |
|
742 } |
|
743 |
|
744 LOCAL_C void TestRecord() |
|
745 { |
|
746 |
|
747 Test.Printf(_L("Testing record operation\r\n")); |
|
748 |
|
749 // Close and re-open the record channel to reset the driver. |
|
750 RxSoundDevice.Close(); |
|
751 TInt r = RxSoundDevice.Open(KSoundScRxUnit0); |
|
752 CHECK_NOERROR(r); |
|
753 |
|
754 /** @SYMTestCaseID PBASE-T_SOUND_API-251 |
|
755 @SYMTestCaseDesc Record operation - recording without having set the buffer configuration. |
|
756 @SYMTestPriority Critical |
|
757 @SYMTestActions Issue a request on the record channel to record some audio data before |
|
758 having set-up the buffer configuration. |
|
759 @SYMTestExpectedResults The record request should fail with KErrNotReady. |
|
760 @SYMREQ PREQ1073.4 */ |
|
761 |
|
762 Test.Next(_L("Test recording without setting buffer config")); |
|
763 |
|
764 TRequestStatus stat; |
|
765 TInt length; |
|
766 RxSoundDevice.RecordData(stat,length); |
|
767 User::WaitForRequest(stat); |
|
768 TInt retOffset=stat.Int(); |
|
769 CHECK_EQUAL(retOffset,KErrNotReady); |
|
770 |
|
771 // Test releasing a buffer without setting buffer config |
|
772 r=RxSoundDevice.ReleaseBuffer(0); |
|
773 CHECK(r==KErrNotReady); |
|
774 |
|
775 /** @SYMTestCaseID PBASE-T_SOUND_API-252 |
|
776 @SYMTestCaseDesc Record operation - recording without having set the audio configuration. |
|
777 @SYMTestPriority Critical |
|
778 @SYMTestActions Setup the buffer configuration on the record channel. |
|
779 1) Issue a request to record a buffer of audio data before having set-up the audio |
|
780 configuration. |
|
781 2) Release the buffer. |
|
782 @SYMTestExpectedResults 1) The record request should complete with KErrNone - with the driver using its |
|
783 default audio configuration for the transfer. |
|
784 2) The request to release the buffer should return KErrNone |
|
785 @SYMREQ PREQ1073.4 */ |
|
786 |
|
787 Test.Next(_L("Test recording without setting audio config")); |
|
788 |
|
789 // Read back the default record configuration |
|
790 RxSoundDevice.AudioFormat(RecordFormatBuf); |
|
791 TCurrentSoundFormatV02 recordFormat=RecordFormatBuf(); |
|
792 PrintConfig(recordFormat,Test); |
|
793 |
|
794 // Set the record buffer configuration. |
|
795 RChunk chunk; |
|
796 TInt bufSize=BytesPerSecond(RecordFormatBuf()); // Large enough to hold 1 second of data. |
|
797 bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver. |
|
798 TTestSharedChunkBufConfig bufferConfig; |
|
799 bufferConfig.iNumBuffers=3; |
|
800 bufferConfig.iBufferSizeInBytes=bufSize; |
|
801 bufferConfig.iFlags=0; |
|
802 TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig); |
|
803 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
804 CHECK_NOERROR(r); |
|
805 RxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
806 PrintBufferConf(bufferConfig,Test); |
|
807 CHECK(bufferConfig.iBufferSizeInBytes==bufSize); |
|
808 |
|
809 // Start recording |
|
810 RxSoundDevice.SetVolume(KSoundMaxVolume); |
|
811 RxSoundDevice.RecordData(stat,length); // Start recording here |
|
812 User::WaitForRequest(stat); |
|
813 retOffset=stat.Int(); |
|
814 CHECK(retOffset>=0); |
|
815 CHECK(length==bufSize); |
|
816 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
817 CHECK_NOERROR(r); |
|
818 |
|
819 /** @SYMTestCaseID PBASE-T_SOUND_API-255 |
|
820 @SYMTestCaseDesc Record operation - invalid attempts to release a record buffer. |
|
821 @SYMTestPriority Critical |
|
822 @SYMTestActions Setup the record channel to record audio data. Issue a request to record a buffer of audio data |
|
823 and then release the buffer. |
|
824 1) Request to release the same buffer just released (without having re-claimed it with a |
|
825 further record request). |
|
826 2) Release a further buffer - specifying an illegal buffer offset for the buffer. |
|
827 3) Stop the driver from recording (using CancelRecordData()). Now release a buffer while |
|
828 recording is disabled. |
|
829 @SYMTestExpectedResults 1) The request to release the buffer should fail with KErrNotFound. |
|
830 2) The request to release the buffer should fail with KErrNotFound. |
|
831 3) The request to release the buffer should fail with KErrNotFound. |
|
832 @SYMREQ PREQ1073.4 */ |
|
833 |
|
834 // Test releasing a buffer twice |
|
835 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
836 CHECK(r==KErrNotFound); |
|
837 |
|
838 // Test releasing an invalid buffer offset |
|
839 r=RxSoundDevice.ReleaseBuffer(0); |
|
840 CHECK(r==KErrNotFound); |
|
841 |
|
842 // Third test case for PBASE-T_SOUND_API-255 is performed later in this function. |
|
843 |
|
844 /** @SYMTestCaseID PBASE-T_SOUND_API-256 |
|
845 @SYMTestCaseDesc Record operation - record overflow detection. |
|
846 @SYMTestPriority Critical |
|
847 @SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration |
|
848 so the shared chunk contains three record buffers. |
|
849 1) Issue a request to record a buffer of audio data (to start the driver recording). |
|
850 2) When the request completes, release the buffer immediately. |
|
851 3) Wait just over 2 buffer periods (i.e. the time it takes for the driver to fill 2 record |
|
852 buffers) and then issue a further record request. |
|
853 4) To test that the driver recovers from the overflow situation, immediately issue a further |
|
854 record request. |
|
855 @SYMTestExpectedResults 1) The record request should complete with KErrNone. |
|
856 2) The request to release the buffer should return KErrNone. |
|
857 3) The record request should fail with KErrOverflow. |
|
858 4) The record request should complete with KErrNone. |
|
859 @SYMREQ PREQ1073.4 */ |
|
860 |
|
861 Test.Next(_L("Test for record overflow")); |
|
862 |
|
863 // Now set the audio configuration to a known state. |
|
864 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
|
865 |
|
866 RxSoundDevice.AudioFormat(RecordFormatBuf); // Read back the current setting which must be valid. |
|
867 if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM) |
|
868 RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM; |
|
869 if (RecordCapsBuf().iChannels&KSoundStereoChannel) |
|
870 RecordFormatBuf().iChannels = 2; |
|
871 |
|
872 // find first supported rate and set the the audio configuration to use it |
|
873 for (TInt i=0 ; i <= (TInt)ESoundRate48000Hz ; i++) |
|
874 { |
|
875 RecordFormatBuf().iRate = (TSoundRate)i; |
|
876 r = RxSoundDevice.SetAudioFormat(RecordFormatBuf); |
|
877 if (RecordCapsBuf().iRates & (1<<i)) |
|
878 { |
|
879 CHECK_NOERROR(r); // Caps reports it is supported |
|
880 break; |
|
881 } |
|
882 } |
|
883 |
|
884 PrintConfig(RecordFormatBuf(),Test); |
|
885 |
|
886 // Reset the record buffer configuration to correspond to the audio configuration. |
|
887 bufSize=BytesPerSecond(RecordFormatBuf())/2; // Large enough to hold 0.5 seconds of data (64K) |
|
888 bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver. |
|
889 bufferConfig.iNumBuffers=3; |
|
890 bufferConfig.iBufferSizeInBytes=bufSize; |
|
891 bufferConfig.iFlags=0; |
|
892 r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk); |
|
893 CHECK_NOERROR(r); |
|
894 RxSoundDevice.GetBufferConfig(bufferConfigBuf); |
|
895 PrintBufferConf(bufferConfig,Test); |
|
896 CHECK(bufferConfig.iBufferSizeInBytes==bufSize); |
|
897 |
|
898 // Test releasing a buffer before we have started recording |
|
899 r=RxSoundDevice.ReleaseBuffer(bufferConfig.iBufferOffsetList[0]); |
|
900 CHECK(r==KErrNotFound); |
|
901 |
|
902 RxSoundDevice.RecordData(stat,length); // Start recording here |
|
903 User::WaitForRequest(stat); |
|
904 retOffset=stat.Int(); |
|
905 CHECK(retOffset>=0); |
|
906 CHECK(length==bufSize); |
|
907 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
908 CHECK_NOERROR(r); |
|
909 |
|
910 User::After(1100000); // Wait 2 buffer periods (1.1 seconds) for data overflow. |
|
911 |
|
912 RxSoundDevice.RecordData(stat,length); |
|
913 User::WaitForRequest(stat); |
|
914 retOffset=stat.Int(); |
|
915 CHECK(retOffset==KErrOverflow); |
|
916 |
|
917 Test.Next(_L("Test that the driver recovers from overflow")); |
|
918 |
|
919 RxSoundDevice.RecordData(stat,length); |
|
920 User::WaitForRequest(stat); |
|
921 retOffset=stat.Int(); |
|
922 CHECK(retOffset>=0); |
|
923 CHECK(length==bufSize); |
|
924 |
|
925 /** @SYMTestCaseID PBASE-T_SOUND_API-257 |
|
926 @SYMTestCaseDesc Record operation - when client is too slow releasing buffers. |
|
927 @SYMTestPriority Critical |
|
928 @SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration |
|
929 so the shared chunk contains three record buffers. Issue a request to record a buffer of |
|
930 audio data (to start the driver recording). When this request completes, issue a further |
|
931 record request without releasing the first buffer. |
|
932 @SYMTestExpectedResults The second record request should fail with KErrInUse. |
|
933 @SYMREQ PREQ1073.4 */ |
|
934 |
|
935 Test.Next(_L("Test when client is too slow releasing buffers")); |
|
936 |
|
937 RxSoundDevice.RecordData(stat,length); |
|
938 User::WaitForRequest(stat); |
|
939 TInt retOffset1=stat.Int(); |
|
940 CHECK(retOffset1==KErrInUse); |
|
941 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
942 CHECK_NOERROR(r); |
|
943 |
|
944 /** @SYMTestCaseID PBASE-T_SOUND_API-258 |
|
945 @SYMTestCaseDesc Record operation - tracking the count of bytes transferred. |
|
946 @SYMTestPriority Critical |
|
947 @SYMTestActions Setup the record channel for recording audio data. |
|
948 1) Reset the channel's count of bytes transferred and read back the count. |
|
949 2) Issue a record request (to start the driver recording) and wait for it to complete. Immediately read the count of bytes transferred. |
|
950 3) Reset the channel's count of bytes transferred and read back the count |
|
951 @SYMTestExpectedResults 1) The count of bytes transferred should equal zero. |
|
952 2) The count of bytes transferred should equal the size of a record buffer. |
|
953 3) The count of bytes transferred should equal zero. |
|
954 @SYMREQ PREQ1073.4 */ |
|
955 |
|
956 Test.Next(_L("Test tracking the number of bytes recorded")); |
|
957 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
|
958 RxSoundDevice.ResetBytesTransferred(); |
|
959 TInt bytesRecorded=RxSoundDevice.BytesTransferred(); |
|
960 CHECK(bytesRecorded==0); |
|
961 RxSoundDevice.RecordData(stat,length); // Re-start recording here |
|
962 User::WaitForRequest(stat); |
|
963 |
|
964 // Quickly check the number of bytes recorded |
|
965 bytesRecorded=RxSoundDevice.BytesTransferred(); |
|
966 CHECK(bytesRecorded==bufSize); |
|
967 |
|
968 // Now check the request was successful and release the buffer |
|
969 retOffset=stat.Int(); |
|
970 CHECK(retOffset>=0); |
|
971 CHECK(length==bufSize); |
|
972 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
973 CHECK_NOERROR(r); |
|
974 |
|
975 RxSoundDevice.ResetBytesTransferred(); |
|
976 bytesRecorded=RxSoundDevice.BytesTransferred(); |
|
977 CHECK(bytesRecorded==0); |
|
978 |
|
979 /** @SYMTestCaseID PBASE-T_SOUND_API-260 |
|
980 @SYMTestCaseDesc Record operation - testing the driver's handling of PDD record errors. |
|
981 @SYMTestPriority Critical |
|
982 @SYMTestActions Setup the record channel for recording. Using the CustomConfig() test mode supported by the driver, induce |
|
983 the following errors returned from the driver PDD back to the LDD:- |
|
984 1) Induce a KErrTimedOut error at the start of the transfer. Then, issue a record request to |
|
985 start the driver recording. Once this completes, stop the channel from recording. |
|
986 2) Induce a KErrTimedOut error once transfer has commenced. Then, issue a record request to |
|
987 re-start the driver recording. Once this completes, issue a further record request. |
|
988 @SYMTestExpectedResults 1) The record request should fail immediately with KErrTimedOut. |
|
989 2) The first record request should soon fail with KErrTimedOut. However, the driver should |
|
990 recover from this and the subsequent record request should complete with KErrNone. |
|
991 @SYMREQ PREQ1073.4 */ |
|
992 |
|
993 #ifdef _DEBUG |
|
994 Test.Next(_L("Test the driver's handling of PDD record errors")); |
|
995 |
|
996 Test.Printf(_L("Induce an error at the start of the transfer.\r\n")); |
|
997 // Use an LDD test mode which induces KErrTimedOut at the start of the transfer. |
|
998 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
|
999 r=RxSoundDevice.CustomConfig(KSndCustom_ForceStartTransferError); |
|
1000 CHECK_NOERROR(r); |
|
1001 RxSoundDevice.RecordData(stat,length); // Re-start recording here |
|
1002 User::WaitForRequest(stat); |
|
1003 retOffset=stat.Int(); |
|
1004 CHECK(retOffset==KErrTimedOut); |
|
1005 RxSoundDevice.CancelRecordData(); // Stop the driver from recording. |
|
1006 |
|
1007 Test.Printf(_L("Induce an error once transfer has commenced.\r\n")); |
|
1008 // Use an LDD test mode which induces KErrTimedOut once transfer has commenced. |
|
1009 r=RxSoundDevice.CustomConfig(KSndCustom_ForceTransferDataError); |
|
1010 CHECK_NOERROR(r); |
|
1011 RxSoundDevice.RecordData(stat,length); // Re-start recording here |
|
1012 User::WaitForRequest(stat); |
|
1013 retOffset=stat.Int(); |
|
1014 CHECK(retOffset==KErrTimedOut); |
|
1015 |
|
1016 Test.Printf(_L("Check that the driver recovers.\r\n")); |
|
1017 RxSoundDevice.RecordData(stat,length); |
|
1018 User::WaitForRequest(stat); |
|
1019 retOffset=stat.Int(); |
|
1020 CHECK(retOffset>=0); |
|
1021 CHECK(length==bufSize); |
|
1022 r=RxSoundDevice.ReleaseBuffer(retOffset); |
|
1023 CHECK_NOERROR(r); |
|
1024 |
|
1025 /* Test disabled |
|
1026 Test.Printf(_L("Induce LDD to be slow servicing transfer completes from PDD.\r\n")); |
|
1027 r=RxSoundDevice.CustomConfig(KSndCustom_ForceTransferTimeout); |
|
1028 CHECK_NOERROR(r); |
|
1029 RxSoundDevice.RecordData(stat,length); |
|
1030 User::WaitForRequest(stat); |
|
1031 retOffset=stat.Int(); |
|
1032 Test.Printf(_L("Driver returned %d.\r\n"),retOffset); */ |
|
1033 #endif |
|
1034 |
|
1035 /** @SYMTestCaseID PBASE-T_SOUND_API-261 |
|
1036 @SYMTestCaseDesc Record operation - closing the channel cancels any record requests. |
|
1037 @SYMTestPriority Critical |
|
1038 @SYMTestActions Start the record channel for recording audio data. Issue a record request and while this is |
|
1039 outstanding, close the record channel |
|
1040 @SYMTestExpectedResults The outstanding request should complete with KErrCancel. |
|
1041 @SYMREQ PREQ1073.4 */ |
|
1042 |
|
1043 Test.Next(_L("Test that closing the channel cancels a play request")); |
|
1044 RxSoundDevice.RecordData(stat,length); |
|
1045 CHECK(stat==KRequestPending); |
|
1046 RxSoundDevice.Close(); |
|
1047 User::WaitForRequest(stat); |
|
1048 CHECK(stat==KErrCancel); |
|
1049 |
|
1050 Test.Next(_L("Re-open the channel")); |
|
1051 r = RxSoundDevice.Open(KSoundScRxUnit0); |
|
1052 CHECK_NOERROR(r); |
|
1053 |
|
1054 chunk.Close(); |
|
1055 } |
|
1056 |
|
1057 #ifdef _DEBUG |
|
1058 LOCAL_C void TestChangeOfHwConfigNotifier() |
|
1059 { |
|
1060 |
|
1061 Test.Printf(_L("Testing the change of h/w config notifier\r\n")); |
|
1062 |
|
1063 // If support for the notifier is not supported on this platform, use a debug custom config command to force |
|
1064 // support for the notifier. |
|
1065 TInt r; |
|
1066 if (!PlayCapsBuf().iHwConfigNotificationSupport) |
|
1067 { |
|
1068 r=TxSoundDevice.CustomConfig(KSndCustom_ForceHwConfigNotifSupported); |
|
1069 CHECK_NOERROR(r); |
|
1070 } |
|
1071 |
|
1072 /** @SYMTestCaseID PBASE-T_SOUND_API-264 |
|
1073 @SYMTestCaseDesc Change of h/w config. notifier - receiving notification. |
|
1074 @SYMTestPriority Critical |
|
1075 @SYMTestActions 1) Register for notification of a change in the hardware configuration of the device on |
|
1076 either the record or playback channel. Using the CustomConfig() test mode supported by the |
|
1077 driver, trigger the notifier - signalling that the headset is not present. |
|
1078 2) Re-register for notification of a change in the hardware configuration on the same channel. |
|
1079 Again using the CustomConfig() test mode, trigger the notifier - this time signalling that the |
|
1080 headset is present. |
|
1081 @SYMTestExpectedResults 1) The outstanding request for notification should complete with KErrNone and the status of |
|
1082 the bolean aHeadsetPresent should be false. |
|
1083 2) The outstanding request for notification should complete with KErrNone and the status of |
|
1084 the bolean aHeadsetPresent should be true. |
|
1085 @SYMREQ PREQ1073.4 */ |
|
1086 |
|
1087 // Register for notification of a change in the hardware configuration of the device. |
|
1088 TRequestStatus stat; |
|
1089 TBool headsetPresent=ETrue; |
|
1090 TxSoundDevice.NotifyChangeOfHwConfig(stat,headsetPresent); |
|
1091 CHECK(stat==KRequestPending); |
|
1092 |
|
1093 Test.Next(_L("Trigger the notifier")); |
|
1094 // Use another debug custom config command to trigger the notifier. |
|
1095 r=TxSoundDevice.CustomConfig(KSndCustom_CompleteChangeOfHwConfig,(TAny*)0x00); // Signal headset not present. |
|
1096 CHECK_NOERROR(r); |
|
1097 User::WaitForRequest(stat); |
|
1098 CHECK_NOERROR(stat.Int()); |
|
1099 CHECK(!headsetPresent); |
|
1100 |
|
1101 Test.Next(_L("Trigger the notifier again")); |
|
1102 TxSoundDevice.NotifyChangeOfHwConfig(stat,headsetPresent); |
|
1103 CHECK(stat==KRequestPending); |
|
1104 r=TxSoundDevice.CustomConfig(KSndCustom_CompleteChangeOfHwConfig,(TAny*)0x01); // Signal headset is present. |
|
1105 CHECK_NOERROR(r); |
|
1106 User::WaitForRequest(stat); |
|
1107 CHECK_NOERROR(stat.Int()); |
|
1108 CHECK(headsetPresent); |
|
1109 |
|
1110 Test.Next(_L("Test cancelling the notifier")); |
|
1111 TxSoundDevice.NotifyChangeOfHwConfig(stat,headsetPresent); |
|
1112 CHECK(stat==KRequestPending); |
|
1113 TxSoundDevice.CancelNotifyChangeOfHwConfig(); |
|
1114 User::WaitForRequest(stat); |
|
1115 CHECK(stat==KErrCancel); |
|
1116 |
|
1117 /** @SYMTestCaseID PBASE-T_SOUND_API-265 |
|
1118 @SYMTestCaseDesc Change of h/w config. notifier - receiving notification. |
|
1119 @SYMTestPriority Critical |
|
1120 @SYMTestActions 1) Register for notification of a change in the hardware configuration of the device on |
|
1121 either the record or playback channel. Using the CustomConfig() test mode supported by the |
|
1122 driver, trigger the notifier - signalling that the headset is not present. |
|
1123 2) Re-register for notification of a change in the hardware configuration on the same channel. |
|
1124 Again using the CustomConfig() test mode, trigger the notifier - this time signalling that the |
|
1125 headset is present. |
|
1126 @SYMTestExpectedResults 1) The outstanding request for notification should complete with KErrNone and the status of |
|
1127 the bolean aHeadsetPresent should be false. |
|
1128 2) The outstanding request for notification should complete with KErrNone and the status of |
|
1129 the bolean aHeadsetPresent should be true. |
|
1130 @SYMREQ PREQ1073.4 */ |
|
1131 |
|
1132 Test.Next(_L("Test that closing the channel cancels the notifier")); |
|
1133 TxSoundDevice.NotifyChangeOfHwConfig(stat,headsetPresent); |
|
1134 CHECK(stat==KRequestPending); |
|
1135 TxSoundDevice.Close(); |
|
1136 User::WaitForRequest(stat); |
|
1137 CHECK(stat==KErrCancel); |
|
1138 |
|
1139 Test.Next(_L("Re-open the channel")); |
|
1140 r = TxSoundDevice.Open(KSoundScTxUnit0); |
|
1141 CHECK_NOERROR(r); |
|
1142 } |
|
1143 #endif |
|
1144 |
|
1145 LOCAL_C void TestUnloadDrivers() |
|
1146 { |
|
1147 /** @SYMTestCaseID PBASE-T_SOUND_API-221 |
|
1148 @SYMTestCaseDesc Un-installing the LDD |
|
1149 @SYMTestPriority Critical |
|
1150 @SYMTestActions Attempt to un-install the LDD (using User::FreeLogicalDevice()). |
|
1151 @SYMTestExpectedResults KErrNone - LDD unloads successfully |
|
1152 @SYMREQ PREQ1073.4 */ |
|
1153 |
|
1154 TInt r=User::FreeLogicalDevice(KDevSoundScName); |
|
1155 Test.Printf(_L("Unloading %S.LDD - %d\r\n"),&KDevSoundScName,r); |
|
1156 CHECK_NOERROR(r); |
|
1157 |
|
1158 /** @SYMTestCaseID PBASE-T_SOUND_API-222 |
|
1159 @SYMTestCaseDesc Un-installing the PDD |
|
1160 @SYMTestPriority Critical |
|
1161 @SYMTestActions Attempt to un-install the PDD (using User::FreePhysicalDevice()). |
|
1162 @SYMTestExpectedResults KErrNone - PDD unloads successfully |
|
1163 @SYMREQ PREQ1073.4 */ |
|
1164 |
|
1165 TName pddName(KDevSoundScName); |
|
1166 _LIT(KPddWildcardExtension,".*"); |
|
1167 pddName.Append(KPddWildcardExtension); |
|
1168 TFindPhysicalDevice findPD(pddName); |
|
1169 TFullName findResult; |
|
1170 r=findPD.Next(findResult); |
|
1171 while (r==KErrNone) |
|
1172 { |
|
1173 r=User::FreePhysicalDevice(findResult); |
|
1174 Test.Printf(_L("Unloading %S.PDD - %d\r\n"),&findResult,r); |
|
1175 CHECK_NOERROR(r); |
|
1176 findPD.Find(pddName); // Reset the find handle now that we have deleted something from the container. |
|
1177 r=findPD.Next(findResult); |
|
1178 } |
|
1179 } |
|
1180 |
|
1181 /** |
|
1182 Invoke the helper executable, tell it what unit to open RSoundSc for. |
|
1183 |
|
1184 @param aUnit Parameter to supply to RSoundSc ie. KSoundScTxUnit0, KSoundScRxUnit0 |
|
1185 @param aExpectedError The expected return code from RSoundSc::Open |
|
1186 */ |
|
1187 static void RunHelper(TInt aUnit, TInt aExpectedError) |
|
1188 { |
|
1189 TInt r; |
|
1190 |
|
1191 RProcess ph; |
|
1192 r = ph.Create(KHelperExe, KNullDesC); |
|
1193 CHECK_NOERROR(r); |
|
1194 r = ph.SetParameter(KSlot, aUnit); |
|
1195 CHECK_NOERROR(r); |
|
1196 |
|
1197 TRequestStatus rsh; |
|
1198 ph.Logon(rsh); |
|
1199 Test(rsh == KRequestPending); |
|
1200 ph.Resume(); |
|
1201 User::WaitForRequest(rsh); |
|
1202 |
|
1203 // process has died so check the panic category and reason match the expected values |
|
1204 CHECK_EQUAL(ph.ExitType(), EExitPanic); |
|
1205 Test(ph.ExitCategory()==KSoundAPICaps,__LINE__,(const TText*)__FILE__); |
|
1206 CHECK_EQUAL(ph.ExitReason(), aExpectedError); |
|
1207 |
|
1208 ph.Close(); |
|
1209 } |
|
1210 |
|
1211 /** |
|
1212 Delete the copy of the helper exe which was created with altered capabilities |
|
1213 */ |
|
1214 static TInt DeleteHelper() |
|
1215 { |
|
1216 RFs fs; |
|
1217 TInt r = fs.Connect(); |
|
1218 CHECK_NOERROR(r); |
|
1219 TFileName fileName(KSysBin); |
|
1220 fileName.Append(KPathDelimiter); |
|
1221 fileName+=KHelperExe; |
|
1222 //delete modified version of helper exe |
|
1223 r = fs.Delete(fileName); |
|
1224 fs.Close(); |
|
1225 return r; |
|
1226 } |
|
1227 |
|
1228 /** |
|
1229 Use setcap.exe to create a copy of the helper executable, t_sound_api_helper.exe |
|
1230 called t_sound_api_helper_caps.exe with the supplied capabilities. |
|
1231 |
|
1232 @param aCaps A bitmask of capabilities to assign to helper exe. |
|
1233 */ |
|
1234 static void SetHelperCaps(TUint32 aCaps) |
|
1235 { |
|
1236 TInt r; |
|
1237 _LIT(KCommandLineArgsFormat, "%S %08x %S\\%S"); |
|
1238 TBuf<128> cmdLine; |
|
1239 cmdLine.Format(KCommandLineArgsFormat, &KHelperExeBase, aCaps, &KSysBin, &KHelperExe); |
|
1240 |
|
1241 RProcess p; |
|
1242 r = p.Create(_L("setcap.exe"), cmdLine); |
|
1243 CHECK_NOERROR(r); |
|
1244 |
|
1245 TRequestStatus rs; |
|
1246 p.Logon(rs); |
|
1247 CHECK_EQUAL(rs.Int(),KRequestPending); |
|
1248 p.Resume(); |
|
1249 User::WaitForRequest(rs); |
|
1250 |
|
1251 p.Close(); |
|
1252 } |
|
1253 |
|
1254 /** |
|
1255 Test that ECapabilityMultimediaDD is required |
|
1256 in order to open RSoundSc for playback and that |
|
1257 ECapabilityUserEnvironment is needed, in addition, |
|
1258 to open for record. |
|
1259 */ |
|
1260 static void TestCapabilityChecks() |
|
1261 { |
|
1262 //convert capabilities into bitmask understood by setcap.exe |
|
1263 const TUint32 KUserEnvironment = 1<<ECapabilityUserEnvironment; |
|
1264 const TUint32 KMultimediaDD= 1<<ECapabilityMultimediaDD; |
|
1265 |
|
1266 //try to delete helper just in case it has been left hanging about from a previous run which failed |
|
1267 DeleteHelper(); |
|
1268 SetHelperCaps(NULL); |
|
1269 RunHelper(KSoundScTxUnit0,KErrPermissionDenied); |
|
1270 RunHelper(KSoundScRxUnit0,KErrPermissionDenied); |
|
1271 |
|
1272 CHECK_NOERROR(DeleteHelper()); |
|
1273 SetHelperCaps(KMultimediaDD); |
|
1274 RunHelper(KSoundScTxUnit0,KErrNone); |
|
1275 RunHelper(KSoundScRxUnit0,KErrPermissionDenied); |
|
1276 |
|
1277 CHECK_NOERROR(DeleteHelper()); |
|
1278 SetHelperCaps(KUserEnvironment); |
|
1279 RunHelper(KSoundScTxUnit0,KErrPermissionDenied); |
|
1280 RunHelper(KSoundScRxUnit0,KErrPermissionDenied); |
|
1281 |
|
1282 CHECK_NOERROR(DeleteHelper()); |
|
1283 SetHelperCaps(KUserEnvironment|KMultimediaDD); |
|
1284 RunHelper(KSoundScTxUnit0,KErrNone); |
|
1285 RunHelper(KSoundScRxUnit0,KErrNone); |
|
1286 |
|
1287 CHECK_NOERROR(DeleteHelper()); |
|
1288 } |
|
1289 |
|
1290 TInt E32Main() |
|
1291 { |
|
1292 TInt r; |
|
1293 |
|
1294 __UHEAP_MARK; |
|
1295 |
|
1296 Test.Title(); |
|
1297 |
|
1298 Test.Start(_L("Load")); |
|
1299 if (Load()==KErrNotFound) |
|
1300 { |
|
1301 Test.Printf(_L("Shared chunk sound driver not supported - test skipped\r\n")); |
|
1302 Test.End(); |
|
1303 Test.Close(); |
|
1304 __UHEAP_MARKEND; |
|
1305 return(KErrNone); |
|
1306 } |
|
1307 |
|
1308 // The __KHEAP_MARK and __KHEAP_MARKEND macros unfortunately have to be commented out or they |
|
1309 // generate false positives on the x86pc target build. This is to do with the launching of the |
|
1310 // helper executable, which results in another component allocating memory and not freeing it, |
|
1311 // thus causing the macros here to trigger a kern-exec 17 that is not related to the sound driver |
|
1312 // itself. The same macros are fine on other platforms. See DEF129273 for more information |
|
1313 //__KHEAP_MARK; |
|
1314 |
|
1315 Test.Next(_L("Test Capability Checking")); |
|
1316 TestCapabilityChecks(); |
|
1317 |
|
1318 Test.Next(_L("Open playback channel")); |
|
1319 r = TxSoundDevice.Open(KSoundScTxUnit0); |
|
1320 CHECK_NOERROR(r); |
|
1321 |
|
1322 Test.Next(_L("Open record channel")); |
|
1323 r = RxSoundDevice.Open(KSoundScRxUnit0); |
|
1324 CHECK_NOERROR(r); |
|
1325 |
|
1326 Test.Next(_L("Query play formats supported")); |
|
1327 TxSoundDevice.Caps(PlayCapsBuf); |
|
1328 TSoundFormatsSupportedV02 playCaps=PlayCapsBuf(); |
|
1329 PrintCaps(playCaps,Test); |
|
1330 |
|
1331 Test.Next(_L("Query record formats supported")); |
|
1332 RxSoundDevice.Caps(RecordCapsBuf); |
|
1333 TSoundFormatsSupportedV02 recordCaps=RecordCapsBuf(); |
|
1334 PrintCaps(recordCaps,Test); |
|
1335 |
|
1336 TestSetAudioFormat(); |
|
1337 TestSetBufferConfig(0); // Without guard pages. |
|
1338 TestSetBufferConfig(KScFlagUseGuardPages); // With guard pages. |
|
1339 TestPlay(); |
|
1340 TestRecord(); |
|
1341 #ifdef _DEBUG |
|
1342 TestChangeOfHwConfigNotifier(); |
|
1343 #endif |
|
1344 // Note that API testing of pause/resume and volume setting are covered in T_SOUND2. |
|
1345 |
|
1346 /** @SYMTestCaseID PBASE-T_SOUND_API-226 |
|
1347 @SYMTestCaseDesc Closing the channel |
|
1348 @SYMTestPriority Critical |
|
1349 @SYMTestActions 1) With a playback channel open on the device, close the channel. |
|
1350 2) With a record channel open on the device, close the channel. |
|
1351 @SYMTestExpectedResults 1) No errors occur closing the channel. |
|
1352 2) No errors occur closing the channel. |
|
1353 @SYMREQ PREQ1073.4 */ |
|
1354 |
|
1355 Test.Next(_L("Close channels")); |
|
1356 RxSoundDevice.Close(); |
|
1357 TxSoundDevice.Close(); |
|
1358 |
|
1359 //__KHEAP_MARKEND; |
|
1360 |
|
1361 // Now that both the channels are closed, unload the LDD and the PDDs. |
|
1362 TestUnloadDrivers(); |
|
1363 |
|
1364 Test.End(); |
|
1365 Test.Close(); |
|
1366 |
|
1367 Cleanup(); |
|
1368 |
|
1369 __UHEAP_MARKEND; |
|
1370 |
|
1371 return(KErrNone); |
|
1372 } |