First public contribution.
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/implementationproxy.h>
18 #include <ecom/ecom.h>
21 #include "dspcontrolci.h"
26 TInt CMMFDspControlMux::OpenInterface(TUid /*aInterfaceId*/)
28 // attempt to open the interface link with the
29 // remote slave device
31 TUid slaveId = {KMmfUidCustomInterfaceDspControlDeMux};
33 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
36 iRemoteHandle = handle;
43 void CMMFDspControlMux::Release()
45 // close the slave device if it exists
46 if (iRemoteHandle > 0)
48 // we assume the slave is closed correctly
49 iUtility->CloseSlave(iRemoteHandle);
55 // tell ECom to destroy us
56 REComSession::DestroyedImplementation(key);
60 void CMMFDspControlMux::PassDestructorKey(TUid aDestructorKey)
62 // store the destructor key
63 iKey = aDestructorKey;
67 void CMMFDspControlMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
69 // store a pointer to the utility
70 iUtility = aCustomUtility;
74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDspControlMux::NewL()
76 CMMFDspControlMux* self = new (ELeave) CMMFDspControlMux;
81 TAny* CMMFDspControlMux::CustomInterface(TUid /*aInterfaceId*/)
83 MMMFDSPControl* interface = this;
88 CMMFDspControlMux::CMMFDspControlMux() :
94 CMMFDspControlMux::~CMMFDspControlMux()
99 // from MMMFDSPControl
100 TInt CMMFDspControlMux::MmdspcGetAudioPlaybackInfo (TInt64& aSamplesPlayed,
102 TUint& aBytesDecoderConsumed,
103 TUint& aBytesDecoderDecoded)
105 TInt result = KErrBadHandle;
107 if (iRemoteHandle > 0)
109 // holds the returned value
110 TPckgBuf<TAudioPlaybackInfo> returnVal;
112 // any return code other than zero is an error
113 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
114 EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo,
118 // assign returned value to the individual parameter. Do nothing if there is an error
119 if(result == KErrNone)
121 aSamplesPlayed = returnVal().iSamplesPlayed;
122 aSystemTime = returnVal().iSystemTime;
123 aBytesDecoderConsumed = returnVal().iBytesDecoderConsumed;
124 aBytesDecoderDecoded = returnVal().iBytesDecoderDecoded;
132 // from MMMFDSPControl
133 TInt CMMFDspControlMux::MmdspcAcceptRecordBuffersInvalidFollowingStop()
135 TInt result = KErrBadHandle;
137 if (iRemoteHandle > 0)
139 // any return code other than zero is an error
140 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
141 EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop,
149 // from MMMFDSPControl
150 TInt CMMFDspControlMux::MmdspcAcceptPlaybackBuffersInvalidFollowingStop()
152 TInt result = KErrBadHandle;
154 if (iRemoteHandle > 0)
156 // any return code other than zero is an error
157 result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
158 EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop,
169 TInt CMMFDspControlDeMux::OpenInterface(TUid /*aInterfaceId*/)
175 void CMMFDspControlDeMux::Release()
181 // tell ECom to destroy us
182 REComSession::DestroyedImplementation(key);
186 void CMMFDspControlDeMux::PassDestructorKey(TUid aDestructorKey)
188 // store the destructor key
189 iKey = aDestructorKey;
193 void CMMFDspControlDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
199 void CMMFDspControlDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
201 // store a pointer to the utility
202 iUtility = aCustomUtility;
206 void CMMFDspControlDeMux::RefreshL()
208 // refetch the DSP Control custom interface if we already have a target
211 iInterfaceDspControl = static_cast <MMMFDSPControl*> (iTarget->CustomInterface(KUidDSPControl));
213 if (!iInterfaceDspControl)
215 iInterfaceDspControl = NULL;
216 User::Leave(KErrNotSupported);
222 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDspControlDeMux::NewL()
224 CMMFDspControlDeMux* self = new (ELeave) CMMFDspControlDeMux;
229 CMMFDspControlDeMux::CMMFDspControlDeMux()
234 CMMFDspControlDeMux::~CMMFDspControlDeMux()
239 TInt CMMFDspControlDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
241 // fetch the DSP Control Hw Device custom interface
242 iInterfaceDspControl = static_cast<MMMFDSPControl*> (iTarget->CustomInterface(KUidDSPControl));
244 if (!iInterfaceDspControl)
246 iInterfaceDspControl = NULL;
247 User::Leave(KErrNotSupported);
254 void CMMFDspControlDeMux::DoCloseSlaveL(TInt /*aHandle*/)
260 // original RMessage is supplied so that remote demux plugin can extract necessary details
261 // using DeMux utility
262 TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
264 TMMFDevSoundCIMessageData data;
265 TInt result = KErrGeneral;
268 iUtility->GetSyncMessageDataL(aMessage, data);
270 switch (data.iCommand)
272 case EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop:
274 result = DoMmdspcAcceptRecordBuffersInvalidFollowingStopL();
278 case EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop:
280 result = DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL();
286 User::Leave(KErrNotSupported);
294 // original RMessage is supplied so that remote demux plugin can extract necessary details
295 // using DeMux utility
296 TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
298 TMMFDevSoundCIMessageData data;
299 TInt result = KErrGeneral;
302 iUtility->GetSyncMessageDataL(aMessage, data);
304 switch (data.iCommand)
306 case EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo:
308 TPckgBuf<TAudioPlaybackInfo> pckData;
310 iUtility->ReadFromInputDesL(aMessage, &pckData);
312 result = DoMmdspcGetAudioPlaybackInfoL(pckData().iSamplesPlayed,
313 pckData().iSystemTime,
314 pckData().iBytesDecoderConsumed,
315 pckData().iBytesDecoderDecoded);
317 TPckgBuf<TAudioPlaybackInfo> des(pckData());
318 iUtility->WriteToOutputDesL(aMessage, des);
324 User::Leave(KErrNotSupported);
332 void CMMFDspControlDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
334 // not used in this interface
338 void CMMFDspControlDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
340 // not used in this interface
344 TInt CMMFDspControlDeMux::DoMmdspcAcceptRecordBuffersInvalidFollowingStopL()
346 TInt result = KErrNotFound;
348 if (iInterfaceDspControl)
350 result = iInterfaceDspControl->MmdspcAcceptRecordBuffersInvalidFollowingStop();
357 TInt CMMFDspControlDeMux::DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL()
359 TInt result = KErrNotFound;
361 if (iInterfaceDspControl)
363 result = iInterfaceDspControl->MmdspcAcceptPlaybackBuffersInvalidFollowingStop();
370 TInt CMMFDspControlDeMux::DoMmdspcGetAudioPlaybackInfoL(TInt64& aSamplesPlayed,
372 TUint& aBytesDecoderConsumed,
373 TUint& aBytesDecoderDecoded)
375 TInt result = KErrNotFound;
377 if (iInterfaceDspControl)
379 result = iInterfaceDspControl->MmdspcGetAudioPlaybackInfo(aSamplesPlayed,
381 aBytesDecoderConsumed,
382 aBytesDecoderDecoded);
390 // ImplementationTable
392 const TImplementationProxy ImplementationTable[] =
394 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlMux, CMMFDspControlMux::NewL),
395 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlDeMux, CMMFDspControlDeMux::NewL),
399 // ImplementationGroupProxy
401 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
403 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
405 return ImplementationTable;