sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "teststepciaudiobufferprefill.h" sl@0: sl@0: const TInt32 KAfterThreeSeconds = 3000000; // Three seconds sl@0: const TInt32 KEveryNinetySeconds = 90000000; // Ninety seconds sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStepL() sl@0: { sl@0: iTestStepResult = ETestSuiteError; sl@0: sl@0: INFO_PRINTF1(_L("Initializing test CI device")); sl@0: sl@0: if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0069-HP")) == 0) sl@0: { sl@0: iTestStepResult = DoTestStep0069L(); sl@0: } sl@0: else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0070-HP")) == 0) sl@0: { sl@0: iTestStepResult = DoTestStep0070L(); sl@0: } sl@0: else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0071-HP")) == 0) sl@0: { sl@0: iTestStepResult = DoTestStep0071L(); sl@0: } sl@0: else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0072-HP")) == 0) sl@0: { sl@0: iTestStepResult = DoTestStep0072L(); sl@0: } sl@0: else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0073-HP")) == 0) sl@0: { sl@0: iTestStepResult = DoTestStep0073L(); sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStep0069L() sl@0: { sl@0: iTestStepResult = EFail; sl@0: sl@0: INFO_PRINTF1(_L("SampleBuffering - Instantiating")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidSampleBufferingTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','1','2'); sl@0: #endif sl@0: sl@0: iTestStepResult = TestInitialize(testUID, EMMFStatePlaying); sl@0: sl@0: if (iTestStepResult != EPass) sl@0: { sl@0: INFO_PRINTF1(_L("DevSound failed to instantiate the test device")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: // reset the value as previous test is pass sl@0: iTestStepResult = EFail; sl@0: sl@0: // KUidMMMFSampleBuffering sl@0: MMMFSampleBuffering* ptr = static_cast (iMMFDevSound->CustomInterface(KUidSampleBuffering)); sl@0: sl@0: if (ptr) sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering instantiated successfully")); sl@0: sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface")); sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStep0070L() sl@0: { sl@0: iTestStepResult = EFail; sl@0: TInt result = KErrGeneral; sl@0: sl@0: INFO_PRINTF1(_L("SampleBuffering - MmsbEnableSampleBufferingBeforePlayback")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidSampleBufferingTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','1','2'); sl@0: #endif sl@0: sl@0: iTestStepResult = TestInitialize(testUID, EMMFStatePlaying); sl@0: sl@0: if (iTestStepResult != EPass) sl@0: { sl@0: INFO_PRINTF1(_L("DevSound failed to instantiate the test device")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: // reset the value as previous test is pass sl@0: iTestStepResult = EFail; sl@0: sl@0: // KUidMMMFSampleBuffering sl@0: MMMFSampleBuffering* ptr = static_cast (iMMFDevSound->CustomInterface(KUidSampleBuffering)); sl@0: sl@0: if (ptr) sl@0: { sl@0: result = ptr->MmsbEnableSampleBufferingBeforePlayback(); // call method sl@0: sl@0: if (result == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback finished successfully")); sl@0: sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback failed with result %d"), result); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStep0071L() sl@0: { sl@0: iTestStepResult = EFail; sl@0: TInt result = KErrGeneral; sl@0: sl@0: INFO_PRINTF1(_L("SampleBuffering - MmsbDisableSampleBufferingBeforePlayback")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidSampleBufferingTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','1','2'); sl@0: #endif sl@0: sl@0: iTestStepResult = TestInitialize(testUID, EMMFStatePlaying); sl@0: sl@0: if (iTestStepResult != EPass) sl@0: { sl@0: INFO_PRINTF1(_L("DevSound failed to instantiate the test device")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: // reset the value as previous test is pass sl@0: iTestStepResult = EFail; sl@0: sl@0: // KUidMMMFSampleBuffering sl@0: MMMFSampleBuffering* ptr = static_cast (iMMFDevSound->CustomInterface(KUidSampleBuffering)); sl@0: sl@0: if (ptr) sl@0: { sl@0: sl@0: result = ptr->MmsbDisableSampleBufferingBeforePlayback(); // call method sl@0: sl@0: if (result == KErrNone) sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback finished successfully")); sl@0: sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback failed with result %d"), result); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStep0072L() sl@0: { sl@0: iTestStepResult = EFail; sl@0: TInt err; sl@0: sl@0: INFO_PRINTF1(_L("SampleBuffering - MmsbNotifyPlayStarted")); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidSampleBufferingTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','1','2'); sl@0: #endif sl@0: sl@0: iTestStepResult = TestInitialize(testUID, EMMFStatePlaying); sl@0: if (iTestStepResult != EPass) sl@0: { sl@0: INFO_PRINTF1(_L("DevSound failed to instantiate the test device")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: // reset the value as previous test is pass sl@0: iTestStepResult = EFail; sl@0: sl@0: // KUidMMMFSampleBuffering sl@0: MMMFSampleBuffering* ptr = static_cast (iMMFDevSound->CustomInterface(KUidSampleBuffering)); sl@0: sl@0: if (ptr) sl@0: { sl@0: CActiveListener* listener = new(ELeave)CActiveListener; sl@0: sl@0: listener->InitialiseActiveListener(); sl@0: sl@0: ptr->MmsbNotifyPlayStarted(listener->iStatus); // call method sl@0: sl@0: CActiveScheduler::Start(); sl@0: sl@0: err = listener->iStatus.Int(); sl@0: sl@0: delete listener; sl@0: sl@0: if (err == KErrNotSupported) sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted finished successfully")); sl@0: sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("MMMFSampleBuffering::MmsbNotifyPlayStarted failed with err %d"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TVerdict CTestStepCISampleBuffering::DoTestStep0073L() sl@0: { sl@0: iTestStepResult = EFail; sl@0: TInt err; sl@0: sl@0: INFO_PRINTF1(_L("SampleBuffering - MmsbCancelNotifyPlayStarted")); sl@0: sl@0: TCallBack callback(CTestStepCISampleBuffering::Callback, this); sl@0: sl@0: iTimer = CPeriodic::NewL(EPriorityNormal); sl@0: sl@0: // Here we use periodic timer to enable us to call MmsbCancelNotifyPlayStarted() after three sl@0: // seconds of issuing MmsbNotifyPlayStarted(). Ninety seconds is long enough to stop the timer sl@0: // before sending a second MmsbCancelNotifyPlayStarted() . sl@0: iTimer->Start(KAfterThreeSeconds, KEveryNinetySeconds, callback); sl@0: sl@0: //Initialize - with the UID of our test HwDevice sl@0: #ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND sl@0: TUid testUID = {KUidSampleBufferingTestDevice}; sl@0: #else sl@0: TFourCC testUID('T','0','1','2'); sl@0: #endif sl@0: sl@0: iTestStepResult = TestInitialize(testUID, EMMFStatePlaying); sl@0: sl@0: if (iTestStepResult != EPass) sl@0: { sl@0: INFO_PRINTF1(_L("DevSound failed to instantiate the test device")); sl@0: return EInconclusive; sl@0: } sl@0: sl@0: // reset the value as previous test is pass sl@0: iTestStepResult = EFail; sl@0: sl@0: // KUidMMMFSampleBuffering sl@0: iInterfacePtr = static_cast (iMMFDevSound->CustomInterface(KUidSampleBuffering)); sl@0: sl@0: if (iInterfacePtr) sl@0: { sl@0: CActiveListener* listener = new(ELeave) CActiveListener; sl@0: listener->InitialiseActiveListener(); sl@0: sl@0: iInterfacePtr->MmsbNotifyPlayStarted(listener->iStatus); // call method sl@0: sl@0: CActiveScheduler::Start(); sl@0: sl@0: err = listener->iStatus.Int(); sl@0: sl@0: delete listener; sl@0: sl@0: if (err == KErrCancel) sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering::MmsbCancelNotifyPlayStarted Successfully completed")); sl@0: sl@0: iTestStepResult = EPass; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Device didn't wait for the expected duration err %d"), err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("MMMFSampleBuffering failed to retrieve the interface")); sl@0: iTestStepResult = EInconclusive; sl@0: } sl@0: sl@0: delete iTimer; sl@0: sl@0: return iTestStepResult; sl@0: } sl@0: sl@0: sl@0: TInt CTestStepCISampleBuffering::Callback(TAny* aAny) sl@0: { sl@0: CTestStepCISampleBuffering* me = reinterpret_cast(aAny); sl@0: me->DoCallback(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CTestStepCISampleBuffering::DoCallback() sl@0: { sl@0: iTimer->Cancel(); sl@0: iInterfacePtr->MmsbCancelNotifyPlayStarted(); // call method sl@0: }