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 sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #include "dspcontrolci.h" sl@0: sl@0: sl@0: // MUX // sl@0: sl@0: TInt CMMFDspControlMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: // attempt to open the interface link with the sl@0: // remote slave device sl@0: iRemoteHandle = -1; sl@0: TUid slaveId = {KMmfUidCustomInterfaceDspControlDeMux}; sl@0: sl@0: TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8); sl@0: if (handle >= 0) sl@0: { sl@0: iRemoteHandle = handle; sl@0: } sl@0: sl@0: return iRemoteHandle; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlMux::Release() sl@0: { sl@0: // close the slave device if it exists sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // we assume the slave is closed correctly sl@0: iUtility->CloseSlave(iRemoteHandle); sl@0: } sl@0: sl@0: TUid key = iKey; sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDspControlMux::NewL() sl@0: { sl@0: CMMFDspControlMux* self = new (ELeave) CMMFDspControlMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: TAny* CMMFDspControlMux::CustomInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: MMMFDSPControl* interface = this; sl@0: return interface; sl@0: } sl@0: sl@0: sl@0: CMMFDspControlMux::CMMFDspControlMux() : sl@0: iRemoteHandle(-1) sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFDspControlMux::~CMMFDspControlMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: // from MMMFDSPControl sl@0: TInt CMMFDspControlMux::MmdspcGetAudioPlaybackInfo (TInt64& aSamplesPlayed, sl@0: TInt64& aSystemTime, sl@0: TUint& aBytesDecoderConsumed, sl@0: TUint& aBytesDecoderDecoded) sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // holds the returned value sl@0: TPckgBuf returnVal; sl@0: sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, sl@0: EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo, sl@0: KNullDesC8, sl@0: returnVal); sl@0: sl@0: // assign returned value to the individual parameter. Do nothing if there is an error sl@0: if(result == KErrNone) sl@0: { sl@0: aSamplesPlayed = returnVal().iSamplesPlayed; sl@0: aSystemTime = returnVal().iSystemTime; sl@0: aBytesDecoderConsumed = returnVal().iBytesDecoderConsumed; sl@0: aBytesDecoderDecoded = returnVal().iBytesDecoderDecoded; sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MMMFDSPControl sl@0: TInt CMMFDspControlMux::MmdspcAcceptRecordBuffersInvalidFollowingStop() sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommand(iRemoteHandle, sl@0: EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // from MMMFDSPControl sl@0: TInt CMMFDspControlMux::MmdspcAcceptPlaybackBuffersInvalidFollowingStop() sl@0: { sl@0: TInt result = KErrBadHandle; sl@0: sl@0: if (iRemoteHandle > 0) sl@0: { sl@0: // any return code other than zero is an error sl@0: result = iUtility->SendSlaveSyncCommand(iRemoteHandle, sl@0: EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop, sl@0: KNullDesC8); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: sl@0: // DEMUX // sl@0: sl@0: TInt CMMFDspControlDeMux::OpenInterface(TUid /*aInterfaceId*/) sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::Release() sl@0: { sl@0: TUid key = iKey; sl@0: sl@0: delete this; sl@0: sl@0: // tell ECom to destroy us sl@0: REComSession::DestroyedImplementation(key); sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::PassDestructorKey(TUid aDestructorKey) sl@0: { sl@0: // store the destructor key sl@0: iKey = aDestructorKey; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget) sl@0: { sl@0: iTarget = aTarget; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility) sl@0: { sl@0: // store a pointer to the utility sl@0: iUtility = aCustomUtility; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::RefreshL() sl@0: { sl@0: // refetch the DSP Control custom interface if we already have a target sl@0: if (iTarget) sl@0: { sl@0: iInterfaceDspControl = static_cast (iTarget->CustomInterface(KUidDSPControl)); sl@0: sl@0: if (!iInterfaceDspControl) sl@0: { sl@0: iInterfaceDspControl = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDspControlDeMux::NewL() sl@0: { sl@0: CMMFDspControlDeMux* self = new (ELeave) CMMFDspControlDeMux; sl@0: return self; sl@0: } sl@0: sl@0: sl@0: CMMFDspControlDeMux::CMMFDspControlDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: CMMFDspControlDeMux::~CMMFDspControlDeMux() sl@0: { sl@0: } sl@0: sl@0: sl@0: TInt CMMFDspControlDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/) sl@0: { sl@0: // fetch the DSP Control Hw Device custom interface sl@0: iInterfaceDspControl = static_cast (iTarget->CustomInterface(KUidDSPControl)); sl@0: sl@0: if (!iInterfaceDspControl) sl@0: { sl@0: iInterfaceDspControl = NULL; sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::DoCloseSlaveL(TInt /*aHandle*/) sl@0: { sl@0: // nothing to do sl@0: } sl@0: sl@0: sl@0: // original RMessage is supplied so that remote demux plugin can extract necessary details sl@0: // using DeMux utility sl@0: TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrGeneral; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop: sl@0: { sl@0: result = DoMmdspcAcceptRecordBuffersInvalidFollowingStopL(); sl@0: sl@0: break; sl@0: } sl@0: case EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop: sl@0: { sl@0: result = DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL(); sl@0: sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // original RMessage is supplied so that remote demux plugin can extract necessary details sl@0: // using DeMux utility sl@0: TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) sl@0: { sl@0: TMMFDevSoundCIMessageData data; sl@0: TInt result = KErrGeneral; sl@0: sl@0: // decode message sl@0: iUtility->GetSyncMessageDataL(aMessage, data); sl@0: sl@0: switch (data.iCommand) sl@0: { sl@0: case EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo: sl@0: { sl@0: TPckgBuf pckData; sl@0: sl@0: iUtility->ReadFromInputDesL(aMessage, &pckData); sl@0: sl@0: result = DoMmdspcGetAudioPlaybackInfoL(pckData().iSamplesPlayed, sl@0: pckData().iSystemTime, sl@0: pckData().iBytesDecoderConsumed, sl@0: pckData().iBytesDecoderDecoded); sl@0: sl@0: TPckgBuf des(pckData()); sl@0: iUtility->WriteToOutputDesL(aMessage, des); sl@0: sl@0: break; sl@0: } sl@0: default: sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: void CMMFDspControlDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/) sl@0: { sl@0: // not used in this interface sl@0: } sl@0: sl@0: sl@0: TInt CMMFDspControlDeMux::DoMmdspcAcceptRecordBuffersInvalidFollowingStopL() sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceDspControl) sl@0: { sl@0: result = iInterfaceDspControl->MmdspcAcceptRecordBuffersInvalidFollowingStop(); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: TInt CMMFDspControlDeMux::DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL() sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceDspControl) sl@0: { sl@0: result = iInterfaceDspControl->MmdspcAcceptPlaybackBuffersInvalidFollowingStop(); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: TInt CMMFDspControlDeMux::DoMmdspcGetAudioPlaybackInfoL(TInt64& aSamplesPlayed, sl@0: TInt64& aSystemTime, sl@0: TUint& aBytesDecoderConsumed, sl@0: TUint& aBytesDecoderDecoded) sl@0: { sl@0: TInt result = KErrNotFound; sl@0: sl@0: if (iInterfaceDspControl) sl@0: { sl@0: result = iInterfaceDspControl->MmdspcGetAudioPlaybackInfo(aSamplesPlayed, sl@0: aSystemTime, sl@0: aBytesDecoderConsumed, sl@0: aBytesDecoderDecoded); sl@0: } sl@0: sl@0: return result; sl@0: } sl@0: sl@0: sl@0: // sl@0: // ImplementationTable sl@0: // sl@0: const TImplementationProxy ImplementationTable[] = sl@0: { sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlMux, CMMFDspControlMux::NewL), sl@0: IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlDeMux, CMMFDspControlDeMux::NewL), sl@0: }; sl@0: sl@0: // sl@0: // ImplementationGroupProxy sl@0: // sl@0: EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) sl@0: { sl@0: aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); sl@0: sl@0: return ImplementationTable; sl@0: } sl@0: