os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/audiobufferprefilltestdevice.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/audiobufferprefilltestdevice.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,240 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <ecom/implementationproxy.h>
1.20 +#include <ecom/ecom.h>
1.21 +#include <f32file.h>
1.22 +#include "audiobufferprefilltestdevice.h"
1.23 +#include "devsoundciutestdevices.hrh"
1.24 +
1.25 +const TInt32 KTenSeconds = 10000000; // Ten seconds
1.26 +
1.27 +/*
1.28 +CMMFSampleBuffering Implementation
1.29 +*/
1.30 +CMMFSampleBuffering* CMMFSampleBuffering::NewL()
1.31 + {
1.32 + CMMFSampleBuffering* self = new(ELeave) CMMFSampleBuffering();
1.33 + CleanupStack::PushL(self);
1.34 + self->ConstructL();
1.35 + CleanupStack::Pop(self);
1.36 + return self;
1.37 + }
1.38 +
1.39 +CMMFSampleBuffering::CMMFSampleBuffering() : CActive(0)
1.40 + {
1.41 + CActiveScheduler::Add(this);
1.42 + }
1.43 +
1.44 +void CMMFSampleBuffering::ConstructL()
1.45 + {
1.46 + User::LeaveIfError( iTimer.CreateLocal() );
1.47 + }
1.48 +
1.49 +CMMFSampleBuffering::~CMMFSampleBuffering()
1.50 + {
1.51 + iTimer.Close();
1.52 + Cancel();
1.53 + }
1.54 +
1.55 +//Actual implementation of method MmsbEnableSampleBufferingBeforePlayback
1.56 +TInt CMMFSampleBuffering::MmsbEnableSampleBufferingBeforePlayback()
1.57 + {
1.58 + return KErrNone;
1.59 + }
1.60 +
1.61 +//Actual implementation of method MmsbDisableSampleBufferingBeforePlayback
1.62 +TInt CMMFSampleBuffering::MmsbDisableSampleBufferingBeforePlayback()
1.63 + {
1.64 + return KErrNone;
1.65 + }
1.66 +
1.67 +//Actual implementation of method MmsbNotifyPlayStarted
1.68 +void CMMFSampleBuffering::MmsbNotifyPlayStarted(TRequestStatus& aStatus)
1.69 + {
1.70 + // check not already active
1.71 + ASSERT(!IsActive());
1.72 +
1.73 + iClientStatus = &aStatus;
1.74 + *iClientStatus = KRequestPending;
1.75 +
1.76 + iTimer.After(iStatus, KTenSeconds);
1.77 +
1.78 + SetActive();
1.79 + }
1.80 +
1.81 +//Actual implementation of method MmsbCancelNotifyPlayStarted
1.82 +void CMMFSampleBuffering::MmsbCancelNotifyPlayStarted()
1.83 + {
1.84 + CActive::Cancel();
1.85 + }
1.86 +
1.87 +//Actual implementation of method RunL
1.88 +void CMMFSampleBuffering::RunL()
1.89 + {
1.90 + TRequestStatus* status = iClientStatus;
1.91 + User::RequestComplete(status, KErrNotSupported);
1.92 + }
1.93 +
1.94 +//Actual implementation of method DoCancel
1.95 +void CMMFSampleBuffering::DoCancel()
1.96 + {
1.97 + iTimer.Cancel();
1.98 + TRequestStatus* status = iClientStatus;
1.99 + User::RequestComplete(status, KErrCancel);
1.100 + }
1.101 +
1.102 +
1.103 +/*
1.104 +CSampleBufferingTestDevice Implementation
1.105 +*/
1.106 +CMMFHwDevice* CSampleBufferingTestDevice::NewL()
1.107 + {
1.108 + CSampleBufferingTestDevice* self=new(ELeave) CSampleBufferingTestDevice();
1.109 + CleanupStack::PushL(self);
1.110 + self->ConstructL();
1.111 + CleanupStack::Pop(self);
1.112 + return self;
1.113 + }
1.114 +
1.115 +CSampleBufferingTestDevice::~CSampleBufferingTestDevice()
1.116 + {
1.117 + delete iSampleBuffering;
1.118 + }
1.119 +
1.120 +CSampleBufferingTestDevice::CSampleBufferingTestDevice()
1.121 + {
1.122 + }
1.123 +
1.124 +void CSampleBufferingTestDevice::ConstructL()
1.125 + {
1.126 + }
1.127 +
1.128 +TInt CSampleBufferingTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/)
1.129 + {
1.130 + return 0;
1.131 + }
1.132 +
1.133 +TInt CSampleBufferingTestDevice::Stop()
1.134 + {
1.135 + return 0;
1.136 + }
1.137 +
1.138 +TInt CSampleBufferingTestDevice::Pause()
1.139 + {
1.140 + return 0;
1.141 + }
1.142 +
1.143 +TInt CSampleBufferingTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
1.144 + {
1.145 + return 0;
1.146 + }
1.147 +
1.148 +TAny* CSampleBufferingTestDevice::CustomInterface(TUid aInterfaceId)
1.149 + {
1.150 + // Just return something non-NULL to keep the
1.151 + // DevSound initialisation process happy
1.152 + TAny* ret = static_cast<TAny*>(this);
1.153 +
1.154 + // Now for the CIs we want to test...
1.155 + if (aInterfaceId == KUidSampleBuffering)
1.156 + {
1.157 + if (!iSampleBuffering)
1.158 + {
1.159 + TRAPD(err, iSampleBuffering = CMMFSampleBuffering::NewL());
1.160 + if (err == KErrNone && iSampleBuffering)
1.161 + {
1.162 + MMMFSampleBuffering* ptr = this;
1.163 + ret = static_cast<TAny*>(ptr);
1.164 + }
1.165 + else
1.166 + {
1.167 + ret = NULL;
1.168 + }
1.169 + }
1.170 + }
1.171 +
1.172 + return ret;
1.173 + }
1.174 +
1.175 +TInt CSampleBufferingTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
1.176 + {
1.177 + return 0;
1.178 + }
1.179 +
1.180 +TInt CSampleBufferingTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
1.181 + {
1.182 + return 0;
1.183 + }
1.184 +
1.185 +TInt CSampleBufferingTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
1.186 + {
1.187 + return 0;
1.188 + }
1.189 +
1.190 +TInt CSampleBufferingTestDevice::StopAndDeleteCodec()
1.191 + {
1.192 + return 0;
1.193 + }
1.194 +
1.195 +TInt CSampleBufferingTestDevice::DeleteCodec()
1.196 + {
1.197 + return 0;
1.198 + }
1.199 +
1.200 +CMMFSwCodec& CSampleBufferingTestDevice::Codec()
1.201 + {
1.202 + return *iCodec;
1.203 + }
1.204 +
1.205 +TInt CSampleBufferingTestDevice::MmsbEnableSampleBufferingBeforePlayback()
1.206 + {
1.207 + TInt result = KErrBadHandle;
1.208 +
1.209 + if (iSampleBuffering)
1.210 + {
1.211 + result = iSampleBuffering->MmsbEnableSampleBufferingBeforePlayback();
1.212 + }
1.213 +
1.214 + return result;
1.215 + }
1.216 +
1.217 +TInt CSampleBufferingTestDevice::MmsbDisableSampleBufferingBeforePlayback()
1.218 + {
1.219 + TInt result = KErrBadHandle;
1.220 +
1.221 + if (iSampleBuffering)
1.222 + {
1.223 + result = iSampleBuffering->MmsbDisableSampleBufferingBeforePlayback();
1.224 + }
1.225 +
1.226 + return result;
1.227 + }
1.228 +
1.229 +void CSampleBufferingTestDevice::MmsbNotifyPlayStarted(TRequestStatus& aStatus)
1.230 + {
1.231 + if (iSampleBuffering)
1.232 + {
1.233 + iSampleBuffering->MmsbNotifyPlayStarted(aStatus);
1.234 + }
1.235 + }
1.236 +
1.237 +void CSampleBufferingTestDevice::MmsbCancelNotifyPlayStarted()
1.238 + {
1.239 + if (iSampleBuffering)
1.240 + {
1.241 + iSampleBuffering->MmsbCancelNotifyPlayStarted();
1.242 + }
1.243 + }