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