|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of Integraton test step classes for A3f DevSound Play test cases. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "tsi_a3f_devsound_play.h" |
|
19 |
|
20 /* |
|
21 * |
|
22 * RTestStepA3FDevSoundPlayBase - Test step constructor |
|
23 * |
|
24 */ |
|
25 RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
26 :RAsyncTestStep(), |
|
27 iMMFDevSound(NULL), |
|
28 iBuffer(NULL), |
|
29 iTimer(NULL), |
|
30 iCallBack(NULL, NULL), |
|
31 iInputDataType(aInputDataType), |
|
32 iSectName(aSectName), |
|
33 iFilename(KNullDesC), |
|
34 iSampleRate(KNullDesC), |
|
35 iMonoStereo(KNullDesC), |
|
36 iPlayState(EStatePlayStart), |
|
37 iBufferCount(0), |
|
38 iConfig(EFalse), |
|
39 iInvalidConfig(EFalse), |
|
40 iUseFourCC(EFalse) |
|
41 { |
|
42 // From RTestStep |
|
43 iTestStepName = aTestName; // store the name of the test case |
|
44 |
|
45 } |
|
46 |
|
47 /* |
|
48 * |
|
49 * RTestStepA3FDevSoundPlayBase - Test step constructor |
|
50 * |
|
51 */ |
|
52 RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName) |
|
53 :RAsyncTestStep(), |
|
54 iMMFDevSound(NULL), |
|
55 iBuffer(NULL), |
|
56 iTimer(NULL), |
|
57 iCallBack(NULL, NULL), |
|
58 iInputDataType(KMMFFourCCCodePCM16), |
|
59 iSectName(aSectName), |
|
60 iFilename(KNullDesC), |
|
61 iSampleRate(KNullDesC), |
|
62 iMonoStereo(KNullDesC), |
|
63 iPlayState(EStatePlayStart), |
|
64 iBufferCount(0), |
|
65 iConfig(EFalse), |
|
66 iInvalidConfig(EFalse), |
|
67 iUseFourCC(EFalse) |
|
68 { |
|
69 // From RTestStep |
|
70 iTestStepName = aTestName; // store the name of the test case |
|
71 |
|
72 } |
|
73 |
|
74 /* |
|
75 * |
|
76 * RTestStepA3FDevSoundPlayBase - Test step constructor |
|
77 * |
|
78 */ |
|
79 RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TFourCC& aInputDataType) |
|
80 :RAsyncTestStep(), |
|
81 iMMFDevSound(NULL), |
|
82 iBuffer(NULL), |
|
83 iTimer(NULL), |
|
84 iCallBack(NULL, NULL), |
|
85 iInputDataType(aInputDataType), |
|
86 iSectName(KNullDesC), |
|
87 iFilename(KNullDesC), |
|
88 iSampleRate(KNullDesC), |
|
89 iMonoStereo(KNullDesC), |
|
90 iPlayState(EStatePlayStart), |
|
91 iBufferCount(0), |
|
92 iConfig(EFalse), |
|
93 iInvalidConfig(EFalse), |
|
94 iUseFourCC(EFalse) |
|
95 { |
|
96 // From RTestStep |
|
97 iTestStepName = aTestName; // store the name of the test case |
|
98 |
|
99 } |
|
100 |
|
101 |
|
102 /* |
|
103 * |
|
104 * RTestStepA3FDevSoundPlayBase - Test step constructor |
|
105 * |
|
106 */ |
|
107 RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName) |
|
108 :RAsyncTestStep(), |
|
109 iMMFDevSound(NULL), |
|
110 iBuffer(NULL), |
|
111 iTimer(NULL), |
|
112 iCallBack(NULL, NULL), |
|
113 iInputDataType(KMMFFourCCCodePCM16), |
|
114 iSectName(KNullDesC), |
|
115 iFilename(KNullDesC), |
|
116 iSampleRate(KNullDesC), |
|
117 iMonoStereo(KNullDesC), |
|
118 iPlayState(EStatePlayStart), |
|
119 iBufferCount(0), |
|
120 iConfig(EFalse), |
|
121 iInvalidConfig(EFalse), |
|
122 iUseFourCC(EFalse) |
|
123 { |
|
124 // From RTestStep |
|
125 iTestStepName = aTestName; // store the name of the test case |
|
126 |
|
127 } |
|
128 |
|
129 /* |
|
130 * |
|
131 * KickoffTestL |
|
132 * - Starts the test |
|
133 * |
|
134 */ |
|
135 void RTestStepA3FDevSoundPlayBase::KickoffTestL() |
|
136 { |
|
137 TInt err = iFs.Connect(); |
|
138 if (err != KErrNone) |
|
139 { |
|
140 ERR_PRINTF2(_L("Could not connect to Filesystem. Error = %d"), err); |
|
141 StopTest(err); |
|
142 } |
|
143 |
|
144 // Get the file name of the audio file to play |
|
145 #ifdef __WINS__ |
|
146 if(!GetStringFromConfig(iSectName, _L("EmuPlayFile"), iFilename)) |
|
147 { |
|
148 TPtrC keyName(_L("EmuPlayFile")); |
|
149 ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
150 StopTest(KErrPathNotFound); |
|
151 return; |
|
152 } |
|
153 |
|
154 #elif __MARM__ |
|
155 if(!GetStringFromConfig(iSectName, _L("HwPlayFile"), iFilename)) |
|
156 { |
|
157 TPtrC keyName(_L("HwPlayFile")); |
|
158 ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
159 StopTest(KErrPathNotFound); |
|
160 return; |
|
161 } |
|
162 #endif |
|
163 |
|
164 // Check if SetConfig and FourCC are to be used or not |
|
165 CheckConfigAndFourCCUsage(); |
|
166 |
|
167 INFO_PRINTF2(_L("Section Name is :%S"), &iSectName); |
|
168 |
|
169 // Open using RFile for playback |
|
170 err = iFile.Open(iFs, iFilename, EFileRead); |
|
171 if (err != KErrNone) |
|
172 { |
|
173 ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err); |
|
174 StopTest(err); |
|
175 } |
|
176 |
|
177 // Create instance of CMMFDevSound |
|
178 iMMFDevSound = CMMFDevSound::NewL(); |
|
179 |
|
180 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
181 iCallBack = TCallBack(TimerCallback, this); |
|
182 |
|
183 DoKickoffTestL(); |
|
184 Fsm(EEventPlayStart, KErrNone); // call to initialize DevSound |
|
185 |
|
186 } |
|
187 |
|
188 /* |
|
189 * |
|
190 * DoKickoffTestL |
|
191 * |
|
192 */ |
|
193 void RTestStepA3FDevSoundPlayBase::DoKickoffTestL() |
|
194 { |
|
195 INFO_PRINTF2(_L("File to be played -> %S"), &iFilename); |
|
196 DisplayCodecInfo(); |
|
197 |
|
198 } |
|
199 |
|
200 /* |
|
201 * ToneFinished |
|
202 * |
|
203 */ |
|
204 void RTestStepA3FDevSoundPlayBase::ToneFinished(TInt /*aError*/) |
|
205 { |
|
206 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall)); |
|
207 |
|
208 } |
|
209 |
|
210 /* |
|
211 * |
|
212 * RecordError |
|
213 * |
|
214 */ |
|
215 void RTestStepA3FDevSoundPlayBase::RecordError(TInt) |
|
216 { |
|
217 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall)); |
|
218 |
|
219 } |
|
220 |
|
221 /* |
|
222 * |
|
223 * BufferToBeEmptied |
|
224 * |
|
225 */ |
|
226 void RTestStepA3FDevSoundPlayBase::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) |
|
227 { |
|
228 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall)); |
|
229 |
|
230 } |
|
231 |
|
232 /* |
|
233 * |
|
234 * ConvertError |
|
235 * |
|
236 */ |
|
237 void RTestStepA3FDevSoundPlayBase::ConvertError(TInt /*aError*/) |
|
238 { |
|
239 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall)); |
|
240 |
|
241 } |
|
242 |
|
243 /* |
|
244 * |
|
245 * DeviceMessage |
|
246 * |
|
247 */ |
|
248 void RTestStepA3FDevSoundPlayBase::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/) |
|
249 { |
|
250 __ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall)); |
|
251 |
|
252 } |
|
253 |
|
254 /* |
|
255 * |
|
256 * TimerCallback |
|
257 * |
|
258 */ |
|
259 TInt RTestStepA3FDevSoundPlayBase::TimerCallback(TAny* aPtr) |
|
260 { |
|
261 static_cast<RTestStepA3FDevSoundPlayBase*>(aPtr)->DoTimerCallback(); |
|
262 return KErrNone; |
|
263 |
|
264 } |
|
265 |
|
266 /* |
|
267 * |
|
268 * DoTimerCallback |
|
269 * |
|
270 */ |
|
271 void RTestStepA3FDevSoundPlayBase::DoTimerCallback() |
|
272 { |
|
273 // The derived classes may provide the implementation if needed |
|
274 } |
|
275 |
|
276 /* |
|
277 * |
|
278 * CallStopTest |
|
279 * |
|
280 */ |
|
281 void RTestStepA3FDevSoundPlayBase::CloseTest() |
|
282 { |
|
283 if (iMMFDevSound) |
|
284 { |
|
285 INFO_PRINTF1(_L("Deleting DevSound object...")); |
|
286 delete iMMFDevSound; |
|
287 iMMFDevSound = NULL; |
|
288 } |
|
289 |
|
290 if (iTimer) |
|
291 { |
|
292 delete iTimer; |
|
293 iTimer = NULL; |
|
294 } |
|
295 |
|
296 iFile.Close(); |
|
297 iFs.Close(); |
|
298 |
|
299 } |
|
300 |
|
301 /* |
|
302 * |
|
303 * InitializeComplete |
|
304 * |
|
305 */ |
|
306 void RTestStepA3FDevSoundPlayBase::InitializeComplete(TInt aError) |
|
307 { |
|
308 if (iPlayState == EStatePlayInitializing) |
|
309 { |
|
310 Fsm(EEventInitCompletePlay,aError); |
|
311 } |
|
312 |
|
313 } |
|
314 |
|
315 /* |
|
316 * |
|
317 * BufferToBeFilled |
|
318 * |
|
319 */ |
|
320 void RTestStepA3FDevSoundPlayBase::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
321 { |
|
322 if (!aBuffer) |
|
323 { |
|
324 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
325 StopTest(KErrGeneral); |
|
326 return; |
|
327 } |
|
328 |
|
329 iBuffer = aBuffer; |
|
330 |
|
331 // Call to continue the Play process |
|
332 Fsm(EEventBTBF,KErrNone); |
|
333 |
|
334 } |
|
335 |
|
336 /* |
|
337 * |
|
338 * PlayError |
|
339 * |
|
340 */ |
|
341 void RTestStepA3FDevSoundPlayBase::PlayError(TInt aError) |
|
342 { |
|
343 INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError); |
|
344 if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow)) |
|
345 { |
|
346 StopTest(); |
|
347 } |
|
348 else |
|
349 { |
|
350 StopTest(aError, EFail); |
|
351 } |
|
352 |
|
353 } |
|
354 |
|
355 /* |
|
356 * |
|
357 * Fsm |
|
358 * - Executes playing events of DevSound in sequence |
|
359 * |
|
360 */ |
|
361 void RTestStepA3FDevSoundPlayBase::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
362 { |
|
363 switch (iPlayState) |
|
364 { |
|
365 case EStatePlayStart: |
|
366 { |
|
367 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed)); |
|
368 if (aDevSoundEvent == EEventPlayStart) |
|
369 { |
|
370 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
371 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
372 TInt err; |
|
373 if(iUseFourCC) |
|
374 { |
|
375 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
376 } |
|
377 else |
|
378 { |
|
379 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
380 } |
|
381 if (err != KErrNone) |
|
382 { |
|
383 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
384 StopTest(err); |
|
385 break; |
|
386 } |
|
387 |
|
388 |
|
389 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
390 iPlayState = EStatePlayInitializing; |
|
391 } |
|
392 else |
|
393 { |
|
394 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
395 StopTest(aError, EFail); |
|
396 } |
|
397 break; |
|
398 } |
|
399 |
|
400 case EStatePlayInitializing: |
|
401 { |
|
402 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
403 { |
|
404 if(iConfig) |
|
405 { |
|
406 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
407 SetSampleRateAndChannelMode(); |
|
408 TMMFCapabilities capabilities; |
|
409 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
410 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
411 |
|
412 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
413 if (errConfig != KErrNone && !iInvalidConfig) |
|
414 { |
|
415 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
416 StopTest(errConfig); |
|
417 return; |
|
418 } |
|
419 else if (errConfig == KErrArgument && iInvalidConfig) |
|
420 { |
|
421 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with expected error = %d"), errConfig); |
|
422 iInvalidConfig = EFalse; |
|
423 StopTest(errConfig, EPass); |
|
424 return; |
|
425 } |
|
426 } |
|
427 |
|
428 // Initialize audio device and starts the playing process |
|
429 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
430 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
431 if (errPlay != KErrNone) |
|
432 { |
|
433 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
434 StopTest(errPlay); |
|
435 break; |
|
436 } |
|
437 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
438 iPlayState = EStatePlaying; |
|
439 } |
|
440 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
441 { |
|
442 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
443 StopTest(aError); |
|
444 } |
|
445 else |
|
446 { |
|
447 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
448 StopTest(aError, EFail); |
|
449 } |
|
450 break; |
|
451 } |
|
452 |
|
453 case EStatePlaying: |
|
454 { |
|
455 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed)); |
|
456 if (aDevSoundEvent == EEventBTBF) |
|
457 { |
|
458 // Fill the buffer with audio data and play the data in the buffer |
|
459 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
460 TInt err = iFile.Read(buffer->Data()); |
|
461 if (err != KErrNone) |
|
462 { |
|
463 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
464 StopTest(err); |
|
465 break; |
|
466 } |
|
467 if (buffer->Data().Length() != buffer->RequestSize()) |
|
468 { |
|
469 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
470 iBuffer->SetLastBuffer(ETrue); |
|
471 } |
|
472 |
|
473 // Playing data in the buffer at the current volume |
|
474 iMMFDevSound->PlayData(); |
|
475 iBufferCount++; |
|
476 } |
|
477 else |
|
478 { |
|
479 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
480 StopTest(aError, EFail); |
|
481 } |
|
482 |
|
483 break; |
|
484 } |
|
485 |
|
486 default: |
|
487 { |
|
488 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
489 StopTest(KErrGeneral); |
|
490 } |
|
491 } |
|
492 |
|
493 } |
|
494 |
|
495 /* |
|
496 * |
|
497 * DisplayCodecInfo |
|
498 * |
|
499 */ |
|
500 void RTestStepA3FDevSoundPlayBase::DisplayCodecInfo() |
|
501 { |
|
502 // Display trace about codec under test |
|
503 TUint32 fourCC = iInputDataType.FourCC(); |
|
504 INFO_PRINTF5(_L("Codec under test -> %c%c%c%c"), fourCC, fourCC>>8, fourCC>>16, fourCC>>24); |
|
505 |
|
506 } |
|
507 |
|
508 /* |
|
509 * |
|
510 * ConvertDesToTMMFSampleRate |
|
511 * |
|
512 */ |
|
513 TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFSampleRate(const TDesC& aSampleRateString) |
|
514 { |
|
515 TUint rate = 0; |
|
516 |
|
517 STR_SWITCH(aSampleRateString) |
|
518 |
|
519 STR_CASE(_L("EMMFSampleRate8000Hz")) |
|
520 { |
|
521 rate = EMMFSampleRate8000Hz; |
|
522 break; |
|
523 } |
|
524 STR_CASE(_L("EMMFSampleRate11025Hz")) |
|
525 { |
|
526 rate = EMMFSampleRate11025Hz; |
|
527 break; |
|
528 } |
|
529 STR_CASE(_L("EMMFSampleRate12000Hz")) |
|
530 { |
|
531 rate = EMMFSampleRate12000Hz; |
|
532 break; |
|
533 } |
|
534 STR_CASE(_L("EMMFSampleRate16000Hz")) |
|
535 { |
|
536 rate = EMMFSampleRate16000Hz; |
|
537 break; |
|
538 } |
|
539 STR_CASE(_L("EMMFSampleRate22050Hz")) |
|
540 { |
|
541 rate = EMMFSampleRate22050Hz; |
|
542 break; |
|
543 } |
|
544 STR_CASE(_L("EMMFSampleRate24000Hz")) |
|
545 { |
|
546 rate = EMMFSampleRate24000Hz; |
|
547 break; |
|
548 } |
|
549 STR_CASE(_L("EMMFSampleRate32000Hz")) |
|
550 { |
|
551 rate = EMMFSampleRate32000Hz; |
|
552 break; |
|
553 } |
|
554 STR_CASE(_L("EMMFSampleRate44100Hz")) |
|
555 { |
|
556 rate = EMMFSampleRate44100Hz; |
|
557 break; |
|
558 } |
|
559 STR_CASE(_L("EMMFSampleRate48000Hz")) |
|
560 { |
|
561 rate = EMMFSampleRate48000Hz; |
|
562 break; |
|
563 } |
|
564 STR_CASE(_L("EMMFSampleRate64000Hz")) |
|
565 { |
|
566 rate = EMMFSampleRate64000Hz; |
|
567 break; |
|
568 } |
|
569 STR_CASE(_L("EMMFSampleRate88200Hz")) |
|
570 { |
|
571 rate = EMMFSampleRate88200Hz; |
|
572 break; |
|
573 } |
|
574 STR_CASE(_L("EMMFSampleRate96000Hz")) |
|
575 { |
|
576 rate = EMMFSampleRate96000Hz; |
|
577 break; |
|
578 } |
|
579 STR_CASE(_L("InvalidRate")) |
|
580 { |
|
581 rate = 0x90000000; |
|
582 break; |
|
583 } |
|
584 |
|
585 DEFAULT_CASE() |
|
586 { |
|
587 ERR_PRINTF1(_L("Attempt to convert invalid sample rate")); |
|
588 StopTest(KErrGeneral); |
|
589 } |
|
590 |
|
591 STR_SWITCH_END() |
|
592 |
|
593 INFO_PRINTF2(_L("Sample Rate = %S"), &iSampleRate); |
|
594 return rate; |
|
595 |
|
596 } |
|
597 |
|
598 /* |
|
599 * |
|
600 * ConvertDesToTMMFMonoStereo |
|
601 * |
|
602 */ |
|
603 TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFMonoStereo(const TDesC& aMonoStereoString) |
|
604 { |
|
605 TUint channelMode = 0; |
|
606 |
|
607 STR_SWITCH(aMonoStereoString) |
|
608 |
|
609 STR_CASE(_L("EMMFMono")) |
|
610 { |
|
611 channelMode = EMMFMono; |
|
612 break; |
|
613 } |
|
614 STR_CASE(_L("EMMFStereo")) |
|
615 { |
|
616 channelMode = EMMFStereo; |
|
617 break; |
|
618 } |
|
619 STR_CASE(_L("InvalidMode")) |
|
620 { |
|
621 channelMode = 0x90000000; |
|
622 break; |
|
623 } |
|
624 DEFAULT_CASE() |
|
625 { |
|
626 ERR_PRINTF1(_L("Attempt to convert invalid channel mode")); |
|
627 StopTest(KErrGeneral); |
|
628 } |
|
629 |
|
630 STR_SWITCH_END() |
|
631 |
|
632 INFO_PRINTF2(_L("Channel = %S"), &iMonoStereo); |
|
633 return channelMode; |
|
634 |
|
635 } |
|
636 |
|
637 /* |
|
638 * |
|
639 * SetSampleRateAndChannelMode |
|
640 * |
|
641 */ |
|
642 void RTestStepA3FDevSoundPlayBase::SetSampleRateAndChannelMode() |
|
643 { |
|
644 if(!GetStringFromConfig(iSectName, _L("SampleRate"), iSampleRate)) |
|
645 { |
|
646 TPtrC keyName(_L("SampleRate")); |
|
647 ERR_PRINTF3(_L("Error in getting sample rate from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
648 StopTest(KErrPathNotFound); |
|
649 return; |
|
650 } |
|
651 |
|
652 if(!GetStringFromConfig(iSectName, _L("MonoStereo"), iMonoStereo)) |
|
653 { |
|
654 TPtrC keyName(_L("MonoStereo")); |
|
655 ERR_PRINTF3(_L("Error in getting channel mode from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
656 StopTest(KErrPathNotFound); |
|
657 return; |
|
658 } |
|
659 |
|
660 } |
|
661 |
|
662 /* |
|
663 * |
|
664 * CheckConfigAndFourCCUsage |
|
665 * |
|
666 */ |
|
667 void RTestStepA3FDevSoundPlayBase::CheckConfigAndFourCCUsage() |
|
668 { |
|
669 if(!GetBoolFromConfig(iSectName, _L("SetConfig"), iConfig)) |
|
670 { |
|
671 TPtrC keyName(_L("SetConfig")); |
|
672 ERR_PRINTF3(_L("Error in getting SetConfig flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
673 StopTest(KErrPathNotFound); |
|
674 return; |
|
675 } |
|
676 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
677 { |
|
678 TPtrC keyName(_L("UseFourCC")); |
|
679 ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
680 StopTest(KErrPathNotFound); |
|
681 return; |
|
682 } |
|
683 |
|
684 } |
|
685 |
|
686 // |
|
687 // RStepA3FDevSoundPlaySimple |
|
688 // |
|
689 |
|
690 /* |
|
691 * |
|
692 * RStepA3FDevSoundPlaySimple - Test step constructor |
|
693 * |
|
694 */ |
|
695 RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
696 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
697 { |
|
698 } |
|
699 |
|
700 /* |
|
701 * |
|
702 * RStepA3FDevSoundPlaySimple - Test step constructor |
|
703 * |
|
704 */ |
|
705 RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName) |
|
706 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName) |
|
707 { |
|
708 } |
|
709 |
|
710 /* |
|
711 * |
|
712 * NewL |
|
713 * |
|
714 */ |
|
715 RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
716 { |
|
717 RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName, aInputDataType); |
|
718 return self; |
|
719 |
|
720 } |
|
721 |
|
722 /* |
|
723 * |
|
724 * NewL |
|
725 * |
|
726 */ |
|
727 RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName) |
|
728 { |
|
729 RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName); |
|
730 return self; |
|
731 |
|
732 } |
|
733 |
|
734 // |
|
735 // RStepA3FDevSoundPlayEmpty |
|
736 // |
|
737 |
|
738 /* |
|
739 * |
|
740 * RStepA3FDevSoundPlayEmpty - Test step constructor |
|
741 * |
|
742 */ |
|
743 RStepA3FDevSoundPlayEmpty::RStepA3FDevSoundPlayEmpty(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
744 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
745 { |
|
746 } |
|
747 |
|
748 /* |
|
749 * |
|
750 * NewL |
|
751 * |
|
752 */ |
|
753 RStepA3FDevSoundPlayEmpty* RStepA3FDevSoundPlayEmpty::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
754 { |
|
755 RStepA3FDevSoundPlayEmpty* self = new (ELeave) RStepA3FDevSoundPlayEmpty(aTestName, aSectName, aInputDataType); |
|
756 return self; |
|
757 |
|
758 } |
|
759 |
|
760 /* |
|
761 * |
|
762 * Fsm |
|
763 * - Executes playing events of DevSound in sequence |
|
764 * |
|
765 */ |
|
766 void RStepA3FDevSoundPlayEmpty::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
767 { |
|
768 switch (iPlayState) |
|
769 { |
|
770 case EStatePlayStart: |
|
771 { |
|
772 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed)); |
|
773 if (aDevSoundEvent == EEventPlayStart) |
|
774 { |
|
775 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
776 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
777 TInt err; |
|
778 if(iUseFourCC) |
|
779 { |
|
780 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
781 } |
|
782 else |
|
783 { |
|
784 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
785 } |
|
786 if (err != KErrNone) |
|
787 { |
|
788 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
789 StopTest(err); |
|
790 break; |
|
791 } |
|
792 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
793 iPlayState = EStatePlayInitializing; |
|
794 } |
|
795 else |
|
796 { |
|
797 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
798 StopTest(aError, EFail); |
|
799 } |
|
800 break; |
|
801 } |
|
802 |
|
803 case EStatePlayInitializing: |
|
804 { |
|
805 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
806 { |
|
807 if(iConfig) |
|
808 { |
|
809 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
810 SetSampleRateAndChannelMode(); |
|
811 TMMFCapabilities capabilities; |
|
812 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
813 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
814 |
|
815 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
816 if (errConfig != KErrNone) |
|
817 { |
|
818 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
819 StopTest(errConfig); |
|
820 return; |
|
821 } |
|
822 } |
|
823 |
|
824 // Initialize audio device and starts the playing process |
|
825 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
826 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
827 if (errPlay != KErrNone) |
|
828 { |
|
829 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
830 StopTest(errPlay); |
|
831 break; |
|
832 } |
|
833 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
834 iPlayState = EStatePlaying; |
|
835 } |
|
836 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
837 { |
|
838 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
839 StopTest(aError); |
|
840 } |
|
841 else |
|
842 { |
|
843 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
844 StopTest(aError, EFail); |
|
845 } |
|
846 break; |
|
847 } |
|
848 |
|
849 case EStatePlaying: |
|
850 { |
|
851 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed)); |
|
852 if (aDevSoundEvent == EEventBTBF) |
|
853 { |
|
854 // Fill the buffer with audio data and play the data in the buffer |
|
855 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
856 TInt err = iFile.Read(buffer->Data()); |
|
857 if (err != KErrNone) |
|
858 { |
|
859 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
860 StopTest(err); |
|
861 break; |
|
862 } |
|
863 if (buffer->Data().Length() != buffer->RequestSize()) |
|
864 { |
|
865 iBuffer->SetLastBuffer(ETrue); |
|
866 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
867 // Playing empty data |
|
868 iMMFDevSound->PlayData(); |
|
869 |
|
870 } |
|
871 iBufferCount++; |
|
872 } |
|
873 else |
|
874 { |
|
875 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
876 StopTest(aError, EFail); |
|
877 } |
|
878 |
|
879 break; |
|
880 } |
|
881 |
|
882 default: |
|
883 { |
|
884 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
885 StopTest(KErrGeneral); |
|
886 } |
|
887 } |
|
888 |
|
889 } |
|
890 |
|
891 // |
|
892 // RStepA3FDevSoundPlayInvalidFourCC |
|
893 // |
|
894 |
|
895 /* |
|
896 * |
|
897 * RStepA3FDevSoundPlayInvalidFourCC - Test step constructor |
|
898 * |
|
899 */ |
|
900 RStepA3FDevSoundPlayInvalidFourCC::RStepA3FDevSoundPlayInvalidFourCC(const TDesC& aTestName, const TFourCC& aInputDataType) |
|
901 :RTestStepA3FDevSoundPlayBase(aTestName, aInputDataType) |
|
902 { |
|
903 } |
|
904 |
|
905 /* |
|
906 * |
|
907 * NewL |
|
908 * |
|
909 */ |
|
910 RStepA3FDevSoundPlayInvalidFourCC* RStepA3FDevSoundPlayInvalidFourCC::NewL(const TDesC& aTestName, const TFourCC& aInputDataType) |
|
911 { |
|
912 RStepA3FDevSoundPlayInvalidFourCC* self = new (ELeave) RStepA3FDevSoundPlayInvalidFourCC(aTestName, aInputDataType); |
|
913 return self; |
|
914 |
|
915 } |
|
916 |
|
917 /* |
|
918 * |
|
919 * KickoffTestL |
|
920 * - Starts the test |
|
921 * |
|
922 */ |
|
923 void RStepA3FDevSoundPlayInvalidFourCC::KickoffTestL() |
|
924 { |
|
925 // Create instance of CMMFDevSound |
|
926 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
927 iMMFDevSound = CMMFDevSound::NewL(); |
|
928 |
|
929 //Display the name of Codec being used |
|
930 DisplayCodecInfo(); |
|
931 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
932 |
|
933 } |
|
934 |
|
935 /* |
|
936 * |
|
937 * Fsm |
|
938 * - Executes playing events of DevSound in sequence |
|
939 * |
|
940 */ |
|
941 void RStepA3FDevSoundPlayInvalidFourCC::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
942 { |
|
943 switch (iPlayState) |
|
944 { |
|
945 case EStatePlayStart: |
|
946 { |
|
947 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInvalidFourCC"),EFsmIncorrectErrorPassed)); |
|
948 if (aDevSoundEvent == EEventPlayStart) |
|
949 { |
|
950 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
951 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
952 TInt err; |
|
953 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
954 if (err == KErrNotSupported) |
|
955 { |
|
956 INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err); |
|
957 StopTest(err, EPass); |
|
958 } |
|
959 else |
|
960 { |
|
961 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
962 INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported); |
|
963 StopTest(err, EFail); |
|
964 } |
|
965 } |
|
966 else |
|
967 { |
|
968 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
969 StopTest(aError, EFail); |
|
970 } |
|
971 break; |
|
972 } |
|
973 default: |
|
974 { |
|
975 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
976 StopTest(KErrGeneral); |
|
977 } |
|
978 } |
|
979 |
|
980 } |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 // |
|
986 // RStepA3FDevSoundInitializeWithHwDeviceUID |
|
987 // |
|
988 |
|
989 /* |
|
990 * |
|
991 * RStepA3FDevSoundInitializeWithHwDeviceUID - Test step constructor |
|
992 * |
|
993 */ |
|
994 RStepA3FDevSoundInitializeWithHwDeviceUID::RStepA3FDevSoundInitializeWithHwDeviceUID(const TDesC& aTestName) |
|
995 :RTestStepA3FDevSoundPlayBase(aTestName) |
|
996 { |
|
997 } |
|
998 |
|
999 /* |
|
1000 * |
|
1001 * NewL |
|
1002 * |
|
1003 */ |
|
1004 RStepA3FDevSoundInitializeWithHwDeviceUID* RStepA3FDevSoundInitializeWithHwDeviceUID::NewL(const TDesC& aTestName) |
|
1005 { |
|
1006 RStepA3FDevSoundInitializeWithHwDeviceUID* self = new (ELeave) RStepA3FDevSoundInitializeWithHwDeviceUID(aTestName); |
|
1007 return self; |
|
1008 |
|
1009 } |
|
1010 |
|
1011 /* |
|
1012 * |
|
1013 * KickoffTestL |
|
1014 * - Starts the test |
|
1015 * |
|
1016 */ |
|
1017 void RStepA3FDevSoundInitializeWithHwDeviceUID::KickoffTestL() |
|
1018 { |
|
1019 // Create instance of CMMFDevSound |
|
1020 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
1021 iMMFDevSound = CMMFDevSound::NewL(); |
|
1022 |
|
1023 //Display the name of Codec being used. |
|
1024 DisplayCodecInfo(); |
|
1025 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
1026 |
|
1027 } |
|
1028 |
|
1029 /* |
|
1030 * |
|
1031 * Fsm |
|
1032 * - Executes playing events of DevSound in sequence |
|
1033 * |
|
1034 */ |
|
1035 void RStepA3FDevSoundInitializeWithHwDeviceUID::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
1036 { |
|
1037 switch (iPlayState) |
|
1038 { |
|
1039 case EStatePlayStart: |
|
1040 { |
|
1041 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWithHwDeviceUID"),EFsmIncorrectErrorPassed)); |
|
1042 if (aDevSoundEvent == EEventPlayStart) |
|
1043 { |
|
1044 // Initializing DevSound object for playing mode to process audio data via HwDeviceUID |
|
1045 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL with KMmfUidHwDevicePCM16ToPCM16")); |
|
1046 TInt err; |
|
1047 TRAP(err, iMMFDevSound->InitializeL(*this, 0x101F9F00 , EMMFStatePlaying)); //KMmfUidHwDevicePCM16ToPCM16 |
|
1048 if (err == KErrNotSupported) |
|
1049 { |
|
1050 INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err); |
|
1051 StopTest(err, EPass); |
|
1052 } |
|
1053 else |
|
1054 { |
|
1055 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1056 INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported); |
|
1057 StopTest(err, EFail); |
|
1058 } |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1063 StopTest(aError, EFail); |
|
1064 } |
|
1065 break; |
|
1066 } |
|
1067 default: |
|
1068 { |
|
1069 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
1070 StopTest(KErrGeneral); |
|
1071 } |
|
1072 } |
|
1073 |
|
1074 } |
|
1075 |
|
1076 // |
|
1077 // RStepA3FDevSoundPlayInvalidConfig |
|
1078 // |
|
1079 |
|
1080 /* |
|
1081 * |
|
1082 * RStepA3FDevSoundPlayInvalidConfig - Test step constructor |
|
1083 * |
|
1084 */ |
|
1085 RStepA3FDevSoundPlayInvalidConfig::RStepA3FDevSoundPlayInvalidConfig(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1086 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
1087 { |
|
1088 } |
|
1089 |
|
1090 /* |
|
1091 * |
|
1092 * NewL |
|
1093 * |
|
1094 */ |
|
1095 RStepA3FDevSoundPlayInvalidConfig* RStepA3FDevSoundPlayInvalidConfig::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1096 { |
|
1097 RStepA3FDevSoundPlayInvalidConfig* self = new (ELeave) RStepA3FDevSoundPlayInvalidConfig(aTestName, aSectName, aInputDataType); |
|
1098 return self; |
|
1099 |
|
1100 } |
|
1101 |
|
1102 /* |
|
1103 * |
|
1104 * KickoffTestL |
|
1105 * - Starts the test |
|
1106 * |
|
1107 */ |
|
1108 void RStepA3FDevSoundPlayInvalidConfig::KickoffTestL() |
|
1109 { |
|
1110 // Create instance of CMMFDevSound |
|
1111 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
1112 iMMFDevSound = CMMFDevSound::NewL(); |
|
1113 |
|
1114 iInvalidConfig = ETrue; |
|
1115 //Display the name of Codec being used |
|
1116 DisplayCodecInfo(); |
|
1117 CheckConfigAndFourCCUsage(); |
|
1118 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
1119 |
|
1120 } |
|
1121 |
|
1122 /* |
|
1123 * |
|
1124 * PlayError |
|
1125 * |
|
1126 */ |
|
1127 void RStepA3FDevSoundPlayInvalidConfig::PlayError(TInt aError) |
|
1128 { |
|
1129 if ((iPlayState == EStatePlaying) && (aError == KErrArgument)) |
|
1130 { |
|
1131 INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError); |
|
1132 StopTest(aError, EPass); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 INFO_PRINTF1(_L("Expected error = -6")); |
|
1137 ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError); |
|
1138 StopTest(aError, EFail); |
|
1139 } |
|
1140 |
|
1141 } |
|
1142 |
|
1143 // |
|
1144 // RStepA3FDevSoundReadConfigDuringPlay |
|
1145 // |
|
1146 |
|
1147 /* |
|
1148 * |
|
1149 * RStepA3FDevSoundReadConfigDuringPlay - Test step constructor |
|
1150 * |
|
1151 */ |
|
1152 RStepA3FDevSoundReadConfigDuringPlay::RStepA3FDevSoundReadConfigDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1153 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
1154 { |
|
1155 } |
|
1156 |
|
1157 /* |
|
1158 * |
|
1159 * NewL |
|
1160 * |
|
1161 */ |
|
1162 RStepA3FDevSoundReadConfigDuringPlay* RStepA3FDevSoundReadConfigDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1163 { |
|
1164 RStepA3FDevSoundReadConfigDuringPlay* self = new (ELeave) RStepA3FDevSoundReadConfigDuringPlay(aTestName, aSectName, aInputDataType); |
|
1165 return self; |
|
1166 |
|
1167 } |
|
1168 |
|
1169 /* |
|
1170 * |
|
1171 * PlayError |
|
1172 * |
|
1173 */ |
|
1174 void RStepA3FDevSoundReadConfigDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
1175 { |
|
1176 if (!aBuffer) |
|
1177 { |
|
1178 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
1179 StopTest(KErrGeneral); |
|
1180 return; |
|
1181 } |
|
1182 |
|
1183 iBuffer = aBuffer; |
|
1184 |
|
1185 if (iPlayState == EStatePlaying) |
|
1186 { |
|
1187 TMMFCapabilities capabilities; |
|
1188 capabilities = iMMFDevSound->Config(); |
|
1189 INFO_PRINTF1(_L("Config values during Play: ")); |
|
1190 if (capabilities.iRate == ConvertDesToTMMFSampleRate(iSampleRate) && capabilities.iChannels == ConvertDesToTMMFMonoStereo(iMonoStereo)) |
|
1191 { |
|
1192 INFO_PRINTF1(_L("Config values before and during playback are same.")); |
|
1193 StopTest(KErrNone); |
|
1194 } |
|
1195 else |
|
1196 { |
|
1197 ERR_PRINTF1(_L("Config values before and during playback are different.")); |
|
1198 StopTest(KErrGeneral); |
|
1199 } |
|
1200 } |
|
1201 |
|
1202 } |
|
1203 |
|
1204 // |
|
1205 // RStepA3FDevSoundSetVolPlayStopGetVol |
|
1206 // |
|
1207 |
|
1208 /* |
|
1209 * |
|
1210 * RStepA3FDevSoundSetVolPlayStopGetVol - Test step constructor |
|
1211 * |
|
1212 */ |
|
1213 RStepA3FDevSoundSetVolPlayStopGetVol::RStepA3FDevSoundSetVolPlayStopGetVol(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1214 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
1215 iSetVolume(0), |
|
1216 iVolDuringStopped(0), |
|
1217 iCheckTimer(ETrue) |
|
1218 { |
|
1219 } |
|
1220 |
|
1221 /* |
|
1222 * |
|
1223 * NewL |
|
1224 * |
|
1225 */ |
|
1226 RStepA3FDevSoundSetVolPlayStopGetVol* RStepA3FDevSoundSetVolPlayStopGetVol::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1227 { |
|
1228 RStepA3FDevSoundSetVolPlayStopGetVol* self = new (ELeave) RStepA3FDevSoundSetVolPlayStopGetVol(aTestName, aSectName, aInputDataType); |
|
1229 return self; |
|
1230 |
|
1231 } |
|
1232 |
|
1233 /* |
|
1234 * |
|
1235 * DoKickoffTestL |
|
1236 * |
|
1237 */ |
|
1238 void RStepA3FDevSoundSetVolPlayStopGetVol::DoKickoffTestL() |
|
1239 { |
|
1240 INFO_PRINTF2(_L("File to be played -> %S"), &iFilename); |
|
1241 DisplayCodecInfo(); |
|
1242 CheckConfigAndFourCCUsage(); |
|
1243 |
|
1244 TBool vol = GetIntFromConfig(iSectName,_L("Setvolume"),iSetVolume); |
|
1245 if (vol) |
|
1246 { |
|
1247 INFO_PRINTF2(_L("SetVolume = %d"), iSetVolume ); |
|
1248 } |
|
1249 else |
|
1250 { |
|
1251 TPtrC keyName(_L("Setvolume")); |
|
1252 ERR_PRINTF3(_L("Error in getting volume to be set from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
1253 StopTest(KErrPathNotFound); |
|
1254 return; |
|
1255 } |
|
1256 |
|
1257 } |
|
1258 |
|
1259 /* |
|
1260 * |
|
1261 * Fsm |
|
1262 * - Executes playing events of DevSound in sequence |
|
1263 * |
|
1264 */ |
|
1265 void RStepA3FDevSoundSetVolPlayStopGetVol::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
1266 { |
|
1267 switch (iPlayState) |
|
1268 { |
|
1269 case EStatePlayStart: |
|
1270 { |
|
1271 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed)); |
|
1272 if (aDevSoundEvent == EEventPlayStart) |
|
1273 { |
|
1274 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
1275 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1276 TInt err; |
|
1277 if(iUseFourCC) |
|
1278 { |
|
1279 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
1284 } |
|
1285 if (err != KErrNone) |
|
1286 { |
|
1287 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1288 StopTest(err); |
|
1289 break; |
|
1290 } |
|
1291 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
1292 iPlayState = EStatePlayInitializing; |
|
1293 } |
|
1294 else |
|
1295 { |
|
1296 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1297 StopTest(aError, EFail); |
|
1298 } |
|
1299 break; |
|
1300 } |
|
1301 |
|
1302 case EStatePlayInitializing: |
|
1303 { |
|
1304 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
1305 { |
|
1306 if(iConfig) |
|
1307 { |
|
1308 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
1309 SetSampleRateAndChannelMode(); |
|
1310 TMMFCapabilities capabilities; |
|
1311 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
1312 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
1313 |
|
1314 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
1315 if (errConfig != KErrNone) |
|
1316 { |
|
1317 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
1318 StopTest(errConfig); |
|
1319 break; |
|
1320 } |
|
1321 } |
|
1322 // Setting Volume Before Playback |
|
1323 iMMFDevSound->SetVolume(iSetVolume); |
|
1324 INFO_PRINTF2(_L("Volume before playback = %d"), iSetVolume); |
|
1325 // Initialize audio device and starts the playing process |
|
1326 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
1327 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
1328 if (errPlay != KErrNone) |
|
1329 { |
|
1330 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
1331 StopTest(errPlay); |
|
1332 break; |
|
1333 } |
|
1334 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
1335 iPlayState = EStatePlaying; |
|
1336 } |
|
1337 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
1338 { |
|
1339 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1340 StopTest(aError); |
|
1341 } |
|
1342 else |
|
1343 { |
|
1344 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
1345 StopTest(aError, EFail); |
|
1346 } |
|
1347 break; |
|
1348 } |
|
1349 |
|
1350 case EStatePlaying: |
|
1351 { |
|
1352 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed)); |
|
1353 if (aDevSoundEvent == EEventBTBF) |
|
1354 { |
|
1355 // Fill the buffer with audio data and play the data in the buffer |
|
1356 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
1357 TInt err = iFile.Read(buffer->Data()); |
|
1358 if (err != KErrNone) |
|
1359 { |
|
1360 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
1361 StopTest(err); |
|
1362 } |
|
1363 if (buffer->Data().Length() != buffer->RequestSize()) |
|
1364 { |
|
1365 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
1366 iBuffer->SetLastBuffer(ETrue); |
|
1367 } |
|
1368 |
|
1369 if (iCheckTimer) |
|
1370 { |
|
1371 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
1372 } |
|
1373 iCheckTimer = EFalse; |
|
1374 // Playing data in the buffer at the current volume |
|
1375 iMMFDevSound->PlayData(); |
|
1376 iBufferCount++; |
|
1377 } |
|
1378 else if (aDevSoundEvent == EEventPlayTimerComplete) |
|
1379 { |
|
1380 iMMFDevSound->Stop(); |
|
1381 iPlayState = EStatePlayStopped; |
|
1382 INFO_PRINTF1(_L("State: EStatePlayStopped")); |
|
1383 } |
|
1384 else |
|
1385 { |
|
1386 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
1387 StopTest(aError, EFail); |
|
1388 } |
|
1389 break; |
|
1390 } |
|
1391 |
|
1392 case EStatePlayStopped: |
|
1393 { |
|
1394 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed)); |
|
1395 if (aDevSoundEvent == EEventPlayStopped) |
|
1396 { |
|
1397 iVolDuringStopped = iMMFDevSound->Volume(); |
|
1398 INFO_PRINTF2(_L("Volume when play is stopped: %d"), iVolDuringStopped); |
|
1399 if (iVolDuringStopped == iSetVolume) |
|
1400 { |
|
1401 INFO_PRINTF1(_L("Volume set before the playback is same as volume during playback stopped")); |
|
1402 StopTest(KErrNone); |
|
1403 } |
|
1404 else |
|
1405 { |
|
1406 ERR_PRINTF1(_L("Volume set before the playback is not the same as volume during playback stopped")); |
|
1407 StopTest(KErrGeneral); |
|
1408 } |
|
1409 } |
|
1410 else |
|
1411 { |
|
1412 ERR_PRINTF1(_L("EStatePlayStopped event not received in EStatePlayStopped state")); |
|
1413 StopTest(KErrGeneral); |
|
1414 break; |
|
1415 } |
|
1416 } |
|
1417 break; |
|
1418 |
|
1419 default: |
|
1420 { |
|
1421 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
1422 StopTest(KErrGeneral); |
|
1423 } |
|
1424 } |
|
1425 |
|
1426 } |
|
1427 |
|
1428 /* |
|
1429 * |
|
1430 * DoTimerCallback |
|
1431 * |
|
1432 */ |
|
1433 void RStepA3FDevSoundSetVolPlayStopGetVol::DoTimerCallback() |
|
1434 { |
|
1435 iTimer->Cancel(); // only really wanted a one-shot |
|
1436 if(!iCheckTimer) |
|
1437 { |
|
1438 Fsm(EEventPlayTimerComplete, KErrNone); |
|
1439 Fsm(EEventPlayStopped, KErrNone); |
|
1440 } |
|
1441 |
|
1442 } |
|
1443 |
|
1444 // |
|
1445 // RStepA3FDevSoundFlushBuffersPaused |
|
1446 // |
|
1447 |
|
1448 /* |
|
1449 * |
|
1450 * RStepA3FDevSoundFlushBuffersPaused - Test step constructor |
|
1451 * |
|
1452 */ |
|
1453 RStepA3FDevSoundFlushBuffersPaused::RStepA3FDevSoundFlushBuffersPaused(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1454 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
1455 iCheckTimer(ETrue) |
|
1456 { |
|
1457 } |
|
1458 |
|
1459 /* |
|
1460 * |
|
1461 * NewL |
|
1462 * |
|
1463 */ |
|
1464 RStepA3FDevSoundFlushBuffersPaused* RStepA3FDevSoundFlushBuffersPaused::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1465 { |
|
1466 RStepA3FDevSoundFlushBuffersPaused* self = new (ELeave) RStepA3FDevSoundFlushBuffersPaused(aTestName, aSectName, aInputDataType); |
|
1467 return self; |
|
1468 |
|
1469 } |
|
1470 |
|
1471 /* |
|
1472 * |
|
1473 * Fsm |
|
1474 * - Executes playing events of DevSound in sequence |
|
1475 * |
|
1476 */ |
|
1477 void RStepA3FDevSoundFlushBuffersPaused::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
1478 { |
|
1479 switch (iPlayState) |
|
1480 { |
|
1481 case EStatePlayStart: |
|
1482 { |
|
1483 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed)); |
|
1484 if (aDevSoundEvent == EEventPlayStart) |
|
1485 { |
|
1486 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
1487 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1488 TInt err; |
|
1489 if(iUseFourCC) |
|
1490 { |
|
1491 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
1492 } |
|
1493 else |
|
1494 { |
|
1495 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
1496 } |
|
1497 if (err != KErrNone) |
|
1498 { |
|
1499 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1500 StopTest(err); |
|
1501 break; |
|
1502 } |
|
1503 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
1504 iPlayState = EStatePlayInitializing; |
|
1505 } |
|
1506 else |
|
1507 { |
|
1508 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1509 StopTest(aError, EFail); |
|
1510 } |
|
1511 break; |
|
1512 } |
|
1513 |
|
1514 case EStatePlayInitializing: |
|
1515 { |
|
1516 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
1517 { |
|
1518 if(iConfig) |
|
1519 { |
|
1520 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
1521 SetSampleRateAndChannelMode(); |
|
1522 TMMFCapabilities capabilities; |
|
1523 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
1524 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
1525 |
|
1526 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
1527 if (errConfig != KErrNone) |
|
1528 { |
|
1529 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
1530 StopTest(errConfig); |
|
1531 return; |
|
1532 } |
|
1533 } |
|
1534 // Initialize audio device and starts the playing process |
|
1535 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
1536 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
1537 if (errPlay != KErrNone) |
|
1538 { |
|
1539 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
1540 StopTest(errPlay); |
|
1541 break; |
|
1542 } |
|
1543 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
1544 iPlayState = EStatePlaying; |
|
1545 } |
|
1546 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
1547 { |
|
1548 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1549 StopTest(aError); |
|
1550 } |
|
1551 else |
|
1552 { |
|
1553 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
1554 StopTest(aError, EFail); |
|
1555 } |
|
1556 break; |
|
1557 } |
|
1558 |
|
1559 case EStatePlaying: |
|
1560 { |
|
1561 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed)); |
|
1562 if (aDevSoundEvent == EEventBTBF) |
|
1563 { |
|
1564 // Fill the buffer with audio data and play the data in the buffer |
|
1565 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
1566 TInt err = iFile.Read(buffer->Data()); |
|
1567 if (err != KErrNone) |
|
1568 { |
|
1569 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
1570 StopTest(err); |
|
1571 break; |
|
1572 } |
|
1573 if (buffer->Data().Length() != buffer->RequestSize()) |
|
1574 { |
|
1575 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
1576 iBuffer->SetLastBuffer(ETrue); |
|
1577 } |
|
1578 if (iCheckTimer) |
|
1579 { |
|
1580 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
1581 } |
|
1582 // Playing data in the buffer at the current volume |
|
1583 iMMFDevSound->PlayData(); |
|
1584 iBufferCount++; |
|
1585 iCheckTimer = EFalse; |
|
1586 } |
|
1587 else if (aDevSoundEvent == EEventPlayTimerComplete) |
|
1588 { |
|
1589 INFO_PRINTF1(_L("Calling CMMFDevSound::Pause()")); |
|
1590 iMMFDevSound->Pause(); |
|
1591 iPlayState = EStatePlayPaused; |
|
1592 INFO_PRINTF1(_L("State: EStatePlayPaused")); |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
1597 StopTest(aError, EFail); |
|
1598 } |
|
1599 |
|
1600 break; |
|
1601 } |
|
1602 |
|
1603 case EStatePlayPaused: |
|
1604 { |
|
1605 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed)); |
|
1606 TInt err; |
|
1607 if (aDevSoundEvent == EEventPlayPaused) |
|
1608 { |
|
1609 err = iMMFDevSound->EmptyBuffers(); |
|
1610 INFO_PRINTF2(_L("EmptyBuffers in paused state returned with %d"), err); |
|
1611 INFO_PRINTF2(_L("Expected to return with %d"), KErrNone); |
|
1612 StopTest(err); |
|
1613 } |
|
1614 break; |
|
1615 } |
|
1616 |
|
1617 default: |
|
1618 { |
|
1619 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
1620 StopTest(KErrGeneral); |
|
1621 } |
|
1622 } |
|
1623 |
|
1624 } |
|
1625 |
|
1626 /* |
|
1627 * |
|
1628 * BufferToBeFilled |
|
1629 * |
|
1630 */ |
|
1631 void RStepA3FDevSoundFlushBuffersPaused::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
1632 { |
|
1633 if (!aBuffer) |
|
1634 { |
|
1635 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
1636 StopTest(KErrGeneral); |
|
1637 return; |
|
1638 } |
|
1639 |
|
1640 iBuffer = aBuffer; |
|
1641 |
|
1642 if(iPlayState != EStatePlayPaused) |
|
1643 { |
|
1644 Fsm(EEventBTBF, KErrNone); |
|
1645 } |
|
1646 |
|
1647 } |
|
1648 |
|
1649 /* |
|
1650 * |
|
1651 * DoTimerCallback |
|
1652 * |
|
1653 */ |
|
1654 void RStepA3FDevSoundFlushBuffersPaused::DoTimerCallback() |
|
1655 { |
|
1656 iTimer->Cancel(); // only really wanted a one-shot |
|
1657 if(!iCheckTimer) |
|
1658 { |
|
1659 Fsm(EEventPlayTimerComplete, KErrNone); |
|
1660 Fsm(EEventPlayPaused, KErrNone); |
|
1661 } |
|
1662 else |
|
1663 { |
|
1664 StopTest(KErrGeneral); |
|
1665 } |
|
1666 |
|
1667 } |
|
1668 |
|
1669 // |
|
1670 // RStepA3FDevSoundInvalidStatePlay |
|
1671 // |
|
1672 |
|
1673 /* |
|
1674 * |
|
1675 * RStepA3FDevSoundInvalidStatePlay - Test step constructor |
|
1676 * |
|
1677 */ |
|
1678 RStepA3FDevSoundInvalidStatePlay::RStepA3FDevSoundInvalidStatePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1679 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
1680 { |
|
1681 } |
|
1682 |
|
1683 /* |
|
1684 * |
|
1685 * NewL |
|
1686 * |
|
1687 */ |
|
1688 RStepA3FDevSoundInvalidStatePlay* RStepA3FDevSoundInvalidStatePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1689 { |
|
1690 RStepA3FDevSoundInvalidStatePlay* self = new (ELeave) RStepA3FDevSoundInvalidStatePlay(aTestName, aSectName, aInputDataType); |
|
1691 return self; |
|
1692 |
|
1693 } |
|
1694 |
|
1695 /* |
|
1696 * |
|
1697 * KickoffTestL |
|
1698 * - Starts the test |
|
1699 * |
|
1700 */ |
|
1701 void RStepA3FDevSoundInvalidStatePlay::KickoffTestL() |
|
1702 { |
|
1703 // Create instance of CMMFDevSound |
|
1704 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
1705 iMMFDevSound = CMMFDevSound::NewL(); |
|
1706 |
|
1707 //Display the name of Codec being used |
|
1708 DisplayCodecInfo(); |
|
1709 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
1710 { |
|
1711 TPtrC keyName(_L("UseFourCC")); |
|
1712 ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
1713 StopTest(KErrPathNotFound); |
|
1714 return; |
|
1715 } |
|
1716 |
|
1717 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
1718 |
|
1719 } |
|
1720 |
|
1721 /* |
|
1722 * |
|
1723 * Fsm |
|
1724 * - Executes playing events of DevSound in sequence |
|
1725 * |
|
1726 */ |
|
1727 void RStepA3FDevSoundInvalidStatePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
1728 { |
|
1729 switch (iPlayState) |
|
1730 { |
|
1731 case EStatePlayStart: |
|
1732 { |
|
1733 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInvalidStatePlay"),EFsmIncorrectErrorPassed)); |
|
1734 if (aDevSoundEvent == EEventPlayStart) |
|
1735 { |
|
1736 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
1737 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1738 TInt err; |
|
1739 INFO_PRINTF1(_L("Initializing DevSound in EMMFStateRecording")); |
|
1740 if(iUseFourCC) |
|
1741 { |
|
1742 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateRecording)); |
|
1743 } |
|
1744 else |
|
1745 { |
|
1746 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording)); |
|
1747 } |
|
1748 if (err != KErrNone) |
|
1749 { |
|
1750 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1751 StopTest(err, EFail); |
|
1752 break; |
|
1753 } |
|
1754 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
1755 iPlayState = EStatePlayInitializing; |
|
1756 } |
|
1757 else |
|
1758 { |
|
1759 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1760 StopTest(aError, EFail); |
|
1761 } |
|
1762 break; |
|
1763 } |
|
1764 |
|
1765 case EStatePlayInitializing: |
|
1766 { |
|
1767 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
1768 { |
|
1769 // Initialize audio device and start the playing process |
|
1770 // Calling CMMFDevSound::PlayInitL() when DevSound initialized for record mode! |
|
1771 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
1772 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
1773 if (errPlay == KErrNotReady) |
|
1774 { |
|
1775 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left as expected with error = %d"), errPlay); |
|
1776 StopTest(errPlay,EPass); |
|
1777 } |
|
1778 else |
|
1779 { |
|
1780 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL did NOT leave with KErrNotReady as expected. Error = %d"), errPlay); |
|
1781 StopTest(KErrUnknown); |
|
1782 } |
|
1783 } |
|
1784 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
1785 { |
|
1786 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1787 StopTest(aError); |
|
1788 } |
|
1789 else |
|
1790 { |
|
1791 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
1792 StopTest(aError, EFail); |
|
1793 } |
|
1794 |
|
1795 break; |
|
1796 |
|
1797 } |
|
1798 default: |
|
1799 { |
|
1800 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
1801 StopTest(KErrGeneral); |
|
1802 } |
|
1803 } |
|
1804 |
|
1805 } |
|
1806 |
|
1807 /* |
|
1808 * |
|
1809 * BufferToBeFilled |
|
1810 * |
|
1811 */ |
|
1812 void RStepA3FDevSoundInvalidStatePlay::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
1813 { |
|
1814 if (!aBuffer) |
|
1815 { |
|
1816 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
1817 StopTest(KErrGeneral); |
|
1818 return; |
|
1819 } |
|
1820 |
|
1821 iBuffer = aBuffer; |
|
1822 |
|
1823 // Call to continue the Play process |
|
1824 Fsm(EEventBTBF,KErrNone); |
|
1825 |
|
1826 } |
|
1827 |
|
1828 /* |
|
1829 * |
|
1830 * PlayError |
|
1831 * |
|
1832 */ |
|
1833 void RStepA3FDevSoundInvalidStatePlay::PlayError(TInt aError) |
|
1834 { |
|
1835 if ((iPlayState == EStatePlaying) && (aError == KErrNotSupported)) |
|
1836 { |
|
1837 INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError); |
|
1838 StopTest(aError, EPass); |
|
1839 } |
|
1840 else |
|
1841 { |
|
1842 INFO_PRINTF1(_L("Expected error = -5")); |
|
1843 ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError); |
|
1844 StopTest(aError, EFail); |
|
1845 } |
|
1846 |
|
1847 } |
|
1848 |
|
1849 // |
|
1850 // RStepA3FDevSoundFlushBuffersPlaying |
|
1851 // |
|
1852 |
|
1853 /* |
|
1854 * |
|
1855 * RStepA3FDevSoundFlushBuffersPlaying - Test step constructor |
|
1856 * |
|
1857 */ |
|
1858 RStepA3FDevSoundFlushBuffersPlaying::RStepA3FDevSoundFlushBuffersPlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1859 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
1860 { |
|
1861 } |
|
1862 |
|
1863 /* |
|
1864 * |
|
1865 * NewL |
|
1866 * |
|
1867 */ |
|
1868 RStepA3FDevSoundFlushBuffersPlaying* RStepA3FDevSoundFlushBuffersPlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
1869 { |
|
1870 RStepA3FDevSoundFlushBuffersPlaying* self = new (ELeave) RStepA3FDevSoundFlushBuffersPlaying(aTestName, aSectName, aInputDataType); |
|
1871 return self; |
|
1872 |
|
1873 } |
|
1874 |
|
1875 /* |
|
1876 * |
|
1877 * Fsm |
|
1878 * - Executes playing events of DevSound in sequence |
|
1879 * |
|
1880 */ |
|
1881 void RStepA3FDevSoundFlushBuffersPlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
1882 { |
|
1883 switch (iPlayState) |
|
1884 { |
|
1885 case EStatePlayStart: |
|
1886 { |
|
1887 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed)); |
|
1888 if (aDevSoundEvent == EEventPlayStart) |
|
1889 { |
|
1890 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
1891 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
1892 TInt err; |
|
1893 if(iUseFourCC) |
|
1894 { |
|
1895 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
1896 } |
|
1897 else |
|
1898 { |
|
1899 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
1900 } |
|
1901 if (err != KErrNone) |
|
1902 { |
|
1903 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
1904 StopTest(err); |
|
1905 break; |
|
1906 } |
|
1907 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
1908 iPlayState = EStatePlayInitializing; |
|
1909 } |
|
1910 else |
|
1911 { |
|
1912 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
1913 StopTest(aError, EFail); |
|
1914 } |
|
1915 break; |
|
1916 } |
|
1917 |
|
1918 case EStatePlayInitializing: |
|
1919 { |
|
1920 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
1921 { |
|
1922 if(iConfig) |
|
1923 { |
|
1924 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
1925 SetSampleRateAndChannelMode(); |
|
1926 TMMFCapabilities capabilities; |
|
1927 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
1928 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
1929 |
|
1930 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
1931 if (errConfig != KErrNone) |
|
1932 { |
|
1933 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
1934 StopTest(errConfig); |
|
1935 break; |
|
1936 } |
|
1937 } |
|
1938 // Initialize audio device and starts the playing process |
|
1939 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
1940 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
1941 if (errPlay != KErrNone) |
|
1942 { |
|
1943 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
1944 StopTest(errPlay); |
|
1945 break; |
|
1946 } |
|
1947 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
1948 iPlayState = EStatePlaying; |
|
1949 } |
|
1950 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
1951 { |
|
1952 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
1953 StopTest(aError); |
|
1954 } |
|
1955 else |
|
1956 { |
|
1957 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
1958 StopTest(aError, EFail); |
|
1959 } |
|
1960 break; |
|
1961 } |
|
1962 |
|
1963 case EStatePlaying: |
|
1964 { |
|
1965 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed)); |
|
1966 if (aDevSoundEvent == EEventBTBF) |
|
1967 { |
|
1968 // Fill the buffer with audio data and play the data in the buffer |
|
1969 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
1970 TInt err = iFile.Read(buffer->Data()); |
|
1971 if (err != KErrNone) |
|
1972 { |
|
1973 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
1974 StopTest(err); |
|
1975 break; |
|
1976 } |
|
1977 if (buffer->Data().Length() != buffer->RequestSize()) |
|
1978 { |
|
1979 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
1980 iBuffer->SetLastBuffer(ETrue); |
|
1981 } |
|
1982 |
|
1983 INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers() during playing")); |
|
1984 err = iMMFDevSound->EmptyBuffers(); |
|
1985 INFO_PRINTF2(_L("CMMFDevSound::EmptyBuffers() left with error = %d"), err); |
|
1986 if(err == KErrNone) |
|
1987 { |
|
1988 StopTest(err, EPass); |
|
1989 } |
|
1990 else |
|
1991 { |
|
1992 StopTest(err, EFail); |
|
1993 } |
|
1994 } |
|
1995 else |
|
1996 { |
|
1997 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
1998 StopTest(aError, EFail); |
|
1999 } |
|
2000 break; |
|
2001 } |
|
2002 |
|
2003 default: |
|
2004 { |
|
2005 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
2006 StopTest(KErrGeneral); |
|
2007 } |
|
2008 } |
|
2009 |
|
2010 } |
|
2011 |
|
2012 // |
|
2013 // RStepA3FDevSoundInitializeWhilePlaying |
|
2014 // |
|
2015 |
|
2016 /* |
|
2017 * |
|
2018 * RStepA3FDevSoundInitializeWhilePlaying - Test step constructor |
|
2019 * |
|
2020 */ |
|
2021 RStepA3FDevSoundInitializeWhilePlaying::RStepA3FDevSoundInitializeWhilePlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2022 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2023 iCheckTimer(ETrue) |
|
2024 { |
|
2025 } |
|
2026 |
|
2027 /* |
|
2028 * |
|
2029 * NewL |
|
2030 * |
|
2031 */ |
|
2032 RStepA3FDevSoundInitializeWhilePlaying* RStepA3FDevSoundInitializeWhilePlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2033 { |
|
2034 RStepA3FDevSoundInitializeWhilePlaying* self = new (ELeave) RStepA3FDevSoundInitializeWhilePlaying(aTestName, aSectName, aInputDataType); |
|
2035 return self; |
|
2036 |
|
2037 } |
|
2038 |
|
2039 /* |
|
2040 * |
|
2041 * Fsm |
|
2042 * - Executes playing events of DevSound in sequence |
|
2043 * |
|
2044 */ |
|
2045 void RStepA3FDevSoundInitializeWhilePlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
2046 { |
|
2047 switch (iPlayState) |
|
2048 { |
|
2049 case EStatePlayStart: |
|
2050 { |
|
2051 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed)); |
|
2052 if (aDevSoundEvent == EEventPlayStart) |
|
2053 { |
|
2054 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
2055 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
2056 TInt err; |
|
2057 if(iUseFourCC) |
|
2058 { |
|
2059 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2060 } |
|
2061 else |
|
2062 { |
|
2063 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
2064 } |
|
2065 if (err != KErrNone) |
|
2066 { |
|
2067 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
2068 StopTest(err); |
|
2069 break; |
|
2070 } |
|
2071 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
2072 iPlayState = EStatePlayInitializing; |
|
2073 } |
|
2074 else |
|
2075 { |
|
2076 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
2077 StopTest(aError, EFail); |
|
2078 } |
|
2079 break; |
|
2080 } |
|
2081 |
|
2082 case EStatePlayInitializing: |
|
2083 { |
|
2084 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
2085 { |
|
2086 if(iConfig) |
|
2087 { |
|
2088 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
2089 SetSampleRateAndChannelMode(); |
|
2090 TMMFCapabilities capabilities; |
|
2091 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
2092 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
2093 |
|
2094 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
2095 if (errConfig != KErrNone) |
|
2096 { |
|
2097 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
2098 StopTest(errConfig); |
|
2099 break; |
|
2100 } |
|
2101 } |
|
2102 // Initialize audio device and starts the playing process |
|
2103 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
2104 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
2105 if (errPlay != KErrNone) |
|
2106 { |
|
2107 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
2108 StopTest(errPlay); |
|
2109 break; |
|
2110 } |
|
2111 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
2112 iPlayState = EStatePlaying; |
|
2113 } |
|
2114 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
2115 { |
|
2116 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
2117 StopTest(aError); |
|
2118 } |
|
2119 else |
|
2120 { |
|
2121 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
2122 StopTest(aError, EFail); |
|
2123 } |
|
2124 break; |
|
2125 } |
|
2126 |
|
2127 case EStatePlaying: |
|
2128 { |
|
2129 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed)); |
|
2130 if (aDevSoundEvent == EEventBTBF) |
|
2131 { |
|
2132 // Fill the buffer with audio data and play the data in the buffer |
|
2133 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
2134 TInt err = iFile.Read(buffer->Data()); |
|
2135 if (err != KErrNone) |
|
2136 { |
|
2137 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
2138 StopTest(err); |
|
2139 break; |
|
2140 } |
|
2141 if (buffer->Data().Length() != buffer->RequestSize()) |
|
2142 { |
|
2143 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
2144 iBuffer->SetLastBuffer(ETrue); |
|
2145 } |
|
2146 |
|
2147 if (iCheckTimer) |
|
2148 { |
|
2149 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
2150 } |
|
2151 iCheckTimer = EFalse; |
|
2152 } |
|
2153 else |
|
2154 { |
|
2155 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
2156 StopTest(aError, EFail); |
|
2157 } |
|
2158 break; |
|
2159 } |
|
2160 |
|
2161 default: |
|
2162 { |
|
2163 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
2164 StopTest(KErrGeneral); |
|
2165 } |
|
2166 } |
|
2167 |
|
2168 } |
|
2169 |
|
2170 /* |
|
2171 * |
|
2172 * DoTimerCallback |
|
2173 * |
|
2174 */ |
|
2175 void RStepA3FDevSoundInitializeWhilePlaying::DoTimerCallback() |
|
2176 { |
|
2177 iTimer->Cancel(); // only really wanted a one-shot |
|
2178 if(!iCheckTimer) |
|
2179 { |
|
2180 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL() during playing")); |
|
2181 TRAPD(errInit, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2182 INFO_PRINTF2(_L("CMMFDevSound::InitializeL() left with error = %d"), errInit); |
|
2183 INFO_PRINTF2(_L("Expected error = %d"), KErrNotReady); |
|
2184 if(errInit == KErrNotReady) |
|
2185 { |
|
2186 StopTest(errInit, EPass); |
|
2187 } |
|
2188 else |
|
2189 { |
|
2190 StopTest(errInit, EFail); |
|
2191 } |
|
2192 } |
|
2193 |
|
2194 } |
|
2195 |
|
2196 // |
|
2197 // RStepA3FDevSoundSetBalanceDuringPlay |
|
2198 // |
|
2199 |
|
2200 /* |
|
2201 * |
|
2202 * RStepA3FDevSoundSetBalanceDuringPlay - Test step constructor |
|
2203 * |
|
2204 */ |
|
2205 RStepA3FDevSoundSetBalanceDuringPlay::RStepA3FDevSoundSetBalanceDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2206 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2207 iPlaybalanceLeft(0), |
|
2208 iPlaybalanceRight(0) |
|
2209 { |
|
2210 } |
|
2211 |
|
2212 /* |
|
2213 * |
|
2214 * NewL |
|
2215 * |
|
2216 */ |
|
2217 RStepA3FDevSoundSetBalanceDuringPlay* RStepA3FDevSoundSetBalanceDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2218 { |
|
2219 RStepA3FDevSoundSetBalanceDuringPlay* self = new (ELeave) RStepA3FDevSoundSetBalanceDuringPlay(aTestName, aSectName, aInputDataType); |
|
2220 return self; |
|
2221 |
|
2222 } |
|
2223 |
|
2224 /* |
|
2225 * |
|
2226 * DoKickoffTestL |
|
2227 * |
|
2228 */ |
|
2229 void RStepA3FDevSoundSetBalanceDuringPlay::DoKickoffTestL() |
|
2230 { |
|
2231 INFO_PRINTF2(_L("File to be played -> %S"), &iFilename); |
|
2232 DisplayCodecInfo(); |
|
2233 CheckConfigAndFourCCUsage(); |
|
2234 |
|
2235 TBool balance = GetIntFromConfig(iSectName,_L("PlaybalanceLeft"),iPlaybalanceLeft ); |
|
2236 if (balance) |
|
2237 { |
|
2238 // Getting the Left balance from Config file |
|
2239 INFO_PRINTF2(_L("Left Percentage Playbalance = %d"),iPlaybalanceLeft); |
|
2240 } |
|
2241 else |
|
2242 { |
|
2243 TPtrC keyName(_L("PlaybalanceLeft")); |
|
2244 ERR_PRINTF3(_L("Error in getting left pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2245 StopTest(KErrPathNotFound); |
|
2246 return; |
|
2247 } |
|
2248 balance = GetIntFromConfig(iSectName,_L("PlaybalanceRight"),iPlaybalanceRight ); |
|
2249 if (balance) |
|
2250 { |
|
2251 // Getting the Right balance from Config file |
|
2252 INFO_PRINTF2(_L("Right Percentage Playbalance = %d"),iPlaybalanceRight); |
|
2253 } |
|
2254 else |
|
2255 { |
|
2256 TPtrC keyName(_L("PlaybalanceRight")); |
|
2257 ERR_PRINTF3(_L("Error in getting right pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2258 StopTest(KErrPathNotFound); |
|
2259 return; |
|
2260 } |
|
2261 |
|
2262 } |
|
2263 |
|
2264 /* |
|
2265 * |
|
2266 * BufferToBeFilled |
|
2267 * |
|
2268 */ |
|
2269 void RStepA3FDevSoundSetBalanceDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
2270 { |
|
2271 if (!aBuffer) |
|
2272 { |
|
2273 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
2274 StopTest(KErrGeneral); |
|
2275 return; |
|
2276 } |
|
2277 |
|
2278 iBuffer = aBuffer; |
|
2279 |
|
2280 INFO_PRINTF3(_L("Setting left and right playbalance. left = %d right = %d"), iPlaybalanceLeft, iPlaybalanceRight ); |
|
2281 TRAPD(setErr, iMMFDevSound->SetPlayBalanceL(iPlaybalanceLeft, iPlaybalanceRight)); |
|
2282 if (setErr == KErrNone) |
|
2283 { |
|
2284 TInt getLeft = 0; |
|
2285 TInt getRight = 0; |
|
2286 INFO_PRINTF1(_L("Getting left and right playbalance")); |
|
2287 TRAPD(getErr, iMMFDevSound->GetPlayBalanceL(getLeft, getRight)); |
|
2288 INFO_PRINTF3(_L("Got left and right playbalance. left = %d right = %d"), getLeft, getRight); |
|
2289 if (getErr == KErrNone) |
|
2290 { |
|
2291 if ((getLeft == iPlaybalanceLeft) && (getRight == iPlaybalanceRight )) |
|
2292 { |
|
2293 INFO_PRINTF1(_L("Left and Right playbalanace values are same as the ones that were set")); |
|
2294 StopTest(getErr); |
|
2295 } |
|
2296 else |
|
2297 { |
|
2298 ERR_PRINTF1(_L("Let and right playbalanace values are not the same as the ones that were set")); |
|
2299 StopTest(KErrGeneral); |
|
2300 } |
|
2301 } |
|
2302 else |
|
2303 { |
|
2304 ERR_PRINTF1(_L("Error in getting left and right play balance.")); |
|
2305 StopTest(getErr); |
|
2306 } |
|
2307 } |
|
2308 else |
|
2309 { |
|
2310 ERR_PRINTF1(_L("Error in setting left and right play balance.")); |
|
2311 StopTest(setErr); |
|
2312 } |
|
2313 |
|
2314 } |
|
2315 |
|
2316 // |
|
2317 // RStepA3FDevSoundPlayStopMultipleTimes |
|
2318 // |
|
2319 |
|
2320 /* |
|
2321 * |
|
2322 * RStepA3FDevSoundPlayStopMultipleTimes - Test step constructor |
|
2323 * |
|
2324 */ |
|
2325 RStepA3FDevSoundPlayStopMultipleTimes::RStepA3FDevSoundPlayStopMultipleTimes(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2326 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2327 iRepeatCount(0), |
|
2328 iRepeatCounter(0), |
|
2329 iCheckTimer(ETrue) |
|
2330 { |
|
2331 } |
|
2332 |
|
2333 /* |
|
2334 * |
|
2335 * NewL |
|
2336 * |
|
2337 */ |
|
2338 RStepA3FDevSoundPlayStopMultipleTimes* RStepA3FDevSoundPlayStopMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2339 { |
|
2340 RStepA3FDevSoundPlayStopMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayStopMultipleTimes(aTestName, aSectName, aInputDataType); |
|
2341 return self; |
|
2342 |
|
2343 } |
|
2344 |
|
2345 /* |
|
2346 * |
|
2347 * DoKickoffTestL |
|
2348 * |
|
2349 */ |
|
2350 void RStepA3FDevSoundPlayStopMultipleTimes::DoKickoffTestL() |
|
2351 { |
|
2352 INFO_PRINTF2(_L("File to be played -> %S"), &iFilename); |
|
2353 DisplayCodecInfo(); |
|
2354 CheckConfigAndFourCCUsage(); |
|
2355 |
|
2356 TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount); |
|
2357 if (repeatCount) |
|
2358 { |
|
2359 INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount); |
|
2360 } |
|
2361 else |
|
2362 { |
|
2363 TPtrC keyName(_L("Repeat")); |
|
2364 ERR_PRINTF3(_L("Error in getting number of times to repeat stop from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2365 StopTest(KErrPathNotFound); |
|
2366 return; |
|
2367 } |
|
2368 |
|
2369 } |
|
2370 |
|
2371 /* |
|
2372 * |
|
2373 * Fsm |
|
2374 * - Executes playing events of DevSound in sequence |
|
2375 * |
|
2376 */ |
|
2377 void RStepA3FDevSoundPlayStopMultipleTimes::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
2378 { |
|
2379 switch (iPlayState) |
|
2380 { |
|
2381 case EStatePlayStart: |
|
2382 { |
|
2383 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed)); |
|
2384 if (aDevSoundEvent == EEventPlayStart) |
|
2385 { |
|
2386 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
2387 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
2388 TInt err; |
|
2389 if(iUseFourCC) |
|
2390 { |
|
2391 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2392 } |
|
2393 else |
|
2394 { |
|
2395 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
2396 } |
|
2397 if (err != KErrNone) |
|
2398 { |
|
2399 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
2400 StopTest(err); |
|
2401 break; |
|
2402 } |
|
2403 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
2404 iPlayState = EStatePlayInitializing; |
|
2405 } |
|
2406 else |
|
2407 { |
|
2408 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
2409 StopTest(aError, EFail); |
|
2410 } |
|
2411 break; |
|
2412 } |
|
2413 |
|
2414 case EStatePlayInitializing: |
|
2415 { |
|
2416 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
2417 { |
|
2418 if(iConfig) |
|
2419 { |
|
2420 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
2421 SetSampleRateAndChannelMode(); |
|
2422 TMMFCapabilities capabilities; |
|
2423 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
2424 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
2425 |
|
2426 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
2427 if (errConfig != KErrNone) |
|
2428 { |
|
2429 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
2430 StopTest(errConfig); |
|
2431 break; |
|
2432 } |
|
2433 } |
|
2434 // Initialize audio device and starts the playing process |
|
2435 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
2436 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
2437 if (errPlay != KErrNone) |
|
2438 { |
|
2439 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
2440 StopTest(errPlay); |
|
2441 break; |
|
2442 } |
|
2443 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
2444 iPlayState = EStatePlaying; |
|
2445 } |
|
2446 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
2447 { |
|
2448 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
2449 StopTest(aError); |
|
2450 } |
|
2451 else |
|
2452 { |
|
2453 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
2454 StopTest(aError, EFail); |
|
2455 } |
|
2456 break; |
|
2457 } |
|
2458 |
|
2459 case EStatePlaying: |
|
2460 { |
|
2461 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed)); |
|
2462 if (aDevSoundEvent == EEventBTBF) |
|
2463 { |
|
2464 // Fill the buffer with audio data and play the data in the buffer |
|
2465 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
2466 TInt err = iFile.Read(buffer->Data()); |
|
2467 if (err != KErrNone) |
|
2468 { |
|
2469 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
2470 StopTest(err); |
|
2471 break; |
|
2472 } |
|
2473 if (buffer->Data().Length() != buffer->RequestSize()) |
|
2474 { |
|
2475 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
2476 iBuffer->SetLastBuffer(ETrue); |
|
2477 } |
|
2478 |
|
2479 if ((iCheckTimer) && (iRepeatCounter < iRepeatCount)) |
|
2480 { |
|
2481 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
2482 } |
|
2483 iCheckTimer = EFalse; |
|
2484 // Playing data in the buffer at the current volume |
|
2485 iMMFDevSound->PlayData(); |
|
2486 iBufferCount++; |
|
2487 } |
|
2488 else if (aDevSoundEvent == EEventPlayTimerComplete) |
|
2489 { |
|
2490 while(iRepeatCounter <= iRepeatCount) |
|
2491 { |
|
2492 INFO_PRINTF1(_L("Calling iMMFDevSound->Stop()")); |
|
2493 iMMFDevSound->Stop(); |
|
2494 iRepeatCounter++; |
|
2495 INFO_PRINTF2(_L("Playback Stopped. Count = %d"), iRepeatCounter); |
|
2496 INFO_PRINTF1(_L("Changing the state to: EStatePlaying ")); |
|
2497 iPlayState = EStatePlayInitializing; |
|
2498 break; |
|
2499 } |
|
2500 } |
|
2501 else |
|
2502 { |
|
2503 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
2504 StopTest(aError, EFail); |
|
2505 } |
|
2506 break; |
|
2507 } |
|
2508 |
|
2509 default: |
|
2510 { |
|
2511 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
2512 StopTest(KErrGeneral); |
|
2513 } |
|
2514 } |
|
2515 } |
|
2516 |
|
2517 /* |
|
2518 * |
|
2519 * DoTimerCallback |
|
2520 * |
|
2521 */ |
|
2522 void RStepA3FDevSoundPlayStopMultipleTimes::DoTimerCallback() |
|
2523 { |
|
2524 iTimer->Cancel(); // only really wanted a one-shot |
|
2525 if(!iCheckTimer) |
|
2526 { |
|
2527 iCheckTimer = ETrue; |
|
2528 Fsm(EEventPlayTimerComplete, KErrNone); |
|
2529 if (iRepeatCounter <= iRepeatCount) |
|
2530 { |
|
2531 Fsm(EEventInitCompletePlay, KErrNone); |
|
2532 } |
|
2533 } |
|
2534 |
|
2535 } |
|
2536 |
|
2537 // |
|
2538 // RStepA3FDevSoundPlayEOFPlayMultipleTimes |
|
2539 // |
|
2540 |
|
2541 /* |
|
2542 * |
|
2543 * RStepA3FDevSoundPlayEOFPlayMultipleTimes - Test step constructor |
|
2544 * |
|
2545 */ |
|
2546 RStepA3FDevSoundPlayEOFPlayMultipleTimes::RStepA3FDevSoundPlayEOFPlayMultipleTimes(const TDesC& aTestName, const TDesC& aSectName) |
|
2547 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName), |
|
2548 iRepeatCount(0), |
|
2549 iRepeatCounter(1) |
|
2550 { |
|
2551 } |
|
2552 |
|
2553 /* |
|
2554 * |
|
2555 * NewL |
|
2556 * |
|
2557 */ |
|
2558 RStepA3FDevSoundPlayEOFPlayMultipleTimes* RStepA3FDevSoundPlayEOFPlayMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName) |
|
2559 { |
|
2560 RStepA3FDevSoundPlayEOFPlayMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayEOFPlayMultipleTimes(aTestName, aSectName); |
|
2561 return self; |
|
2562 |
|
2563 } |
|
2564 |
|
2565 /* |
|
2566 * |
|
2567 * DoKickoffTestL |
|
2568 * |
|
2569 */ |
|
2570 void RStepA3FDevSoundPlayEOFPlayMultipleTimes::DoKickoffTestL() |
|
2571 { |
|
2572 INFO_PRINTF2(_L("File to be played -> %S"), &iFilename); |
|
2573 DisplayCodecInfo(); |
|
2574 CheckConfigAndFourCCUsage(); |
|
2575 |
|
2576 TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount); |
|
2577 if (repeatCount) |
|
2578 { |
|
2579 INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount); |
|
2580 } |
|
2581 else |
|
2582 { |
|
2583 TPtrC keyName(_L("Repeat")); |
|
2584 ERR_PRINTF3(_L("Error in getting number of times to repeat playback from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2585 StopTest(KErrPathNotFound); |
|
2586 return; |
|
2587 } |
|
2588 |
|
2589 } |
|
2590 |
|
2591 /* |
|
2592 * |
|
2593 * PlayError |
|
2594 * |
|
2595 */ |
|
2596 void RStepA3FDevSoundPlayEOFPlayMultipleTimes::PlayError(TInt aError) |
|
2597 { |
|
2598 INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError); |
|
2599 if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow)) |
|
2600 { |
|
2601 INFO_PRINTF2(_L("Finished playing. Playback Count = %d"), iRepeatCounter); |
|
2602 if (iRepeatCounter < iRepeatCount) |
|
2603 { |
|
2604 iRepeatCounter++; |
|
2605 INFO_PRINTF1(_L("Starting to Play again")); |
|
2606 iFile.Close(); |
|
2607 TInt err = iFile.Open(iFs, iFilename, EFileRead); |
|
2608 if (err != KErrNone) |
|
2609 { |
|
2610 ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err); |
|
2611 StopTest(err); |
|
2612 } |
|
2613 iPlayState = EStatePlayInitializing; |
|
2614 Fsm(EEventInitCompletePlay, KErrNone); |
|
2615 } |
|
2616 else |
|
2617 { |
|
2618 INFO_PRINTF2(_L("Finished playing %d number of times."), iRepeatCounter); |
|
2619 StopTest(KErrNone); |
|
2620 } |
|
2621 } |
|
2622 else |
|
2623 { |
|
2624 StopTest(aError, EFail); |
|
2625 } |
|
2626 |
|
2627 } |
|
2628 |
|
2629 // |
|
2630 // RStepA3FDevSoundInititalizeDuringInitialize |
|
2631 // |
|
2632 |
|
2633 /* |
|
2634 * |
|
2635 * RStepA3FDevSoundInititalizeDuringInitialize - Test step constructor |
|
2636 * |
|
2637 */ |
|
2638 RStepA3FDevSoundInititalizeDuringInitialize::RStepA3FDevSoundInititalizeDuringInitialize(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2639 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2640 iSecondInitErr(0) |
|
2641 { |
|
2642 } |
|
2643 |
|
2644 /* |
|
2645 * |
|
2646 * NewL |
|
2647 * |
|
2648 */ |
|
2649 RStepA3FDevSoundInititalizeDuringInitialize* RStepA3FDevSoundInititalizeDuringInitialize::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2650 { |
|
2651 RStepA3FDevSoundInititalizeDuringInitialize* self = new (ELeave) RStepA3FDevSoundInititalizeDuringInitialize(aTestName, aSectName, aInputDataType); |
|
2652 return self; |
|
2653 |
|
2654 } |
|
2655 |
|
2656 /* |
|
2657 * |
|
2658 * KickoffTestL |
|
2659 * - Starts the test |
|
2660 * |
|
2661 */ |
|
2662 void RStepA3FDevSoundInititalizeDuringInitialize::KickoffTestL() |
|
2663 { |
|
2664 // Create instance of CMMFDevSound |
|
2665 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
2666 iMMFDevSound = CMMFDevSound::NewL(); |
|
2667 |
|
2668 //Display the name of Codec being used |
|
2669 DisplayCodecInfo(); |
|
2670 |
|
2671 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
2672 { |
|
2673 TPtrC keyName(_L("UseFourCC")); |
|
2674 ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2675 StopTest(KErrPathNotFound); |
|
2676 return; |
|
2677 } |
|
2678 |
|
2679 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
2680 |
|
2681 } |
|
2682 |
|
2683 /* |
|
2684 * |
|
2685 * Fsm |
|
2686 * - Executes playing events of DevSound in sequence |
|
2687 * |
|
2688 */ |
|
2689 void RStepA3FDevSoundInititalizeDuringInitialize::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
2690 { |
|
2691 switch (iPlayState) |
|
2692 { |
|
2693 case EStatePlayStart: |
|
2694 { |
|
2695 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInititalizeDuringInitialize"),EFsmIncorrectErrorPassed)); |
|
2696 if (aDevSoundEvent == EEventPlayStart) |
|
2697 { |
|
2698 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
2699 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
2700 TInt err; |
|
2701 if(iUseFourCC) |
|
2702 { |
|
2703 INFO_PRINTF1(_L("Calling first InitializeL()")); |
|
2704 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2705 if (err != KErrNone) |
|
2706 { |
|
2707 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
2708 StopTest(err); |
|
2709 break; |
|
2710 } |
|
2711 else |
|
2712 { |
|
2713 INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns.")); |
|
2714 TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2715 } |
|
2716 } |
|
2717 else |
|
2718 { |
|
2719 INFO_PRINTF1(_L("Calling first InitializeL()")); |
|
2720 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
2721 if (err != KErrNone) |
|
2722 { |
|
2723 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
2724 StopTest(err); |
|
2725 break; |
|
2726 } |
|
2727 else |
|
2728 { |
|
2729 INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns.")); |
|
2730 TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
2731 } |
|
2732 } |
|
2733 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
2734 iPlayState = EStatePlayInitializing; |
|
2735 } |
|
2736 else |
|
2737 { |
|
2738 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
2739 StopTest(aError, EFail); |
|
2740 } |
|
2741 break; |
|
2742 } |
|
2743 |
|
2744 default: |
|
2745 { |
|
2746 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
2747 StopTest(KErrGeneral); |
|
2748 } |
|
2749 } |
|
2750 |
|
2751 } |
|
2752 |
|
2753 /* |
|
2754 * |
|
2755 * InitializeComplete |
|
2756 * |
|
2757 */ |
|
2758 void RStepA3FDevSoundInititalizeDuringInitialize::InitializeComplete(TInt aError) |
|
2759 { |
|
2760 INFO_PRINTF2(_L("First Initialize returned with = %d"), aError); |
|
2761 INFO_PRINTF2(_L("Second Initialize left with = %d"), iSecondInitErr); |
|
2762 |
|
2763 if ((aError == KErrNone) && (iSecondInitErr == KErrNotReady)) |
|
2764 { |
|
2765 INFO_PRINTF1(_L("This is expected")); |
|
2766 StopTest(aError); |
|
2767 } |
|
2768 else |
|
2769 { |
|
2770 INFO_PRINTF2(_L("This is not expected. Second InitializeL should fail with %d"), KErrNotReady); |
|
2771 StopTest(aError, EFail); |
|
2772 } |
|
2773 |
|
2774 } |
|
2775 |
|
2776 // |
|
2777 // RStepA3FDevSoundPlayInitDuringPlayInit |
|
2778 // |
|
2779 |
|
2780 /* |
|
2781 * |
|
2782 * RStepA3FDevSoundPlayInitDuringPlayInit - Test step constructor |
|
2783 * |
|
2784 */ |
|
2785 RStepA3FDevSoundPlayInitDuringPlayInit::RStepA3FDevSoundPlayInitDuringPlayInit(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2786 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2787 iFirstPlayInitErr(0), |
|
2788 iSecondPlayInitErr(0) |
|
2789 { |
|
2790 } |
|
2791 |
|
2792 /* |
|
2793 * |
|
2794 * NewL |
|
2795 * |
|
2796 */ |
|
2797 RStepA3FDevSoundPlayInitDuringPlayInit* RStepA3FDevSoundPlayInitDuringPlayInit::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2798 { |
|
2799 RStepA3FDevSoundPlayInitDuringPlayInit* self = new (ELeave) RStepA3FDevSoundPlayInitDuringPlayInit(aTestName, aSectName, aInputDataType); |
|
2800 return self; |
|
2801 } |
|
2802 |
|
2803 /* |
|
2804 * |
|
2805 * KickoffTestL |
|
2806 * - Starts the test |
|
2807 * |
|
2808 */ |
|
2809 void RStepA3FDevSoundPlayInitDuringPlayInit::KickoffTestL() |
|
2810 { |
|
2811 // Create instance of CMMFDevSound |
|
2812 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
2813 iMMFDevSound = CMMFDevSound::NewL(); |
|
2814 |
|
2815 //Display the name of Codec being used |
|
2816 DisplayCodecInfo(); |
|
2817 CheckConfigAndFourCCUsage(); |
|
2818 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
2819 |
|
2820 } |
|
2821 |
|
2822 /* |
|
2823 * |
|
2824 * Fsm |
|
2825 * - Executes playing events of DevSound in sequence |
|
2826 * |
|
2827 */ |
|
2828 void RStepA3FDevSoundPlayInitDuringPlayInit::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
2829 { |
|
2830 switch (iPlayState) |
|
2831 { |
|
2832 case EStatePlayStart: |
|
2833 { |
|
2834 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInitDuringPlayInit"),EFsmIncorrectErrorPassed)); |
|
2835 if (aDevSoundEvent == EEventPlayStart) |
|
2836 { |
|
2837 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
2838 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
2839 TInt err; |
|
2840 if(iUseFourCC) |
|
2841 { |
|
2842 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
2843 } |
|
2844 else |
|
2845 { |
|
2846 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
2847 } |
|
2848 if (err != KErrNone) |
|
2849 { |
|
2850 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
2851 StopTest(err); |
|
2852 break; |
|
2853 } |
|
2854 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
2855 iPlayState = EStatePlayInitializing; |
|
2856 } |
|
2857 else |
|
2858 { |
|
2859 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
2860 StopTest(aError, EFail); |
|
2861 } |
|
2862 break; |
|
2863 } |
|
2864 |
|
2865 case EStatePlayInitializing: |
|
2866 { |
|
2867 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
2868 { |
|
2869 if(iConfig) |
|
2870 { |
|
2871 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
2872 SetSampleRateAndChannelMode(); |
|
2873 TMMFCapabilities capabilities; |
|
2874 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
2875 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
2876 |
|
2877 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
2878 if (errConfig != KErrNone) |
|
2879 { |
|
2880 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
2881 StopTest(errConfig); |
|
2882 break; |
|
2883 } |
|
2884 } |
|
2885 |
|
2886 // Initialize audio device and starts the playing process |
|
2887 INFO_PRINTF1(_L("Calling First CMMFDevSound::PlayInitL()")); |
|
2888 TRAPD(iFirstPlayInitErr, iMMFDevSound->PlayInitL()); |
|
2889 TRAP(iSecondPlayInitErr, iMMFDevSound->PlayInitL()); |
|
2890 if (iFirstPlayInitErr != KErrNone) |
|
2891 { |
|
2892 ERR_PRINTF2(_L("First CMMFDevSound::PlayInitL() left with error = %d"), iFirstPlayInitErr); |
|
2893 StopTest(iFirstPlayInitErr); |
|
2894 break; |
|
2895 } |
|
2896 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
2897 iPlayState = EStatePlaying; |
|
2898 } |
|
2899 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
2900 { |
|
2901 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
2902 StopTest(aError); |
|
2903 } |
|
2904 else |
|
2905 { |
|
2906 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
2907 StopTest(aError, EFail); |
|
2908 } |
|
2909 break; |
|
2910 } |
|
2911 |
|
2912 default: |
|
2913 { |
|
2914 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
2915 StopTest(KErrGeneral); |
|
2916 } |
|
2917 } |
|
2918 |
|
2919 } |
|
2920 |
|
2921 /* |
|
2922 * |
|
2923 * BufferToBeFilled |
|
2924 * |
|
2925 */ |
|
2926 void RStepA3FDevSoundPlayInitDuringPlayInit::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
2927 { |
|
2928 if (!aBuffer) |
|
2929 { |
|
2930 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
2931 StopTest(KErrGeneral); |
|
2932 return; |
|
2933 } |
|
2934 iBuffer = aBuffer; |
|
2935 |
|
2936 INFO_PRINTF2(_L("First PlayInit left with = %d"), iFirstPlayInitErr); |
|
2937 INFO_PRINTF2(_L("Second PlayInit left with = %d"), iSecondPlayInitErr); |
|
2938 |
|
2939 if ((iFirstPlayInitErr == KErrNone) && (iSecondPlayInitErr == KErrNotReady)) |
|
2940 { |
|
2941 INFO_PRINTF1(_L("This is expected")); |
|
2942 StopTest(KErrNone); |
|
2943 } |
|
2944 else |
|
2945 { |
|
2946 INFO_PRINTF2(_L("This is not expected. Second PlayInit should fail with %d"), KErrNotReady); |
|
2947 StopTest(iFirstPlayInitErr, EFail); |
|
2948 } |
|
2949 |
|
2950 } |
|
2951 |
|
2952 // |
|
2953 // RStepA3FDevSoundVolumeCrop |
|
2954 // |
|
2955 |
|
2956 /* |
|
2957 * |
|
2958 * RStepA3FDevSoundVolumeCrop - Test step constructor |
|
2959 * |
|
2960 */ |
|
2961 RStepA3FDevSoundVolumeCrop::RStepA3FDevSoundVolumeCrop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2962 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
2963 iIncreaseMaxVolume(0), |
|
2964 iMinVolume(0) |
|
2965 { |
|
2966 } |
|
2967 |
|
2968 /* |
|
2969 * |
|
2970 * NewL |
|
2971 * |
|
2972 */ |
|
2973 RStepA3FDevSoundVolumeCrop* RStepA3FDevSoundVolumeCrop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
2974 { |
|
2975 RStepA3FDevSoundVolumeCrop* self = new (ELeave) RStepA3FDevSoundVolumeCrop(aTestName, aSectName, aInputDataType); |
|
2976 return self; |
|
2977 |
|
2978 } |
|
2979 |
|
2980 /* |
|
2981 * |
|
2982 * KickoffTestL |
|
2983 * |
|
2984 */ |
|
2985 void RStepA3FDevSoundVolumeCrop::KickoffTestL() |
|
2986 { |
|
2987 //Create instance of CMMFDevSound |
|
2988 iMMFDevSound = CMMFDevSound::NewL(); |
|
2989 //Display the name of Codec being used |
|
2990 DisplayCodecInfo(); |
|
2991 |
|
2992 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
2993 { |
|
2994 TPtrC keyName(_L("UseFourCC")); |
|
2995 ERR_PRINTF3(_L("Error in getting UseFourCC flag from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
2996 StopTest(KErrPathNotFound); |
|
2997 return; |
|
2998 } |
|
2999 |
|
3000 TBool maxVol = GetIntFromConfig(iSectName,_L("IncreaseMaxVolume"),iIncreaseMaxVolume); |
|
3001 if (maxVol) |
|
3002 { |
|
3003 INFO_PRINTF2(_L("Volume to be added to the MaxVolume supported by device = %d"), iIncreaseMaxVolume); |
|
3004 } |
|
3005 else |
|
3006 { |
|
3007 TPtrC keyName(_L("IncreaseMaxVolume")); |
|
3008 ERR_PRINTF3(_L("Error in getting the volume to increase maxvolume by from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
3009 StopTest(KErrPathNotFound); |
|
3010 return; |
|
3011 } |
|
3012 |
|
3013 TBool minVol = GetIntFromConfig(iSectName,_L("SetMinVolume"),iMinVolume); |
|
3014 if (minVol) |
|
3015 { |
|
3016 INFO_PRINTF2(_L("Seting MinVolume value = %d"), iMinVolume); |
|
3017 } |
|
3018 else |
|
3019 { |
|
3020 TPtrC keyName(_L("SetMinVolume")); |
|
3021 ERR_PRINTF3(_L("Error in getting volume below zero from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
3022 return; |
|
3023 } |
|
3024 |
|
3025 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3026 |
|
3027 } |
|
3028 |
|
3029 /* |
|
3030 * |
|
3031 * Fsm |
|
3032 * - Executes playing events of DevSound in sequence |
|
3033 * |
|
3034 */ |
|
3035 void RStepA3FDevSoundVolumeCrop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3036 { |
|
3037 switch (iPlayState) |
|
3038 { |
|
3039 case EStatePlayStart: |
|
3040 { |
|
3041 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundVolumeCrop"),EFsmIncorrectErrorPassed)); |
|
3042 if (aDevSoundEvent == EEventPlayStart) |
|
3043 { |
|
3044 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3045 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3046 TInt err; |
|
3047 if(iUseFourCC) |
|
3048 { |
|
3049 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
3050 } |
|
3051 else |
|
3052 { |
|
3053 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
3054 } |
|
3055 if (err != KErrNone) |
|
3056 { |
|
3057 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3058 StopTest(err); |
|
3059 break; |
|
3060 } |
|
3061 else |
|
3062 { |
|
3063 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3064 TInt deviceMaxVol = iMMFDevSound->MaxVolume(); |
|
3065 INFO_PRINTF2(_L("Maximum volume supported by the device is %d"), deviceMaxVol); |
|
3066 INFO_PRINTF2(_L("Setting the volume beyond the maximum volume supported by the device: %d"), deviceMaxVol + iIncreaseMaxVolume); |
|
3067 iMMFDevSound->SetVolume(deviceMaxVol + iIncreaseMaxVolume); |
|
3068 INFO_PRINTF1(_L("Getting the volume set")); |
|
3069 TInt maxVolumeObtained = iMMFDevSound->Volume(); |
|
3070 INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), maxVolumeObtained); |
|
3071 if (maxVolumeObtained != deviceMaxVol) |
|
3072 { |
|
3073 ERR_PRINTF1(_L("Volume was not cropped to equal to maximum volume supported by device")); |
|
3074 StopTest(KErrGeneral); |
|
3075 } |
|
3076 else |
|
3077 { |
|
3078 INFO_PRINTF1(_L("Volume was cropped to equal to maximum volume supported by device")); |
|
3079 INFO_PRINTF2(_L("Setting volume to less than zero: %d"), iMinVolume); |
|
3080 iMMFDevSound->SetVolume(iMinVolume); |
|
3081 INFO_PRINTF1(_L("Getting the volume set")); |
|
3082 TInt minVolumeObtained = iMMFDevSound->Volume(); |
|
3083 INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), minVolumeObtained); |
|
3084 if (minVolumeObtained != KNULLVolume) |
|
3085 { |
|
3086 ERR_PRINTF1(_L("Volume was not cropped to equal to minimum volume supported by device")); |
|
3087 StopTest(KErrGeneral); |
|
3088 } |
|
3089 else |
|
3090 { |
|
3091 INFO_PRINTF1(_L("Volume was cropped to equal to minimum volume supported by device")); |
|
3092 StopTest(KErrNone); |
|
3093 } |
|
3094 } |
|
3095 } |
|
3096 } |
|
3097 else |
|
3098 { |
|
3099 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3100 StopTest(aError, EFail); |
|
3101 } |
|
3102 break; |
|
3103 } |
|
3104 default: |
|
3105 { |
|
3106 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3107 StopTest(KErrGeneral); |
|
3108 } |
|
3109 } |
|
3110 |
|
3111 } |
|
3112 |
|
3113 // |
|
3114 // RStepA3FDevSoundInitializeForConverting |
|
3115 // |
|
3116 |
|
3117 /* |
|
3118 * |
|
3119 * RStepA3FDevSoundInitializeForConverting - Test step constructor |
|
3120 * |
|
3121 */ |
|
3122 RStepA3FDevSoundInitializeForConverting::RStepA3FDevSoundInitializeForConverting(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3123 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
3124 { |
|
3125 } |
|
3126 |
|
3127 /* |
|
3128 * |
|
3129 * NewL |
|
3130 * |
|
3131 */ |
|
3132 RStepA3FDevSoundInitializeForConverting* RStepA3FDevSoundInitializeForConverting::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3133 { |
|
3134 RStepA3FDevSoundInitializeForConverting* self = new (ELeave) RStepA3FDevSoundInitializeForConverting(aTestName, aSectName, aInputDataType); |
|
3135 return self; |
|
3136 |
|
3137 } |
|
3138 |
|
3139 /* |
|
3140 * |
|
3141 * KickoffTestL |
|
3142 * - Starts the test |
|
3143 * |
|
3144 */ |
|
3145 void RStepA3FDevSoundInitializeForConverting::KickoffTestL() |
|
3146 { |
|
3147 // Create instance of CMMFDevSound |
|
3148 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3149 iMMFDevSound = CMMFDevSound::NewL(); |
|
3150 |
|
3151 //Display the name of Codec being used |
|
3152 DisplayCodecInfo(); |
|
3153 |
|
3154 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
3155 { |
|
3156 TPtrC keyName(_L("UseFourCC")); |
|
3157 ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
3158 StopTest(KErrPathNotFound); |
|
3159 return; |
|
3160 } |
|
3161 |
|
3162 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3163 |
|
3164 } |
|
3165 |
|
3166 /* |
|
3167 * |
|
3168 * Fsm |
|
3169 * - Executes playing events of DevSound in sequence |
|
3170 * |
|
3171 */ |
|
3172 void RStepA3FDevSoundInitializeForConverting::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3173 { |
|
3174 switch (iPlayState) |
|
3175 { |
|
3176 case EStatePlayStart: |
|
3177 { |
|
3178 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeForConverting"),EFsmIncorrectErrorPassed)); |
|
3179 if (aDevSoundEvent == EEventPlayStart) |
|
3180 { |
|
3181 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3182 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3183 TInt err; |
|
3184 if(iUseFourCC) |
|
3185 { |
|
3186 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateConverting)); |
|
3187 } |
|
3188 else |
|
3189 { |
|
3190 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateConverting)); |
|
3191 } |
|
3192 if (err == KErrNotSupported) |
|
3193 { |
|
3194 INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d for EMMFStateConverting"), err); |
|
3195 StopTest(err, EPass); |
|
3196 } |
|
3197 else |
|
3198 { |
|
3199 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d for EMMFStateConverting"), err); |
|
3200 StopTest(err, EFail); |
|
3201 } |
|
3202 } |
|
3203 else |
|
3204 { |
|
3205 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3206 StopTest(aError, EFail); |
|
3207 } |
|
3208 break; |
|
3209 } |
|
3210 } |
|
3211 |
|
3212 } |
|
3213 |
|
3214 // |
|
3215 // RStepA3FDevSoundGetSampleNumsAfterStop |
|
3216 // |
|
3217 |
|
3218 /* |
|
3219 * |
|
3220 * RStepA3FDevSoundGetSampleNumsAfterStop - Test step constructor |
|
3221 * |
|
3222 */ |
|
3223 RStepA3FDevSoundGetSampleNumsAfterStop::RStepA3FDevSoundGetSampleNumsAfterStop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3224 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType), |
|
3225 iCheckTimer(ETrue) |
|
3226 { |
|
3227 } |
|
3228 |
|
3229 /* |
|
3230 * |
|
3231 * NewL |
|
3232 * |
|
3233 */ |
|
3234 RStepA3FDevSoundGetSampleNumsAfterStop* RStepA3FDevSoundGetSampleNumsAfterStop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3235 { |
|
3236 RStepA3FDevSoundGetSampleNumsAfterStop* self = new (ELeave) RStepA3FDevSoundGetSampleNumsAfterStop(aTestName, aSectName, aInputDataType); |
|
3237 return self; |
|
3238 |
|
3239 } |
|
3240 |
|
3241 /* |
|
3242 * |
|
3243 * Fsm |
|
3244 * - Executes playing events of DevSound in sequence |
|
3245 * |
|
3246 */ |
|
3247 void RStepA3FDevSoundGetSampleNumsAfterStop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3248 { |
|
3249 switch (iPlayState) |
|
3250 { |
|
3251 case EStatePlayStart: |
|
3252 { |
|
3253 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed)); |
|
3254 if (aDevSoundEvent == EEventPlayStart) |
|
3255 { |
|
3256 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3257 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3258 TInt err; |
|
3259 if(iUseFourCC) |
|
3260 { |
|
3261 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
3262 } |
|
3263 else |
|
3264 { |
|
3265 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
3266 } |
|
3267 if (err != KErrNone) |
|
3268 { |
|
3269 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3270 StopTest(err); |
|
3271 break; |
|
3272 } |
|
3273 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
3274 iPlayState = EStatePlayInitializing; |
|
3275 } |
|
3276 else |
|
3277 { |
|
3278 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3279 StopTest(aError, EFail); |
|
3280 } |
|
3281 break; |
|
3282 } |
|
3283 |
|
3284 case EStatePlayInitializing: |
|
3285 { |
|
3286 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
3287 { |
|
3288 if(iConfig) |
|
3289 { |
|
3290 // Set Devsound capability settings using CMMFDevSound::SetConfigL |
|
3291 SetSampleRateAndChannelMode(); |
|
3292 TMMFCapabilities capabilities; |
|
3293 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
3294 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
3295 |
|
3296 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
3297 if (errConfig != KErrNone) |
|
3298 { |
|
3299 ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig); |
|
3300 StopTest(errConfig); |
|
3301 break; |
|
3302 } |
|
3303 } |
|
3304 // Initialize audio device and starts the playing process |
|
3305 INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()")); |
|
3306 TRAPD(errPlay, iMMFDevSound->PlayInitL()); |
|
3307 if (errPlay != KErrNone) |
|
3308 { |
|
3309 ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay); |
|
3310 StopTest(errPlay); |
|
3311 break; |
|
3312 } |
|
3313 INFO_PRINTF1(_L("State: EStatePlaying")); |
|
3314 iPlayState = EStatePlaying; |
|
3315 } |
|
3316 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
3317 { |
|
3318 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
3319 StopTest(aError); |
|
3320 } |
|
3321 else |
|
3322 { |
|
3323 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
3324 StopTest(aError, EFail); |
|
3325 } |
|
3326 |
|
3327 break; |
|
3328 |
|
3329 } |
|
3330 |
|
3331 case EStatePlaying: |
|
3332 { |
|
3333 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed)); |
|
3334 if (aDevSoundEvent == EEventBTBF) |
|
3335 { |
|
3336 // Fill the buffer with audio data and play the data in the buffer |
|
3337 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
3338 TInt err = iFile.Read(buffer->Data()); |
|
3339 if (err != KErrNone) |
|
3340 { |
|
3341 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err); |
|
3342 StopTest(err); |
|
3343 break; |
|
3344 } |
|
3345 if (buffer->Data().Length() != buffer->RequestSize()) |
|
3346 { |
|
3347 INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize()); |
|
3348 iBuffer->SetLastBuffer(ETrue); |
|
3349 } |
|
3350 |
|
3351 if (iCheckTimer) |
|
3352 { |
|
3353 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
3354 } |
|
3355 iCheckTimer = EFalse; |
|
3356 // Playing data in the buffer at the current volume |
|
3357 iMMFDevSound->PlayData(); |
|
3358 iBufferCount++; |
|
3359 } |
|
3360 else if (aDevSoundEvent == EEventPlayTimerComplete) |
|
3361 { |
|
3362 iMMFDevSound->Stop(); |
|
3363 iPlayState = EStatePlayStopped; |
|
3364 INFO_PRINTF1(_L("EStatePlayStopped")); |
|
3365 } |
|
3366 else |
|
3367 { |
|
3368 ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent); |
|
3369 StopTest(aError, EFail); |
|
3370 } |
|
3371 break; |
|
3372 } |
|
3373 |
|
3374 case EStatePlayStopped: |
|
3375 { |
|
3376 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed)); |
|
3377 if (aDevSoundEvent == EEventPlayStopped) |
|
3378 { |
|
3379 INFO_PRINTF1(_L("Getting SamplesPlayed after Stop")); |
|
3380 TInt numSamplesStop = iMMFDevSound->SamplesPlayed(); |
|
3381 INFO_PRINTF2(_L("SamplesPlayed after Stop: %d"), numSamplesStop); |
|
3382 if (numSamplesStop == KNULLSamples) |
|
3383 { |
|
3384 ERR_PRINTF2(_L("Number of samples played after stop should not be %d"), KNULLSamples ); |
|
3385 StopTest(KErrGeneral); |
|
3386 } |
|
3387 else |
|
3388 { |
|
3389 INFO_PRINTF2(_L("Number of samples played after stop is greater than %d"), KNULLSamples ); |
|
3390 StopTest(KErrNone); |
|
3391 } |
|
3392 } |
|
3393 else |
|
3394 { |
|
3395 ERR_PRINTF2(_L("Invalid DevSound event received: %d"), aDevSoundEvent); |
|
3396 StopTest(KErrGeneral); |
|
3397 } |
|
3398 } |
|
3399 break; |
|
3400 |
|
3401 default: |
|
3402 { |
|
3403 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3404 StopTest(KErrGeneral); |
|
3405 } |
|
3406 } |
|
3407 |
|
3408 } |
|
3409 |
|
3410 /* |
|
3411 * |
|
3412 * DoTimerCallback |
|
3413 * |
|
3414 */ |
|
3415 void RStepA3FDevSoundGetSampleNumsAfterStop::DoTimerCallback() |
|
3416 { |
|
3417 iTimer->Cancel(); // only really wanted a one-shot |
|
3418 if(!iCheckTimer) |
|
3419 { |
|
3420 Fsm(EEventPlayTimerComplete, KErrNone); |
|
3421 Fsm(EEventPlayStopped, KErrNone); |
|
3422 } |
|
3423 |
|
3424 } |
|
3425 |
|
3426 // |
|
3427 // RStepA3FDevSoundCancelInitializePlay |
|
3428 // |
|
3429 |
|
3430 /* |
|
3431 * |
|
3432 * RStepA3FDevSoundCancelInitializePlay - Test step constructor |
|
3433 * |
|
3434 */ |
|
3435 RStepA3FDevSoundCancelInitializePlay::RStepA3FDevSoundCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3436 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
3437 { |
|
3438 } |
|
3439 |
|
3440 /* |
|
3441 * |
|
3442 * NewL |
|
3443 * |
|
3444 */ |
|
3445 RStepA3FDevSoundCancelInitializePlay* RStepA3FDevSoundCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3446 { |
|
3447 RStepA3FDevSoundCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundCancelInitializePlay(aTestName, aSectName, aInputDataType); |
|
3448 return self; |
|
3449 |
|
3450 } |
|
3451 |
|
3452 /* |
|
3453 * |
|
3454 * KickoffTestL |
|
3455 * - Starts the test |
|
3456 * |
|
3457 */ |
|
3458 void RStepA3FDevSoundCancelInitializePlay::KickoffTestL() |
|
3459 { |
|
3460 // Create instance of CMMFDevSound |
|
3461 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3462 iMMFDevSound = CMMFDevSound::NewL(); |
|
3463 |
|
3464 iTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
3465 iCallBack = TCallBack(TimerCallback, this); |
|
3466 |
|
3467 //Display the name of Codec being used |
|
3468 DisplayCodecInfo(); |
|
3469 CheckConfigAndFourCCUsage(); |
|
3470 |
|
3471 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3472 |
|
3473 } |
|
3474 |
|
3475 /* |
|
3476 * |
|
3477 * InitializeComplete |
|
3478 * |
|
3479 */ |
|
3480 void RStepA3FDevSoundCancelInitializePlay::InitializeComplete(TInt aError) |
|
3481 { |
|
3482 INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour")); |
|
3483 INFO_PRINTF1(_L("InitializeL was not cancelled")); |
|
3484 StopTest(aError, EFail); |
|
3485 } |
|
3486 |
|
3487 /* |
|
3488 * |
|
3489 * DoTimerCallback |
|
3490 * |
|
3491 */ |
|
3492 void RStepA3FDevSoundCancelInitializePlay::DoTimerCallback() |
|
3493 { |
|
3494 iTimer->Cancel(); // only really wanted a one-shot |
|
3495 INFO_PRINTF1(_L("InitializeComplete callback was not received. This is the expected behaviour")); |
|
3496 INFO_PRINTF1(_L("Use SetConfigL to verify that DevSound has not been initialised")); |
|
3497 SetSampleRateAndChannelMode(); |
|
3498 TMMFCapabilities capabilities; |
|
3499 capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate); |
|
3500 capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo); |
|
3501 |
|
3502 TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities)); |
|
3503 if(errConfig == KErrNotReady) |
|
3504 { |
|
3505 INFO_PRINTF2(_L("SetConfigL returned with %d as expected"), errConfig); |
|
3506 INFO_PRINTF1(_L("InitializeL was cancelled successfully")); |
|
3507 StopTest(KErrNone); |
|
3508 } |
|
3509 else if (errConfig == KErrNone) |
|
3510 { |
|
3511 INFO_PRINTF2(_L("SetConfigL returned with KErrNone %d"), errConfig); |
|
3512 INFO_PRINTF1(_L("InitializeL was not cancelled successfully")); |
|
3513 StopTest(errConfig, EFail); |
|
3514 } |
|
3515 else |
|
3516 { |
|
3517 INFO_PRINTF2(_L("SetConfigL returned with unexpected error %d"), errConfig); |
|
3518 StopTest(errConfig, EFail); |
|
3519 } |
|
3520 } |
|
3521 |
|
3522 /* |
|
3523 * |
|
3524 * Fsm |
|
3525 * - Executes playing events of DevSound in sequence |
|
3526 * |
|
3527 */ |
|
3528 void RStepA3FDevSoundCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3529 { |
|
3530 switch (iPlayState) |
|
3531 { |
|
3532 case EStatePlayStart: |
|
3533 { |
|
3534 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed)); |
|
3535 if (aDevSoundEvent == EEventPlayStart) |
|
3536 { |
|
3537 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3538 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3539 TInt err; |
|
3540 if(iUseFourCC) |
|
3541 { |
|
3542 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
3543 } |
|
3544 else |
|
3545 { |
|
3546 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
3547 } |
|
3548 if (err != KErrNone) |
|
3549 { |
|
3550 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3551 StopTest(err); |
|
3552 break; |
|
3553 } |
|
3554 else |
|
3555 { |
|
3556 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
3557 iPlayState = EStatePlayInitializing; |
|
3558 INFO_PRINTF1(_L("Calling CMMFDevSound::CancelInitialize()")); |
|
3559 iMMFDevSound->CancelInitialize(); |
|
3560 } |
|
3561 INFO_PRINTF1(_L("Start timer to wait for InitializeComplete")); |
|
3562 iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack); |
|
3563 } |
|
3564 else |
|
3565 { |
|
3566 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3567 StopTest(aError, EFail); |
|
3568 } |
|
3569 break; |
|
3570 } |
|
3571 default: |
|
3572 { |
|
3573 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3574 StopTest(KErrGeneral); |
|
3575 } |
|
3576 } |
|
3577 |
|
3578 } |
|
3579 |
|
3580 // |
|
3581 // RStepA3FDevSoundNegCancelInitializePlay |
|
3582 // |
|
3583 |
|
3584 /* |
|
3585 * |
|
3586 * RStepA3FDevSoundNegCancelInitializePlay - Test step constructor |
|
3587 * |
|
3588 */ |
|
3589 RStepA3FDevSoundNegCancelInitializePlay::RStepA3FDevSoundNegCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3590 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
3591 { |
|
3592 } |
|
3593 |
|
3594 /* |
|
3595 * |
|
3596 * NewL |
|
3597 * |
|
3598 */ |
|
3599 RStepA3FDevSoundNegCancelInitializePlay* RStepA3FDevSoundNegCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3600 { |
|
3601 RStepA3FDevSoundNegCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundNegCancelInitializePlay(aTestName, aSectName, aInputDataType); |
|
3602 return self; |
|
3603 |
|
3604 } |
|
3605 |
|
3606 /* |
|
3607 * |
|
3608 * KickoffTestL |
|
3609 * - Starts the test |
|
3610 * |
|
3611 */ |
|
3612 void RStepA3FDevSoundNegCancelInitializePlay::KickoffTestL() |
|
3613 { |
|
3614 // Create instance of CMMFDevSound |
|
3615 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3616 iMMFDevSound = CMMFDevSound::NewL(); |
|
3617 |
|
3618 //Display the name of Codec being used |
|
3619 DisplayCodecInfo(); |
|
3620 if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC)) |
|
3621 { |
|
3622 TPtrC keyName(_L("UseFourCC")); |
|
3623 ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName); |
|
3624 StopTest(KErrPathNotFound); |
|
3625 return; |
|
3626 } |
|
3627 |
|
3628 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3629 |
|
3630 } |
|
3631 |
|
3632 /* |
|
3633 * |
|
3634 * InitializeComplete |
|
3635 * |
|
3636 */ |
|
3637 void RStepA3FDevSoundNegCancelInitializePlay::InitializeComplete(TInt aError) |
|
3638 { |
|
3639 if (aError == KErrNone) |
|
3640 { |
|
3641 INFO_PRINTF1(_L("InitializeComplete returned with KErrNone")); |
|
3642 INFO_PRINTF1(_L("Calling CancelInitialize after InitializeComplete")); |
|
3643 TInt err; |
|
3644 err = iMMFDevSound->CancelInitialize(); |
|
3645 if (err == KErrNotReady) |
|
3646 { |
|
3647 INFO_PRINTF1(_L("CancelInitialize returned with KErrNotReady as expected")); |
|
3648 StopTest(aError); |
|
3649 } |
|
3650 else |
|
3651 { |
|
3652 INFO_PRINTF2(_L("CancelInitialize return with error %d instead of KErrNotReady as expected"), aError); |
|
3653 StopTest(aError, EFail); |
|
3654 } |
|
3655 } |
|
3656 else |
|
3657 { |
|
3658 INFO_PRINTF2(_L("InitializeComplete returned with error %d"), aError); |
|
3659 StopTest(aError, EFail); |
|
3660 } |
|
3661 |
|
3662 } |
|
3663 |
|
3664 /* |
|
3665 * |
|
3666 * Fsm |
|
3667 * - Executes playing events of DevSound in sequence |
|
3668 * |
|
3669 */ |
|
3670 void RStepA3FDevSoundNegCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3671 { |
|
3672 switch (iPlayState) |
|
3673 { |
|
3674 case EStatePlayStart: |
|
3675 { |
|
3676 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNegCancelInitializePlay"),EFsmIncorrectErrorPassed)); |
|
3677 if (aDevSoundEvent == EEventPlayStart) |
|
3678 { |
|
3679 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3680 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3681 TInt err; |
|
3682 if(iUseFourCC) |
|
3683 { |
|
3684 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
3685 } |
|
3686 else |
|
3687 { |
|
3688 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
3689 } |
|
3690 if (err != KErrNone) |
|
3691 { |
|
3692 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3693 StopTest(err); |
|
3694 break; |
|
3695 } |
|
3696 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
3697 iPlayState = EStatePlayInitializing; |
|
3698 } |
|
3699 else |
|
3700 { |
|
3701 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3702 StopTest(aError, EFail); |
|
3703 } |
|
3704 break; |
|
3705 } |
|
3706 |
|
3707 default: |
|
3708 { |
|
3709 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3710 StopTest(KErrGeneral); |
|
3711 } |
|
3712 } |
|
3713 |
|
3714 } |
|
3715 |
|
3716 // |
|
3717 // RStepA3FDevSoundEmptyBuffersInCreatedState |
|
3718 // |
|
3719 |
|
3720 /* |
|
3721 * |
|
3722 * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor |
|
3723 * |
|
3724 */ |
|
3725 RStepA3FDevSoundEmptyBuffersInCreatedState::RStepA3FDevSoundEmptyBuffersInCreatedState(const TDesC& aTestName) |
|
3726 :RTestStepA3FDevSoundPlayBase(aTestName) |
|
3727 { |
|
3728 } |
|
3729 |
|
3730 /* |
|
3731 * |
|
3732 * NewL |
|
3733 * |
|
3734 */ |
|
3735 RStepA3FDevSoundEmptyBuffersInCreatedState* RStepA3FDevSoundEmptyBuffersInCreatedState::NewL(const TDesC& aTestName) |
|
3736 { |
|
3737 RStepA3FDevSoundEmptyBuffersInCreatedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInCreatedState(aTestName); |
|
3738 return self; |
|
3739 |
|
3740 } |
|
3741 |
|
3742 /* |
|
3743 * |
|
3744 * KickoffTestL |
|
3745 * - Starts the test |
|
3746 * |
|
3747 */ |
|
3748 void RStepA3FDevSoundEmptyBuffersInCreatedState::KickoffTestL() |
|
3749 { |
|
3750 // Create instance of CMMFDevSound |
|
3751 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3752 iMMFDevSound = CMMFDevSound::NewL(); |
|
3753 |
|
3754 //Display the name of Codec being used |
|
3755 DisplayCodecInfo(); |
|
3756 |
|
3757 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3758 |
|
3759 } |
|
3760 |
|
3761 /* |
|
3762 * |
|
3763 * Fsm |
|
3764 * - Executes playing events of DevSound in sequence |
|
3765 * |
|
3766 */ |
|
3767 void RStepA3FDevSoundEmptyBuffersInCreatedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3768 { |
|
3769 switch (iPlayState) |
|
3770 { |
|
3771 case EStatePlayStart: |
|
3772 { |
|
3773 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed)); |
|
3774 if (aDevSoundEvent == EEventPlayStart) |
|
3775 { |
|
3776 // Calling EmptyBuffers |
|
3777 INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()")); |
|
3778 TInt err; |
|
3779 err = iMMFDevSound->EmptyBuffers(); |
|
3780 if (err == KErrNotReady) |
|
3781 { |
|
3782 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err); |
|
3783 StopTest(); |
|
3784 } |
|
3785 else |
|
3786 { |
|
3787 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err); |
|
3788 StopTest(err); |
|
3789 } |
|
3790 } |
|
3791 else |
|
3792 { |
|
3793 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3794 StopTest(aError, EFail); |
|
3795 } |
|
3796 break; |
|
3797 } |
|
3798 default: |
|
3799 { |
|
3800 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3801 StopTest(KErrGeneral); |
|
3802 } |
|
3803 } |
|
3804 |
|
3805 } |
|
3806 |
|
3807 // |
|
3808 // RStepA3FDevSoundEmptyBuffersInInitializedState |
|
3809 // |
|
3810 |
|
3811 /* |
|
3812 * |
|
3813 * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor |
|
3814 * |
|
3815 */ |
|
3816 RStepA3FDevSoundEmptyBuffersInInitializedState::RStepA3FDevSoundEmptyBuffersInInitializedState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3817 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
3818 { |
|
3819 } |
|
3820 |
|
3821 /* |
|
3822 * |
|
3823 * NewL |
|
3824 * |
|
3825 */ |
|
3826 RStepA3FDevSoundEmptyBuffersInInitializedState* RStepA3FDevSoundEmptyBuffersInInitializedState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3827 { |
|
3828 RStepA3FDevSoundEmptyBuffersInInitializedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializedState(aTestName, aSectName, aInputDataType); |
|
3829 return self; |
|
3830 |
|
3831 } |
|
3832 |
|
3833 /* |
|
3834 * |
|
3835 * KickoffTestL |
|
3836 * - Starts the test |
|
3837 * |
|
3838 */ |
|
3839 void RStepA3FDevSoundEmptyBuffersInInitializedState::KickoffTestL() |
|
3840 { |
|
3841 // Create instance of CMMFDevSound |
|
3842 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3843 iMMFDevSound = CMMFDevSound::NewL(); |
|
3844 |
|
3845 //Display the name of Codec being used |
|
3846 DisplayCodecInfo(); |
|
3847 CheckConfigAndFourCCUsage(); |
|
3848 |
|
3849 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3850 |
|
3851 } |
|
3852 |
|
3853 /* |
|
3854 * |
|
3855 * Fsm |
|
3856 * - Executes playing events of DevSound in sequence |
|
3857 * |
|
3858 */ |
|
3859 void RStepA3FDevSoundEmptyBuffersInInitializedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3860 { |
|
3861 switch (iPlayState) |
|
3862 { |
|
3863 case EStatePlayStart: |
|
3864 { |
|
3865 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed)); |
|
3866 if (aDevSoundEvent == EEventPlayStart) |
|
3867 { |
|
3868 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
3869 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
3870 TInt err; |
|
3871 if(iUseFourCC) |
|
3872 { |
|
3873 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
3874 } |
|
3875 else |
|
3876 { |
|
3877 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
3878 } |
|
3879 if (err != KErrNone) |
|
3880 { |
|
3881 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
3882 StopTest(err); |
|
3883 break; |
|
3884 } |
|
3885 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
3886 iPlayState = EStatePlayInitializing; |
|
3887 } |
|
3888 else |
|
3889 { |
|
3890 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
3891 StopTest(aError, EFail); |
|
3892 } |
|
3893 break; |
|
3894 } |
|
3895 case EStatePlayInitializing: |
|
3896 { |
|
3897 if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone) |
|
3898 { |
|
3899 // Calling EmptyBuffers |
|
3900 INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()")); |
|
3901 TInt err; |
|
3902 err = iMMFDevSound->EmptyBuffers(); |
|
3903 if (err == KErrNotReady) |
|
3904 { |
|
3905 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err); |
|
3906 StopTest(); |
|
3907 } |
|
3908 else |
|
3909 { |
|
3910 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err); |
|
3911 StopTest(err); |
|
3912 } |
|
3913 } |
|
3914 else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone) |
|
3915 { |
|
3916 ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError); |
|
3917 StopTest(aError); |
|
3918 } |
|
3919 else |
|
3920 { |
|
3921 ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent); |
|
3922 StopTest(aError, EFail); |
|
3923 } |
|
3924 break; |
|
3925 } |
|
3926 default: |
|
3927 { |
|
3928 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
3929 StopTest(KErrGeneral); |
|
3930 } |
|
3931 } |
|
3932 } |
|
3933 |
|
3934 // |
|
3935 // RStepA3FDevSoundEmptyBuffersInInitializingState |
|
3936 // |
|
3937 |
|
3938 /* |
|
3939 * |
|
3940 * RStepA3FDevSoundCancelInitializePlay - Test step constructor |
|
3941 * |
|
3942 */ |
|
3943 RStepA3FDevSoundEmptyBuffersInInitializingState::RStepA3FDevSoundEmptyBuffersInInitializingState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3944 :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType) |
|
3945 { |
|
3946 } |
|
3947 |
|
3948 /* |
|
3949 * |
|
3950 * NewL |
|
3951 * |
|
3952 */ |
|
3953 RStepA3FDevSoundEmptyBuffersInInitializingState* RStepA3FDevSoundEmptyBuffersInInitializingState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType) |
|
3954 { |
|
3955 RStepA3FDevSoundEmptyBuffersInInitializingState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializingState(aTestName, aSectName, aInputDataType); |
|
3956 return self; |
|
3957 |
|
3958 } |
|
3959 |
|
3960 /* |
|
3961 * |
|
3962 * KickoffTestL |
|
3963 * - Starts the test |
|
3964 * |
|
3965 */ |
|
3966 void RStepA3FDevSoundEmptyBuffersInInitializingState::KickoffTestL() |
|
3967 { |
|
3968 // Create instance of CMMFDevSound |
|
3969 INFO_PRINTF1(_L("--- Creating DevSound object...")); |
|
3970 iMMFDevSound = CMMFDevSound::NewL(); |
|
3971 |
|
3972 //Display the name of Codec being used |
|
3973 DisplayCodecInfo(); |
|
3974 CheckConfigAndFourCCUsage(); |
|
3975 |
|
3976 Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing |
|
3977 |
|
3978 } |
|
3979 |
|
3980 /* |
|
3981 * |
|
3982 * InitializeComplete |
|
3983 * |
|
3984 */ |
|
3985 void RStepA3FDevSoundEmptyBuffersInInitializingState::InitializeComplete(TInt aError) |
|
3986 { |
|
3987 INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour")); |
|
3988 INFO_PRINTF1(_L("EmptyBuffers was not called before InitializeComplete ")); |
|
3989 StopTest(aError, EFail); |
|
3990 } |
|
3991 |
|
3992 /* |
|
3993 * |
|
3994 * Fsm |
|
3995 * - Executes playing events of DevSound in sequence |
|
3996 * |
|
3997 */ |
|
3998 void RStepA3FDevSoundEmptyBuffersInInitializingState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError) |
|
3999 { |
|
4000 switch (iPlayState) |
|
4001 { |
|
4002 case EStatePlayStart: |
|
4003 { |
|
4004 __ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed)); |
|
4005 if (aDevSoundEvent == EEventPlayStart) |
|
4006 { |
|
4007 // Initializing DevSound object for playing mode to process audio data via desired FourCC code |
|
4008 INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL")); |
|
4009 TInt err; |
|
4010 if(iUseFourCC) |
|
4011 { |
|
4012 TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying)); |
|
4013 } |
|
4014 else |
|
4015 { |
|
4016 TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying)); |
|
4017 } |
|
4018 if (err != KErrNone) |
|
4019 { |
|
4020 ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err); |
|
4021 StopTest(err); |
|
4022 break; |
|
4023 } |
|
4024 else |
|
4025 { |
|
4026 INFO_PRINTF1(_L("State: EStatePlayInitializing")); |
|
4027 iPlayState = EStatePlayInitializing; |
|
4028 INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()")); |
|
4029 TInt err; |
|
4030 err = iMMFDevSound->EmptyBuffers(); |
|
4031 if (err == KErrNotReady) |
|
4032 { |
|
4033 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err); |
|
4034 StopTest(); |
|
4035 } |
|
4036 else |
|
4037 { |
|
4038 ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err); |
|
4039 StopTest(err); |
|
4040 } |
|
4041 } |
|
4042 } |
|
4043 else |
|
4044 { |
|
4045 ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent); |
|
4046 StopTest(aError, EFail); |
|
4047 } |
|
4048 break; |
|
4049 } |
|
4050 default: |
|
4051 { |
|
4052 ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState); |
|
4053 StopTest(KErrGeneral); |
|
4054 } |
|
4055 } |
|
4056 } |