First public contribution.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the TSI_MMFACLNT suite that tests CR1566 (TruePause) on AudioOutputStream
19 @file TestOutputStreamTruePause.cpp
22 #include "testoutputstreamtruepause.h"
26 * RMdaOutputStreamTestBase - Test step constructor
29 RMdaOutputStreamTestBase::RMdaOutputStreamTestBase(const TDesC& aTestName, const TDesC& aSectName)
30 : iAudioOutputStreamState(EStateAOSInitial),
31 iAudioOutputStream(NULL),
35 iInvalidConfig(EFalse),
46 iTestStepName = aTestName;
47 iSectName = aSectName;
52 * ~RMdaOutputStreamTestBase - Test step destructor
55 RMdaOutputStreamTestBase::~RMdaOutputStreamTestBase()
57 if (iAudioOutputStream)
59 delete iAudioOutputStream;
72 * KickoffTestL - Starts the test
75 void RMdaOutputStreamTestBase::KickoffTestL()
77 User::LeaveIfError(iFs.Connect());
78 INFO_PRINTF1(_L("__________ Creating AudioOutputStream object ___________"));
80 TRAPD(err, iAudioOutputStream = CMdaAudioOutputStream::NewL(*this));
83 ERR_PRINTF2(_L("Could not create Tone Utility object. Error = %d"), err);
87 INFO_PRINTF1(_L("AudioOutputStream State: EStateCreated"));
88 iAudioOutputStreamState = EStateAOSCreated;
92 INFO_PRINTF1(_L("AudioOutputStream: EEventInitialize"));
93 Fsm(EEventAOSInitialize, KErrNone);
101 void RMdaOutputStreamTestBase::CloseTest()
103 INFO_PRINTF1(_L("Deleting AudioOutputStream object"));
104 delete iAudioOutputStream;
110 * StartTimer - Starts timer and timer callback
113 void RMdaOutputStreamTestBase::StartTimer(TTimeIntervalMicroSeconds32 aWaitTime)
115 TTimeIntervalMicroSeconds32 timeInterval;
117 if(aWaitTime <= TTimeIntervalMicroSeconds32(0))
119 timeInterval = KOneSecond;
123 timeInterval = aWaitTime;
125 TCallBack callback (TimerCallback, this);
126 iTimer->Start(timeInterval, timeInterval, callback);
127 INFO_PRINTF1(_L("Timer has been started"));
135 TInt RMdaOutputStreamTestBase::TimerCallback(TAny* aPtr)
137 static_cast<RMdaOutputStreamTestBase*>(aPtr)->DoTimerCallback();
143 * Fsm - Executes playing events of AudioToneUtility in sequence
146 void RMdaOutputStreamTestBase::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
149 TTimeIntervalMicroSeconds resumeposition;
150 switch (iAudioOutputStreamState)
152 case EStateAOSCreated:
154 if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
156 TMdaAudioDataSettings settings;
159 settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
160 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
161 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
162 iAudioOutputStream->Open(&settings);
163 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
164 iAudioOutputStreamState = EStateAOSInitializing;
168 ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
169 StopTest(aError, EFail);
173 case EStateAOSInitializing:
175 if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
177 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
178 iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
179 INFO_PRINTF1(_L("Starting playback"));
180 iAudioOutputStream->WriteL(iBuffer);
181 iAudioOutputStreamState = EStateAOSPlaying;
182 StartTimer(iPause*KOneSecond);
184 else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
186 ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
191 ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
192 StopTest(aError, EFail);
196 case EStateAOSPlaying:
198 if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
202 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
203 error = iAudioOutputStream->Pause();
204 if(error == KErrNone)
206 INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
210 ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
213 iPosition = iAudioOutputStream->Position();
214 INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
215 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
216 iAudioOutputStreamState = EStateAOSPause;
221 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
222 error = iAudioOutputStream->Pause();
223 if(error == KErrNone)
225 INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
229 ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
232 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
233 iPosition = iAudioOutputStream->Position();
234 INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
235 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
236 iAudioOutputStreamState = EStateAOSPause;
238 INFO_PRINTF1(_L("Calling GetBytes"));
239 iBytes = iAudioOutputStream->GetBytes();
244 ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
245 StopTest(aError, EFail);
251 if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
253 if(!iWait && !iConfig && !iInvalidConfig && !iGetBytes)
255 if(iPosition == iAudioOutputStream->Position())
257 INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
261 ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
262 StopTest(KErrGeneral);
264 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
265 error = iAudioOutputStream->Resume();
266 resumeposition = iAudioOutputStream->Position();
267 if(error == KErrNone)
269 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
270 iAudioOutputStreamState = EStateAOSPlaying;
271 if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
273 INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
277 ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
278 StopTest(KErrGeneral);
283 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
287 else if(!iWait && iConfig)
289 if(iPosition == iAudioOutputStream->Position())
291 INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
295 ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
296 StopTest(KErrGeneral);
298 INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
299 INFO_PRINTF3(_L("Changing Volume and Balance while paused to Volume = %d and Balance = %d"),iVolume,iBalance);
300 iAudioOutputStream->SetVolume(iVolume);
301 iAudioOutputStream->SetBalanceL(iBalance);
302 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
303 error = iAudioOutputStream->Resume();
304 resumeposition = iAudioOutputStream->Position();
305 if(error == KErrNone)
307 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
308 iAudioOutputStreamState = EStateAOSPlaying;
309 if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
311 INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
315 ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
316 StopTest(KErrGeneral);
321 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
326 else if(!iWait && iInvalidConfig)
328 if(iPosition == iAudioOutputStream->Position())
330 INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
334 ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
335 StopTest(KErrGeneral);
337 INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
338 INFO_PRINTF1(_L("Changing AudioProperties while paused"));
339 TRAPD(err,iAudioOutputStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate48000Hz, TMdaAudioDataSettings::EChannelsStereo));
340 if(err == KErrNotReady)
342 INFO_PRINTF1(_L("SetAudioPropertiesL returned with KErrNotReady as expected"));
343 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
344 error = iAudioOutputStream->Resume();
345 resumeposition = iAudioOutputStream->Position();
346 if(error == KErrNone)
348 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
349 iAudioOutputStreamState = EStateAOSPlaying;
350 if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
352 INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
356 ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
357 StopTest(KErrGeneral);
362 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),err);
365 iInvalidConfig = EFalse;
369 ERR_PRINTF2(_L("SetAudioPropertiesL did not return with KErrNotSupported as expected, returned with %d instead"), err);
370 StopTest(KErrGeneral);
373 else if(!iWait && iGetBytes)
375 if(iPosition == iAudioOutputStream->Position())
377 INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
381 ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
382 StopTest(KErrGeneral);
384 INFO_PRINTF2(_L("Playback paused for %d seconds"),iPause);
385 INFO_PRINTF1(_L("Calling GetBytes to verify the value hasn't changed"));
386 TInt myBytes = iAudioOutputStream->GetBytes();
387 if(myBytes == iBytes)
389 INFO_PRINTF1(_L("GetBytes value did not change while in pause, this is expected."));
390 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
391 error = iAudioOutputStream->Resume();
392 resumeposition = iAudioOutputStream->Position();
393 if(error == KErrNone)
395 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
396 iAudioOutputStreamState = EStateAOSPlaying;
397 if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
399 INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
403 ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
404 StopTest(KErrGeneral);
409 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
416 ERR_PRINTF3(_L("GetBytes value changed while in pause, this is unexpected. Expected = %d Retrieved = %d"),iBytes,myBytes);
417 StopTest(KErrGeneral);
423 ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
424 StopTest(aError, EFail);
430 ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
431 StopTest(KErrGeneral);
438 * MaoscOpenComplete - From MMdaAudioOutputStreamObserver
441 void RMdaOutputStreamTestBase::MaoscOpenComplete(TInt aError)
443 INFO_PRINTF1(_L("========== AudioOutputStream MaoscOpenComplete() callback =========="));
444 if(iAudioOutputStreamState == EStateAOSInitializing)
446 INFO_PRINTF1(_L("AudioOutputStream MaoscOpenComplete"));
447 Fsm(EEventAOSOpenComplete, aError);
453 * MaoscBufferCopied - From MMdaAudioOutputStreamObserver
456 void RMdaOutputStreamTestBase::MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/)
458 INFO_PRINTF1(_L("========== AudioOutputStream MaoscBufferCopied() callback =========="));
459 INFO_PRINTF1(_L("Reading file"));
460 TInt err = iFile.Read(iBuffer);
463 INFO_PRINTF2(_L("Error reading iFile %d"), err);
466 if (iBuffer != KNullDesC8 && iAudioOutputStreamState != EStateAOSStopped)
468 INFO_PRINTF1(_L("Writing to stream"));
469 iAudioOutputStream->WriteL(iBuffer);
471 if(iAudioOutputStreamState == EStateAOSPlaying)
473 INFO_PRINTF1(_L("AudioOutputStream MaoscBufferCopied"));
475 else if(iAudioOutputStreamState == EStateAOSPause)
477 ERR_PRINTF1(_L("AudioOutputStream MaoscBufferCopied in Paused. This is unexpected"));
478 StopTest(KErrGeneral);
484 * MaoscPlayComplete - From MMdaAudioOutputStreamObserver
487 void RMdaOutputStreamTestBase::MaoscPlayComplete(TInt aError)
489 INFO_PRINTF1(_L("========== AudioOutputStream MaoscPlayComplete() callback =========="));
490 if (aError == KErrUnderflow)
492 INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
497 ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
498 ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
504 *========================================================================================================
505 * MM-MMF-ACLNT-I-0175-HP
506 *========================================================================================================
508 RMdaOutputStreamPauseResumeBeforeWriteTest::RMdaOutputStreamPauseResumeBeforeWriteTest(const TDesC& aTestName, const TDesC& aSectName)
509 : RMdaOutputStreamTestBase(aTestName,aSectName)
518 RMdaOutputStreamPauseResumeBeforeWriteTest* RMdaOutputStreamPauseResumeBeforeWriteTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
520 RMdaOutputStreamPauseResumeBeforeWriteTest * self = new(ELeave)RMdaOutputStreamPauseResumeBeforeWriteTest(aTestName,aSectName);
529 void RMdaOutputStreamPauseResumeBeforeWriteTest::DoKickoffTestL()
532 // Get the filename of the audio file to play
533 if (!GetStringFromConfig(iSectName, KRawFile, filename))
535 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
536 StopTest(KErrNotFound);
539 // open using RFile for playback
540 iFilename.Copy(filename);
541 TInt err = iFile.Open(iFs, iFilename, EFileRead);
544 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
551 err = iFile.Size(filesize);
554 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
559 iBuffer.CreateMaxL(filesize/KFileDivision);
561 //Read first half of the file
562 err = iFile.Read(iBuffer);
565 INFO_PRINTF2(_L("Error reading iFile %d"), err);
570 iPause = KTimeout; //Set timeout to stop test if playback was paused
571 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
572 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
577 * Fsm - Executes playing events of AudioToneUtility in sequence
580 void RMdaOutputStreamPauseResumeBeforeWriteTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
583 TTimeIntervalMicroSeconds resumeposition;
584 switch (iAudioOutputStreamState)
586 case EStateAOSCreated:
588 if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
590 TMdaAudioDataSettings settings;
593 settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
594 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
595 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause before Open"));
596 error = iAudioOutputStream->Pause();
597 if(error == KErrNotReady)
599 INFO_PRINTF1(_L("Pause before open returned with KErrNotReady as expected"));
603 ERR_PRINTF2(_L("Pause before open returned with %d instead of KErrNotReady as expected"),error);
606 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
607 iAudioOutputStream->Open(&settings);
608 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
609 iAudioOutputStreamState = EStateAOSInitializing;
613 ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
614 StopTest(aError, EFail);
618 case EStateAOSInitializing:
620 if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
622 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
623 iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
624 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause before first WriteL"));
625 error = iAudioOutputStream->Pause();
626 if(error == KErrNotReady)
628 INFO_PRINTF1(_L("Pause before first WriteL returned with KErrNotReady as expected"));
632 ERR_PRINTF2(_L("Pause before first WriteL returned with %d instead of KErrNotReady as expected"),error);
635 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume before first WriteL"));
636 error = iAudioOutputStream->Resume();
637 if(error == KErrNotReady)
639 INFO_PRINTF1(_L("Resume before first WriteL returned with KErrNotReady as expected"));
643 ERR_PRINTF2(_L("Resume before first WriteL returned with %d instead of KErrNotReady as expected"),error);
646 INFO_PRINTF1(_L("Starting playback"));
647 iAudioOutputStream->WriteL(iBuffer);
648 iAudioOutputStreamState = EStateAOSPlaying;
649 StartTimer(iPause*KOneSecond);
651 else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
653 ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
658 ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
659 StopTest(aError, EFail);
665 ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
666 StopTest(KErrGeneral);
676 void RMdaOutputStreamPauseResumeBeforeWriteTest::DoTimerCallback()
678 INFO_PRINTF1(_L("Cancelling timer"));
680 ERR_PRINTF1(_L("Playback was paused when it shouldn't"));
681 StopTest(KErrGeneral);
685 *========================================================================================================
686 * MM-MMF-ACLNT-I-0176-HP
687 *========================================================================================================
689 RMdaOutputStreamResumeTest::RMdaOutputStreamResumeTest(const TDesC& aTestName, const TDesC& aSectName)
690 : RMdaOutputStreamTestBase(aTestName,aSectName)
699 RMdaOutputStreamResumeTest* RMdaOutputStreamResumeTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
701 RMdaOutputStreamResumeTest * self = new(ELeave)RMdaOutputStreamResumeTest(aTestName,aSectName);
710 void RMdaOutputStreamResumeTest::DoKickoffTestL()
713 // Get the pause time
714 if (!GetIntFromConfig(iSectName, KPause, iPause))
716 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
717 StopTest(KErrNotFound);
720 // Get the filename of the audio file to play
721 if (!GetStringFromConfig(iSectName, KRawFile, filename))
723 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
724 StopTest(KErrNotFound);
727 // open using RFile for playback
728 iFilename.Copy(filename);
729 TInt err = iFile.Open(iFs, iFilename, EFileRead);
732 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
739 err = iFile.Size(filesize);
742 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
747 iBuffer.CreateMaxL(filesize/KFileDivision);
749 //Read first half of the file
750 err = iFile.Read(iBuffer);
753 INFO_PRINTF2(_L("Error reading iFile %d"), err);
758 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
759 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
767 void RMdaOutputStreamResumeTest::DoTimerCallback()
771 INFO_PRINTF1(_L("Cancelling timer"));
776 INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
778 Fsm (EEventAOSTimerComplete, KErrNone);
782 *========================================================================================================
783 * MM-MMF-ACLNT-I-0177-HP
784 *========================================================================================================
786 RMdaOutputStreamResumeThriceTest::RMdaOutputStreamResumeThriceTest(const TDesC& aTestName, const TDesC& aSectName)
787 : RMdaOutputStreamTestBase(aTestName,aSectName)
796 RMdaOutputStreamResumeThriceTest* RMdaOutputStreamResumeThriceTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
798 RMdaOutputStreamResumeThriceTest * self = new(ELeave)RMdaOutputStreamResumeThriceTest(aTestName,aSectName);
807 void RMdaOutputStreamResumeThriceTest::DoKickoffTestL()
810 // Get the pause time
811 if (!GetIntFromConfig(iSectName, KPause, iPause))
813 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
814 StopTest(KErrNotFound);
817 // Get the filename of the audio file to play
818 if (!GetStringFromConfig(iSectName, KRawFile, filename))
820 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
821 StopTest(KErrNotFound);
824 // open using RFile for playback
825 iFilename.Copy(filename);
826 TInt err = iFile.Open(iFs, iFilename, EFileRead);
829 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
836 err = iFile.Size(filesize);
839 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
844 iBuffer.CreateMaxL(filesize/KFileDivision);
846 //Read first half of the file
847 err = iFile.Read(iBuffer);
850 INFO_PRINTF2(_L("Error reading iFile %d"), err);
855 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
856 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
864 void RMdaOutputStreamResumeThriceTest::DoTimerCallback()
867 if(!iWait && iCount == 2*KRepeatThrice) //Repeating Pause-Resume cycle three times. Timer should be called 6 times
870 Fsm (EEventAOSTimerComplete, KErrNone);
874 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
875 Fsm (EEventAOSTimerComplete, KErrNone);
880 *========================================================================================================
881 * MM-MMF-ACLNT-I-0178-HP
882 *========================================================================================================
884 RMdaOutputStreamConfigInPauseTest::RMdaOutputStreamConfigInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
885 : RMdaOutputStreamTestBase(aTestName,aSectName)
894 RMdaOutputStreamConfigInPauseTest* RMdaOutputStreamConfigInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
896 RMdaOutputStreamConfigInPauseTest * self = new(ELeave)RMdaOutputStreamConfigInPauseTest(aTestName,aSectName);
905 void RMdaOutputStreamConfigInPauseTest::DoKickoffTestL()
908 // Get the pause time
909 if (!GetIntFromConfig(iSectName, KPause, iPause))
911 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
912 StopTest(KErrNotFound);
915 // Get the filename of the audio file to play
916 if (!GetStringFromConfig(iSectName, KRawFile, filename))
918 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
919 StopTest(KErrNotFound);
923 if (!GetIntFromConfig(iSectName, KVolume, iVolume))
925 ERR_PRINTF1(_L("Volume could not be retrieved from ini file"));
926 StopTest(KErrNotFound);
930 if (!GetIntFromConfig(iSectName, KBalance, iBalance))
932 ERR_PRINTF1(_L("Balance could not be retrieved from ini file"));
933 StopTest(KErrNotFound);
936 // open using RFile for playback
937 iFilename.Copy(filename);
938 TInt err = iFile.Open(iFs, iFilename, EFileRead);
941 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
948 err = iFile.Size(filesize);
951 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
956 iBuffer.CreateMaxL(filesize/KFileDivision);
958 //Read first half of the file
959 err = iFile.Read(iBuffer);
962 INFO_PRINTF2(_L("Error reading iFile %d"), err);
968 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
969 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
977 void RMdaOutputStreamConfigInPauseTest::DoTimerCallback()
979 if(!iWait && !iConfig)
982 INFO_PRINTF1(_L("Comparing Volume and Balance with values set"));
983 if (iVolume == iAudioOutputStream->Volume() && Abs(iBalance - iAudioOutputStream->GetBalanceL())<KBalanceTolerance)
985 INFO_PRINTF3(_L("Volume = %d and Balance = %d as expected"),iVolume,iBalance);
989 ERR_PRINTF1(_L("Retrieved values are different than expected"));
990 ERR_PRINTF5(_L("Retrieved Volume = %d and Balance = %d. Expected Volume = %d and Balance = %d"),iAudioOutputStream->Volume(),iAudioOutputStream->GetBalanceL(),iVolume,iBalance);
991 StopTest(KErrGeneral);
996 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
997 Fsm (EEventAOSTimerComplete, KErrNone);
1002 *========================================================================================================
1003 * MM-MMF-ACLNT-I-0179-HP
1004 *========================================================================================================
1006 RMdaOutputStreamInvalidConfigInPauseTest::RMdaOutputStreamInvalidConfigInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1007 : RMdaOutputStreamTestBase(aTestName,aSectName)
1016 RMdaOutputStreamInvalidConfigInPauseTest* RMdaOutputStreamInvalidConfigInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1018 RMdaOutputStreamInvalidConfigInPauseTest * self = new(ELeave)RMdaOutputStreamInvalidConfigInPauseTest(aTestName,aSectName);
1027 void RMdaOutputStreamInvalidConfigInPauseTest::DoKickoffTestL()
1030 // Get the pause time
1031 if (!GetIntFromConfig(iSectName, KPause, iPause))
1033 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1034 StopTest(KErrNotFound);
1037 // Get the filename of the audio file to play
1038 if (!GetStringFromConfig(iSectName, KRawFile, filename))
1040 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1041 StopTest(KErrNotFound);
1044 // open using RFile for playback
1045 iFilename.Copy(filename);
1046 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1047 if (err != KErrNone)
1049 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1054 // Get size of iFile
1056 err = iFile.Size(filesize);
1057 if (err != KErrNone)
1059 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1064 iBuffer.CreateMaxL(filesize/KFileDivision);
1066 //Read first half of the file
1067 err = iFile.Read(iBuffer);
1068 if (err != KErrNone)
1070 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1075 iInvalidConfig = ETrue;
1076 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1077 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1085 void RMdaOutputStreamInvalidConfigInPauseTest::DoTimerCallback()
1089 INFO_PRINTF1(_L("Cancelling timer"));
1094 INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
1096 Fsm (EEventAOSTimerComplete, KErrNone);
1100 *========================================================================================================
1101 * MM-MMF-ACLNT-I-0180-HP
1102 *========================================================================================================
1104 RMdaOutputStreamGetBytesInPauseTest::RMdaOutputStreamGetBytesInPauseTest(const TDesC& aTestName, const TDesC& aSectName)
1105 : RMdaOutputStreamTestBase(aTestName,aSectName)
1114 RMdaOutputStreamGetBytesInPauseTest* RMdaOutputStreamGetBytesInPauseTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1116 RMdaOutputStreamGetBytesInPauseTest * self = new(ELeave)RMdaOutputStreamGetBytesInPauseTest(aTestName,aSectName);
1125 void RMdaOutputStreamGetBytesInPauseTest::DoKickoffTestL()
1128 // Get the pause time
1129 if (!GetIntFromConfig(iSectName, KPause, iPause))
1131 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1132 StopTest(KErrNotFound);
1135 // Get the filename of the audio file to play
1136 if (!GetStringFromConfig(iSectName, KRawFile, filename))
1138 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1139 StopTest(KErrNotFound);
1142 // open using RFile for playback
1143 iFilename.Copy(filename);
1144 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1145 if (err != KErrNone)
1147 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1152 // Get size of iFile
1154 err = iFile.Size(filesize);
1155 if (err != KErrNone)
1157 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1162 iBuffer.CreateMaxL(filesize/KFileDivision);
1164 //Read first half of the file
1165 err = iFile.Read(iBuffer);
1166 if (err != KErrNone)
1168 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1174 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1175 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1183 void RMdaOutputStreamGetBytesInPauseTest::DoTimerCallback()
1187 INFO_PRINTF1(_L("Cancelling timer"));
1192 INFO_PRINTF1(_L("MdaAudioOutputStream Event: EEventTimerComplete"));
1194 Fsm (EEventAOSTimerComplete, KErrNone);
1198 *========================================================================================================
1199 * MM-MMF-ACLNT-I-0181-HP
1200 *========================================================================================================
1202 RMdaOutputStreamPlayPauseStopPlayTest::RMdaOutputStreamPlayPauseStopPlayTest(const TDesC& aTestName, const TDesC& aSectName)
1203 : RMdaOutputStreamTestBase(aTestName,aSectName)
1212 RMdaOutputStreamPlayPauseStopPlayTest* RMdaOutputStreamPlayPauseStopPlayTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1214 RMdaOutputStreamPlayPauseStopPlayTest * self = new(ELeave)RMdaOutputStreamPlayPauseStopPlayTest(aTestName,aSectName);
1223 void RMdaOutputStreamPlayPauseStopPlayTest::DoKickoffTestL()
1226 // Get the pause time
1227 if (!GetIntFromConfig(iSectName, KPause, iPause))
1229 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1230 StopTest(KErrNotFound);
1233 // Get the filename of the audio file to play
1234 if (!GetStringFromConfig(iSectName, KRawFile, filename))
1236 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1237 StopTest(KErrNotFound);
1240 // open using RFile for playback
1241 iFilename.Copy(filename);
1242 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1243 if (err != KErrNone)
1245 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1250 // Get size of iFile
1252 err = iFile.Size(filesize);
1253 if (err != KErrNone)
1255 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1260 iBuffer.CreateMaxL(filesize/KFileDivision);
1262 //Read first half of the file
1263 err = iFile.Read(iBuffer);
1264 if (err != KErrNone)
1266 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1272 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1273 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1281 void RMdaOutputStreamPlayPauseStopPlayTest::DoTimerCallback()
1285 iAudioOutputStreamState = EStateAOSStopped;
1288 INFO_PRINTF1(_L("MAudioOutputStream Event: EEventTimerComplete"));
1289 Fsm (EEventAOSTimerComplete, KErrNone);
1291 else if(!iWait && !iStop)
1294 Fsm (EEventAOSTimerComplete, KErrNone);
1298 INFO_PRINTF1(_L("MdaToneUtility Event: EEventTimerComplete"));
1299 Fsm (EEventAOSTimerComplete, KErrNone);
1305 * Fsm - Executes playing events of AudioToneUtility in sequence
1308 void RMdaOutputStreamPlayPauseStopPlayTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1311 TTimeIntervalMicroSeconds resumeposition;
1312 switch (iAudioOutputStreamState)
1314 case EStateAOSCreated:
1316 if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1318 TMdaAudioDataSettings settings;
1321 settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1322 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1323 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1324 iAudioOutputStream->Open(&settings);
1325 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1326 iAudioOutputStreamState = EStateAOSInitializing;
1330 ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1331 StopTest(aError, EFail);
1335 case EStateAOSInitializing:
1337 if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1339 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1340 iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1341 INFO_PRINTF1(_L("Starting playback"));
1342 iAudioOutputStream->WriteL(iBuffer);
1343 iAudioOutputStreamState = EStateAOSPlaying;
1344 StartTimer(iPause*KOneSecond);
1346 else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1348 ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1353 ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1354 StopTest(aError, EFail);
1358 case EStateAOSPlaying:
1360 if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1362 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause"));
1363 error = iAudioOutputStream->Pause();
1364 if(error == KErrNone)
1366 INFO_PRINTF1(_L("Pause returned with KErrNone as expected"));
1370 ERR_PRINTF2(_L("Pause returned with %d instead of KErrNone as expected"),error);
1373 iPosition = iAudioOutputStream->Position();
1374 INFO_PRINTF2(_L("Stream was paused at %Ld"),iPosition.Int64());
1375 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStatePause"));
1376 iAudioOutputStreamState = EStateAOSPause;
1381 ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1382 StopTest(aError, EFail);
1386 case EStateAOSPause:
1388 if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1390 if(iPosition == iAudioOutputStream->Position())
1392 INFO_PRINTF2(_L("Paused position was maintained at %Ld"),iPosition.Int64());
1396 ERR_PRINTF3(_L("Position was not maintained during pause. Expected %Ld Retrieved %Ld"),iPosition.Int64(),iAudioOutputStream->Position().Int64());
1397 StopTest(KErrGeneral);
1399 INFO_PRINTF1(_L("Resuming playback. Calling CMdaAudioOutputStream::Resume"));
1400 error = iAudioOutputStream->Resume();
1401 resumeposition = iAudioOutputStream->Position();
1402 if(error == KErrNone)
1404 INFO_PRINTF1(_L("Resume returned with KErrNone as expected"));
1405 iAudioOutputStreamState = EStateAOSPlaying;
1406 if(Abs(resumeposition.Int64() - iPosition.Int64()) <= KOneSecond/2)
1408 INFO_PRINTF2(_L("Playback resumed from expected position %Ld"),iPosition.Int64());
1412 ERR_PRINTF3(_L("Playback did not resume from expected position. Expected %Ld Retrieved %Ld"),iPosition.Int64(),resumeposition.Int64());
1413 StopTest(KErrGeneral);
1418 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNone as expected"),error);
1424 ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1425 StopTest(aError, EFail);
1429 case EStateAOSStopped:
1431 if (aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1435 INFO_PRINTF1(_L("Stopping playback for 2 seconds"));
1436 iAudioOutputStream->Stop();
1441 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume while in Stop"));
1442 error = iAudioOutputStream->Resume();
1443 if(error == KErrNotReady)
1445 INFO_PRINTF1(_L("Resume returned with KErrNotReady as expected"));
1449 ERR_PRINTF2(_L("Resume returned with %d instead of KErrNotReady as expected"),error);
1453 INFO_PRINTF1(_L("Restarting file to start position"));
1454 error = iFile.Seek(ESeekStart, filepos);
1455 if (error != KErrNone)
1457 INFO_PRINTF2(_L("Error restarting iFile %d"), error);
1460 error = iFile.Read(iBuffer);
1461 if (error != KErrNone)
1463 INFO_PRINTF2(_L("Error reading iFile %d"), error);
1466 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::WriteL while in Stop to restart playback"));
1467 iAudioOutputStream->WriteL(iBuffer);
1468 iAudioOutputStreamState = EStateAOSPlaying;
1473 ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1474 StopTest(aError, EFail);
1480 ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1481 StopTest(KErrGeneral);
1488 * MaoscPlayComplete - From MMdaAudioOutputStreamObserver
1491 void RMdaOutputStreamPlayPauseStopPlayTest::MaoscPlayComplete(TInt aError)
1493 INFO_PRINTF1(_L("========== AudioOutputStream MaoscPlayComplete() callback =========="));
1494 if(iAudioOutputStreamState == EStateAOSStopped)
1496 if (aError == KErrCancel)
1498 INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
1502 ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
1503 ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1507 else if(iAudioOutputStreamState == EStateAOSPlaying)
1509 if(aError == KErrUnderflow)
1511 INFO_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d as expected"), aError);
1516 ERR_PRINTF2(_L("AudioOutputStream called MaoscPlayComplete with error = %d"), aError);
1517 ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
1523 ERR_PRINTF1(_L("AudioOutputStream called MaoscPlayComplete at invalid state"));
1524 StopTest(KErrGeneral);
1529 *========================================================================================================
1530 * MM-MMF-ACLNT-I-0182-HP
1531 *========================================================================================================
1533 RMdaOutputStreamInvalidFormatsTest::RMdaOutputStreamInvalidFormatsTest(const TDesC& aTestName, const TDesC& aSectName)
1534 : RMdaOutputStreamTestBase(aTestName,aSectName)
1543 RMdaOutputStreamInvalidFormatsTest* RMdaOutputStreamInvalidFormatsTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1545 RMdaOutputStreamInvalidFormatsTest * self = new(ELeave)RMdaOutputStreamInvalidFormatsTest(aTestName,aSectName);
1554 void RMdaOutputStreamInvalidFormatsTest::DoKickoffTestL()
1557 // Get the pause time
1558 if (!GetIntFromConfig(iSectName, KPause, iPause))
1560 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1561 StopTest(KErrNotFound);
1564 // Get the filename of the audio file to play
1565 if (!GetStringFromConfig(iSectName, KOggFile, filename))
1567 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1568 StopTest(KErrNotFound);
1571 // open using RFile for playback
1572 iFilename.Copy(filename);
1573 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1574 if (err != KErrNone)
1576 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1581 // Get size of iFile
1583 err = iFile.Size(filesize);
1584 if (err != KErrNone)
1586 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1591 iBuffer.CreateMaxL(filesize/KFileDivision);
1593 //Read first half of the file
1594 err = iFile.Read(iBuffer);
1595 if (err != KErrNone)
1597 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1602 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1603 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1611 void RMdaOutputStreamInvalidFormatsTest::DoTimerCallback()
1613 INFO_PRINTF1(_L("Cancelling timer"));
1615 Fsm (EEventAOSTimerComplete, KErrNone);
1620 * Fsm - Executes playing events of AudioToneUtility in sequence
1623 void RMdaOutputStreamInvalidFormatsTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1626 TTimeIntervalMicroSeconds resumeposition;
1627 switch (iAudioOutputStreamState)
1629 case EStateAOSCreated:
1631 if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1633 TMdaAudioDataSettings settings;
1634 //setting for OGG file
1636 settings.iChannels = TMdaAudioDataSettings::EChannelsStereo;
1637 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate44100Hz;
1638 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1639 iAudioOutputStream->Open(&settings);
1640 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1641 iAudioOutputStreamState = EStateAOSInitializing;
1645 ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1646 StopTest(aError, EFail);
1650 case EStateAOSInitializing:
1652 if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1654 TFourCC KVORBDataType('V', 'O', 'R', 'B');
1655 TRAPD(err,iAudioOutputStream->SetDataTypeL(KVORBDataType));
1658 INFO_PRINTF1(_L("Failed to set non-PCM Format"));
1661 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1662 iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1663 INFO_PRINTF1(_L("Starting playback"));
1664 iAudioOutputStream->WriteL(iBuffer);
1665 iAudioOutputStreamState = EStateAOSPlaying;
1666 StartTimer(iPause*KOneSecond);
1668 else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1670 ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1675 ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1676 StopTest(aError, EFail);
1680 case EStateAOSPlaying:
1682 if(aMdaAudioOutputStreamEvent == EEventAOSTimerComplete)
1684 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause while playing non-PCM format"));
1685 error = iAudioOutputStream->Pause();
1686 if(error == KErrNotSupported)
1688 INFO_PRINTF1(_L("Pause while playing non-PCM format returned with KErrNotSupported as expected"));
1692 ERR_PRINTF2(_L("Pause while playing non-PCM format returned with %d instead of KErrNotReady as expected"),error);
1698 ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1699 StopTest(aError, EFail);
1705 ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1706 StopTest(KErrGeneral);
1712 *========================================================================================================
1713 * MM-MMF-ACLNT-I-0184-HP
1714 *========================================================================================================
1716 RMdaOutputStreamPauseNonA3FTest::RMdaOutputStreamPauseNonA3FTest(const TDesC& aTestName, const TDesC& aSectName)
1717 : RMdaOutputStreamTestBase(aTestName,aSectName)
1726 RMdaOutputStreamPauseNonA3FTest* RMdaOutputStreamPauseNonA3FTest::NewL(const TDesC& aTestName, const TDesC& aSectName)
1728 RMdaOutputStreamPauseNonA3FTest * self = new(ELeave)RMdaOutputStreamPauseNonA3FTest(aTestName,aSectName);
1737 void RMdaOutputStreamPauseNonA3FTest::DoKickoffTestL()
1740 // Get the pause time
1741 if (!GetIntFromConfig(iSectName, KPause, iPause))
1743 ERR_PRINTF1(_L("Pause time could not be retrieved from ini file"));
1744 StopTest(KErrNotFound);
1747 // Get the filename of the audio file to play
1748 if (!GetStringFromConfig(iSectName, KRawFile, filename))
1750 ERR_PRINTF1(_L("Filename could not be retrieved from ini file"));
1751 StopTest(KErrNotFound);
1754 // open using RFile for playback
1755 iFilename.Copy(filename);
1756 TInt err = iFile.Open(iFs, iFilename, EFileRead);
1757 if (err != KErrNone)
1759 ERR_PRINTF3(_L("Could not open input file %S. Error = %d"), &iFilename, err);
1764 // Get size of iFile
1766 err = iFile.Size(filesize);
1767 if (err != KErrNone)
1769 INFO_PRINTF2(_L("Error getting size of iFile = %d"), err);
1774 iBuffer.CreateMaxL(filesize/KFileDivision);
1776 //Read first half of the file
1777 err = iFile.Read(iBuffer);
1778 if (err != KErrNone)
1780 INFO_PRINTF2(_L("Error reading iFile %d"), err);
1784 iPause = KTimeout; //Set timeout to stop test if playback was paused
1786 INFO_PRINTF2(_L("File under test -> %S"), &iFilename);
1787 iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
1795 void RMdaOutputStreamPauseNonA3FTest::DoTimerCallback()
1797 INFO_PRINTF1(_L("Cancelling timer"));
1799 ERR_PRINTF1(_L("Playback was paused when it shouldn't"));
1800 StopTest(KErrGeneral);
1805 * Fsm - Executes playing events of AudioToneUtility in sequence
1808 void RMdaOutputStreamPauseNonA3FTest::Fsm(TMdaAOSEvent aMdaAudioOutputStreamEvent, TInt aError)
1810 switch (iAudioOutputStreamState)
1812 case EStateAOSCreated:
1814 if (aMdaAudioOutputStreamEvent == EEventAOSInitialize)
1816 TMdaAudioDataSettings settings;
1819 settings.iChannels = TMdaAudioDataSettings::EChannelsMono;
1820 settings.iSampleRate = TMdaAudioDataSettings::ESampleRate8000Hz;
1821 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Open"));
1822 iAudioOutputStream->Open(&settings);
1823 INFO_PRINTF1(_L("MdaAudioOutputStream State: EStateInitializing"));
1824 iAudioOutputStreamState = EStateAOSInitializing;
1828 ERR_PRINTF2(_L("MdaAudioOutputStream EEventInitialize not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1829 StopTest(aError, EFail);
1833 case EStateAOSInitializing:
1835 if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError == KErrNone)
1837 INFO_PRINTF1(_L("Calling SetVolume using MaxVolume/2"));
1838 iAudioOutputStream->SetVolume(iAudioOutputStream->MaxVolume()/2);
1839 INFO_PRINTF1(_L("Starting playback"));
1840 iAudioOutputStream->WriteL(iBuffer);
1841 StartTimer(iPause*KOneSecond);
1842 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Pause in non-a3f configuration"));
1843 TInt err = iAudioOutputStream->Pause();
1844 if(err == KErrNotSupported)
1846 INFO_PRINTF1(_L("Pause in CMdaAudioOutputStream returned with KErrNotSupported as expected"));
1850 ERR_PRINTF2(_L("Pause in CMdaAudioOutputStream returned with %d instead of KErrNotSupported as expected"),err);
1853 INFO_PRINTF1(_L("Calling CMdaAudioOutputStream::Resume in non-a3f configuration"));
1854 err = iAudioOutputStream->Resume();
1855 if(err == KErrNotReady)
1857 INFO_PRINTF1(_L("Resume in CMdaAudioOutputStream returned with KErrNotReady as expected"));
1861 ERR_PRINTF2(_L("Resume in CMdaAudioOutputStream returned with %d instead of KErrNotReady as expected"),err);
1865 else if (aMdaAudioOutputStreamEvent == EEventAOSOpenComplete && aError != KErrNone)
1867 ERR_PRINTF2(_L("MaoscOpenComplete returned with error = %d"), aError);
1872 ERR_PRINTF2(_L("MdaAudioOutputStream EEventOpenComplete not received as expected. Received event: %d"), aMdaAudioOutputStreamEvent);
1873 StopTest(aError, EFail);
1879 ERR_PRINTF2(_L("Invalid MdaAudioOutputStream state received: %d"), iAudioOutputStreamState);
1880 StopTest(KErrGeneral);