0
|
1 |
// Copyright (c) 1998-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_sound2.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file General test code for the shared chunk sound driver - based on T_SOUND.
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include <e32test.h>
|
|
23 |
#include "t_soundutils.h"
|
|
24 |
#include <hal.h>
|
|
25 |
#include <e32def.h>
|
|
26 |
#include <e32def_private.h>
|
|
27 |
|
|
28 |
// #define SOAKTEST
|
|
29 |
|
|
30 |
const TSoundRate speedTable[] = {ESoundRate48000Hz,ESoundRate44100Hz,ESoundRate32000Hz,ESoundRate29400Hz,
|
|
31 |
ESoundRate24000Hz,ESoundRate22050Hz,ESoundRate16000Hz,ESoundRate14700Hz,
|
|
32 |
ESoundRate12000Hz,ESoundRate11025Hz,ESoundRate9600Hz,ESoundRate8820Hz,
|
|
33 |
ESoundRate8000Hz,ESoundRate7350Hz,(TSoundRate)-1}; // ALL RATES DECENDING
|
|
34 |
|
|
35 |
#define CHECK(aValue) {Test(aValue,__LINE__);}
|
|
36 |
#define CHECK_NOERROR(aValue) { TInt v=(aValue); if(v) { Test.Printf(_L("Error value = %d\n"),v); Test(EFalse,__LINE__); }}
|
|
37 |
#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__); }}
|
|
38 |
#define CHECK_POSITIVE(aOffset) { if(aOffset<0) { Test.Printf(_L("CHECK_POSITIVE(%d) failed\n"), aOffset); Test(EFalse,__LINE__); } }
|
|
39 |
|
|
40 |
_LIT(KSndLddFileName,"ESOUNDSC.LDD");
|
|
41 |
_LIT(KSndPddFileName,"SOUNDSC.PDD");
|
|
42 |
|
|
43 |
RTest Test(_L("T_SOUND2"));
|
|
44 |
RSoundSc TxSoundDevice;
|
|
45 |
RSoundSc RxSoundDevice;
|
|
46 |
|
|
47 |
TSoundFormatsSupportedV02Buf RecordCapsBuf;
|
|
48 |
TSoundFormatsSupportedV02Buf PlayCapsBuf;
|
|
49 |
TCurrentSoundFormatV02Buf PlayFormatBuf;
|
|
50 |
TCurrentSoundFormatV02Buf RecordFormatBuf;
|
|
51 |
|
|
52 |
LOCAL_C TInt Load()
|
|
53 |
{
|
|
54 |
TInt r;
|
|
55 |
|
|
56 |
Test.Start(_L("Load sound PDD"));
|
|
57 |
r=User::LoadPhysicalDevice(KSndPddFileName);
|
|
58 |
if (r==KErrNotFound)
|
|
59 |
{
|
|
60 |
Test.End();
|
|
61 |
return(r);
|
|
62 |
}
|
|
63 |
CHECK(r==KErrNone || r==KErrAlreadyExists);
|
|
64 |
r=User::LoadPhysicalDevice(KSndPddFileName);
|
|
65 |
CHECK(r==KErrAlreadyExists);
|
|
66 |
|
|
67 |
Test.Next(_L("Load sound LDD"));
|
|
68 |
r=User::LoadLogicalDevice(KSndLddFileName);
|
|
69 |
CHECK(r==KErrNone || r==KErrAlreadyExists);
|
|
70 |
r=User::LoadPhysicalDevice(KSndPddFileName);
|
|
71 |
CHECK(r==KErrAlreadyExists);
|
|
72 |
|
|
73 |
Test.End();
|
|
74 |
return(KErrNone);
|
|
75 |
}
|
|
76 |
|
|
77 |
LOCAL_C void CheckConfig(const TCurrentSoundFormatV02& aConfig,const TSoundFormatsSupportedV02& aCaps)
|
|
78 |
{
|
|
79 |
if (!((1<<(aConfig.iChannels-1)) & aCaps.iChannels))
|
|
80 |
CHECK_NOERROR(ETrue);
|
|
81 |
if (!((1<<aConfig.iRate) & aCaps.iRates))
|
|
82 |
CHECK_NOERROR(ETrue);
|
|
83 |
if (!((1<<aConfig.iEncoding) & aCaps.iEncodings))
|
|
84 |
CHECK_NOERROR(ETrue);
|
|
85 |
if (!((1<<aConfig.iDataFormat) & aCaps.iDataFormats))
|
|
86 |
CHECK_NOERROR(ETrue);
|
|
87 |
}
|
|
88 |
|
|
89 |
|
|
90 |
////////////////////////////////////////////////////////////////////////////////
|
|
91 |
// Tests
|
|
92 |
|
|
93 |
const TInt KMaxLinearVolume=256;
|
|
94 |
const TInt KLinearTodB[KMaxLinearVolume+1] =
|
|
95 |
{
|
|
96 |
0 ,158,170,177,182,186,189,192,194,196,198,200,201,203,204,205,
|
|
97 |
206,207,208,209,210,211,212,213,213,214,215,215,216,217,217,218,
|
|
98 |
218,219,219,220,220,221,221,222,222,223,223,224,224,224,225,225,
|
|
99 |
225,226,226,226,227,227,227,228,228,228,229,229,229,230,230,230,
|
|
100 |
230,231,231,231,231,232,232,232,232,233,233,233,233,234,234,234,
|
|
101 |
234,235,235,235,235,235,236,236,236,236,236,237,237,237,237,237,
|
|
102 |
237,238,238,238,238,238,239,239,239,239,239,239,240,240,240,240,
|
|
103 |
240,240,240,241,241,241,241,241,241,241,242,242,242,242,242,242,
|
|
104 |
242,243,243,243,243,243,243,243,244,244,244,244,244,244,244,244,
|
|
105 |
245,245,245,245,245,245,245,245,245,246,246,246,246,246,246,246,
|
|
106 |
246,246,247,247,247,247,247,247,247,247,247,247,248,248,248,248,
|
|
107 |
248,248,248,248,248,248,249,249,249,249,249,249,249,249,249,249,
|
|
108 |
250,250,250,250,250,250,250,250,250,250,250,250,251,251,251,251,
|
|
109 |
251,251,251,251,251,251,251,251,252,252,252,252,252,252,252,252,
|
|
110 |
252,252,252,252,252,253,253,253,253,253,253,253,253,253,253,253,
|
|
111 |
253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255
|
|
112 |
};
|
|
113 |
|
|
114 |
LOCAL_C void TestBasicPlayFunctions()
|
|
115 |
{
|
|
116 |
TRequestStatus stat[2];
|
|
117 |
|
|
118 |
Test.Next(_L("Preparing to play..."));
|
|
119 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
120 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
121 |
PlayFormatBuf().iChannels = 1;
|
|
122 |
PrintConfig(PlayFormatBuf(),Test);
|
|
123 |
TInt r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
124 |
CHECK_NOERROR(r);
|
|
125 |
|
|
126 |
// Set the play buffer configuration, then read it back.
|
|
127 |
RChunk chunk;
|
|
128 |
TInt bufSize=BytesPerSecond(PlayFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
129 |
bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver.
|
|
130 |
TTestSharedChunkBufConfig bufferConfig;
|
|
131 |
bufferConfig.iNumBuffers=2;
|
|
132 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
133 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
134 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
135 |
r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
136 |
CHECK_NOERROR(r);
|
|
137 |
TxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
138 |
PrintBufferConf(bufferConfig,Test);
|
|
139 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
140 |
TPtr8* tPtr[2];
|
|
141 |
TInt i;
|
|
142 |
for (i=0;i<2;i++)
|
|
143 |
tPtr[i]=new TPtr8(chunk.Base()+bufferConfig.iBufferOffsetList[i],bufSize);
|
|
144 |
|
|
145 |
/** @SYMTestCaseID PBASE-T_SOUND2-249
|
|
146 |
@SYMTestCaseDesc Play pause / resume - pausing and resuming before playback has commenced.
|
|
147 |
@SYMTestPriority Critical
|
|
148 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer configuration.
|
|
149 |
1) Attempt to resume playback before playback has been started.
|
|
150 |
2) Attempt to pause playback before playback has been started.
|
|
151 |
@SYMTestExpectedResults 1) The resume request should complete with KErrNotReady.
|
|
152 |
2) The pause request should complete with KErrNotReady
|
|
153 |
@SYMREQ PREQ1073.4 */
|
|
154 |
|
|
155 |
Test.Printf(_L("Resume when not playing\r\n"));
|
|
156 |
r=TxSoundDevice.Resume();
|
|
157 |
CHECK(r==KErrNotReady)
|
|
158 |
|
|
159 |
Test.Printf(_L("Pause when not playing\r\n"));
|
|
160 |
r=TxSoundDevice.Pause();
|
|
161 |
CHECK(r==KErrNotReady)
|
|
162 |
|
|
163 |
/** @SYMTestCaseID PBASE-T_SOUND2-237
|
|
164 |
@SYMTestCaseDesc Play operation - with zero length.
|
|
165 |
@SYMTestPriority Critical
|
|
166 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer
|
|
167 |
configuration. Issue a transfer request from one of the buffers to play data specifying a
|
|
168 |
length of zero.
|
|
169 |
@SYMTestExpectedResults The play request should complete with KErrNone.
|
|
170 |
@SYMREQ PREQ1073.4 */
|
|
171 |
|
|
172 |
Test.Next(_L("Play empty buffer"));
|
|
173 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],0,KSndFlagLastSample); // Play length of zero
|
|
174 |
User::WaitForRequest(stat[0]);
|
|
175 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
176 |
|
|
177 |
/** @SYMTestCaseID PBASE-T_SOUND2-238
|
|
178 |
@SYMTestCaseDesc Play operation - with a short transfer.
|
|
179 |
@SYMTestPriority Critical
|
|
180 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer configuration.
|
|
181 |
1) Issue a transfer requests from one of the buffers to play data, specifying a length equal to the
|
|
182 |
minimum request size that the device supports - i.e.
|
|
183 |
TSoundFormatsSupportedV02::iRequestMinSize, or 2 bytes, whichever is greater.
|
|
184 |
2) Issue a transfer requests from one of the buffers to play data, specifying a length equal
|
|
185 |
to twice the minimum request size that the device supports, or 34 bytes, whichever
|
|
186 |
is greater.
|
|
187 |
@SYMTestExpectedResults 1) The play request should complete with KErrNone.
|
|
188 |
2) The play request should complete with KErrNone.
|
|
189 |
@SYMREQ PREQ1073.4 */
|
|
190 |
|
|
191 |
Test.Next(_L("Play short buffer"));
|
|
192 |
TInt len=Max(2,PlayCapsBuf().iRequestMinSize);
|
|
193 |
Test.Printf(_L("Play length is %d bytes\r\n"),len);
|
|
194 |
tPtr[0]->FillZ(bufSize);
|
|
195 |
tPtr[1]->FillZ(len);
|
|
196 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,0);
|
|
197 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],len,KSndFlagLastSample);
|
|
198 |
User::WaitForRequest(stat[0]);
|
|
199 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
200 |
User::WaitForRequest(stat[1]);
|
|
201 |
CHECK_EQUAL(stat[1].Int(),KErrNone);
|
|
202 |
|
|
203 |
Test.Next(_L("Play a slightly longer buffer"));
|
|
204 |
len=Max(34,(PlayCapsBuf().iRequestMinSize<<1));
|
|
205 |
if (PlayCapsBuf().iRequestMinSize)
|
|
206 |
len&=~(PlayCapsBuf().iRequestMinSize-1);
|
|
207 |
Test.Printf(_L("Play length is %d bytes\r\n"),len);
|
|
208 |
tPtr[1]->FillZ(bufSize);
|
|
209 |
tPtr[0]->FillZ(len);
|
|
210 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[1],bufSize,0); // Play 2nd buffer 1st
|
|
211 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[0],len,KSndFlagLastSample);
|
|
212 |
User::WaitForRequest(stat[0]);
|
|
213 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
214 |
User::WaitForRequest(stat[1]);
|
|
215 |
CHECK_EQUAL(stat[1].Int(),KErrNone);
|
|
216 |
|
|
217 |
/** @SYMTestCaseID PBASE-T_SOUND2-240
|
|
218 |
@SYMTestCaseDesc Play operation - altering the volume.
|
|
219 |
@SYMTestPriority Critical
|
|
220 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer configuration
|
|
221 |
so it contains multiple buffers. Using multiple simultaneous play requests, play 4 seconds
|
|
222 |
of continuous tone - with each individual play request consisting of 1/8th second of tone.
|
|
223 |
Each time a request completes, increase the volume slightly - starting at the minimum
|
|
224 |
and ending at maximum volume. (Ensure the last request is marked with the
|
|
225 |
KSndFlagLastSample flag).
|
|
226 |
@SYMTestExpectedResults The driver should successfully play 4 seconds of tone with all requests completing with
|
|
227 |
KErrNone.
|
|
228 |
@SYMREQ PREQ1073.4 */
|
|
229 |
|
|
230 |
/** @SYMTestCaseID PBASE-T_SOUND2-250
|
|
231 |
@SYMTestCaseDesc Play pause / resume - pausing and resuming while playback is in progress.
|
|
232 |
@SYMTestPriority Critical
|
|
233 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer configuration
|
|
234 |
so it contains multiple buffers. Reset the channel's count of bytes transferred.
|
|
235 |
Using multiple simultaneous play requests, play 4 seconds of continuous tone - with
|
|
236 |
each individual play request consisting of 1/8th second of tone.
|
|
237 |
1) After 10 requests have completed, pause transfer for 2 seconds, then resume it.
|
|
238 |
2) After 20 requests have completed, attempt to resume playback while playback is not paused.
|
|
239 |
3) With only 0.25 second of tone still to play, pause transfer for 1 second, then resume it.
|
|
240 |
4) 10ms after resuming, pause transfer again for 1 second, then resume it.
|
|
241 |
5) Once transfer has completed, read back the count of bytes transferred.
|
|
242 |
@SYMTestExpectedResults 1) Playback of the tone should be interrupted for 2 seconds with the pause and resume requests
|
|
243 |
both completing with KErrNone.
|
|
244 |
2) The resume request should complete with KErrNotReady.
|
|
245 |
3) Playback of the tone should be interrupted for 1 second with the pause and resume requests
|
|
246 |
both completing with KErrNone.
|
|
247 |
4) Playback of the tone should be interrupted for 1 second with the pause and resume requests
|
|
248 |
both completing with KErrNone.
|
|
249 |
5) The count of bytes transferred should not be affected by pausing and resuming playback
|
|
250 |
(i.e. it should equal the value calculated for 4 seconds at the selected sampe rate and
|
|
251 |
number of channels).
|
|
252 |
@SYMREQ PREQ1073.4 */
|
|
253 |
|
|
254 |
Test.Next(_L("Playing..."));
|
|
255 |
r=MakeSineTable(PlayFormatBuf());
|
|
256 |
CHECK_NOERROR(r);
|
|
257 |
r=SetToneFrequency(440,PlayFormatBuf());
|
|
258 |
CHECK_NOERROR(r);
|
|
259 |
TxSoundDevice.ResetBytesTransferred();
|
|
260 |
TInt remainingPlayCount = BytesPerSecond(PlayFormatBuf())*4/bufSize;
|
|
261 |
|
|
262 |
// Set the initial value for the volume.
|
|
263 |
TInt bytesToPlay = remainingPlayCount*bufSize;
|
|
264 |
TInt bytesPlayed = 0;
|
|
265 |
TInt vol = I64LOW(TInt64(KMaxLinearVolume)*TInt64(bytesPlayed)/TInt64(bytesToPlay));
|
|
266 |
vol = KLinearTodB[vol]; // Rather than varying the volume logarithmically (in dB), vary it linearly (as done by MM).
|
|
267 |
TxSoundDevice.SetVolume(vol);
|
|
268 |
|
|
269 |
// Issue a pair of play requests.
|
|
270 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
271 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize);
|
|
272 |
WriteTone(*tPtr[1],PlayFormatBuf());
|
|
273 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize);
|
|
274 |
|
|
275 |
TInt lcount = 0;
|
|
276 |
TUint flags;
|
|
277 |
while (remainingPlayCount>2)
|
|
278 |
{
|
|
279 |
// Wait for either of the outstanding play requests to complete.
|
|
280 |
User::WaitForAnyRequest();
|
|
281 |
remainingPlayCount--;
|
|
282 |
|
|
283 |
// Work out which request this applies to.
|
|
284 |
for (i=0;i<2;i++)
|
|
285 |
{
|
|
286 |
if (stat[i]!=KRequestPending)
|
|
287 |
break;
|
|
288 |
}
|
|
289 |
CHECK(i<2);
|
|
290 |
CHECK_NOERROR(stat[i].Int());
|
|
291 |
|
|
292 |
// Issue a further play request using the buffer just made free.
|
|
293 |
WriteTone(*tPtr[i],PlayFormatBuf());
|
|
294 |
flags=(remainingPlayCount<=2)?KSndFlagLastSample:0;
|
|
295 |
TxSoundDevice.PlayData(stat[i],bufferConfig.iBufferOffsetList[i],bufSize,flags);
|
|
296 |
|
|
297 |
// Adjust the volume
|
|
298 |
bytesPlayed = TxSoundDevice.BytesTransferred();
|
|
299 |
vol = I64LOW(TInt64(KMaxLinearVolume)*TInt64(bytesPlayed)/TInt64(bytesToPlay));
|
|
300 |
vol = KLinearTodB[vol]; // Rather than varying the volume logarithmically (in dB), vary it linearly (as done by MM).
|
|
301 |
Test.Printf(_L("Bytes played = %d (vol = %d)\r\n"),bytesPlayed,vol);
|
|
302 |
TxSoundDevice.SetVolume(vol);
|
|
303 |
|
|
304 |
if (lcount == 10)
|
|
305 |
{
|
|
306 |
// Do a pause/resume
|
|
307 |
r=TxSoundDevice.Pause();
|
|
308 |
CHECK_NOERROR(r);
|
|
309 |
Test.Printf(_L("Pause 2 seconds\r\n"));
|
|
310 |
User::After(2000000);
|
|
311 |
Test.Printf(_L("Restart\r\n"));
|
|
312 |
r=TxSoundDevice.Resume();
|
|
313 |
CHECK_NOERROR(r);
|
|
314 |
}
|
|
315 |
if (lcount == 20)
|
|
316 |
{
|
|
317 |
Test.Printf(_L("Resume when playing\r\n"));
|
|
318 |
r=TxSoundDevice.Resume();
|
|
319 |
CHECK(r==KErrNotReady)
|
|
320 |
}
|
|
321 |
|
|
322 |
CHECK_EQUAL(TxSoundDevice.Volume(),vol);
|
|
323 |
CHECK_EQUAL(TxSoundDevice.SetAudioFormat(PlayFormatBuf),KErrInUse);
|
|
324 |
lcount++;
|
|
325 |
}
|
|
326 |
|
|
327 |
// Last 2 play requests still outstanding - do a pause/resume
|
|
328 |
r=TxSoundDevice.Pause();
|
|
329 |
CHECK_NOERROR(r);
|
|
330 |
Test.Printf(_L("Pause 1 second\r\n"));
|
|
331 |
User::After(1000000);
|
|
332 |
Test.Printf(_L("Restart\r\n"));
|
|
333 |
r=TxSoundDevice.Resume();
|
|
334 |
CHECK_NOERROR(r);
|
|
335 |
bytesPlayed = TxSoundDevice.BytesTransferred();
|
|
336 |
|
|
337 |
User::After(10000); // 10ms
|
|
338 |
|
|
339 |
r=TxSoundDevice.Pause();
|
|
340 |
Test.Printf(_L("Bytes played = %d\r\n"),bytesPlayed);
|
|
341 |
|
|
342 |
CHECK_NOERROR(r);
|
|
343 |
Test.Printf(_L("Pause 1 second\r\n"));
|
|
344 |
User::After(1000000);
|
|
345 |
Test.Printf(_L("Restart\r\n"));
|
|
346 |
r=TxSoundDevice.Resume();
|
|
347 |
CHECK_NOERROR(r);
|
|
348 |
bytesPlayed = TxSoundDevice.BytesTransferred();
|
|
349 |
Test.Printf(_L("Bytes played = %d\r\n"),bytesPlayed);
|
|
350 |
|
|
351 |
User::WaitForRequest(stat[0]);
|
|
352 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
353 |
User::WaitForRequest(stat[1]);
|
|
354 |
CHECK_EQUAL(stat[1].Int(),KErrNone);
|
|
355 |
|
|
356 |
bytesPlayed = TxSoundDevice.BytesTransferred();
|
|
357 |
Test.Printf(_L("Bytes played = %d vs %d\n"),bytesPlayed, bytesToPlay);
|
|
358 |
CHECK_EQUAL(bytesToPlay,bytesPlayed);
|
|
359 |
|
|
360 |
TxSoundDevice.ResetBytesTransferred();
|
|
361 |
CHECK_EQUAL(TxSoundDevice.BytesTransferred(),0);
|
|
362 |
|
|
363 |
Test.Next(_L("Pause and resume when not playing"));
|
|
364 |
TxSoundDevice.Pause();
|
|
365 |
TxSoundDevice.Resume();
|
|
366 |
|
|
367 |
chunk.Close();
|
|
368 |
for (i=0;i<2;i++)
|
|
369 |
delete tPtr[i];
|
|
370 |
}
|
|
371 |
|
|
372 |
LOCAL_C void TestBasicRecordFunctions()
|
|
373 |
{
|
|
374 |
TRequestStatus stat;
|
|
375 |
TInt length, r, i;
|
|
376 |
|
|
377 |
Test.Next(_L("Preparing to record..."));
|
|
378 |
|
|
379 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
380 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
381 |
RecordFormatBuf().iChannels = 2;
|
|
382 |
|
|
383 |
// find first supported rate and set the the audio configuration to use it
|
|
384 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
385 |
{
|
|
386 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
387 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
388 |
if (RecordCapsBuf().iRates & (1<<i))
|
|
389 |
{
|
|
390 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
391 |
break;
|
|
392 |
}
|
|
393 |
}
|
|
394 |
|
|
395 |
PrintConfig(RecordFormatBuf(),Test);
|
|
396 |
|
|
397 |
// Set the record buffer configuration, then read it back.
|
|
398 |
RChunk chunk;
|
|
399 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
400 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
401 |
TTestSharedChunkBufConfig bufferConfig;
|
|
402 |
bufferConfig.iNumBuffers=3;
|
|
403 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
404 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
405 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
406 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
407 |
CHECK_NOERROR(r);
|
|
408 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
409 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
410 |
|
|
411 |
Test.Next(_L("Test for record overflow"));
|
|
412 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
413 |
RxSoundDevice.RecordData(stat,length);
|
|
414 |
User::WaitForRequest(stat);
|
|
415 |
TInt retOffset=stat.Int();
|
|
416 |
CHECK_POSITIVE(retOffset);
|
|
417 |
CHECK(length>0);
|
|
418 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
419 |
CHECK_NOERROR(r);
|
|
420 |
|
|
421 |
User::After(500000); // Wait 1/2 second for data overflow.
|
|
422 |
|
|
423 |
RxSoundDevice.RecordData(stat,length);
|
|
424 |
User::WaitForRequest(stat);
|
|
425 |
retOffset=stat.Int();
|
|
426 |
CHECK(retOffset==KErrOverflow);
|
|
427 |
|
|
428 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
429 |
chunk.Close();
|
|
430 |
}
|
|
431 |
|
|
432 |
/** @SYMTestCaseID PBASE-T_SOUND2-241
|
|
433 |
@SYMTestCaseDesc Play operation - playing all rates.
|
|
434 |
@SYMTestPriority Critical
|
|
435 |
@SYMTestActions 1) For each of the sample rates supported by the device, setup the audio configuration
|
|
436 |
on the playback channel for mono operation (i.e. 1 audio channel) and then setup
|
|
437 |
the buffer configuration so it contains multiple buffers. Using multiple simultaneous play requests,
|
|
438 |
play 4 seconds of continuous tone - with each individual play request consisting of 1/8th second of
|
|
439 |
tone. (Ensure the last request is marked with the KSndFlagLastSample flag).
|
|
440 |
2) Repeat the above with the driver configured for stereo operation (i.e. 2 audio channels).
|
|
441 |
@SYMTestExpectedResults 1) For each of the sample rates supported by the device, the driver should successfully play
|
|
442 |
4 seconds of tone, with no interruptions in the sound produced and with all requests
|
|
443 |
completing with KErrNone.
|
|
444 |
2) For each of the sample rates supported by the device, the driver should successfully play
|
|
445 |
4 seconds of tone, with no interruptions in the sound produced and with all requests
|
|
446 |
completing with KErrNone.
|
|
447 |
@SYMREQ PREQ1073.4
|
|
448 |
*/
|
|
449 |
LOCAL_C void TestPlayAllRates(TInt aNumChannels,TInt aNumSeconds)
|
|
450 |
{
|
|
451 |
TRequestStatus stat[2];
|
|
452 |
TPtr8* tPtr[2];
|
|
453 |
TInt i;
|
|
454 |
for (i=0;i<2;i++)
|
|
455 |
tPtr[i]=new TPtr8(NULL,0);
|
|
456 |
|
|
457 |
Test.Next(_L("Play all rates test"));
|
|
458 |
Test.Printf(_L("Number of channels %d, duration %d seconds\n"), aNumChannels, aNumSeconds);
|
|
459 |
|
|
460 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
461 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
462 |
PlayFormatBuf().iChannels = aNumChannels;
|
|
463 |
TInt r=MakeSineTable(PlayFormatBuf());
|
|
464 |
CHECK_NOERROR(r);
|
|
465 |
|
|
466 |
TxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
467 |
|
|
468 |
RChunk chunk;
|
|
469 |
TInt speed = 0;
|
|
470 |
while (speedTable[speed]>=0)
|
|
471 |
{
|
|
472 |
PlayFormatBuf().iRate = speedTable[speed++];
|
|
473 |
PlayFormatBuf().iChannels = aNumChannels;
|
|
474 |
|
|
475 |
// Set the play format.
|
|
476 |
Test.Printf(_L("Testing playback rate %d...\r\n"),RateInSamplesPerSecond(PlayFormatBuf().iRate));
|
|
477 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
478 |
if (r==KErrNotSupported)
|
|
479 |
{
|
|
480 |
Test.Printf(_L("Sample rate not supported\r\n"));
|
|
481 |
continue;
|
|
482 |
}
|
|
483 |
CHECK_NOERROR(r);
|
|
484 |
|
|
485 |
// Set the play buffer configuration, then read it back.
|
|
486 |
TInt bufSize=BytesPerSecond(PlayFormatBuf())/4; // Large enough to hold 1/4th second of data.
|
|
487 |
bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver.
|
|
488 |
TTestSharedChunkBufConfig bufferConfig;
|
|
489 |
bufferConfig.iNumBuffers=2;
|
|
490 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
491 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
492 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
493 |
r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
494 |
CHECK_NOERROR(r);
|
|
495 |
TxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
496 |
PrintBufferConf(bufferConfig,Test);
|
|
497 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
498 |
tPtr[0]->Set(chunk.Base()+bufferConfig.iBufferOffsetList[0],0,bufSize);
|
|
499 |
tPtr[1]->Set(chunk.Base()+bufferConfig.iBufferOffsetList[1],0,bufSize);
|
|
500 |
|
|
501 |
r=SetToneFrequency(440,PlayFormatBuf());
|
|
502 |
CHECK_NOERROR(r);
|
|
503 |
TxSoundDevice.ResetBytesTransferred();
|
|
504 |
CHECK_EQUAL(TxSoundDevice.BytesTransferred(),0);
|
|
505 |
|
|
506 |
// Issue a pair of play requests.
|
|
507 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
508 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize);
|
|
509 |
WriteTone(*tPtr[1],PlayFormatBuf());
|
|
510 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize);
|
|
511 |
|
|
512 |
TInt remainingPlayCount = BytesPerSecond(PlayFormatBuf())*aNumSeconds/bufSize;
|
|
513 |
TInt bytesToPlay = remainingPlayCount*bufSize;
|
|
514 |
TInt bytesPlayed = 0;
|
|
515 |
TInt i;
|
|
516 |
TUint flags;
|
|
517 |
while(remainingPlayCount>2)
|
|
518 |
{
|
|
519 |
// Wait for either of the outstanding play requests to complete.
|
|
520 |
User::WaitForAnyRequest();
|
|
521 |
remainingPlayCount--;
|
|
522 |
|
|
523 |
// Work out which request this applies to.
|
|
524 |
for (i=0;i<2;i++)
|
|
525 |
{
|
|
526 |
if (stat[i]!=KRequestPending)
|
|
527 |
break;
|
|
528 |
}
|
|
529 |
CHECK(i<2);
|
|
530 |
CHECK_NOERROR(stat[i].Int());
|
|
531 |
|
|
532 |
WriteTone(*tPtr[i],PlayFormatBuf());
|
|
533 |
flags=(remainingPlayCount<=2)?KSndFlagLastSample:0;
|
|
534 |
TxSoundDevice.PlayData(stat[i],bufferConfig.iBufferOffsetList[i],bufSize,flags);
|
|
535 |
}
|
|
536 |
|
|
537 |
// Last 2 play requests still outstanding.
|
|
538 |
User::WaitForRequest(stat[0]);
|
|
539 |
CHECK_NOERROR(stat[0].Int());
|
|
540 |
User::WaitForRequest(stat[1]);
|
|
541 |
CHECK_NOERROR(stat[1].Int());
|
|
542 |
|
|
543 |
Test.Printf(_L("Sample rate successful\r\n"));
|
|
544 |
bytesPlayed = TxSoundDevice.BytesTransferred();
|
|
545 |
CHECK_EQUAL(bytesToPlay,bytesPlayed);
|
|
546 |
chunk.Close();
|
|
547 |
}
|
|
548 |
|
|
549 |
for (i=0;i<2;i++)
|
|
550 |
delete tPtr[i];
|
|
551 |
}
|
|
552 |
|
|
553 |
/** @SYMTestCaseID PBASE-T_SOUND2-254
|
|
554 |
@SYMTestCaseDesc Record operation - recording all rates.
|
|
555 |
@SYMTestPriority Critical
|
|
556 |
@SYMTestActions 1) For each of the sample rates supported by the device, setup the audio configuration on
|
|
557 |
the record channel for mono operation (i.e. 1 audio channel) and then setup the buffer
|
|
558 |
configuration so it contains multiple buffers. Using multiple simultaneous record
|
|
559 |
requests, record 4 seconds of audio data - with each individual record request being
|
|
560 |
for 1/8th second of data.
|
|
561 |
2) Repeat the above with the driver configured for stereo operation (i.e. 2 audio channels).
|
|
562 |
@SYMTestExpectedResults 1) For each of the sample rates supported by the device, the driver should successfully
|
|
563 |
record 4 seconds of data, with all requests completing with KErrNone.
|
|
564 |
2) For each of the sample rates supported by the device, the driver should successfully
|
|
565 |
record 4 seconds of data, with all requests completing with KErrNone
|
|
566 |
@SYMREQ PREQ1073.4
|
|
567 |
*/
|
|
568 |
LOCAL_C void TestRecordAllRates(TInt aNumChannels,TInt aNumSeconds)
|
|
569 |
{
|
|
570 |
|
|
571 |
TRequestStatus stat[2];
|
|
572 |
TInt length[2];
|
|
573 |
|
|
574 |
Test.Next(_L("Record all rate test"));
|
|
575 |
Test.Printf(_L("Number of channels %d, duration %d seconds\n"), aNumChannels, aNumSeconds);
|
|
576 |
|
|
577 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
578 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
579 |
|
|
580 |
RChunk chunk;
|
|
581 |
TInt speed = 0;
|
|
582 |
while (speedTable[speed]>=0)
|
|
583 |
{
|
|
584 |
RecordFormatBuf().iRate = speedTable[speed++];
|
|
585 |
RecordFormatBuf().iChannels = aNumChannels;
|
|
586 |
|
|
587 |
// Set the record format.
|
|
588 |
Test.Printf(_L("Testing record rate %d...\r\n"),RateInSamplesPerSecond(RecordFormatBuf().iRate));
|
|
589 |
TInt r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
590 |
if (r==KErrNotSupported)
|
|
591 |
{
|
|
592 |
Test.Printf(_L("Sample rate not supported\r\n"));
|
|
593 |
continue;
|
|
594 |
}
|
|
595 |
CHECK_NOERROR(r);
|
|
596 |
|
|
597 |
// Set the record buffer configuration, then read it back.
|
|
598 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
599 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
600 |
TTestSharedChunkBufConfig bufferConfig;
|
|
601 |
bufferConfig.iNumBuffers=4;
|
|
602 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
603 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
604 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
605 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
606 |
CHECK_NOERROR(r);
|
|
607 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
608 |
PrintBufferConf(bufferConfig,Test);
|
|
609 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
610 |
|
|
611 |
TInt remainingRecordCount = BytesPerSecond(RecordFormatBuf())*aNumSeconds/bufSize;
|
|
612 |
TInt bytesToRecord = remainingRecordCount*bufSize;
|
|
613 |
TInt bytesRecorded = 0;
|
|
614 |
|
|
615 |
// The driver rounds up the buffer size to the nearest page meaning the total duration
|
|
616 |
// to complete this test won't be exactly equal to 'aNumSeconds' anymore. Hence, the
|
|
617 |
// predicted time is no longer simply: aNumSeconds * 1000000.
|
|
618 |
TInt64 predictedTime = (bufSize * remainingRecordCount);
|
|
619 |
predictedTime*=1000000;
|
|
620 |
predictedTime+=BytesPerSecond(RecordFormatBuf())>>1;
|
|
621 |
predictedTime/=BytesPerSecond(RecordFormatBuf());
|
|
622 |
TTime starttime;
|
|
623 |
starttime.HomeTime();
|
|
624 |
|
|
625 |
// Issue a pair of record requests.
|
|
626 |
TInt vol = I64LOW(TInt64(KSoundMaxVolume)*TInt64(bytesRecorded)/TInt64(bytesToRecord));
|
|
627 |
RxSoundDevice.SetVolume(vol);
|
|
628 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
629 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
630 |
TInt currentReq=0;
|
|
631 |
|
|
632 |
TInt retOffset;
|
|
633 |
do
|
|
634 |
{
|
|
635 |
// Wait for the next expected request to complete.
|
|
636 |
User::WaitForRequest(stat[currentReq]);
|
|
637 |
remainingRecordCount--;
|
|
638 |
retOffset=stat[currentReq].Int();
|
|
639 |
CHECK_POSITIVE(retOffset);
|
|
640 |
|
|
641 |
CHECK(length[currentReq]>0);
|
|
642 |
bytesRecorded += length[currentReq];
|
|
643 |
|
|
644 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
645 |
CHECK_NOERROR(r);
|
|
646 |
CHECK_EQUAL(RxSoundDevice.Volume(),vol);
|
|
647 |
CHECK_EQUAL(RxSoundDevice.SetAudioFormat(RecordFormatBuf),KErrInUse);
|
|
648 |
|
|
649 |
vol = I64LOW(TInt64(KSoundMaxVolume)*TInt64(bytesRecorded)/TInt64(bytesToRecord));
|
|
650 |
RxSoundDevice.SetVolume(vol);
|
|
651 |
|
|
652 |
// Don't issue any further record requests on the last two loop passes - to allow for the
|
|
653 |
// two record requests made before the loop started.
|
|
654 |
if (remainingRecordCount>=2)
|
|
655 |
RxSoundDevice.RecordData(stat[currentReq],length[currentReq]);
|
|
656 |
|
|
657 |
currentReq^=0x01; // Toggle the current req. indicator
|
|
658 |
}
|
|
659 |
while(remainingRecordCount>0);
|
|
660 |
|
|
661 |
TTime endtime;
|
|
662 |
endtime.HomeTime();
|
|
663 |
TInt64 elapsedTime = endtime.Int64()-starttime.Int64(); // us
|
|
664 |
Test.Printf(_L("Recorded %d bytes in %d us\n"),bytesRecorded, I64LOW(elapsedTime));
|
|
665 |
if (elapsedTime < predictedTime)
|
|
666 |
{
|
|
667 |
Test.Printf(_L("**** FAIL: time travelling; record took less time than it could have done\n"));
|
|
668 |
// CHECK_NOERROR(1);
|
|
669 |
}
|
|
670 |
CHECK_EQUAL(bytesToRecord,bytesRecorded);
|
|
671 |
Test.Printf(_L("Sample rate successful\r\n"));
|
|
672 |
|
|
673 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
674 |
chunk.Close();
|
|
675 |
}
|
|
676 |
}
|
|
677 |
|
|
678 |
/** @SYMTestCaseID PBASE-T_SOUND2-253
|
|
679 |
@SYMTestCaseDesc Record operation - altering the record level.
|
|
680 |
@SYMTestPriority Critical
|
|
681 |
@SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration
|
|
682 |
so it contains multiple buffers. Using multiple simultaneous record requests, record 10
|
|
683 |
seconds of audio data - with each individual record request being for 1/8th second of data.
|
|
684 |
Each time a request completes, increase the record level slightly - starting at the minimum
|
|
685 |
and ending at maximum record level.
|
|
686 |
@SYMTestExpectedResults The driver should successfully record 10 seconds of data - i.e. all requests should complete
|
|
687 |
with KErrNone.
|
|
688 |
@SYMREQ PREQ1073.4
|
|
689 |
*/
|
|
690 |
LOCAL_C void TestRecordVolume(TInt aNumChannels,TInt aNumSeconds)
|
|
691 |
{
|
|
692 |
TRequestStatus stat[2];
|
|
693 |
TInt length[2];
|
|
694 |
TInt r, i;
|
|
695 |
|
|
696 |
Test.Next(_L("Preparing to test variable record levels..."));
|
|
697 |
|
|
698 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
699 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
700 |
|
|
701 |
RecordFormatBuf().iChannels = aNumChannels;
|
|
702 |
|
|
703 |
// find first supported rate and set the the audio configuration to use it
|
|
704 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
705 |
{
|
|
706 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
707 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
708 |
if (RecordCapsBuf().iRates & (1<<i))
|
|
709 |
{
|
|
710 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
711 |
break;
|
|
712 |
}
|
|
713 |
}
|
|
714 |
PrintConfig(RecordFormatBuf(),Test);
|
|
715 |
|
|
716 |
// Set the record buffer configuration, then read it back.
|
|
717 |
RChunk chunk;
|
|
718 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
719 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
720 |
TTestSharedChunkBufConfig bufferConfig;
|
|
721 |
bufferConfig.iNumBuffers=8;
|
|
722 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
723 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
724 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
725 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
726 |
CHECK_NOERROR(r);
|
|
727 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
728 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
729 |
|
|
730 |
Test.Next(_L("Recording..."));
|
|
731 |
TInt remainingRecordCount = BytesPerSecond(RecordFormatBuf())*aNumSeconds/bufSize;
|
|
732 |
TInt bytesToRecord = remainingRecordCount*bufSize;
|
|
733 |
TInt bytesRecorded = 0;
|
|
734 |
|
|
735 |
// Issue a pair of record requests.
|
|
736 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
737 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
738 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
739 |
TInt currentReq=0;
|
|
740 |
|
|
741 |
TInt retOffset;
|
|
742 |
do
|
|
743 |
{
|
|
744 |
// Adjust the record level.
|
|
745 |
TInt vol = I64LOW(TInt64(KSoundMaxVolume)*TInt64(bytesRecorded)/TInt64(bytesToRecord));
|
|
746 |
r=RxSoundDevice.SetVolume(vol);
|
|
747 |
CHECK_NOERROR(r);
|
|
748 |
|
|
749 |
// Wait for the next expected request to complete.
|
|
750 |
User::WaitForRequest(stat[currentReq]);
|
|
751 |
remainingRecordCount--;
|
|
752 |
retOffset=stat[currentReq].Int();
|
|
753 |
CHECK_POSITIVE(retOffset);
|
|
754 |
|
|
755 |
// Check the length recorded and update bytes recorded.
|
|
756 |
CHECK(length[currentReq]>0);
|
|
757 |
bytesRecorded += length[currentReq];
|
|
758 |
Test.Printf(_L("."));
|
|
759 |
|
|
760 |
// Read back the record level / check we can't reconfig while recording.
|
|
761 |
CHECK_EQUAL(RxSoundDevice.Volume(),vol);
|
|
762 |
CHECK_EQUAL(RxSoundDevice.SetAudioFormat(RecordFormatBuf),KErrInUse);
|
|
763 |
|
|
764 |
// Now release the buffer and issue another record request.
|
|
765 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
766 |
CHECK_NOERROR(r);
|
|
767 |
// Don't issue any further record requests on the last two loop passes - to allow for the
|
|
768 |
// two record requests made before the loop started.
|
|
769 |
if (remainingRecordCount>=2)
|
|
770 |
RxSoundDevice.RecordData(stat[currentReq],length[currentReq]);
|
|
771 |
|
|
772 |
currentReq^=0x01; // Toggle the current req. indicator
|
|
773 |
}
|
|
774 |
while(remainingRecordCount>0);
|
|
775 |
|
|
776 |
CHECK_EQUAL(bytesToRecord,bytesRecorded);
|
|
777 |
|
|
778 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
779 |
Test.Printf(_L("\nBytes recorded = %d\r\n"),bytesRecorded);
|
|
780 |
chunk.Close();
|
|
781 |
}
|
|
782 |
|
|
783 |
/** @SYMTestCaseID PBASE-T_SOUND2-245
|
|
784 |
@SYMTestCaseDesc Play operation - play cancellation.
|
|
785 |
@SYMTestPriority Critical
|
|
786 |
@SYMTestActions Setup the audio configuration on the playback channel and then setup the buffer configuration
|
|
787 |
so it contains two buffers.
|
|
788 |
1) Issue two simultaneous play requests, one from each buffer, each of 1/2 second of tone.
|
|
789 |
Wait for the first one to complete and issue a further play request from the same buffer.
|
|
790 |
Then immediately cancel all outstanding play requests (using CancelPlayData()).
|
|
791 |
2) Issue two simultaneous play requests, one from each buffer, each of 1/2 second of tone.
|
|
792 |
Wait for the first one to complete and issue a further play request from the same buffer.
|
|
793 |
Then immediately cancel the 2nd (i.e. now active) play request (using Cancel()).
|
|
794 |
@SYMTestExpectedResults 1) Both outstanding requests should complete, either with KErrNone or with KErrCancel.
|
|
795 |
2) The second request should complete, either with KErrNone or with KErrCancel whereas the
|
|
796 |
third should complete only with KErrNone.
|
|
797 |
@SYMREQ PREQ1073.4
|
|
798 |
*/
|
|
799 |
LOCAL_C void TestPlayCancel()
|
|
800 |
{
|
|
801 |
TRequestStatus stat[2];
|
|
802 |
TPtr8* tPtr[2];
|
|
803 |
TInt i, r;
|
|
804 |
for (i=0;i<2;i++)
|
|
805 |
tPtr[i]=new TPtr8(NULL,0);
|
|
806 |
|
|
807 |
Test.Next(_L("Test play cancellation"));
|
|
808 |
|
|
809 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
810 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
811 |
PlayFormatBuf().iChannels = 2;
|
|
812 |
|
|
813 |
// find first supported rate and set the the audio configuration to use it
|
|
814 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
815 |
{
|
|
816 |
// check record channel
|
|
817 |
PlayFormatBuf().iRate = (TSoundRate)i;
|
|
818 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
819 |
if (PlayCapsBuf().iRates & (1 << i))
|
|
820 |
{
|
|
821 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
822 |
break;
|
|
823 |
}
|
|
824 |
}
|
|
825 |
PrintConfig(PlayFormatBuf(),Test);
|
|
826 |
r=MakeSineTable(PlayFormatBuf());
|
|
827 |
CHECK_NOERROR(r);
|
|
828 |
|
|
829 |
// Set the play buffer configuration, then read it back.
|
|
830 |
RChunk chunk;
|
|
831 |
TInt bufSize=BytesPerSecond(PlayFormatBuf())/2; // Large enough to hold 1/2 second of data.
|
|
832 |
bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver.
|
|
833 |
TTestSharedChunkBufConfig bufferConfig;
|
|
834 |
bufferConfig.iNumBuffers=2;
|
|
835 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
836 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
837 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
838 |
r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
839 |
CHECK_NOERROR(r);
|
|
840 |
TxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
841 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
842 |
tPtr[0]->Set(chunk.Base()+bufferConfig.iBufferOffsetList[0],0,bufSize);
|
|
843 |
tPtr[1]->Set(chunk.Base()+bufferConfig.iBufferOffsetList[1],0,bufSize);
|
|
844 |
|
|
845 |
Test.Next(_L("Test cancelling all outstanding requests"));
|
|
846 |
// Issue a pair of play requests.
|
|
847 |
r=SetToneFrequency(440,PlayFormatBuf());
|
|
848 |
CHECK_NOERROR(r);
|
|
849 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
850 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize);
|
|
851 |
WriteTone(*tPtr[1],PlayFormatBuf());
|
|
852 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize);
|
|
853 |
|
|
854 |
// Wait for the 1st request to complete. Then, re-queue a further request but then
|
|
855 |
// immediately cancel both requests.
|
|
856 |
User::WaitForRequest(stat[0]);
|
|
857 |
CHECK_NOERROR(stat[0].Int());
|
|
858 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
859 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize);
|
|
860 |
TxSoundDevice.CancelPlayData();
|
|
861 |
|
|
862 |
User::WaitForRequest(stat[1]);
|
|
863 |
if (stat[1]==KErrNone)
|
|
864 |
Test.Printf(_L("Note: 2nd request finished without cancel error\r\n"));
|
|
865 |
else
|
|
866 |
CHECK_EQUAL(stat[1].Int(),KErrCancel);
|
|
867 |
User::WaitForRequest(stat[0]);
|
|
868 |
if (stat[0]==KErrNone)
|
|
869 |
Test.Printf(_L("Note: 3rd request finished without cancel error\r\n"));
|
|
870 |
else
|
|
871 |
CHECK_EQUAL(stat[0].Int(),KErrCancel);
|
|
872 |
|
|
873 |
Test.Next(_L("Test cancelling an individual requests"));
|
|
874 |
// Issue a further pair of play requests.
|
|
875 |
r=SetToneFrequency(440,PlayFormatBuf());
|
|
876 |
CHECK_NOERROR(r);
|
|
877 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
878 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,0);
|
|
879 |
WriteTone(*tPtr[1],PlayFormatBuf());
|
|
880 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize,0);
|
|
881 |
|
|
882 |
// Again, wait for the 1st request to complete. Then, re-queue a further request but then
|
|
883 |
// immediately cancel the 2nd request.
|
|
884 |
User::WaitForRequest(stat[0]);
|
|
885 |
CHECK_NOERROR(stat[0].Int());
|
|
886 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
887 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,KSndFlagLastSample);
|
|
888 |
TxSoundDevice.Cancel(stat[1]);
|
|
889 |
|
|
890 |
User::WaitForRequest(stat[1]);
|
|
891 |
if (stat[1]==KErrNone)
|
|
892 |
Test.Printf(_L("Note: 2nd request finished without cancel error\r\n"));
|
|
893 |
else
|
|
894 |
CHECK_EQUAL(stat[1].Int(),KErrCancel);
|
|
895 |
User::WaitForRequest(stat[0]);
|
|
896 |
CHECK_NOERROR(stat[0].Int());
|
|
897 |
|
|
898 |
chunk.Close();
|
|
899 |
Test.Printf(_L("Cancel play test completed successful\r\n"));
|
|
900 |
|
|
901 |
for (i=0;i<2;i++)
|
|
902 |
delete tPtr[i];
|
|
903 |
}
|
|
904 |
|
|
905 |
/** @SYMTestCaseID PBASE-T_SOUND2-259
|
|
906 |
@SYMTestCaseDesc Record operation - record cancellation.
|
|
907 |
@SYMTestPriority Critical
|
|
908 |
@SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration
|
|
909 |
so it contains multiple buffers.
|
|
910 |
1) Issue two simultaneous record requests requests, each for 1/2 second of data. Wait for
|
|
911 |
the first one to complete and issue a further record request. Then immediately cancel all
|
|
912 |
outstanding record requests (using CancelRecordData()).
|
|
913 |
2) Issue two simultaneous record requests, each for 1/2 second of data. Wait for the first
|
|
914 |
one to complete and issue a further record request. Then immediately cancel the 2nd (i.e.
|
|
915 |
now active) record request (using Cancel()).
|
|
916 |
@SYMTestExpectedResults 1) Both outstanding requests should complete, either with KErrNone or with KErrCancel.
|
|
917 |
2) The second requests should complete, either with KErrNone or with KErrCancel whereas the
|
|
918 |
third should complete only with KErrNone.
|
|
919 |
@SYMREQ PREQ1073.4
|
|
920 |
*/
|
|
921 |
LOCAL_C void TestRecordCancel()
|
|
922 |
{
|
|
923 |
TRequestStatus stat[2];
|
|
924 |
TInt length[2];
|
|
925 |
TPtr8* tPtr[2];
|
|
926 |
TInt i, r;
|
|
927 |
for (i=0;i<2;i++)
|
|
928 |
tPtr[i]=new TPtr8(NULL,0);
|
|
929 |
|
|
930 |
Test.Next(_L("Test record cancellation"));
|
|
931 |
|
|
932 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
933 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
934 |
RecordFormatBuf().iChannels = 2;
|
|
935 |
|
|
936 |
// find first supported rate and set the the audio configuration to use it
|
|
937 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
938 |
{
|
|
939 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
940 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
941 |
if (RecordCapsBuf().iRates & (1<<i))
|
|
942 |
{
|
|
943 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
944 |
break;
|
|
945 |
}
|
|
946 |
}
|
|
947 |
|
|
948 |
PrintConfig(RecordFormatBuf(),Test);
|
|
949 |
|
|
950 |
// Set the record buffer configuration, then read it back.
|
|
951 |
RChunk chunk;
|
|
952 |
TTestSharedChunkBufConfig bufferConfig;
|
|
953 |
bufferConfig.iNumBuffers=3;
|
|
954 |
bufferConfig.iBufferSizeInBytes=BytesPerSecond(RecordFormatBuf())/2; // Large enough to hold 1/2 second of data.
|
|
955 |
bufferConfig.iBufferSizeInBytes=ValidBufferSize(bufferConfig.iBufferSizeInBytes,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
956 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
957 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
958 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
959 |
CHECK_NOERROR(r);
|
|
960 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
961 |
|
|
962 |
Test.Next(_L("Test cancelling all outstanding requests"));
|
|
963 |
// Issue a pair of record requests.
|
|
964 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
965 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
966 |
|
|
967 |
// Wait for the 1st request to complete. Then, re-queue a further request but then
|
|
968 |
// immediately cancel both requests.
|
|
969 |
TInt retOffset;
|
|
970 |
User::WaitForRequest(stat[0]);
|
|
971 |
retOffset=stat[0].Int();
|
|
972 |
CHECK_POSITIVE(retOffset);
|
|
973 |
CHECK(length[0]>0);
|
|
974 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
975 |
CHECK_NOERROR(r);
|
|
976 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
977 |
RxSoundDevice.CancelRecordData();
|
|
978 |
|
|
979 |
User::WaitForRequest(stat[1]);
|
|
980 |
retOffset=stat[1].Int();
|
|
981 |
if (retOffset>=0)
|
|
982 |
Test.Printf(_L("Note: 2nd request finished without cancel error\r\n"));
|
|
983 |
else
|
|
984 |
CHECK_EQUAL(retOffset,KErrCancel);
|
|
985 |
User::WaitForRequest(stat[0]);
|
|
986 |
retOffset=stat[0].Int();
|
|
987 |
if (retOffset>=0)
|
|
988 |
Test.Printf(_L("Note: 3rd request finished without cancel error\r\n"));
|
|
989 |
else
|
|
990 |
CHECK_EQUAL(retOffset,KErrCancel);
|
|
991 |
|
|
992 |
Test.Next(_L("Test cancelling an individual requests"));
|
|
993 |
// Issue a further pair of record requests.
|
|
994 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
995 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
996 |
|
|
997 |
// Again, wait for the 1st request to complete. Then, re-queue a further request but then
|
|
998 |
// immediately cancel the 2nd request.
|
|
999 |
User::WaitForRequest(stat[0]);
|
|
1000 |
retOffset=stat[0].Int();
|
|
1001 |
CHECK_POSITIVE(retOffset);
|
|
1002 |
CHECK(length[0]>0);
|
|
1003 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
1004 |
CHECK_NOERROR(r);
|
|
1005 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1006 |
RxSoundDevice.Cancel(stat[1]);
|
|
1007 |
|
|
1008 |
User::WaitForRequest(stat[1]);
|
|
1009 |
retOffset=stat[1].Int();
|
|
1010 |
if (retOffset>=0)
|
|
1011 |
Test.Printf(_L("Note: 2nd request finished without cancel error\r\n"));
|
|
1012 |
else
|
|
1013 |
CHECK_EQUAL(retOffset,KErrCancel);
|
|
1014 |
User::WaitForRequest(stat[0]);
|
|
1015 |
retOffset=stat[0].Int();
|
|
1016 |
CHECK_POSITIVE(retOffset);
|
|
1017 |
CHECK(length[0]>0);
|
|
1018 |
|
|
1019 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
1020 |
chunk.Close();
|
|
1021 |
Test.Printf(_L("Cancel record test completed successful\r\n"));
|
|
1022 |
|
|
1023 |
for (i=0;i<2;i++)
|
|
1024 |
delete tPtr[i];
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
/** @SYMTestCaseID PBASE-T_SOUND2-262
|
|
1028 |
@SYMTestCaseDesc Play pause / resume - pausing and resuming before playback has commenced.
|
|
1029 |
@SYMTestPriority Critical
|
|
1030 |
@SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration.
|
|
1031 |
1) Attempt to resume recording before recording has been started.
|
|
1032 |
2) Attempt to pause recording before recording has been started.
|
|
1033 |
@SYMTestExpectedResults 1) The resume request should complete with KErrNotReady.
|
|
1034 |
2) The pause request should complete with KErrNotReady.
|
|
1035 |
@SYMREQ PREQ1073.4
|
|
1036 |
*/
|
|
1037 |
|
|
1038 |
/** @SYMTestCaseID PBASE-T_SOUND2-263
|
|
1039 |
@SYMTestCaseDesc Record pause / resume - pausing and resuming while recording is in progress.
|
|
1040 |
@SYMTestPriority Critical
|
|
1041 |
@SYMTestActions Setup the audio configuration on the record channel and then setup the buffer configuration
|
|
1042 |
so it contains multiple buffers. For the audio configuration selected, calculate the total
|
|
1043 |
number of bytes expected to be transferred in order record 4 seconds of data. Using multiple
|
|
1044 |
simultaneous record requests, record 4 seconds of audio data - with each individual record
|
|
1045 |
request being for 1/8th second of data. Increment a count of actual total bytes transferred
|
|
1046 |
by examining the count of bytes stored in the buffer for each request as it completes.
|
|
1047 |
1) After 10 requests have completed, pause transfer for 1 second, then resume it. If pausing
|
|
1048 |
causes a record request to complete with a shorter than requested length then reduce the
|
|
1049 |
count of expected total bytes transferred.
|
|
1050 |
2) Repeat step 1 when 20 requests have completed.
|
|
1051 |
3) Once transfer has completed, compare the counts of expected and actual total bytes
|
|
1052 |
transferred.
|
|
1053 |
@SYMTestExpectedResults 1) The pause and resume requests should both complete with KErrNone.
|
|
1054 |
2) The pause and resume requests should both complete with KErrNone.
|
|
1055 |
3) The counts should be equal.
|
|
1056 |
@SYMREQ PREQ1073.4
|
|
1057 |
*/
|
|
1058 |
LOCAL_C void TestRecordPauseResume()
|
|
1059 |
{
|
|
1060 |
TRequestStatus stat[2];
|
|
1061 |
TInt length[2];
|
|
1062 |
|
|
1063 |
Test.Next(_L("Test record pause and resume"));
|
|
1064 |
RecordFormatBuf().iRate = ESoundRate44100Hz;
|
|
1065 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
1066 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1067 |
PlayFormatBuf().iChannels = 2;
|
|
1068 |
PrintConfig(RecordFormatBuf(),Test);
|
|
1069 |
TInt r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
1070 |
CHECK_NOERROR(r);
|
|
1071 |
|
|
1072 |
// Set the record buffer configuration, then read it back.
|
|
1073 |
RChunk chunk;
|
|
1074 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
1075 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
1076 |
TTestSharedChunkBufConfig bufferConfig;
|
|
1077 |
bufferConfig.iNumBuffers=8;
|
|
1078 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
1079 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
1080 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
1081 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
1082 |
CHECK_NOERROR(r);
|
|
1083 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
1084 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
1085 |
|
|
1086 |
Test.Printf(_L("Resume when not recording\r\n"));
|
|
1087 |
r=RxSoundDevice.Resume();
|
|
1088 |
CHECK(r==KErrNotReady)
|
|
1089 |
|
|
1090 |
Test.Printf(_L("Pause when not recording\r\n"));
|
|
1091 |
r=RxSoundDevice.Pause();
|
|
1092 |
CHECK(r==KErrNotReady)
|
|
1093 |
|
|
1094 |
// Record for 4 seconds
|
|
1095 |
Test.Printf(_L("Record...\r\n"));
|
|
1096 |
TInt remainingRecordCount = BytesPerSecond(RecordFormatBuf())*4/bufSize;
|
|
1097 |
TInt bytesToRecord = remainingRecordCount*bufSize;
|
|
1098 |
TInt bytesRecorded = 0;
|
|
1099 |
|
|
1100 |
// Issue a pair of record requests.
|
|
1101 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
1102 |
length[0] = -42;
|
|
1103 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1104 |
length[1] = -42;
|
|
1105 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
1106 |
TInt currentReq=0;
|
|
1107 |
|
|
1108 |
TInt lcount = 0;
|
|
1109 |
TInt retOffset;
|
|
1110 |
do
|
|
1111 |
{
|
|
1112 |
// Do a pause / resume on 10th and 20th loop passes.
|
|
1113 |
if (lcount && !(lcount%10))
|
|
1114 |
{
|
|
1115 |
// Do a pause/resume
|
|
1116 |
Test.Printf(_L("Pause 1 second\r\n"));
|
|
1117 |
r=RxSoundDevice.Pause();
|
|
1118 |
CHECK_NOERROR(r);
|
|
1119 |
|
|
1120 |
// Pausing record may result in the driver completing with a buffer not completely full. This isn't an error. Otherwise, all outstanding
|
|
1121 |
// requests should complete with KErrCancel. Wait for the 1st outstanding request to complete.
|
|
1122 |
User::WaitForRequest(stat[currentReq]);
|
|
1123 |
retOffset=stat[currentReq].Int();
|
|
1124 |
if (retOffset>=0)
|
|
1125 |
{
|
|
1126 |
// Partially filled buffer. We need to adjust the bytes expected when an incomplete buffer arrives.
|
|
1127 |
remainingRecordCount--;
|
|
1128 |
|
|
1129 |
CHECK_POSITIVE(length[currentReq]);
|
|
1130 |
bytesRecorded += length[currentReq];
|
|
1131 |
if (length[currentReq]<bufSize)
|
|
1132 |
bytesToRecord-=(bufSize-length[currentReq]);
|
|
1133 |
Test.Printf(_L("1st outstanding req partially completed(len=%d)\r\n"),length[currentReq]);
|
|
1134 |
|
|
1135 |
r=RxSoundDevice.ReleaseBuffer(retOffset); // Release the buffer ready for resuming
|
|
1136 |
CHECK_NOERROR(r);
|
|
1137 |
}
|
|
1138 |
else
|
|
1139 |
{
|
|
1140 |
CHECK(retOffset==KErrCancel);
|
|
1141 |
Test.Printf(_L("1st outstanding req cancelled\r\n"));
|
|
1142 |
}
|
|
1143 |
currentReq^=0x01; // Toggle the current req. indicator
|
|
1144 |
|
|
1145 |
// Wait for the 2nd outstanding request to complete
|
|
1146 |
User::WaitForRequest(stat[currentReq]);
|
|
1147 |
retOffset=stat[currentReq].Int();
|
|
1148 |
CHECK(retOffset==KErrCancel);
|
|
1149 |
Test.Printf(_L("2nd outstanding req cancelled\r\n"));
|
|
1150 |
|
|
1151 |
// Idle for 1 second, resume and then re-issue a pair of record requests.
|
|
1152 |
User::After(1000000);
|
|
1153 |
Test.Printf(_L("Resume\r\n"));
|
|
1154 |
r=RxSoundDevice.Resume();
|
|
1155 |
CHECK_NOERROR(r);
|
|
1156 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1157 |
RxSoundDevice.RecordData(stat[1],length[1]);
|
|
1158 |
currentReq=0;
|
|
1159 |
}
|
|
1160 |
|
|
1161 |
// Wait for the next expected request to complete.
|
|
1162 |
User::WaitForRequest(stat[currentReq]);
|
|
1163 |
remainingRecordCount--;
|
|
1164 |
retOffset=stat[currentReq].Int();
|
|
1165 |
CHECK_POSITIVE(retOffset);
|
|
1166 |
CHECK(length[currentReq]>0);
|
|
1167 |
bytesRecorded += length[currentReq];
|
|
1168 |
|
|
1169 |
// Now release the buffer and issue another record request
|
|
1170 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
1171 |
CHECK_NOERROR(r);
|
|
1172 |
// Don't issue any further record requests on the last two loop passes - to allow for the
|
|
1173 |
// two record requests made before the loop started.
|
|
1174 |
if (remainingRecordCount>=2)
|
|
1175 |
RxSoundDevice.RecordData(stat[currentReq],length[currentReq]);
|
|
1176 |
lcount++;
|
|
1177 |
currentReq^=0x01; // Toggle the current req. indicator
|
|
1178 |
}
|
|
1179 |
while(remainingRecordCount>0);
|
|
1180 |
|
|
1181 |
CHECK_EQUAL(bytesToRecord,bytesRecorded);
|
|
1182 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
1183 |
Test.Printf(_L("Record pause/resume successful\r\n"));
|
|
1184 |
|
|
1185 |
Test.Next(_L("Test record pause alone"));
|
|
1186 |
|
|
1187 |
// Issue a single record request, wait for it to complete and then release it.
|
|
1188 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1189 |
User::WaitForRequest(stat[0]);
|
|
1190 |
retOffset=stat[0].Int();
|
|
1191 |
CHECK_POSITIVE(retOffset);
|
|
1192 |
CHECK(length[0]==bufSize);
|
|
1193 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
1194 |
CHECK_NOERROR(r);
|
|
1195 |
|
|
1196 |
// Without issuing another record request, wait for a duration equal to one record buffer, then pause.
|
|
1197 |
User::After(150000); // Wait a bit longer than 1 buffer's worth (125000 is 1/8 second).
|
|
1198 |
Test.Printf(_L("Pause\r\n"));
|
|
1199 |
r=RxSoundDevice.Pause();
|
|
1200 |
CHECK_NOERROR(r);
|
|
1201 |
|
|
1202 |
// Check that there is at least 1 buffer's worth of record data available
|
|
1203 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1204 |
User::WaitForRequest(stat[0]);
|
|
1205 |
retOffset=stat[0].Int();
|
|
1206 |
CHECK_POSITIVE(retOffset);
|
|
1207 |
CHECK(length[0]==bufSize);
|
|
1208 |
Test.Printf(_L("1st req completed successfully\r\n"));
|
|
1209 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
1210 |
CHECK_NOERROR(r);
|
|
1211 |
|
|
1212 |
// There's probably also a partially filled buffer
|
|
1213 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1214 |
User::WaitForRequest(stat[0]);
|
|
1215 |
retOffset=stat[0].Int();
|
|
1216 |
if (retOffset>=0)
|
|
1217 |
{
|
|
1218 |
// Partially filled buffer.
|
|
1219 |
CHECK(length[0]>0);
|
|
1220 |
Test.Printf(_L("2nd req partially completed(len=%d)\r\n"),length[0]);
|
|
1221 |
r=RxSoundDevice.ReleaseBuffer(retOffset);
|
|
1222 |
CHECK_NOERROR(r);
|
|
1223 |
}
|
|
1224 |
else
|
|
1225 |
{
|
|
1226 |
CHECK(retOffset==KErrCancel);
|
|
1227 |
Test.Printf(_L("2nd req cancelled\r\n"));
|
|
1228 |
}
|
|
1229 |
|
|
1230 |
// Any further record request should return straight away with KErrCancel
|
|
1231 |
RxSoundDevice.RecordData(stat[0],length[0]);
|
|
1232 |
User::WaitForRequest(stat[0]);
|
|
1233 |
retOffset=stat[0].Int();
|
|
1234 |
CHECK(retOffset==KErrCancel);
|
|
1235 |
Test.Printf(_L("3rd req cancelled\r\n"));
|
|
1236 |
|
|
1237 |
r=RxSoundDevice.Resume(); // Don't leave it in paused state.
|
|
1238 |
CHECK_NOERROR(r);
|
|
1239 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
1240 |
Test.Printf(_L("Record pause successful\r\n"));
|
|
1241 |
|
|
1242 |
chunk.Close();
|
|
1243 |
}
|
|
1244 |
|
|
1245 |
template <class T>
|
|
1246 |
class RQueue
|
|
1247 |
{
|
|
1248 |
public:
|
|
1249 |
RQueue()
|
|
1250 |
: iArray()
|
|
1251 |
{ }
|
|
1252 |
void Close()
|
|
1253 |
{
|
|
1254 |
iArray.Close();
|
|
1255 |
}
|
|
1256 |
TInt Count() const
|
|
1257 |
{
|
|
1258 |
return iArray.Count();
|
|
1259 |
}
|
|
1260 |
void PushL(const T &aItem)
|
|
1261 |
{
|
|
1262 |
iArray.AppendL(aItem);
|
|
1263 |
}
|
|
1264 |
T PopL()
|
|
1265 |
{
|
|
1266 |
if(iArray.Count() == 0)
|
|
1267 |
{
|
|
1268 |
User::Leave(KErrUnderflow);
|
|
1269 |
}
|
|
1270 |
const T ret = iArray[0];
|
|
1271 |
iArray.Remove(0);
|
|
1272 |
return ret;
|
|
1273 |
}
|
|
1274 |
private:
|
|
1275 |
RArray<T> iArray;
|
|
1276 |
};
|
|
1277 |
/** @SYMTestCaseID PBASE-T_SOUND2-248
|
|
1278 |
@SYMTestCaseDesc Play operation - simultaneous play and record on the same device, using a common shared chunk.
|
|
1279 |
@SYMTestPriority Critical
|
|
1280 |
@SYMTestActions Setup the audio configuration on the record channel and setup an identical audio
|
|
1281 |
configuration on the playback channel. On the record channel, create a shared chunk
|
|
1282 |
(i.e. using SetBufferChunkCreate()) with a buffer configuration containing multiple buffers.
|
|
1283 |
Open the same shared chunk on the playback channel (i.e. using SetBufferChunkOpen()).
|
|
1284 |
Set the volume to maximum level in both channels. Record 10 seconds of audio data - with
|
|
1285 |
each individual record request being for 1/8th second of data. As soon as each record request
|
|
1286 |
completes, issue a corresponding request on the playback channel to playback the
|
|
1287 |
1/8th second of data recorded. Only release each buffer for further recording once its
|
|
1288 |
contents have been played back. Continue until 10 seconds of audio data has been both
|
|
1289 |
recorded and played back. (Ensure the last play request is marked with the
|
|
1290 |
KSndFlagLastSample flag).
|
|
1291 |
@SYMTestExpectedResults The driver should successfully record and play 10 seconds of data - with all requests
|
|
1292 |
completing with KErrNone.
|
|
1293 |
@SYMREQ PREQ1073.4
|
|
1294 |
*/
|
|
1295 |
void TestSimultaneousPlayRecord()
|
|
1296 |
{
|
|
1297 |
Test.Next(_L("Preparing to record/play simultaneously..."));
|
|
1298 |
TInt r = KErrNone;
|
|
1299 |
TInt i;
|
|
1300 |
// Setup the same sound configuration for both - record and play channels
|
|
1301 |
if (RecordCapsBuf().iEncodings & KSoundEncoding16BitPCM)
|
|
1302 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1303 |
|
|
1304 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
1305 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1306 |
|
|
1307 |
RecordFormatBuf().iChannels = 2;
|
|
1308 |
PlayFormatBuf().iChannels = 2;
|
|
1309 |
|
|
1310 |
// find first supported rate and set the the audio configuration to use it
|
|
1311 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
1312 |
{
|
|
1313 |
// check record channel
|
|
1314 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
1315 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
1316 |
if (RecordCapsBuf().iRates & (1 << i))
|
|
1317 |
{
|
|
1318 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
1319 |
|
|
1320 |
// ..and try the same bitrate for playback
|
|
1321 |
PlayFormatBuf().iRate = (TSoundRate)i;
|
|
1322 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
1323 |
if (PlayCapsBuf().iRates & (1 << i))
|
|
1324 |
{
|
|
1325 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
1326 |
break;
|
|
1327 |
}
|
|
1328 |
}
|
|
1329 |
}
|
|
1330 |
|
|
1331 |
// both channels are set at this point, continue
|
|
1332 |
PrintConfig(RecordFormatBuf(),Test);
|
|
1333 |
PrintConfig(PlayFormatBuf(),Test);
|
|
1334 |
|
|
1335 |
// Set the volume level in both channels
|
|
1336 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
1337 |
TxSoundDevice.SetVolume(KSoundMaxVolume - 10);
|
|
1338 |
|
|
1339 |
// Set the record buffer configuration, then read it back.
|
|
1340 |
RChunk chunk;
|
|
1341 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
1342 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
1343 |
TTestSharedChunkBufConfig bufferConfig;
|
|
1344 |
bufferConfig.iNumBuffers=7+7; // Must be able to use less than this
|
|
1345 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
1346 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
1347 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
1348 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
1349 |
CHECK_NOERROR(r);
|
|
1350 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
1351 |
PrintBufferConf(bufferConfig,Test);
|
|
1352 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
1353 |
|
|
1354 |
// Assign the same chunk to the play channel.
|
|
1355 |
r=TxSoundDevice.SetBufferChunkOpen(bufferConfigBuf,chunk);
|
|
1356 |
CHECK_NOERROR(r);
|
|
1357 |
|
|
1358 |
Test.Next(_L("Starting transfer..."));
|
|
1359 |
TInt remainingRecordCount = BytesPerSecond(RecordFormatBuf())*10/bufSize; // 10 seconds
|
|
1360 |
TInt remainingPlayCount = remainingRecordCount;
|
|
1361 |
TInt bytesToTransfer = remainingRecordCount*bufSize;
|
|
1362 |
TInt bytesRecorded = 0;
|
|
1363 |
TInt bytesPlayed = 0;
|
|
1364 |
|
|
1365 |
TRequestStatus stat[3]; // 1 record + 2 play request statuses
|
|
1366 |
TInt length;
|
|
1367 |
TInt activePlayOffset[2]; // To keep track of the buffer offset for each active play request.
|
|
1368 |
RQueue<TInt> playQueue; // A list containing the offsets for any buffer which is waiting to be played.
|
|
1369 |
|
|
1370 |
// Issue three record requests and wait for them to complete.
|
|
1371 |
TInt retOffset;
|
|
1372 |
for (i=0 ; i<3 ; i++)
|
|
1373 |
{
|
|
1374 |
RxSoundDevice.RecordData(stat[2],length);
|
|
1375 |
User::WaitForRequest(stat[2]);
|
|
1376 |
retOffset=stat[2].Int();
|
|
1377 |
// Test.Printf(_L("RECORD(%d)-Buf %d\r\n"),i,retOffset);
|
|
1378 |
CHECK_POSITIVE(retOffset);
|
|
1379 |
CHECK(length==bufSize);
|
|
1380 |
bytesRecorded += length;
|
|
1381 |
playQueue.PushL(retOffset);
|
|
1382 |
remainingRecordCount--;
|
|
1383 |
Test.Printf(_L("."));
|
|
1384 |
}
|
|
1385 |
|
|
1386 |
// Start playing first two buffers
|
|
1387 |
TUint flags=0;
|
|
1388 |
activePlayOffset[0]=playQueue.PopL();
|
|
1389 |
TxSoundDevice.PlayData(stat[0],activePlayOffset[0],bufSize,flags);
|
|
1390 |
activePlayOffset[1]=playQueue.PopL();
|
|
1391 |
TxSoundDevice.PlayData(stat[1],activePlayOffset[1],bufSize,flags);
|
|
1392 |
|
|
1393 |
// Now queue the next record request.
|
|
1394 |
RxSoundDevice.RecordData(stat[2],length);
|
|
1395 |
|
|
1396 |
do
|
|
1397 |
{
|
|
1398 |
// Wait for the next request to complete.
|
|
1399 |
User::WaitForAnyRequest();
|
|
1400 |
|
|
1401 |
// Work out which request this applies to.
|
|
1402 |
for (i=0;i<3;i++)
|
|
1403 |
{
|
|
1404 |
if (stat[i]!=KRequestPending)
|
|
1405 |
break;
|
|
1406 |
}
|
|
1407 |
CHECK(i<3);
|
|
1408 |
|
|
1409 |
if (i==2)
|
|
1410 |
{
|
|
1411 |
// It is the record request that has completed
|
|
1412 |
remainingRecordCount--;
|
|
1413 |
retOffset=stat[2].Int();
|
|
1414 |
// Test.Printf(_L("RECORD(%d)-Buf %d\r\n"),remainingRecordCount,retOffset);
|
|
1415 |
CHECK_POSITIVE(retOffset);
|
|
1416 |
CHECK(length==bufSize);
|
|
1417 |
bytesRecorded += length;
|
|
1418 |
Test.Printf(_L("."));
|
|
1419 |
|
|
1420 |
// Add the buffer to playQueue
|
|
1421 |
playQueue.PushL(retOffset);
|
|
1422 |
|
|
1423 |
// If we haven't recorded enough data yet then record some more.
|
|
1424 |
if (remainingRecordCount>0)
|
|
1425 |
RxSoundDevice.RecordData(stat[2],length);
|
|
1426 |
else
|
|
1427 |
{
|
|
1428 |
Test.Printf(_L("***Disabling stat[2]\r\n"));
|
|
1429 |
stat[2]=KRequestPending;
|
|
1430 |
}
|
|
1431 |
}
|
|
1432 |
else
|
|
1433 |
{
|
|
1434 |
// Its one of the play requests that have completed, release the buffer.
|
|
1435 |
CHECK_NOERROR(stat[i].Int());
|
|
1436 |
// Test.Printf(_L("PLAY(%d) i%d CompBuf %d\r\n"),remainingPlayCount-1,i,activePlayOffset[i]);
|
|
1437 |
r=RxSoundDevice.ReleaseBuffer(activePlayOffset[i]);
|
|
1438 |
CHECK_NOERROR(r);
|
|
1439 |
|
|
1440 |
remainingPlayCount--;
|
|
1441 |
bytesPlayed += bufSize;
|
|
1442 |
Test.Printf(_L("*"));
|
|
1443 |
|
|
1444 |
// If there are buffers available then issue a further play request and update the 'next to play' list.
|
|
1445 |
if (playQueue.Count() != 0)
|
|
1446 |
{
|
|
1447 |
activePlayOffset[i]=playQueue.PopL();
|
|
1448 |
|
|
1449 |
// Test.Printf(_L("PLAY(%d) i%d NextBuf%d\r\n"),remainingPlayCount,i,activePlayOffset[i]);
|
|
1450 |
flags=(remainingPlayCount<=2)?KSndFlagLastSample:0;
|
|
1451 |
TxSoundDevice.PlayData(stat[i],activePlayOffset[i],bufSize,flags);
|
|
1452 |
}
|
|
1453 |
else
|
|
1454 |
{
|
|
1455 |
Test.Printf(_L("***Disabling stat[%d]\r\n"), i, stat[i].Int());
|
|
1456 |
stat[i]=KRequestPending;
|
|
1457 |
}
|
|
1458 |
}
|
|
1459 |
}
|
|
1460 |
while (remainingRecordCount>0 || remainingPlayCount>0);
|
|
1461 |
playQueue.Close();
|
|
1462 |
CHECK_EQUAL(bytesToTransfer,bytesRecorded);
|
|
1463 |
CHECK_EQUAL(bytesToTransfer,bytesPlayed);
|
|
1464 |
|
|
1465 |
RxSoundDevice.CancelRecordData(); // Stop the driver from recording.
|
|
1466 |
chunk.Close();
|
|
1467 |
|
|
1468 |
Test.Printf(_L("\nSimultaneous test ends\r\n"));
|
|
1469 |
return;
|
|
1470 |
}
|
|
1471 |
|
|
1472 |
void TestSpeed()
|
|
1473 |
{
|
|
1474 |
Test.Next(_L("Preparing to measure record/playback speed..."));
|
|
1475 |
TInt r = KErrNone;
|
|
1476 |
TInt i;
|
|
1477 |
// Setup the same sound configuration for both - record and play channels
|
|
1478 |
if (RecordCapsBuf().iEncodings & KSoundEncoding16BitPCM)
|
|
1479 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1480 |
|
|
1481 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
1482 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1483 |
|
|
1484 |
RecordFormatBuf().iChannels = 2;
|
|
1485 |
PlayFormatBuf().iChannels = 2;
|
|
1486 |
|
|
1487 |
// find first supported rate and set the the audio configuration to use it
|
|
1488 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
1489 |
{
|
|
1490 |
// check record channel
|
|
1491 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
1492 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
1493 |
if (RecordCapsBuf().iRates & (1 << i))
|
|
1494 |
{
|
|
1495 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
1496 |
|
|
1497 |
// ..and try the same bitrate for playback
|
|
1498 |
PlayFormatBuf().iRate = (TSoundRate)i;
|
|
1499 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
1500 |
if (PlayCapsBuf().iRates & (1 << i))
|
|
1501 |
{
|
|
1502 |
CHECK_NOERROR(r); // Caps reports it is supported
|
|
1503 |
break;
|
|
1504 |
}
|
|
1505 |
}
|
|
1506 |
}
|
|
1507 |
|
|
1508 |
// both channels are set at this point, continue
|
|
1509 |
PrintConfig(RecordFormatBuf(),Test);
|
|
1510 |
PrintConfig(PlayFormatBuf(),Test);
|
|
1511 |
|
|
1512 |
// Set the volume level in both channels
|
|
1513 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
1514 |
TxSoundDevice.SetVolume(KSoundMaxVolume - 10);
|
|
1515 |
|
|
1516 |
// Set the record buffer configuration, then read it back.
|
|
1517 |
RChunk chunk;
|
|
1518 |
TInt bufSize=BytesPerSecond(RecordFormatBuf())/8; // Large enough to hold 1/8th second of data.
|
|
1519 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
1520 |
TTestSharedChunkBufConfig bufferConfig;
|
|
1521 |
bufferConfig.iNumBuffers=7+7; // Must be able to use less than this
|
|
1522 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
1523 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
1524 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
1525 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
1526 |
CHECK_NOERROR(r);
|
|
1527 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
1528 |
PrintBufferConf(bufferConfig,Test);
|
|
1529 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
1530 |
|
|
1531 |
// Assign the same chunk to the play channel.
|
|
1532 |
r=TxSoundDevice.SetBufferChunkOpen(bufferConfigBuf,chunk);
|
|
1533 |
CHECK_NOERROR(r);
|
|
1534 |
|
|
1535 |
Test.Next(_L("Starting recording speed test..."));
|
|
1536 |
TInt length;
|
|
1537 |
|
|
1538 |
// Recording speed test
|
|
1539 |
TTime preTime, postTime;
|
|
1540 |
preTime.UniversalTime();
|
|
1541 |
for(i=0; i<100; ++i)
|
|
1542 |
{
|
|
1543 |
TRequestStatus s;
|
|
1544 |
length = -1;
|
|
1545 |
|
|
1546 |
TTime preBufTime, postBufTime;
|
|
1547 |
preBufTime.UniversalTime();
|
|
1548 |
RxSoundDevice.RecordData(s, length);
|
|
1549 |
User::WaitForRequest(s);
|
|
1550 |
|
|
1551 |
postBufTime.UniversalTime();
|
|
1552 |
TTimeIntervalMicroSeconds elapsedBufTime = postBufTime.MicroSecondsFrom(preBufTime);
|
|
1553 |
Test.Printf(_L("\tElapsed buf (%d/100) recording time %d\n"), i, elapsedBufTime.Int64());
|
|
1554 |
CHECK(s.Int() >= 0);
|
|
1555 |
CHECK(RxSoundDevice.ReleaseBuffer(s.Int()) == KErrNone);
|
|
1556 |
CHECK(length == bufSize);
|
|
1557 |
}
|
|
1558 |
postTime.UniversalTime();
|
|
1559 |
TTimeIntervalMicroSeconds elapsedRecordingTime = postTime.MicroSecondsFrom(preTime);
|
|
1560 |
Test.Printf(_L("Elapsed recording time %d\n"), elapsedRecordingTime.Int64());
|
|
1561 |
Test.Printf(_L("Record timing done\n"));
|
|
1562 |
|
|
1563 |
|
|
1564 |
//
|
|
1565 |
// Playback test
|
|
1566 |
//
|
|
1567 |
TxSoundDevice.CancelPlayData();
|
|
1568 |
struct RequestInfo {
|
|
1569 |
TRequestStatus s_m;
|
|
1570 |
TUint bufOffset_m;
|
|
1571 |
};
|
|
1572 |
RequestInfo requestA;
|
|
1573 |
RequestInfo requestB;
|
|
1574 |
|
|
1575 |
// Get two buffers for playback speed test
|
|
1576 |
RxSoundDevice.RecordData(requestA.s_m, length);
|
|
1577 |
User::WaitForRequest(requestA.s_m);
|
|
1578 |
CHECK(requestA.s_m.Int() >= 0);
|
|
1579 |
requestA.bufOffset_m = requestA.s_m.Int();
|
|
1580 |
|
|
1581 |
RxSoundDevice.RecordData(requestB.s_m, length);
|
|
1582 |
User::WaitForRequest(requestB.s_m);
|
|
1583 |
CHECK(requestB.s_m.Int() >= 0);
|
|
1584 |
requestB.bufOffset_m = requestB.s_m.Int();
|
|
1585 |
|
|
1586 |
Test.Printf(_L("buf offsets %d %d\n"), requestA.bufOffset_m, requestB.bufOffset_m);
|
|
1587 |
|
|
1588 |
RequestInfo *prevRequest = &requestA;
|
|
1589 |
RequestInfo *currRequest = &requestB;
|
|
1590 |
|
|
1591 |
// Issue initial play request
|
|
1592 |
TxSoundDevice.PlayData(prevRequest->s_m, prevRequest->bufOffset_m, bufSize);
|
|
1593 |
|
|
1594 |
preTime.UniversalTime();
|
|
1595 |
for(i=0; i<100; ++i)
|
|
1596 |
{
|
|
1597 |
// Issue new request so we do not underflow....
|
|
1598 |
TxSoundDevice.PlayData(currRequest->s_m, currRequest->bufOffset_m, bufSize, (i==99)?(KSndFlagLastSample) : (0));
|
|
1599 |
|
|
1600 |
// Wait for previous request to complete
|
|
1601 |
TTime preBufTime, postBufTime;
|
|
1602 |
preBufTime.UniversalTime();
|
|
1603 |
User::WaitForRequest(prevRequest->s_m);
|
|
1604 |
CHECK_NOERROR(prevRequest->s_m.Int());
|
|
1605 |
|
|
1606 |
postBufTime.UniversalTime();
|
|
1607 |
TTimeIntervalMicroSeconds elapsedBufTime = postBufTime.MicroSecondsFrom(preBufTime);
|
|
1608 |
Test.Printf(_L("\tElapsed buf (%d/100) playback time %d\n"), i, elapsedBufTime.Int64());
|
|
1609 |
|
|
1610 |
// Swap previous and current requests
|
|
1611 |
RequestInfo *p = prevRequest;
|
|
1612 |
prevRequest = currRequest;
|
|
1613 |
currRequest = p;
|
|
1614 |
}
|
|
1615 |
|
|
1616 |
postTime.UniversalTime();
|
|
1617 |
TTimeIntervalMicroSeconds elapsedPlaybackTime = postTime.MicroSecondsFrom(preTime);
|
|
1618 |
Test.Printf(_L("Elapsed playback time = %d us\n"), elapsedPlaybackTime.Int64());
|
|
1619 |
Test.Printf(_L("Elapsed recording time = %d us\n"), elapsedRecordingTime.Int64());
|
|
1620 |
|
|
1621 |
double play = (double) elapsedPlaybackTime.Int64();
|
|
1622 |
double record = (double) elapsedRecordingTime.Int64();
|
|
1623 |
Test.Printf(_L("difference %f%%\n"), (play*100)/record);
|
|
1624 |
|
|
1625 |
User::WaitForRequest(prevRequest->s_m);
|
|
1626 |
CHECK_NOERROR(prevRequest->s_m.Int());
|
|
1627 |
|
|
1628 |
// Free the two buffers
|
|
1629 |
CHECK(RxSoundDevice.ReleaseBuffer(requestA.bufOffset_m) == KErrNone);
|
|
1630 |
CHECK(RxSoundDevice.ReleaseBuffer(requestB.bufOffset_m) == KErrNone);
|
|
1631 |
|
|
1632 |
Test.Printf(_L("Playback done\n"));
|
|
1633 |
TxSoundDevice.CancelPlayData();
|
|
1634 |
RxSoundDevice.CancelPlayData();
|
|
1635 |
|
|
1636 |
chunk.Close();
|
|
1637 |
return;
|
|
1638 |
}
|
|
1639 |
|
|
1640 |
#ifdef __WINS__
|
|
1641 |
void TestDefectDTWMM00678()
|
|
1642 |
{
|
|
1643 |
// DTW-MM00678 RSoundSc::RecordData() returns recorded length > allocated buffer size
|
|
1644 |
TRequestStatus status[3];
|
|
1645 |
TInt length[3];
|
|
1646 |
Test.Next(_L("DTW-MM00678 RSoundSc::RecordData() returns recorded length > allocated buffer size"));
|
|
1647 |
|
|
1648 |
// Make sure recording is not in progress
|
|
1649 |
RxSoundDevice.CancelRecordData();
|
|
1650 |
|
|
1651 |
TInt r = KErrNone;
|
|
1652 |
TInt i;
|
|
1653 |
// Setup the same sound configuration for both - record and play channels
|
|
1654 |
if (RecordCapsBuf().iEncodings & KSoundEncoding16BitPCM)
|
|
1655 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1656 |
|
|
1657 |
RecordFormatBuf().iChannels = 2;
|
|
1658 |
|
|
1659 |
// Find first supported rate and set the the audio configuration to use it
|
|
1660 |
for (i=0 ; i <= (TInt)ESoundRate48000Hz ; i++)
|
|
1661 |
{
|
|
1662 |
// check record channel
|
|
1663 |
RecordFormatBuf().iRate = (TSoundRate)i;
|
|
1664 |
if (RecordCapsBuf().iRates & (1 << i))
|
|
1665 |
{
|
|
1666 |
// Caps reports it is supported
|
|
1667 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
1668 |
CHECK_NOERROR(r);
|
|
1669 |
break;
|
|
1670 |
}
|
|
1671 |
}
|
|
1672 |
// Check we found/set a valid format
|
|
1673 |
CHECK(i <= ESoundRate48000Hz);
|
|
1674 |
|
|
1675 |
// Set recording format
|
|
1676 |
PrintConfig(RecordFormatBuf(),Test);
|
|
1677 |
|
|
1678 |
// Set the volume level
|
|
1679 |
RxSoundDevice.SetVolume(KSoundMaxVolume);
|
|
1680 |
|
|
1681 |
// Set the record buffer configuration, then read it back.
|
|
1682 |
RChunk chunk;
|
|
1683 |
TInt bufSize = 64 * 1024; // The defect is seen, on windows, when the buffer size is 64k and the LDD does 2x 32k transfers per buffer
|
|
1684 |
TTestSharedChunkBufConfig bufferConfig;
|
|
1685 |
bufferConfig.iNumBuffers=7;
|
|
1686 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
1687 |
bufferConfig.iFlags=0;
|
|
1688 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
1689 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
1690 |
CHECK_NOERROR(r);
|
|
1691 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
1692 |
PrintBufferConf(bufferConfig,Test);
|
|
1693 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
1694 |
|
|
1695 |
// Calculate time required to fill a single 64k byte buffer
|
|
1696 |
TUint32 durationOneBufferMsec = (1000 * bufSize) / BytesPerSecond(RecordFormatBuf());
|
|
1697 |
Test.Printf(_L("durationOneBufferMsec %d\n"), durationOneBufferMsec);
|
|
1698 |
|
|
1699 |
// Start recording....
|
|
1700 |
Test.Printf(_L("Issue 3 RecordData requests then wait to pause during second internal 32k internal transfers of the second buffer...\n"));
|
|
1701 |
for(i=0; i<3; ++i)
|
|
1702 |
{
|
|
1703 |
RxSoundDevice.RecordData(status[i], length[i]);
|
|
1704 |
}
|
|
1705 |
|
|
1706 |
// Wait for 1 3/4 64k buffers. In other words, wait for 3.75x32k byte internal transfers so we pause during the second transfer of the second buffer
|
|
1707 |
User::After(durationOneBufferMsec *1000 * (1 + 3/4) );
|
|
1708 |
|
|
1709 |
CHECK_NOERROR(RxSoundDevice.Pause());
|
|
1710 |
Test.Printf(_L("Paused\n"));
|
|
1711 |
|
|
1712 |
for(i=0; i<3; ++i)
|
|
1713 |
{
|
|
1714 |
User::WaitForRequest(status[i]);
|
|
1715 |
Test.Printf(_L("status[%d].Int() = %d\n"), i, status[i].Int());
|
|
1716 |
Test.Printf(_L("length[%d] = %d\n"), i, length[i]);
|
|
1717 |
}
|
|
1718 |
|
|
1719 |
bool testValid = true;
|
|
1720 |
|
|
1721 |
if((status[0].Int() < 0) || (length[0] != bufSize))
|
|
1722 |
{
|
|
1723 |
testValid = false;
|
|
1724 |
Test.Printf(_L("Test invalid because pause hit first request\n"));
|
|
1725 |
}
|
|
1726 |
|
|
1727 |
if(testValid && (status[1].Int() == KErrCancel))
|
|
1728 |
{
|
|
1729 |
testValid = false;
|
|
1730 |
Test.Printf(_L("Test invalid because pause hit before second request started\n"));
|
|
1731 |
}
|
|
1732 |
|
|
1733 |
if(testValid && (status[2].Int() != KErrCancel))
|
|
1734 |
{
|
|
1735 |
testValid = false;
|
|
1736 |
Test.Printf(_L("Test invalid because pause missed all requests\n"));
|
|
1737 |
}
|
|
1738 |
|
|
1739 |
if(testValid)
|
|
1740 |
{
|
|
1741 |
Test.Printf(_L("Appear to have issued pause at the correct time, check results\n"));
|
|
1742 |
// First request should have completed with a full buffer of data
|
|
1743 |
CHECK(status[0].Int() >= 0);
|
|
1744 |
CHECK(length[0] == bufSize);
|
|
1745 |
|
|
1746 |
// second request should have been truncated
|
|
1747 |
CHECK(status[1].Int() >= 0);
|
|
1748 |
CHECK(length[1] < bufSize);
|
|
1749 |
|
|
1750 |
// Last request should have been cancelled.
|
|
1751 |
CHECK(status[2].Int() == KErrCancel);
|
|
1752 |
}
|
|
1753 |
Test.Printf(_L("DTW-MM00678 test done\r\n"));
|
|
1754 |
|
|
1755 |
//CHECK_NOERROR(RxSoundDevice.Resume());
|
|
1756 |
|
|
1757 |
// Make sure recording is not in progress
|
|
1758 |
RxSoundDevice.CancelRecordData();
|
|
1759 |
TxSoundDevice.CancelPlayData();
|
|
1760 |
|
|
1761 |
chunk.Close();
|
|
1762 |
return;
|
|
1763 |
}
|
|
1764 |
#endif
|
|
1765 |
|
|
1766 |
LOCAL_C void TestUnloadDrivers()
|
|
1767 |
{
|
|
1768 |
TInt r=User::FreeLogicalDevice(KDevSoundScName);
|
|
1769 |
Test.Printf(_L("Unloading %S.LDD - %d\r\n"),&KDevSoundScName,r);
|
|
1770 |
CHECK_NOERROR(r);
|
|
1771 |
|
|
1772 |
TName pddName(KDevSoundScName);
|
|
1773 |
_LIT(KPddWildcardExtension,".*");
|
|
1774 |
pddName.Append(KPddWildcardExtension);
|
|
1775 |
TFindPhysicalDevice findPD(pddName);
|
|
1776 |
TFullName findResult;
|
|
1777 |
r=findPD.Next(findResult);
|
|
1778 |
while (r==KErrNone)
|
|
1779 |
{
|
|
1780 |
r=User::FreePhysicalDevice(findResult);
|
|
1781 |
Test.Printf(_L("Unloading %S.PDD - %d\r\n"),&findResult,r);
|
|
1782 |
CHECK_NOERROR(r);
|
|
1783 |
findPD.Find(pddName); // Reset the find handle now that we have deleted something from the container.
|
|
1784 |
r=findPD.Next(findResult);
|
|
1785 |
}
|
|
1786 |
}
|
|
1787 |
|
|
1788 |
void TestTimePlayed()
|
|
1789 |
{
|
|
1790 |
TTimeIntervalMicroSecondsBuf timeIntervalBuf;
|
|
1791 |
|
|
1792 |
// Don't try to do the tests if TimePlayed() is not supported
|
|
1793 |
TInt r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1794 |
if (r == KErrNotSupported)
|
|
1795 |
{
|
|
1796 |
Test.Printf(_L("TimePlayed() is not supported, skipping tests\n"));
|
|
1797 |
return;
|
|
1798 |
}
|
|
1799 |
CHECK_NOERROR(r);
|
|
1800 |
|
|
1801 |
TInt rate;
|
|
1802 |
|
|
1803 |
// Find first supported rate and set the the audio configuration to use it
|
|
1804 |
for (rate = 0; rate <= ESoundRate48000Hz; ++rate)
|
|
1805 |
{
|
|
1806 |
if (PlayCapsBuf().iRates & (1 << rate))
|
|
1807 |
{
|
|
1808 |
break;
|
|
1809 |
}
|
|
1810 |
}
|
|
1811 |
|
|
1812 |
// Test mono and Stereo
|
|
1813 |
for (TInt channels=1; channels<=2; ++channels)
|
|
1814 |
{
|
|
1815 |
TRequestStatus stat[2];
|
|
1816 |
|
|
1817 |
Test.Next(_L("Preparing to play..."));
|
|
1818 |
if (PlayCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
1819 |
PlayFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
1820 |
PlayFormatBuf().iRate = (TSoundRate) rate;
|
|
1821 |
PlayFormatBuf().iChannels = channels;
|
|
1822 |
PrintConfig(PlayFormatBuf(),Test);
|
|
1823 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
1824 |
CHECK_NOERROR(r);
|
|
1825 |
|
|
1826 |
// Set the play buffer configuration, then read it back.
|
|
1827 |
RChunk chunk;
|
|
1828 |
TInt bufSize=BytesPerSecond(PlayFormatBuf()); // Large enough to hold 1 second of data.
|
|
1829 |
bufSize=ValidBufferSize(bufSize,PlayCapsBuf().iRequestMinSize,PlayFormatBuf()); // Keep the buffer length valid for driver.
|
|
1830 |
TTestSharedChunkBufConfig bufferConfig;
|
|
1831 |
bufferConfig.iNumBuffers=2;
|
|
1832 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
1833 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
1834 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
1835 |
r=TxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
1836 |
CHECK_NOERROR(r);
|
|
1837 |
TxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
1838 |
PrintBufferConf(bufferConfig,Test);
|
|
1839 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
1840 |
TPtr8* tPtr[2];
|
|
1841 |
TInt i;
|
|
1842 |
for (i=0;i<2;i++)
|
|
1843 |
tPtr[i]=new TPtr8(chunk.Base()+bufferConfig.iBufferOffsetList[i],bufSize);
|
|
1844 |
|
|
1845 |
|
|
1846 |
r=MakeSineTable(PlayFormatBuf());
|
|
1847 |
CHECK_NOERROR(r);
|
|
1848 |
r=SetToneFrequency(440,PlayFormatBuf());
|
|
1849 |
CHECK_NOERROR(r);
|
|
1850 |
|
|
1851 |
WriteTone(*tPtr[0],PlayFormatBuf());
|
|
1852 |
WriteTone(*tPtr[1],PlayFormatBuf());
|
|
1853 |
|
|
1854 |
// set up a timer to interrogate time played
|
|
1855 |
TRequestStatus timerStat;
|
|
1856 |
RTimer timer;
|
|
1857 |
timer.CreateLocal();
|
|
1858 |
TTimeIntervalMicroSeconds32 timerInterval(50000);
|
|
1859 |
|
|
1860 |
TInt64 currentTime, previousTime;
|
|
1861 |
|
|
1862 |
Test.Next(_L("Time Played..."));
|
|
1863 |
|
|
1864 |
currentTime = previousTime = MAKE_TINT64(0,0);
|
|
1865 |
|
|
1866 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,0);
|
|
1867 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize,KSndFlagLastSample);
|
|
1868 |
|
|
1869 |
// check requests are pending
|
|
1870 |
CHECK_EQUAL(stat[0].Int(),KRequestPending);
|
|
1871 |
CHECK_EQUAL(stat[1].Int(),KRequestPending);
|
|
1872 |
|
|
1873 |
// check time recorded is not supported for play channel
|
|
1874 |
CHECK(TxSoundDevice.TimeRecorded(timeIntervalBuf)==KErrNotSupported);
|
|
1875 |
|
|
1876 |
timer.After(timerStat,timerInterval);
|
|
1877 |
// first buffer
|
|
1878 |
while (stat[0] == KRequestPending)
|
|
1879 |
{
|
|
1880 |
User::WaitForRequest(stat[0],timerStat);
|
|
1881 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
1882 |
previousTime = currentTime;
|
|
1883 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1884 |
CHECK_NOERROR(r);
|
|
1885 |
currentTime = timeIntervalBuf().Int64();
|
|
1886 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
1887 |
|
|
1888 |
// ensure time is increasing or function is not supported
|
|
1889 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
1890 |
|
|
1891 |
if (timerStat != KRequestPending)
|
|
1892 |
{
|
|
1893 |
timer.After(timerStat,timerInterval);
|
|
1894 |
}
|
|
1895 |
}
|
|
1896 |
timer.Cancel();
|
|
1897 |
|
|
1898 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
1899 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1900 |
CHECK_NOERROR(r);
|
|
1901 |
currentTime = timeIntervalBuf().Int64();
|
|
1902 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
1903 |
|
|
1904 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
1905 |
|
|
1906 |
timer.After(timerStat,timerInterval);
|
|
1907 |
// second buffer
|
|
1908 |
while (stat[1] == KRequestPending)
|
|
1909 |
{
|
|
1910 |
User::WaitForRequest(stat[1],timerStat);
|
|
1911 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
1912 |
previousTime = currentTime;
|
|
1913 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1914 |
CHECK_NOERROR(r);
|
|
1915 |
|
|
1916 |
currentTime = timeIntervalBuf().Int64();
|
|
1917 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
1918 |
|
|
1919 |
// ensure time is increasing or function is not supported
|
|
1920 |
if (stat[1] == KRequestPending) // still playing
|
|
1921 |
{
|
|
1922 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
1923 |
}
|
|
1924 |
|
|
1925 |
if (timerStat != KRequestPending)
|
|
1926 |
{
|
|
1927 |
timer.After(timerStat,timerInterval);
|
|
1928 |
}
|
|
1929 |
|
|
1930 |
}
|
|
1931 |
timer.Cancel();
|
|
1932 |
|
|
1933 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
1934 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1935 |
CHECK_NOERROR(r);
|
|
1936 |
|
|
1937 |
currentTime = timeIntervalBuf().Int64();
|
|
1938 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(timeIntervalBuf().Int64()),I64LOW(timeIntervalBuf().Int64()));
|
|
1939 |
|
|
1940 |
CHECK_EQUAL(stat[1].Int(),KErrNone);
|
|
1941 |
|
|
1942 |
//
|
|
1943 |
// Time Played with pause
|
|
1944 |
//
|
|
1945 |
|
|
1946 |
Test.Next(_L("Time Played with pause..."));
|
|
1947 |
|
|
1948 |
TTimeIntervalMicroSeconds32 pauseInterval(2000000);
|
|
1949 |
TBool paused = EFalse;
|
|
1950 |
|
|
1951 |
currentTime = previousTime = MAKE_TINT64(0,0);
|
|
1952 |
timer.Cancel();
|
|
1953 |
|
|
1954 |
TxSoundDevice.PlayData(stat[0],bufferConfig.iBufferOffsetList[0],bufSize,0);
|
|
1955 |
TxSoundDevice.PlayData(stat[1],bufferConfig.iBufferOffsetList[1],bufSize,KSndFlagLastSample);
|
|
1956 |
|
|
1957 |
// check requests are pending
|
|
1958 |
CHECK_EQUAL(stat[0].Int(),KRequestPending);
|
|
1959 |
CHECK_EQUAL(stat[1].Int(),KRequestPending);
|
|
1960 |
|
|
1961 |
// check time recorded is not supported for play channel
|
|
1962 |
CHECK(TxSoundDevice.TimeRecorded(timeIntervalBuf)==KErrNotSupported);
|
|
1963 |
|
|
1964 |
timer.After(timerStat,timerInterval);
|
|
1965 |
// first buffer
|
|
1966 |
while (stat[0] == KRequestPending)
|
|
1967 |
{
|
|
1968 |
User::WaitForRequest(stat[0],timerStat);
|
|
1969 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
1970 |
previousTime = currentTime;
|
|
1971 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1972 |
CHECK_NOERROR(r);
|
|
1973 |
currentTime = timeIntervalBuf().Int64();
|
|
1974 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
1975 |
|
|
1976 |
// ensure time is increasing or function is not supported
|
|
1977 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
1978 |
|
|
1979 |
// Pause and resume ...
|
|
1980 |
if (paused == EFalse && I64LOW(currentTime) > 500000)
|
|
1981 |
{
|
|
1982 |
paused = ETrue;
|
|
1983 |
TxSoundDevice.Pause();
|
|
1984 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1985 |
CHECK_NOERROR(r);
|
|
1986 |
TInt64 pausedTime1 = timeIntervalBuf().Int64();
|
|
1987 |
Test.Printf(_L("Paused time_high %d, time_low %d\n"),I64HIGH(pausedTime1),I64LOW(pausedTime1));
|
|
1988 |
|
|
1989 |
User::After(pauseInterval);
|
|
1990 |
|
|
1991 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
1992 |
CHECK_NOERROR(r);
|
|
1993 |
TInt64 pausedTime2 = timeIntervalBuf().Int64();
|
|
1994 |
Test.Printf(_L("Resumed time_high %d, time_low %d\n"),I64HIGH(pausedTime2),I64LOW(pausedTime2));
|
|
1995 |
//CHECK(pausedTime1 == pausedTime2);
|
|
1996 |
TxSoundDevice.Resume();
|
|
1997 |
}
|
|
1998 |
|
|
1999 |
if (timerStat != KRequestPending)
|
|
2000 |
{
|
|
2001 |
timer.After(timerStat,timerInterval);
|
|
2002 |
}
|
|
2003 |
}
|
|
2004 |
timer.Cancel();
|
|
2005 |
|
|
2006 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2007 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
2008 |
CHECK_NOERROR(r);
|
|
2009 |
currentTime = timeIntervalBuf().Int64();
|
|
2010 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2011 |
|
|
2012 |
CHECK_EQUAL(stat[0].Int(),KErrNone);
|
|
2013 |
|
|
2014 |
timer.After(timerStat,timerInterval);
|
|
2015 |
// second buffer
|
|
2016 |
while (stat[1] == KRequestPending)
|
|
2017 |
{
|
|
2018 |
User::WaitForRequest(stat[1],timerStat);
|
|
2019 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
2020 |
previousTime = currentTime;
|
|
2021 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
2022 |
CHECK_NOERROR(r);
|
|
2023 |
|
|
2024 |
currentTime = timeIntervalBuf().Int64();
|
|
2025 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2026 |
|
|
2027 |
// ensure time is increasing or function is not supported
|
|
2028 |
if (stat[1] == KRequestPending) // still playing
|
|
2029 |
{
|
|
2030 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
2031 |
}
|
|
2032 |
|
|
2033 |
if (timerStat != KRequestPending)
|
|
2034 |
{
|
|
2035 |
timer.After(timerStat,timerInterval);
|
|
2036 |
}
|
|
2037 |
|
|
2038 |
}
|
|
2039 |
timer.Cancel();
|
|
2040 |
|
|
2041 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
2042 |
r = TxSoundDevice.TimePlayed(timeIntervalBuf);
|
|
2043 |
CHECK_NOERROR(r);
|
|
2044 |
|
|
2045 |
currentTime = timeIntervalBuf().Int64();
|
|
2046 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(timeIntervalBuf().Int64()),I64LOW(timeIntervalBuf().Int64()));
|
|
2047 |
|
|
2048 |
CHECK_EQUAL(stat[1].Int(),KErrNone);
|
|
2049 |
|
|
2050 |
// clean up
|
|
2051 |
timer.Close();
|
|
2052 |
chunk.Close();
|
|
2053 |
for (i=0;i<2;i++)
|
|
2054 |
delete tPtr[i];
|
|
2055 |
|
|
2056 |
} // channel loop
|
|
2057 |
}
|
|
2058 |
|
|
2059 |
void TestTimeRecorded()
|
|
2060 |
{
|
|
2061 |
TTimeIntervalMicroSecondsBuf timeIntervalBuf;
|
|
2062 |
|
|
2063 |
TInt r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2064 |
if (r == KErrNotSupported)
|
|
2065 |
{
|
|
2066 |
Test.Printf(_L("TimeRecorded() is not supported, skipping tests\n"));
|
|
2067 |
return;
|
|
2068 |
}
|
|
2069 |
CHECK_NOERROR(r);
|
|
2070 |
|
|
2071 |
TInt rate;
|
|
2072 |
|
|
2073 |
// Find first supported rate and set the the audio configuration to use it
|
|
2074 |
for (rate = 0; rate <= ESoundRate48000Hz; ++rate)
|
|
2075 |
{
|
|
2076 |
if (PlayCapsBuf().iRates & (1 << rate))
|
|
2077 |
{
|
|
2078 |
break;
|
|
2079 |
}
|
|
2080 |
}
|
|
2081 |
|
|
2082 |
// Test mono and Stereo
|
|
2083 |
for (TInt channels=1; channels<=2; ++channels)
|
|
2084 |
{
|
|
2085 |
TRequestStatus stat[2];
|
|
2086 |
|
|
2087 |
Test.Next(_L("Preparing to record..."));
|
|
2088 |
if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
|
|
2089 |
RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
|
|
2090 |
RecordFormatBuf().iRate = (TSoundRate) rate;
|
|
2091 |
RecordFormatBuf().iChannels = channels;
|
|
2092 |
PrintConfig(RecordFormatBuf(),Test);
|
|
2093 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
2094 |
CHECK_NOERROR(r);
|
|
2095 |
|
|
2096 |
// Set the play buffer configuration, then read it back.
|
|
2097 |
RChunk chunk;
|
|
2098 |
TInt bufSize=BytesPerSecond(RecordFormatBuf()); // Large enough to hold 1 second of data.
|
|
2099 |
bufSize=ValidBufferSize(bufSize,RecordCapsBuf().iRequestMinSize,RecordFormatBuf()); // Keep the buffer length valid for driver.
|
|
2100 |
TTestSharedChunkBufConfig bufferConfig;
|
|
2101 |
bufferConfig.iNumBuffers=4;
|
|
2102 |
bufferConfig.iBufferSizeInBytes=bufSize;
|
|
2103 |
bufferConfig.iFlags=0; // All buffers will be contiguous
|
|
2104 |
TPckg<TTestSharedChunkBufConfig> bufferConfigBuf(bufferConfig);
|
|
2105 |
r=RxSoundDevice.SetBufferChunkCreate(bufferConfigBuf,chunk);
|
|
2106 |
CHECK_NOERROR(r);
|
|
2107 |
RxSoundDevice.GetBufferConfig(bufferConfigBuf);
|
|
2108 |
PrintBufferConf(bufferConfig,Test);
|
|
2109 |
CHECK(bufferConfig.iBufferSizeInBytes==bufSize);
|
|
2110 |
|
|
2111 |
// set up a timer to interrogate time played
|
|
2112 |
TRequestStatus timerStat;
|
|
2113 |
RTimer timer;
|
|
2114 |
timer.CreateLocal();
|
|
2115 |
TTimeIntervalMicroSeconds32 timerInterval(50000);
|
|
2116 |
|
|
2117 |
TInt64 currentTime, previousTime;
|
|
2118 |
|
|
2119 |
Test.Next(_L("Time Recorded..."));
|
|
2120 |
|
|
2121 |
currentTime = previousTime = MAKE_TINT64(0,0);
|
|
2122 |
|
|
2123 |
TInt length1=0, length2=0;
|
|
2124 |
RxSoundDevice.RecordData(stat[0],length1);
|
|
2125 |
RxSoundDevice.RecordData(stat[1],length2);
|
|
2126 |
|
|
2127 |
// check requests are pending
|
|
2128 |
CHECK_EQUAL(stat[0].Int(),KRequestPending);
|
|
2129 |
CHECK_EQUAL(stat[1].Int(),KRequestPending);
|
|
2130 |
|
|
2131 |
// check time played is not supported for record channel
|
|
2132 |
CHECK(RxSoundDevice.TimePlayed(timeIntervalBuf)==KErrNotSupported);
|
|
2133 |
|
|
2134 |
timer.After(timerStat,timerInterval);
|
|
2135 |
// first buffer
|
|
2136 |
while (stat[0] == KRequestPending)
|
|
2137 |
{
|
|
2138 |
User::WaitForRequest(stat[0],timerStat);
|
|
2139 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2140 |
previousTime = currentTime;
|
|
2141 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2142 |
CHECK_NOERROR(r);
|
|
2143 |
currentTime = timeIntervalBuf().Int64();
|
|
2144 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2145 |
|
|
2146 |
// ensure time is increasing or function is not supported
|
|
2147 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
2148 |
|
|
2149 |
if (timerStat != KRequestPending)
|
|
2150 |
{
|
|
2151 |
timer.After(timerStat,timerInterval);
|
|
2152 |
}
|
|
2153 |
}
|
|
2154 |
timer.Cancel();
|
|
2155 |
|
|
2156 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2157 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2158 |
CHECK_NOERROR(r);
|
|
2159 |
currentTime = timeIntervalBuf().Int64();
|
|
2160 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2161 |
|
|
2162 |
CHECK(stat[0].Int() == 0);
|
|
2163 |
|
|
2164 |
timer.After(timerStat,timerInterval);
|
|
2165 |
// second buffer
|
|
2166 |
while (stat[1] == KRequestPending)
|
|
2167 |
{
|
|
2168 |
User::WaitForRequest(stat[1],timerStat);
|
|
2169 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
2170 |
previousTime = currentTime;
|
|
2171 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2172 |
CHECK_NOERROR(r);
|
|
2173 |
currentTime = timeIntervalBuf().Int64();
|
|
2174 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2175 |
|
|
2176 |
// ensure time is increasing or function is not supported
|
|
2177 |
if (stat[1] == KRequestPending) // still playing
|
|
2178 |
{
|
|
2179 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
2180 |
}
|
|
2181 |
|
|
2182 |
if (timerStat != KRequestPending)
|
|
2183 |
{
|
|
2184 |
timer.After(timerStat,timerInterval);
|
|
2185 |
}
|
|
2186 |
|
|
2187 |
}
|
|
2188 |
timer.Cancel();
|
|
2189 |
|
|
2190 |
Test.Printf(_L("stat[1] %x, timerStat %x\n"),stat[1].Int(),timerStat.Int());
|
|
2191 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2192 |
CHECK_NOERROR(r);
|
|
2193 |
currentTime = timeIntervalBuf().Int64();
|
|
2194 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(timeIntervalBuf().Int64()),I64LOW(timeIntervalBuf().Int64()));
|
|
2195 |
|
|
2196 |
CHECK(stat[1].Int() > 0);
|
|
2197 |
|
|
2198 |
// stop recording into the next buffer
|
|
2199 |
RxSoundDevice.CancelRecordData();
|
|
2200 |
|
|
2201 |
// Release the buffers
|
|
2202 |
r = RxSoundDevice.ReleaseBuffer(stat[0].Int());
|
|
2203 |
CHECK_EQUAL(r, KErrNone);
|
|
2204 |
r = RxSoundDevice.ReleaseBuffer(stat[1].Int());
|
|
2205 |
CHECK_EQUAL(r, KErrNone);
|
|
2206 |
|
|
2207 |
//
|
|
2208 |
// Time Recorded with pause
|
|
2209 |
//
|
|
2210 |
|
|
2211 |
Test.Next(_L("Time Recorded with pause..."));
|
|
2212 |
|
|
2213 |
TTimeIntervalMicroSeconds32 pauseInterval(2000000);
|
|
2214 |
TBool paused = EFalse;
|
|
2215 |
|
|
2216 |
currentTime = previousTime = MAKE_TINT64(0,0);
|
|
2217 |
|
|
2218 |
// Record and discard some data to make sure all testing is not within the first buffer...
|
|
2219 |
RxSoundDevice.RecordData(stat[0],length1);
|
|
2220 |
User::WaitForRequest(stat[0]);
|
|
2221 |
CHECK(stat[0].Int() >= 0);
|
|
2222 |
RxSoundDevice.ReleaseBuffer(stat[0].Int());
|
|
2223 |
|
|
2224 |
RxSoundDevice.RecordData(stat[0],length1);
|
|
2225 |
RxSoundDevice.RecordData(stat[1],length2);
|
|
2226 |
|
|
2227 |
// check requests are pending
|
|
2228 |
CHECK_EQUAL(stat[0].Int(),KRequestPending);
|
|
2229 |
|
|
2230 |
// check time recorded is not supported for play channel
|
|
2231 |
CHECK(RxSoundDevice.TimePlayed(timeIntervalBuf)==KErrNotSupported);
|
|
2232 |
|
|
2233 |
timer.After(timerStat,timerInterval);
|
|
2234 |
// first buffer
|
|
2235 |
while (stat[0] == KRequestPending)
|
|
2236 |
{
|
|
2237 |
User::WaitForRequest(stat[0],timerStat);
|
|
2238 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2239 |
previousTime = currentTime;
|
|
2240 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2241 |
CHECK_NOERROR(r);
|
|
2242 |
currentTime = timeIntervalBuf().Int64();
|
|
2243 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2244 |
|
|
2245 |
// ensure time is increasing or function is not supported
|
|
2246 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
2247 |
|
|
2248 |
// Pause and resume ...
|
|
2249 |
if (paused == EFalse && I64LOW(currentTime) > 500000)
|
|
2250 |
{
|
|
2251 |
paused = ETrue;
|
|
2252 |
RxSoundDevice.Pause();
|
|
2253 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2254 |
CHECK_NOERROR(r);
|
|
2255 |
TInt64 pausedTime1 = timeIntervalBuf().Int64();
|
|
2256 |
Test.Printf(_L("Paused time_high %d, time_low %d\n"),I64HIGH(pausedTime1),I64LOW(pausedTime1));
|
|
2257 |
// Check time is increasing
|
|
2258 |
CHECK((I64LOW(pausedTime1) >= I64LOW(currentTime)));
|
|
2259 |
|
|
2260 |
User::After(pauseInterval);
|
|
2261 |
|
|
2262 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2263 |
CHECK_NOERROR(r);
|
|
2264 |
TInt64 pausedTime2 = timeIntervalBuf().Int64();
|
|
2265 |
Test.Printf(_L("Resumed time_high %d, time_low %d\n"),I64HIGH(pausedTime2),I64LOW(pausedTime2));
|
|
2266 |
// Check time is unchanged
|
|
2267 |
CHECK((I64LOW(pausedTime2) == I64LOW(pausedTime1)));
|
|
2268 |
}
|
|
2269 |
|
|
2270 |
if (timerStat != KRequestPending)
|
|
2271 |
{
|
|
2272 |
timer.After(timerStat,timerInterval);
|
|
2273 |
}
|
|
2274 |
}
|
|
2275 |
|
|
2276 |
timer.Cancel();
|
|
2277 |
|
|
2278 |
// Buffer should complete normally or be empty (indicated by KErrCancel)
|
|
2279 |
CHECK((stat[0].Int() >= 0) || (stat[0].Int() == KErrCancel));
|
|
2280 |
// Release the first buffer, if it contained any data
|
|
2281 |
if (stat[0].Int() >= 0)
|
|
2282 |
{
|
|
2283 |
r = RxSoundDevice.ReleaseBuffer(stat[0].Int());
|
|
2284 |
CHECK_EQUAL(r, KErrNone);
|
|
2285 |
}
|
|
2286 |
// Check second buffer completed or cancelled
|
|
2287 |
User::WaitForRequest(stat[1]);
|
|
2288 |
CHECK_EQUAL(stat[1].Int(), KErrCancel);
|
|
2289 |
|
|
2290 |
// Now resume the recording
|
|
2291 |
r = RxSoundDevice.Resume();
|
|
2292 |
CHECK_EQUAL(r, KErrNone);
|
|
2293 |
|
|
2294 |
// Need to re-setup buffers
|
|
2295 |
RxSoundDevice.RecordData(stat[0],length1);
|
|
2296 |
RxSoundDevice.RecordData(stat[1],length2);
|
|
2297 |
|
|
2298 |
timer.After(timerStat,timerInterval);
|
|
2299 |
// another buffer
|
|
2300 |
while (stat[0] == KRequestPending)
|
|
2301 |
{
|
|
2302 |
User::WaitForRequest(stat[0],timerStat);
|
|
2303 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2304 |
previousTime = currentTime;
|
|
2305 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2306 |
CHECK_NOERROR(r);
|
|
2307 |
currentTime = timeIntervalBuf().Int64();
|
|
2308 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(currentTime),I64LOW(currentTime));
|
|
2309 |
|
|
2310 |
// ensure time is increasing or function is not supported
|
|
2311 |
if (stat[0] == KRequestPending) // still recording
|
|
2312 |
{
|
|
2313 |
CHECK((I64LOW(currentTime) >= I64LOW(previousTime)) || r == KErrNotSupported);
|
|
2314 |
}
|
|
2315 |
|
|
2316 |
if (timerStat != KRequestPending)
|
|
2317 |
{
|
|
2318 |
timer.After(timerStat,timerInterval);
|
|
2319 |
}
|
|
2320 |
|
|
2321 |
}
|
|
2322 |
timer.Cancel();
|
|
2323 |
|
|
2324 |
Test.Printf(_L("stat[0] %x, timerStat %x\n"),stat[0].Int(),timerStat.Int());
|
|
2325 |
r = RxSoundDevice.TimeRecorded(timeIntervalBuf);
|
|
2326 |
CHECK_NOERROR(r);
|
|
2327 |
currentTime = timeIntervalBuf().Int64();
|
|
2328 |
Test.Printf(_L("time_high %d, time_low %d\n"),I64HIGH(timeIntervalBuf().Int64()),I64LOW(timeIntervalBuf().Int64()));
|
|
2329 |
|
|
2330 |
CHECK(stat[0].Int() > 0);
|
|
2331 |
|
|
2332 |
// stop recording into the next buffer
|
|
2333 |
RxSoundDevice.CancelRecordData();
|
|
2334 |
|
|
2335 |
// Release the buffers
|
|
2336 |
r = RxSoundDevice.ReleaseBuffer(stat[0].Int());
|
|
2337 |
CHECK_EQUAL(r, KErrNone);
|
|
2338 |
|
|
2339 |
// clean up
|
|
2340 |
timer.Close();
|
|
2341 |
chunk.Close();
|
|
2342 |
} // channel loop
|
|
2343 |
}
|
|
2344 |
|
|
2345 |
TInt E32Main()
|
|
2346 |
{
|
|
2347 |
// User::SetDebugMask(0x10,1); // Enable KSOUND1
|
|
2348 |
|
|
2349 |
__UHEAP_MARK;
|
|
2350 |
TInt r;
|
|
2351 |
|
|
2352 |
Test.Title();
|
|
2353 |
|
|
2354 |
Test.Start(_L("Load"));
|
|
2355 |
if (Load()==KErrNotFound)
|
|
2356 |
{
|
|
2357 |
Test.Printf(_L("Shared chunk sound driver not supported - test skipped\r\n"));
|
|
2358 |
Test.End();
|
|
2359 |
Test.Close();
|
|
2360 |
__UHEAP_MARKEND;
|
|
2361 |
return(KErrNone);
|
|
2362 |
}
|
|
2363 |
|
|
2364 |
__KHEAP_MARK;
|
|
2365 |
|
|
2366 |
/** @SYMTestCaseID PBASE-T_SOUND2-223
|
|
2367 |
@SYMTestCaseDesc Opening the channel - normal
|
|
2368 |
@SYMTestPriority Critical
|
|
2369 |
@SYMTestActions 1) With the LDD and PDD installed and with all channels closed on the device,
|
|
2370 |
open a channel for playback on the device.
|
|
2371 |
2) Without closing the playback channel, open a channel for record on the device.
|
|
2372 |
3) Close the playback channel and then open it again.
|
|
2373 |
4) Close the record channel and then open it again.
|
|
2374 |
@SYMTestExpectedResults 1) KErrNone - Channel opens successfully.
|
|
2375 |
2) KErrNone - Channel opens successfully.
|
|
2376 |
3) KErrNone - Channel re-opens successfully.
|
|
2377 |
4) KErrNone - Channel re-opens successfully.
|
|
2378 |
@SYMREQ PREQ1073.4 */
|
|
2379 |
|
|
2380 |
Test.Next(_L("Open playback channel"));
|
|
2381 |
r = TxSoundDevice.Open(KSoundScTxUnit0);
|
|
2382 |
CHECK_NOERROR(r);
|
|
2383 |
|
|
2384 |
Test.Next(_L("Open record channel"));
|
|
2385 |
r = RxSoundDevice.Open(KSoundScRxUnit0);
|
|
2386 |
CHECK_NOERROR(r);
|
|
2387 |
|
|
2388 |
Test.Next(_L("Query play formats supported"));
|
|
2389 |
TxSoundDevice.Caps(PlayCapsBuf);
|
|
2390 |
TSoundFormatsSupportedV02 playCaps=PlayCapsBuf();
|
|
2391 |
PrintCaps(playCaps,Test);
|
|
2392 |
|
|
2393 |
Test.Next(_L("Close playback channel"));
|
|
2394 |
TxSoundDevice.Close();
|
|
2395 |
Test.Next(_L("Re-open playback channel"));
|
|
2396 |
r = TxSoundDevice.Open(KSoundScTxUnit0);
|
|
2397 |
CHECK_NOERROR(r);
|
|
2398 |
Test.Next(_L("Close record channel"));
|
|
2399 |
RxSoundDevice.Close();
|
|
2400 |
Test.Next(_L("Re-open record channel"));
|
|
2401 |
r = RxSoundDevice.Open(KSoundScRxUnit0);
|
|
2402 |
CHECK_NOERROR(r);
|
|
2403 |
|
|
2404 |
Test.Next(_L("Query play formats supported"));
|
|
2405 |
TxSoundDevice.Caps(PlayCapsBuf);
|
|
2406 |
PrintCaps(playCaps,Test);
|
|
2407 |
|
|
2408 |
Test.Next(_L("Query record formats supported"));
|
|
2409 |
RxSoundDevice.Caps(RecordCapsBuf);
|
|
2410 |
TSoundFormatsSupportedV02 recordCaps=RecordCapsBuf();
|
|
2411 |
PrintCaps(recordCaps,Test);
|
|
2412 |
|
|
2413 |
Test.Next(_L("Query current play settings"));
|
|
2414 |
TxSoundDevice.AudioFormat(PlayFormatBuf);
|
|
2415 |
TCurrentSoundFormatV02 playFormat=PlayFormatBuf();
|
|
2416 |
PrintConfig(playFormat,Test);
|
|
2417 |
CheckConfig(playFormat,playCaps);
|
|
2418 |
|
|
2419 |
Test.Next(_L("Query current record settings"));
|
|
2420 |
RxSoundDevice.AudioFormat(RecordFormatBuf);
|
|
2421 |
TCurrentSoundFormatV02 recordFormat=RecordFormatBuf();
|
|
2422 |
PrintConfig(recordFormat,Test);
|
|
2423 |
CheckConfig(recordFormat,recordCaps);
|
|
2424 |
|
|
2425 |
Test.Next(_L("Set play format"));
|
|
2426 |
if (playCaps.iEncodings&KSoundEncoding16BitPCM)
|
|
2427 |
playFormat.iEncoding = ESoundEncoding16BitPCM;
|
|
2428 |
PrintConfig(playFormat,Test);
|
|
2429 |
r = TxSoundDevice.SetAudioFormat(PlayFormatBuf);
|
|
2430 |
CHECK_NOERROR(r);
|
|
2431 |
|
|
2432 |
Test.Next(_L("Set Record Format"));
|
|
2433 |
if (recordCaps.iEncodings&KSoundEncoding16BitPCM)
|
|
2434 |
recordFormat.iEncoding = ESoundEncoding16BitPCM;
|
|
2435 |
PrintConfig(recordFormat,Test);
|
|
2436 |
r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
|
|
2437 |
CHECK_NOERROR(r);
|
|
2438 |
|
|
2439 |
#ifdef SOAKTEST
|
|
2440 |
TInt freeRamInBytes=0;
|
|
2441 |
TTime stim;
|
|
2442 |
stim.HomeTime();
|
|
2443 |
|
|
2444 |
FOREVER
|
|
2445 |
{
|
|
2446 |
#endif
|
|
2447 |
|
|
2448 |
TestBasicPlayFunctions();
|
|
2449 |
TestBasicRecordFunctions();
|
|
2450 |
TestPlayAllRates(1,4);
|
|
2451 |
TestPlayAllRates(2,4);
|
|
2452 |
TestRecordAllRates(1,4);
|
|
2453 |
TestRecordAllRates(2,4);
|
|
2454 |
TestRecordVolume(2,10);
|
|
2455 |
TestPlayCancel();
|
|
2456 |
TestRecordCancel();
|
|
2457 |
TestRecordPauseResume();
|
|
2458 |
TestSimultaneousPlayRecord();
|
|
2459 |
TestTimePlayed();
|
|
2460 |
TestTimeRecorded();
|
|
2461 |
#ifdef __WINS__
|
|
2462 |
TestDefectDTWMM00678();
|
|
2463 |
#endif
|
|
2464 |
//TestSpeed(); // Gives information which may help debug h4 FMM issues
|
|
2465 |
|
|
2466 |
#ifdef SOAKTEST
|
|
2467 |
TInt free;
|
|
2468 |
HAL::Get(HAL::EMemoryRAMFree,free);
|
|
2469 |
Test.Printf(_L("Free ram is %d bytes\r\n"),free);
|
|
2470 |
// if (freeRamInBytes)
|
|
2471 |
// CHECK(freeRamInBytes == free)
|
|
2472 |
freeRamInBytes=free;
|
|
2473 |
|
|
2474 |
TTime ntim;
|
|
2475 |
ntim.HomeTime();
|
|
2476 |
TTimeIntervalMinutes elapsed;
|
|
2477 |
r=ntim.MinutesFrom(stim,elapsed);
|
|
2478 |
CHECK_NOERROR(r);
|
|
2479 |
Test.Printf(_L("Test has been running for %d minutes\r\n"),elapsed.Int());
|
|
2480 |
}
|
|
2481 |
#endif
|
|
2482 |
|
|
2483 |
Test.Next(_L("Close channels"));
|
|
2484 |
RxSoundDevice.Close();
|
|
2485 |
TxSoundDevice.Close();
|
|
2486 |
|
|
2487 |
__KHEAP_MARKEND;
|
|
2488 |
|
|
2489 |
// Now that both the channels are closed, unload the LDD and the PDDs.
|
|
2490 |
TestUnloadDrivers();
|
|
2491 |
|
|
2492 |
Test.End();
|
|
2493 |
Test.Close();
|
|
2494 |
|
|
2495 |
Cleanup();
|
|
2496 |
__UHEAP_MARKEND;
|
|
2497 |
User::Allocator().Check();
|
|
2498 |
return(KErrNone);
|
|
2499 |
}
|