os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/audiobufferprefilltestdevice.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <ecom/implementationproxy.h>
17 #include <ecom/ecom.h>
19 #include "audiobufferprefilltestdevice.h"
20 #include "devsoundciutestdevices.hrh"
22 const TInt32 KTenSeconds = 10000000; // Ten seconds
25 CMMFSampleBuffering Implementation
27 CMMFSampleBuffering* CMMFSampleBuffering::NewL()
29 CMMFSampleBuffering* self = new(ELeave) CMMFSampleBuffering();
30 CleanupStack::PushL(self);
32 CleanupStack::Pop(self);
36 CMMFSampleBuffering::CMMFSampleBuffering() : CActive(0)
38 CActiveScheduler::Add(this);
41 void CMMFSampleBuffering::ConstructL()
43 User::LeaveIfError( iTimer.CreateLocal() );
46 CMMFSampleBuffering::~CMMFSampleBuffering()
52 //Actual implementation of method MmsbEnableSampleBufferingBeforePlayback
53 TInt CMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback()
58 //Actual implementation of method MmsbDisableSampleBufferingBeforePlayback
59 TInt CMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback()
64 //Actual implementation of method MmsbNotifyPlayStarted
65 void CMMFSampleBuffering::MmsbNotifyPlayStarted(TRequestStatus& aStatus)
67 // check not already active
70 iClientStatus = &aStatus;
71 *iClientStatus = KRequestPending;
73 iTimer.After(iStatus, KTenSeconds);
78 //Actual implementation of method MmsbCancelNotifyPlayStarted
79 void CMMFSampleBuffering::MmsbCancelNotifyPlayStarted()
84 //Actual implementation of method RunL
85 void CMMFSampleBuffering::RunL()
87 TRequestStatus* status = iClientStatus;
88 User::RequestComplete(status, KErrNotSupported);
91 //Actual implementation of method DoCancel
92 void CMMFSampleBuffering::DoCancel()
95 TRequestStatus* status = iClientStatus;
96 User::RequestComplete(status, KErrCancel);
101 CSampleBufferingTestDevice Implementation
103 CMMFHwDevice* CSampleBufferingTestDevice::NewL()
105 CSampleBufferingTestDevice* self=new(ELeave) CSampleBufferingTestDevice();
106 CleanupStack::PushL(self);
108 CleanupStack::Pop(self);
112 CSampleBufferingTestDevice::~CSampleBufferingTestDevice()
114 delete iSampleBuffering;
117 CSampleBufferingTestDevice::CSampleBufferingTestDevice()
121 void CSampleBufferingTestDevice::ConstructL()
125 TInt CSampleBufferingTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/)
130 TInt CSampleBufferingTestDevice::Stop()
135 TInt CSampleBufferingTestDevice::Pause()
140 TInt CSampleBufferingTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
145 TAny* CSampleBufferingTestDevice::CustomInterface(TUid aInterfaceId)
147 // Just return something non-NULL to keep the
148 // DevSound initialisation process happy
149 TAny* ret = static_cast<TAny*>(this);
151 // Now for the CIs we want to test...
152 if (aInterfaceId == KUidSampleBuffering)
154 if (!iSampleBuffering)
156 TRAPD(err, iSampleBuffering = CMMFSampleBuffering::NewL());
157 if (err == KErrNone && iSampleBuffering)
159 MMMFSampleBuffering* ptr = this;
160 ret = static_cast<TAny*>(ptr);
172 TInt CSampleBufferingTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
177 TInt CSampleBufferingTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
182 TInt CSampleBufferingTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
187 TInt CSampleBufferingTestDevice::StopAndDeleteCodec()
192 TInt CSampleBufferingTestDevice::DeleteCodec()
197 CMMFSwCodec& CSampleBufferingTestDevice::Codec()
202 TInt CSampleBufferingTestDevice::MmsbEnableSampleBufferingBeforePlayback()
204 TInt result = KErrBadHandle;
206 if (iSampleBuffering)
208 result = iSampleBuffering->MmsbEnableSampleBufferingBeforePlayback();
214 TInt CSampleBufferingTestDevice::MmsbDisableSampleBufferingBeforePlayback()
216 TInt result = KErrBadHandle;
218 if (iSampleBuffering)
220 result = iSampleBuffering->MmsbDisableSampleBufferingBeforePlayback();
226 void CSampleBufferingTestDevice::MmsbNotifyPlayStarted(TRequestStatus& aStatus)
228 if (iSampleBuffering)
230 iSampleBuffering->MmsbNotifyPlayStarted(aStatus);
234 void CSampleBufferingTestDevice::MmsbCancelNotifyPlayStarted()
236 if (iSampleBuffering)
238 iSampleBuffering->MmsbCancelNotifyPlayStarted();