sl@0
|
1 |
// Copyright (c) 2007-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 |
// @file PBASE-T_USBDI-0482.cpp
|
sl@0
|
15 |
// @internalComponent
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "PBASE-T_USBDI-0482.h"
|
sl@0
|
20 |
#include "tada22.h"
|
sl@0
|
21 |
#include <d32usbdescriptors.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
|
sl@0
|
24 |
namespace NUnitTesting_USBDI
|
sl@0
|
25 |
{
|
sl@0
|
26 |
|
sl@0
|
27 |
_LIT(KTestCaseId,"PBASE-T_USBDI-0482");
|
sl@0
|
28 |
const TFunctorTestCase<CUT_PBASE_T_USBDI_0482,TBool> CUT_PBASE_T_USBDI_0482::iFunctor(KTestCaseId);
|
sl@0
|
29 |
_LIT8(KHighRecordSamplingRate, "\x80\xBB\x00"); // sampling rate : 48,000 Hz
|
sl@0
|
30 |
_LIT8(KLowSamplingRate , "\x22\x56\x00"); // sampling rate : 22,050 Hz
|
sl@0
|
31 |
|
sl@0
|
32 |
_LIT(KTrackFileName, "Z:\\scripts\\track.dat");
|
sl@0
|
33 |
|
sl@0
|
34 |
const TInt KRecordedDataId = 0x12345;
|
sl@0
|
35 |
const TUint KRecordedPacketsExpected = 1000;
|
sl@0
|
36 |
const TUint KAudioCDQualityFrequency = 176; // 176 kB/s
|
sl@0
|
37 |
const TUint KMaxPacketSizeOutExpected = 192;
|
sl@0
|
38 |
const TUint KMaxPacketSizeInExpected = 96;
|
sl@0
|
39 |
const TUint KMaxPacketSizeOffset = 4;
|
sl@0
|
40 |
const TUint KIsochInMaxNumPackets = 2000;
|
sl@0
|
41 |
const TUint KChunkSize = 500000; // 0.5 Mb
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
TInt CUT_PBASE_T_USBDI_0482::iExpectedTransferId = 0;
|
sl@0
|
45 |
|
sl@0
|
46 |
CUT_PBASE_T_USBDI_0482* CUT_PBASE_T_USBDI_0482::NewL(TBool aHostRole)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
CUT_PBASE_T_USBDI_0482* self = new (ELeave) CUT_PBASE_T_USBDI_0482(aHostRole);
|
sl@0
|
49 |
CleanupStack::PushL(self);
|
sl@0
|
50 |
self->ConstructL();
|
sl@0
|
51 |
CleanupStack::Pop(self);
|
sl@0
|
52 |
return self;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
CUT_PBASE_T_USBDI_0482::CUT_PBASE_T_USBDI_0482(TBool aHostRole)
|
sl@0
|
57 |
: CBaseTestCase(KTestCaseId,aHostRole),
|
sl@0
|
58 |
iCaseStep(EInProgress)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
iEndpointAddressIn = 0x84;
|
sl@0
|
61 |
iEndpointAddressOut = 0x01;
|
sl@0
|
62 |
iOutTransferBuf.CreateL(KChunkSize);
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
void CUT_PBASE_T_USBDI_0482::ConstructL()
|
sl@0
|
67 |
{
|
sl@0
|
68 |
BaseConstructL();
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
|
sl@0
|
72 |
CUT_PBASE_T_USBDI_0482::~CUT_PBASE_T_USBDI_0482()
|
sl@0
|
73 |
{
|
sl@0
|
74 |
LOG_FUNC
|
sl@0
|
75 |
|
sl@0
|
76 |
Cancel();
|
sl@0
|
77 |
|
sl@0
|
78 |
// Close pipes before interfaces
|
sl@0
|
79 |
iPipeOut.Close();
|
sl@0
|
80 |
iPipeIn.Close();
|
sl@0
|
81 |
|
sl@0
|
82 |
iUsbInterface0.Close();
|
sl@0
|
83 |
iUsbInterface1.Close();
|
sl@0
|
84 |
iUsbInterface2.Close();
|
sl@0
|
85 |
|
sl@0
|
86 |
// Destroy transfers
|
sl@0
|
87 |
iOutTransfers.ResetAndDestroy();
|
sl@0
|
88 |
|
sl@0
|
89 |
iOutTransferBuf.Close();
|
sl@0
|
90 |
iDataPolledBuf.Close();
|
sl@0
|
91 |
|
sl@0
|
92 |
delete iIsochInTransfer;
|
sl@0
|
93 |
delete iControlEp0;
|
sl@0
|
94 |
delete iActorFDF;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
void CUT_PBASE_T_USBDI_0482::ExecuteHostTestCaseL()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
LOG_FUNC
|
sl@0
|
100 |
|
sl@0
|
101 |
iActorFDF = CActorFDF::NewL(*this);
|
sl@0
|
102 |
iControlEp0 = new (ELeave) CEp0Transfer(iUsbInterface0);
|
sl@0
|
103 |
iActorFDF->Monitor();
|
sl@0
|
104 |
|
sl@0
|
105 |
// Wait for the usb headset to be connected
|
sl@0
|
106 |
TimeoutIn(30);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
|
sl@0
|
110 |
void CUT_PBASE_T_USBDI_0482::HostDoCancel()
|
sl@0
|
111 |
{
|
sl@0
|
112 |
LOG_FUNC
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
|
sl@0
|
116 |
void CUT_PBASE_T_USBDI_0482::ExecuteDeviceTestCaseL()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
LOG_FUNC
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
void CUT_PBASE_T_USBDI_0482::DeviceDoCancel()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
LOG_FUNC
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
|
sl@0
|
128 |
void CUT_PBASE_T_USBDI_0482::DeviceStateChangeL(RUsbDevice::TDeviceState aPreviousState,RUsbDevice::TDeviceState aNewState,
|
sl@0
|
129 |
TInt aCompletionCode)
|
sl@0
|
130 |
{
|
sl@0
|
131 |
LOG_FUNC
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
|
sl@0
|
135 |
TInt CUT_PBASE_T_USBDI_0482::FindOUTIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
LOG_FUNC
|
sl@0
|
138 |
aDescriptor = NULL;
|
sl@0
|
139 |
|
sl@0
|
140 |
TUsbInterfaceDescriptor alternate;
|
sl@0
|
141 |
TInt err = iUsbInterface1.GetAlternateInterfaceDescriptor(1, alternate);
|
sl@0
|
142 |
if(err)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
RDebug::Printf("iUsbInterface1.GetAlternateInterfaceDescriptor error = %d",err);
|
sl@0
|
145 |
return err;
|
sl@0
|
146 |
}
|
sl@0
|
147 |
|
sl@0
|
148 |
TUsbGenericDescriptor* descriptor = alternate.iFirstChild;
|
sl@0
|
149 |
while(descriptor)
|
sl@0
|
150 |
{
|
sl@0
|
151 |
RDebug::Printf("ibDescriptorType = %d", descriptor->ibDescriptorType);
|
sl@0
|
152 |
if(descriptor->ibDescriptorType == EEndpoint)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
aDescriptor = descriptor;
|
sl@0
|
155 |
RDebug::Printf("found descriptor return KErrNone");
|
sl@0
|
156 |
return KErrNone;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
descriptor = descriptor->iNextPeer;
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
return KErrNotFound;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
|
sl@0
|
165 |
TInt CUT_PBASE_T_USBDI_0482::FindINIsochronousEndpoint(TUsbGenericDescriptor*& aDescriptor)
|
sl@0
|
166 |
{
|
sl@0
|
167 |
LOG_FUNC
|
sl@0
|
168 |
aDescriptor = NULL;
|
sl@0
|
169 |
|
sl@0
|
170 |
TUsbInterfaceDescriptor alternate;
|
sl@0
|
171 |
TInt err = iUsbInterface2.GetAlternateInterfaceDescriptor(1, alternate);
|
sl@0
|
172 |
if(err)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
RDebug::Printf("iUsbInterface2.GetAlternateInterfaceDescriptor error = %d",err);
|
sl@0
|
175 |
return err;
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
TUsbGenericDescriptor* descriptor = alternate.iFirstChild;
|
sl@0
|
179 |
while(descriptor)
|
sl@0
|
180 |
{
|
sl@0
|
181 |
RDebug::Printf("ibDescriptorType = %d", descriptor->ibDescriptorType);
|
sl@0
|
182 |
if(descriptor->ibDescriptorType == EEndpoint)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
aDescriptor = descriptor;
|
sl@0
|
185 |
RDebug::Printf("found descriptor return KErrNone");
|
sl@0
|
186 |
return KErrNone;
|
sl@0
|
187 |
}
|
sl@0
|
188 |
descriptor = descriptor->iNextPeer;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
return KErrNotFound;
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
|
sl@0
|
195 |
|
sl@0
|
196 |
void CUT_PBASE_T_USBDI_0482::DeviceInsertedL(TUint aDeviceHandle)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
LOG_FUNC
|
sl@0
|
199 |
|
sl@0
|
200 |
Cancel();
|
sl@0
|
201 |
CUsbTestDevice& testDevice = iActorFDF->DeviceL(aDeviceHandle);
|
sl@0
|
202 |
|
sl@0
|
203 |
CHECK(CheckTreeAfterDeviceInsertion(testDevice, _L("RLogitechHeadSet")) == KErrNone);
|
sl@0
|
204 |
|
sl@0
|
205 |
TUint32 token0, token1, token2;
|
sl@0
|
206 |
CHECK(testDevice.Device().GetTokenForInterface(0,token0) == KErrNone);
|
sl@0
|
207 |
|
sl@0
|
208 |
CHECK(iUsbInterface0.Open(token0) == KErrNone); // Default interface setting 0
|
sl@0
|
209 |
|
sl@0
|
210 |
|
sl@0
|
211 |
// open interface 1, alt. sett. 1
|
sl@0
|
212 |
CHECK(testDevice.Device().GetTokenForInterface(1,token1) == KErrNone);
|
sl@0
|
213 |
|
sl@0
|
214 |
CHECK(iUsbInterface1.Open(token1) == KErrNone); // Default interface setting 0
|
sl@0
|
215 |
|
sl@0
|
216 |
RDebug::Printf("Selecting alternate interface setting 1");
|
sl@0
|
217 |
CHECK(iUsbInterface1.SelectAlternateInterface(1) == KErrNone);
|
sl@0
|
218 |
|
sl@0
|
219 |
|
sl@0
|
220 |
// open interface 2, alt. sett. 1
|
sl@0
|
221 |
CHECK(testDevice.Device().GetTokenForInterface(2,token2) == KErrNone);
|
sl@0
|
222 |
|
sl@0
|
223 |
CHECK(iUsbInterface2.Open(token2) == KErrNone); // Default interface setting 0
|
sl@0
|
224 |
|
sl@0
|
225 |
|
sl@0
|
226 |
RDebug::Printf("Selecting alternate interface setting 1");
|
sl@0
|
227 |
CHECK(iUsbInterface2.SelectAlternateInterface(1) == KErrNone);
|
sl@0
|
228 |
|
sl@0
|
229 |
|
sl@0
|
230 |
iCaseStep = EWaitEndOfMusicTrack;
|
sl@0
|
231 |
|
sl@0
|
232 |
// Open a pipe for endpoint (Isoch out)
|
sl@0
|
233 |
RDebug::Printf("Finding address for an out isoch endpoint on interface 1 setting 1");
|
sl@0
|
234 |
// Isochronous OUT
|
sl@0
|
235 |
TUsbGenericDescriptor* isochEpDescriptorOut;
|
sl@0
|
236 |
CHECK(KErrNone == FindOUTIsochronousEndpoint(isochEpDescriptorOut));
|
sl@0
|
237 |
|
sl@0
|
238 |
// Get the maximum packet size for this isochronous endpoint
|
sl@0
|
239 |
TUint16 wMaxPacketSizeOut = isochEpDescriptorOut->TUint16At(KMaxPacketSizeOffset);
|
sl@0
|
240 |
RDebug::Printf("wMaxPacketSizeOut = %d", wMaxPacketSizeOut);
|
sl@0
|
241 |
CHECK(wMaxPacketSizeOut == KMaxPacketSizeOutExpected);
|
sl@0
|
242 |
|
sl@0
|
243 |
// Isochronous IN
|
sl@0
|
244 |
TUsbGenericDescriptor* isochEpDescriptorIn;
|
sl@0
|
245 |
CHECK(KErrNone == FindINIsochronousEndpoint(isochEpDescriptorIn));
|
sl@0
|
246 |
|
sl@0
|
247 |
// Get the maximum packet size for this isochronous endpoint
|
sl@0
|
248 |
TUint16 wMaxPacketSizeIn = isochEpDescriptorIn->TUint16At(KMaxPacketSizeOffset);
|
sl@0
|
249 |
RDebug::Printf("wMaxPacketSizeIn = %d", wMaxPacketSizeIn);
|
sl@0
|
250 |
CHECK(wMaxPacketSizeIn == KMaxPacketSizeInExpected);
|
sl@0
|
251 |
|
sl@0
|
252 |
|
sl@0
|
253 |
// open pipes now.
|
sl@0
|
254 |
// Out
|
sl@0
|
255 |
RDebug::Printf("Opening a pipe to %08x",iEndpointAddressOut);
|
sl@0
|
256 |
CHECK(iUsbInterface1.OpenPipeForEndpoint(iPipeOut,iEndpointAddressOut,EFalse) == KErrNone);
|
sl@0
|
257 |
|
sl@0
|
258 |
RDebug::Printf("Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressOut);
|
sl@0
|
259 |
|
sl@0
|
260 |
// In
|
sl@0
|
261 |
RDebug::Printf("Opening a pipe to %08x",iEndpointAddressIn);
|
sl@0
|
262 |
CHECK(iUsbInterface2.OpenPipeForEndpoint(iPipeIn,iEndpointAddressIn,EFalse) == KErrNone);
|
sl@0
|
263 |
|
sl@0
|
264 |
RDebug::Printf("Opened pipe to endpoint address %08x for isochronous transfer to device",iEndpointAddressIn);
|
sl@0
|
265 |
|
sl@0
|
266 |
// SET_CUR class specific command
|
sl@0
|
267 |
TSetCurRequest request(KHighRecordSamplingRate ,iEndpointAddressIn);
|
sl@0
|
268 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
269 |
|
sl@0
|
270 |
// Que transfers now
|
sl@0
|
271 |
// Transfer IN
|
sl@0
|
272 |
iIsochInTransfer = new (ELeave) CIsochTransfer(iPipeIn,iUsbInterface2,wMaxPacketSizeIn,
|
sl@0
|
273 |
KIsochInMaxNumPackets ,*this, KRecordedDataId);
|
sl@0
|
274 |
|
sl@0
|
275 |
CHECK(iIsochInTransfer->RegisterTransferDescriptor() == KErrNone);
|
sl@0
|
276 |
|
sl@0
|
277 |
// Initialise the descriptors for transfer
|
sl@0
|
278 |
RDebug::Printf("Initialising the transfer descriptors interface 2");
|
sl@0
|
279 |
CHECK(iUsbInterface2.InitialiseTransferDescriptors() == KErrNone);
|
sl@0
|
280 |
|
sl@0
|
281 |
|
sl@0
|
282 |
// que interrupt transfer
|
sl@0
|
283 |
CHECK(iIsochInTransfer->TransferInL(KRecordedPacketsExpected) == KErrNone);
|
sl@0
|
284 |
|
sl@0
|
285 |
|
sl@0
|
286 |
// Transfer OUT
|
sl@0
|
287 |
RFs iFs;
|
sl@0
|
288 |
TInt ret = KErrNone;
|
sl@0
|
289 |
ret = iFs.Connect();
|
sl@0
|
290 |
CHECK(ret==KErrNone || ret==KErrAlreadyExists);
|
sl@0
|
291 |
RFile trackFile;
|
sl@0
|
292 |
CHECK(trackFile.Open(iFs,KTrackFileName,EFileShareAny|EFileRead) == KErrNone);
|
sl@0
|
293 |
|
sl@0
|
294 |
|
sl@0
|
295 |
TInt trackFileSize;
|
sl@0
|
296 |
trackFile.Size(trackFileSize);
|
sl@0
|
297 |
|
sl@0
|
298 |
|
sl@0
|
299 |
wMaxPacketSizeOut = KAudioCDQualityFrequency;
|
sl@0
|
300 |
|
sl@0
|
301 |
TInt nbChunks = trackFileSize/KChunkSize;
|
sl@0
|
302 |
TInt remainderSize = trackFileSize%KChunkSize;
|
sl@0
|
303 |
|
sl@0
|
304 |
if(remainderSize != 0)
|
sl@0
|
305 |
{
|
sl@0
|
306 |
nbChunks++;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
TInt iChunk = 0;
|
sl@0
|
310 |
TInt size = KChunkSize;
|
sl@0
|
311 |
|
sl@0
|
312 |
// create Transfers
|
sl@0
|
313 |
for(iChunk = 0; iChunk < nbChunks; iChunk++)
|
sl@0
|
314 |
{
|
sl@0
|
315 |
RDebug::Printf("iChunk = %d", iChunk);
|
sl@0
|
316 |
|
sl@0
|
317 |
// remainder(last loop)
|
sl@0
|
318 |
if(remainderSize != 0 && (iChunk == nbChunks-1))
|
sl@0
|
319 |
{
|
sl@0
|
320 |
size = remainderSize;
|
sl@0
|
321 |
}
|
sl@0
|
322 |
CIsochTransfer* transfer = new (ELeave) CIsochTransfer(iPipeOut,iUsbInterface1,wMaxPacketSizeOut,
|
sl@0
|
323 |
(size/wMaxPacketSizeOut),*this, iChunk);
|
sl@0
|
324 |
CHECK(transfer->RegisterTransferDescriptor() == KErrNone);
|
sl@0
|
325 |
iOutTransfers.AppendL(transfer);
|
sl@0
|
326 |
iOutTransferBuf.Zero();
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
// Initialise the descriptors for transfer
|
sl@0
|
330 |
RDebug::Printf("Initialising the transfer descriptors");
|
sl@0
|
331 |
CHECK(iUsbInterface1.InitialiseTransferDescriptors() == KErrNone);
|
sl@0
|
332 |
|
sl@0
|
333 |
// prepare & send transfers(TODO streaming algorithm with 3 Transfers only, filling 2 while the 3rd is transferring his data)
|
sl@0
|
334 |
size = KChunkSize;
|
sl@0
|
335 |
for(TInt iTransfers = 0; iTransfers < iOutTransfers.Count(); iTransfers++)
|
sl@0
|
336 |
{
|
sl@0
|
337 |
RDebug::Printf("iTransfers = %d", iTransfers);
|
sl@0
|
338 |
// remainder(last loop)
|
sl@0
|
339 |
if(remainderSize != 0 && (iTransfers == iOutTransfers.Count()-1))
|
sl@0
|
340 |
{
|
sl@0
|
341 |
RDebug::Printf("remainderSize = %d", remainderSize);
|
sl@0
|
342 |
size = remainderSize;
|
sl@0
|
343 |
}
|
sl@0
|
344 |
CHECK(trackFile.Read(KChunkSize*iTransfers, iOutTransferBuf, size) == KErrNone);
|
sl@0
|
345 |
CHECK(iOutTransfers[iTransfers]->PrepareTransfer(iOutTransferBuf) == KErrNone);
|
sl@0
|
346 |
CHECK(iOutTransfers[iTransfers]->TransferOut() == KErrNone);
|
sl@0
|
347 |
iOutTransferBuf.Zero();
|
sl@0
|
348 |
}
|
sl@0
|
349 |
}
|
sl@0
|
350 |
|
sl@0
|
351 |
TBool CUT_PBASE_T_USBDI_0482::ReplayRecordedData()
|
sl@0
|
352 |
{
|
sl@0
|
353 |
LOG_FUNC
|
sl@0
|
354 |
|
sl@0
|
355 |
iOutTransferBuf.Zero();
|
sl@0
|
356 |
|
sl@0
|
357 |
// Transfer OUT
|
sl@0
|
358 |
TInt nbChunks = iDataPolledBuf.Length()/KChunkSize;
|
sl@0
|
359 |
TInt remainderSize = iDataPolledBuf.Length()%KChunkSize;
|
sl@0
|
360 |
RDebug::Printf("nbChunks = %d", nbChunks);
|
sl@0
|
361 |
RDebug::Printf("remainderSize = %d", remainderSize);
|
sl@0
|
362 |
|
sl@0
|
363 |
if(remainderSize != 0)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
nbChunks++;
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
// prepare transfers
|
sl@0
|
369 |
for(TInt iTransfers = 0; iTransfers < nbChunks; iTransfers++)
|
sl@0
|
370 |
{
|
sl@0
|
371 |
RDebug::Printf("iTransfers = %d", iTransfers);
|
sl@0
|
372 |
// remainder(last loop)
|
sl@0
|
373 |
if(remainderSize != 0 && (iTransfers == nbChunks-1))
|
sl@0
|
374 |
{
|
sl@0
|
375 |
RDebug::Printf("remainderSize = %d", remainderSize);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
CHECK_RET_BOOL(iOutTransfers[iTransfers]->PrepareTransfer(iDataPolledBuf) == KErrNone); // TODO retrieve relevant part of iDataPolledBuf if several chunks
|
sl@0
|
378 |
CHECK_RET_BOOL(iOutTransfers[iTransfers]->TransferOut() == KErrNone);
|
sl@0
|
379 |
iOutTransferBuf.Zero();
|
sl@0
|
380 |
}
|
sl@0
|
381 |
return ETrue;
|
sl@0
|
382 |
}
|
sl@0
|
383 |
|
sl@0
|
384 |
void CUT_PBASE_T_USBDI_0482::TransferCompleteL(TInt aTransferId,TInt aCompletionCode)
|
sl@0
|
385 |
{
|
sl@0
|
386 |
LOG_FUNC
|
sl@0
|
387 |
RDebug::Printf("Transfer completed (id=%d), aCompletionCode = %d",aTransferId, aCompletionCode);
|
sl@0
|
388 |
Cancel();
|
sl@0
|
389 |
|
sl@0
|
390 |
if(aCompletionCode != KErrNone)
|
sl@0
|
391 |
{
|
sl@0
|
392 |
RDebug::Printf("<Error %d> Transfer %d not successful",aCompletionCode,aTransferId);
|
sl@0
|
393 |
TestFailed(aCompletionCode);
|
sl@0
|
394 |
return;
|
sl@0
|
395 |
}
|
sl@0
|
396 |
|
sl@0
|
397 |
if(aTransferId == KRecordedDataId)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
// data successfully recorded
|
sl@0
|
400 |
// 1. save data recorded
|
sl@0
|
401 |
CHECK(iIsochInTransfer->DataPolled(KRecordedPacketsExpected, iDataPolledBuf));
|
sl@0
|
402 |
// 2. waiting now for the end of the music track
|
sl@0
|
403 |
return;
|
sl@0
|
404 |
}
|
sl@0
|
405 |
|
sl@0
|
406 |
switch(iCaseStep)
|
sl@0
|
407 |
{
|
sl@0
|
408 |
case EWaitEndOfMusicTrack:
|
sl@0
|
409 |
{
|
sl@0
|
410 |
if(aTransferId != iExpectedTransferId)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
RDebug::Printf("unexpected transfer!");
|
sl@0
|
413 |
TestFailed(KErrCorrupt);
|
sl@0
|
414 |
}
|
sl@0
|
415 |
iExpectedTransferId++;
|
sl@0
|
416 |
// is it the last transfer?
|
sl@0
|
417 |
if(iExpectedTransferId == iOutTransfers.Count())
|
sl@0
|
418 |
{
|
sl@0
|
419 |
RDebug::Printf("last transfer successful! lets replay recorded data");
|
sl@0
|
420 |
|
sl@0
|
421 |
iCaseStep = EReplayRecordedData; // assuming that recording is finished
|
sl@0
|
422 |
TSetCurRequest request(KLowSamplingRate ,iEndpointAddressOut);
|
sl@0
|
423 |
iControlEp0->SendRequest(request,this);
|
sl@0
|
424 |
}
|
sl@0
|
425 |
}
|
sl@0
|
426 |
break;
|
sl@0
|
427 |
|
sl@0
|
428 |
case EReplayRecordedData:
|
sl@0
|
429 |
{
|
sl@0
|
430 |
TestPassed(); // TODO only one transfer used in this case(few data recorded), cope with several ones
|
sl@0
|
431 |
}
|
sl@0
|
432 |
break;
|
sl@0
|
433 |
|
sl@0
|
434 |
default:
|
sl@0
|
435 |
TestFailed(KErrDisconnected);
|
sl@0
|
436 |
break;
|
sl@0
|
437 |
}
|
sl@0
|
438 |
}
|
sl@0
|
439 |
|
sl@0
|
440 |
void CUT_PBASE_T_USBDI_0482::Ep0TransferCompleteL(TInt aCompletionCode)
|
sl@0
|
441 |
{
|
sl@0
|
442 |
LOG_FUNC
|
sl@0
|
443 |
RDebug::Printf("Transfer EP0 completed aCompletionCode = %d", aCompletionCode);
|
sl@0
|
444 |
|
sl@0
|
445 |
if(aCompletionCode != KErrNone)
|
sl@0
|
446 |
{
|
sl@0
|
447 |
TBuf<256> msg;
|
sl@0
|
448 |
msg.Format(_L("<Error %d> Transfer to control endpoint 0 was not successful"),aCompletionCode);
|
sl@0
|
449 |
RDebug::Print(msg);
|
sl@0
|
450 |
return;
|
sl@0
|
451 |
}
|
sl@0
|
452 |
switch(iCaseStep)
|
sl@0
|
453 |
{
|
sl@0
|
454 |
case EWaitEndOfMusicTrack:
|
sl@0
|
455 |
break;
|
sl@0
|
456 |
|
sl@0
|
457 |
case EReplayRecordedData:
|
sl@0
|
458 |
{
|
sl@0
|
459 |
CHECK(ReplayRecordedData());
|
sl@0
|
460 |
}
|
sl@0
|
461 |
break;
|
sl@0
|
462 |
|
sl@0
|
463 |
default:
|
sl@0
|
464 |
RDebug::Printf("<Error> Unknown test step");
|
sl@0
|
465 |
TestFailed(KErrUnknown);
|
sl@0
|
466 |
break;
|
sl@0
|
467 |
}
|
sl@0
|
468 |
}
|
sl@0
|
469 |
|
sl@0
|
470 |
|
sl@0
|
471 |
void CUT_PBASE_T_USBDI_0482::DeviceRemovedL(TUint aDeviceHandle)
|
sl@0
|
472 |
{
|
sl@0
|
473 |
LOG_FUNC
|
sl@0
|
474 |
|
sl@0
|
475 |
// Manual test over
|
sl@0
|
476 |
switch(iCaseStep)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
case EFailed:
|
sl@0
|
479 |
TestFailed(KErrCompletion);
|
sl@0
|
480 |
break;
|
sl@0
|
481 |
|
sl@0
|
482 |
case EInProgress:
|
sl@0
|
483 |
default:
|
sl@0
|
484 |
TestFailed(KErrDisconnected);
|
sl@0
|
485 |
break;
|
sl@0
|
486 |
}
|
sl@0
|
487 |
}
|
sl@0
|
488 |
|
sl@0
|
489 |
|
sl@0
|
490 |
void CUT_PBASE_T_USBDI_0482::BusErrorL(TInt aError)
|
sl@0
|
491 |
{
|
sl@0
|
492 |
LOG_FUNC
|
sl@0
|
493 |
// This test case handles no failiures on the bus
|
sl@0
|
494 |
TestFailed(KErrCompletion);
|
sl@0
|
495 |
}
|
sl@0
|
496 |
|
sl@0
|
497 |
|
sl@0
|
498 |
void CUT_PBASE_T_USBDI_0482::HostRunL()
|
sl@0
|
499 |
{
|
sl@0
|
500 |
LOG_FUNC
|
sl@0
|
501 |
|
sl@0
|
502 |
// Obtain the completion code
|
sl@0
|
503 |
TInt completionCode(iStatus.Int());
|
sl@0
|
504 |
|
sl@0
|
505 |
if(completionCode == KErrNone)
|
sl@0
|
506 |
{
|
sl@0
|
507 |
// Action timeout
|
sl@0
|
508 |
RDebug::Printf("<Error> Action timeout");
|
sl@0
|
509 |
TestFailed(KErrTimedOut);
|
sl@0
|
510 |
}
|
sl@0
|
511 |
else
|
sl@0
|
512 |
{
|
sl@0
|
513 |
RDebug::Printf("<Error %d> Timeout timer could not complete",completionCode);
|
sl@0
|
514 |
TestFailed(completionCode);
|
sl@0
|
515 |
}
|
sl@0
|
516 |
}
|
sl@0
|
517 |
|
sl@0
|
518 |
void CUT_PBASE_T_USBDI_0482::DeviceRunL()
|
sl@0
|
519 |
{
|
sl@0
|
520 |
}
|
sl@0
|
521 |
|
sl@0
|
522 |
}
|