os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/MMFDevSoundCIMuxDeMuxPluginImp.cpp
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.
16 #include <ecom/implementationproxy.h>
17 #include <ecom/ecom.h>
20 #include "devsoundciutestdevices.hrh"
21 #include "MMFDevSoundCIMuxDeMuxPluginImp.h"
27 TInt CMMFDevSoundCIMuxPluginImp::OpenInterface(TUid /*aInterfaceId*/)
29 // attempt to open the interface link with the
30 // remote slave device
32 TUid slaveId = {KUidMmfDevSoundCustomInterfaceDeMuxPlugin};
34 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
37 iRemoteHandle = handle;
44 void CMMFDevSoundCIMuxPluginImp::Release()
46 // close the slave device if it exists
47 if (iRemoteHandle > 0)
49 // we assume the slave is closed correctly
50 iUtility->CloseSlave(iRemoteHandle);
56 // tell ECom to destroy us
57 REComSession::DestroyedImplementation(key);
61 void CMMFDevSoundCIMuxPluginImp::PassDestructorKey(TUid aDestructorKey)
63 // store the destructor key
64 iKey = aDestructorKey;
68 void CMMFDevSoundCIMuxPluginImp::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
70 // store a pointer to the the MMFDevSoundCustomMuxUtility class
71 iUtility = aCustomUtility;
75 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDevSoundCIMuxPluginImp::NewL()
77 CMMFDevSoundCIMuxPluginImp* self = new (ELeave) CMMFDevSoundCIMuxPluginImp;
82 TAny* CMMFDevSoundCIMuxPluginImp::CustomInterface(TUid /*aInterfaceId*/)
84 MMMFDevSoundCIMuxPluginInterface* interface = this;
89 CMMFDevSoundCIMuxPluginImp::CMMFDevSoundCIMuxPluginImp()
94 CMMFDevSoundCIMuxPluginImp::~CMMFDevSoundCIMuxPluginImp()
99 TInt CMMFDevSoundCIMuxPluginImp::DevSoundCIMuxStopHeapFail()
103 if (iRemoteHandle > 0)
105 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
106 EMMFDevSoundCIMuxDemuxStopHeapFail,
113 TInt CMMFDevSoundCIMuxPluginImp::DevSoundCIMuxCauseHeapFail(TInt aFailCount)
117 if (iRemoteHandle > 0)
119 TPckgBuf<TInt> failCount(aFailCount);
120 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
121 EMMFDevSoundCIMuxDemuxCauseHeapFail,
127 TInt CMMFDevSoundCIMuxPluginImp::DevSoundCIMuxCheckHeapFail()
130 TPckgBuf<TInt> responsePckg;
132 if (iRemoteHandle > 0)
134 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
135 EMMFDevSoundCIMuxDemuxCheckHeapFail,
140 User::LeaveIfError(result);
141 return responsePckg();
147 TInt CMMFDevSoundCIDemuxPluginImp::OpenInterface(TUid /*aInterfaceId*/)
153 void CMMFDevSoundCIDemuxPluginImp::Release()
159 // tell ECom to destroy us
160 REComSession::DestroyedImplementation(key);
164 void CMMFDevSoundCIDemuxPluginImp::PassDestructorKey(TUid aDestructorKey)
166 // store the destructor key
167 iKey = aDestructorKey;
171 void CMMFDevSoundCIDemuxPluginImp::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
177 void CMMFDevSoundCIDemuxPluginImp::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
179 // store a pointer to the MMFDevSoundCustomDeMuxUtility class
180 iUtility = aCustomUtility;
184 void CMMFDevSoundCIDemuxPluginImp::RefreshL()
186 // Nothing to do in this implementation
190 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDevSoundCIDemuxPluginImp::NewL()
192 CMMFDevSoundCIDemuxPluginImp* self = new (ELeave) CMMFDevSoundCIDemuxPluginImp;
197 CMMFDevSoundCIDemuxPluginImp::CMMFDevSoundCIDemuxPluginImp()
202 CMMFDevSoundCIDemuxPluginImp::~CMMFDevSoundCIDemuxPluginImp()
204 // Nothing to do in this implementation
208 TInt CMMFDevSoundCIDemuxPluginImp::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
210 // Nothing to do in this implementation
215 void CMMFDevSoundCIDemuxPluginImp::DoCloseSlaveL(TInt /*aHandle*/)
217 // Nothing to do in this implementation
220 TInt CMMFDevSoundCIDemuxPluginImp::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
222 TMMFDevSoundCIMessageData data;
223 TInt result = KErrNotSupported;
226 iUtility->GetSyncMessageDataL(aMessage, data);
228 switch (data.iCommand)
230 case EMMFDevSoundCIMuxDemuxCauseHeapFail:
233 TPckgBuf<TInt> failCount; //Create an empty TPckgBuf<INT TYPE> to be empty
234 iUtility->ReadFromInputDesL(aMessage, &failCount); //readFromInputDesL treats this as a descriptor and populates it
235 User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext, failCount());
238 case EMMFDevSoundCIMuxDemuxStopHeapFail:
241 User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext,NULL);
246 User::Leave(KErrNotSupported);
253 TInt CMMFDevSoundCIDemuxPluginImp::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) //This method returns an error to Client Side
255 TMMFDevSoundCIMessageData data;
256 TInt result = KErrNotSupported;
259 iUtility->GetSyncMessageDataL(aMessage, data);
261 switch (data.iCommand)
263 case EMMFDevSoundCIMuxDemuxCheckHeapFail:
266 TPckgBuf<TBool> failCheck;
267 TAny *testAlloc = User::Alloc(1);
268 if ( testAlloc == NULL )
271 User::__DbgSetAllocFail(RHeap::EUser,RHeap::EFailNext,NULL);
276 User::Free(testAlloc);
278 iUtility->WriteToOutputDesL(aMessage, failCheck);
283 User::Leave(KErrNotSupported);
290 void CMMFDevSoundCIDemuxPluginImp::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
292 // not used in this interface
296 void CMMFDevSoundCIDemuxPluginImp::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
298 // not used in this interface