1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/dspcontrolci.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,407 @@
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/implementationproxy.h>
1.21 +#include <ecom/ecom.h>
1.22 +#include <s32mem.h>
1.23 +
1.24 +#include "dspcontrolci.h"
1.25 +
1.26 +
1.27 +// MUX //
1.28 +
1.29 +TInt CMMFDspControlMux::OpenInterface(TUid /*aInterfaceId*/)
1.30 + {
1.31 + // attempt to open the interface link with the
1.32 + // remote slave device
1.33 + iRemoteHandle = -1;
1.34 + TUid slaveId = {KMmfUidCustomInterfaceDspControlDeMux};
1.35 +
1.36 + TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
1.37 + if (handle >= 0)
1.38 + {
1.39 + iRemoteHandle = handle;
1.40 + }
1.41 +
1.42 + return iRemoteHandle;
1.43 + }
1.44 +
1.45 +
1.46 +void CMMFDspControlMux::Release()
1.47 + {
1.48 + // close the slave device if it exists
1.49 + if (iRemoteHandle > 0)
1.50 + {
1.51 + // we assume the slave is closed correctly
1.52 + iUtility->CloseSlave(iRemoteHandle);
1.53 + }
1.54 +
1.55 + TUid key = iKey;
1.56 + delete this;
1.57 +
1.58 + // tell ECom to destroy us
1.59 + REComSession::DestroyedImplementation(key);
1.60 + }
1.61 +
1.62 +
1.63 +void CMMFDspControlMux::PassDestructorKey(TUid aDestructorKey)
1.64 + {
1.65 + // store the destructor key
1.66 + iKey = aDestructorKey;
1.67 + }
1.68 +
1.69 +
1.70 +void CMMFDspControlMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
1.71 + {
1.72 + // store a pointer to the utility
1.73 + iUtility = aCustomUtility;
1.74 + }
1.75 +
1.76 +
1.77 +MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDspControlMux::NewL()
1.78 + {
1.79 + CMMFDspControlMux* self = new (ELeave) CMMFDspControlMux;
1.80 + return self;
1.81 + }
1.82 +
1.83 +
1.84 +TAny* CMMFDspControlMux::CustomInterface(TUid /*aInterfaceId*/)
1.85 + {
1.86 + MMMFDSPControl* interface = this;
1.87 + return interface;
1.88 + }
1.89 +
1.90 +
1.91 +CMMFDspControlMux::CMMFDspControlMux() :
1.92 + iRemoteHandle(-1)
1.93 + {
1.94 + }
1.95 +
1.96 +
1.97 +CMMFDspControlMux::~CMMFDspControlMux()
1.98 + {
1.99 + }
1.100 +
1.101 +
1.102 +// from MMMFDSPControl
1.103 +TInt CMMFDspControlMux::MmdspcGetAudioPlaybackInfo (TInt64& aSamplesPlayed,
1.104 + TInt64& aSystemTime,
1.105 + TUint& aBytesDecoderConsumed,
1.106 + TUint& aBytesDecoderDecoded)
1.107 + {
1.108 + TInt result = KErrBadHandle;
1.109 +
1.110 + if (iRemoteHandle > 0)
1.111 + {
1.112 + // holds the returned value
1.113 + TPckgBuf<TAudioPlaybackInfo> returnVal;
1.114 +
1.115 + // any return code other than zero is an error
1.116 + result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle,
1.117 + EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo,
1.118 + KNullDesC8,
1.119 + returnVal);
1.120 +
1.121 + // assign returned value to the individual parameter. Do nothing if there is an error
1.122 + if(result == KErrNone)
1.123 + {
1.124 + aSamplesPlayed = returnVal().iSamplesPlayed;
1.125 + aSystemTime = returnVal().iSystemTime;
1.126 + aBytesDecoderConsumed = returnVal().iBytesDecoderConsumed;
1.127 + aBytesDecoderDecoded = returnVal().iBytesDecoderDecoded;
1.128 + }
1.129 + }
1.130 +
1.131 + return result;
1.132 + }
1.133 +
1.134 +
1.135 +// from MMMFDSPControl
1.136 +TInt CMMFDspControlMux::MmdspcAcceptRecordBuffersInvalidFollowingStop()
1.137 + {
1.138 + TInt result = KErrBadHandle;
1.139 +
1.140 + if (iRemoteHandle > 0)
1.141 + {
1.142 + // any return code other than zero is an error
1.143 + result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
1.144 + EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop,
1.145 + KNullDesC8);
1.146 + }
1.147 +
1.148 + return result;
1.149 + }
1.150 +
1.151 +
1.152 +// from MMMFDSPControl
1.153 +TInt CMMFDspControlMux::MmdspcAcceptPlaybackBuffersInvalidFollowingStop()
1.154 + {
1.155 + TInt result = KErrBadHandle;
1.156 +
1.157 + if (iRemoteHandle > 0)
1.158 + {
1.159 + // any return code other than zero is an error
1.160 + result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
1.161 + EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop,
1.162 + KNullDesC8);
1.163 + }
1.164 +
1.165 + return result;
1.166 + }
1.167 +
1.168 +
1.169 +
1.170 +// DEMUX //
1.171 +
1.172 +TInt CMMFDspControlDeMux::OpenInterface(TUid /*aInterfaceId*/)
1.173 + {
1.174 + return KErrNone;
1.175 + }
1.176 +
1.177 +
1.178 +void CMMFDspControlDeMux::Release()
1.179 + {
1.180 + TUid key = iKey;
1.181 +
1.182 + delete this;
1.183 +
1.184 + // tell ECom to destroy us
1.185 + REComSession::DestroyedImplementation(key);
1.186 + }
1.187 +
1.188 +
1.189 +void CMMFDspControlDeMux::PassDestructorKey(TUid aDestructorKey)
1.190 + {
1.191 + // store the destructor key
1.192 + iKey = aDestructorKey;
1.193 + }
1.194 +
1.195 +
1.196 +void CMMFDspControlDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
1.197 + {
1.198 + iTarget = aTarget;
1.199 + }
1.200 +
1.201 +
1.202 +void CMMFDspControlDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
1.203 + {
1.204 + // store a pointer to the utility
1.205 + iUtility = aCustomUtility;
1.206 + }
1.207 +
1.208 +
1.209 +void CMMFDspControlDeMux::RefreshL()
1.210 + {
1.211 + // refetch the DSP Control custom interface if we already have a target
1.212 + if (iTarget)
1.213 + {
1.214 + iInterfaceDspControl = static_cast <MMMFDSPControl*> (iTarget->CustomInterface(KUidDSPControl));
1.215 +
1.216 + if (!iInterfaceDspControl)
1.217 + {
1.218 + iInterfaceDspControl = NULL;
1.219 + User::Leave(KErrNotSupported);
1.220 + }
1.221 + }
1.222 + }
1.223 +
1.224 +
1.225 +MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDspControlDeMux::NewL()
1.226 + {
1.227 + CMMFDspControlDeMux* self = new (ELeave) CMMFDspControlDeMux;
1.228 + return self;
1.229 + }
1.230 +
1.231 +
1.232 +CMMFDspControlDeMux::CMMFDspControlDeMux()
1.233 + {
1.234 + }
1.235 +
1.236 +
1.237 +CMMFDspControlDeMux::~CMMFDspControlDeMux()
1.238 + {
1.239 + }
1.240 +
1.241 +
1.242 +TInt CMMFDspControlDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
1.243 + {
1.244 + // fetch the DSP Control Hw Device custom interface
1.245 + iInterfaceDspControl = static_cast<MMMFDSPControl*> (iTarget->CustomInterface(KUidDSPControl));
1.246 +
1.247 + if (!iInterfaceDspControl)
1.248 + {
1.249 + iInterfaceDspControl = NULL;
1.250 + User::Leave(KErrNotSupported);
1.251 + }
1.252 +
1.253 + return KErrNone;
1.254 + }
1.255 +
1.256 +
1.257 +void CMMFDspControlDeMux::DoCloseSlaveL(TInt /*aHandle*/)
1.258 + {
1.259 + // nothing to do
1.260 + }
1.261 +
1.262 +
1.263 +// original RMessage is supplied so that remote demux plugin can extract necessary details
1.264 +// using DeMux utility
1.265 +TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
1.266 + {
1.267 + TMMFDevSoundCIMessageData data;
1.268 + TInt result = KErrGeneral;
1.269 +
1.270 + // decode message
1.271 + iUtility->GetSyncMessageDataL(aMessage, data);
1.272 +
1.273 + switch (data.iCommand)
1.274 + {
1.275 + case EMMFDevSoundCIDspCtrlAcceptRecordBuffersInvalidFollowingStop:
1.276 + {
1.277 + result = DoMmdspcAcceptRecordBuffersInvalidFollowingStopL();
1.278 +
1.279 + break;
1.280 + }
1.281 + case EMMFDevSoundCIDspCtrlAcceptPlaybackBuffersInvalidFollowingStop:
1.282 + {
1.283 + result = DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL();
1.284 +
1.285 + break;
1.286 + }
1.287 + default:
1.288 + {
1.289 + User::Leave(KErrNotSupported);
1.290 + }
1.291 + }
1.292 +
1.293 + return result;
1.294 + }
1.295 +
1.296 +
1.297 +// original RMessage is supplied so that remote demux plugin can extract necessary details
1.298 +// using DeMux utility
1.299 +TInt CMMFDspControlDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage)
1.300 + {
1.301 + TMMFDevSoundCIMessageData data;
1.302 + TInt result = KErrGeneral;
1.303 +
1.304 + // decode message
1.305 + iUtility->GetSyncMessageDataL(aMessage, data);
1.306 +
1.307 + switch (data.iCommand)
1.308 + {
1.309 + case EMMFDevSoundCIDspCtrlGetAudioPlaybackInfo:
1.310 + {
1.311 + TPckgBuf<TAudioPlaybackInfo> pckData;
1.312 +
1.313 + iUtility->ReadFromInputDesL(aMessage, &pckData);
1.314 +
1.315 + result = DoMmdspcGetAudioPlaybackInfoL(pckData().iSamplesPlayed,
1.316 + pckData().iSystemTime,
1.317 + pckData().iBytesDecoderConsumed,
1.318 + pckData().iBytesDecoderDecoded);
1.319 +
1.320 + TPckgBuf<TAudioPlaybackInfo> des(pckData());
1.321 + iUtility->WriteToOutputDesL(aMessage, des);
1.322 +
1.323 + break;
1.324 + }
1.325 + default:
1.326 + {
1.327 + User::Leave(KErrNotSupported);
1.328 + }
1.329 + }
1.330 +
1.331 + return result;
1.332 + }
1.333 +
1.334 +
1.335 +void CMMFDspControlDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
1.336 + {
1.337 + // not used in this interface
1.338 + }
1.339 +
1.340 +
1.341 +void CMMFDspControlDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
1.342 + {
1.343 + // not used in this interface
1.344 + }
1.345 +
1.346 +
1.347 +TInt CMMFDspControlDeMux::DoMmdspcAcceptRecordBuffersInvalidFollowingStopL()
1.348 + {
1.349 + TInt result = KErrNotFound;
1.350 +
1.351 + if (iInterfaceDspControl)
1.352 + {
1.353 + result = iInterfaceDspControl->MmdspcAcceptRecordBuffersInvalidFollowingStop();
1.354 + }
1.355 +
1.356 + return result;
1.357 + }
1.358 +
1.359 +
1.360 +TInt CMMFDspControlDeMux::DoMmdspcAcceptPlaybackBuffersInvalidFollowingStopL()
1.361 + {
1.362 + TInt result = KErrNotFound;
1.363 +
1.364 + if (iInterfaceDspControl)
1.365 + {
1.366 + result = iInterfaceDspControl->MmdspcAcceptPlaybackBuffersInvalidFollowingStop();
1.367 + }
1.368 +
1.369 + return result;
1.370 + }
1.371 +
1.372 +
1.373 +TInt CMMFDspControlDeMux::DoMmdspcGetAudioPlaybackInfoL(TInt64& aSamplesPlayed,
1.374 + TInt64& aSystemTime,
1.375 + TUint& aBytesDecoderConsumed,
1.376 + TUint& aBytesDecoderDecoded)
1.377 + {
1.378 + TInt result = KErrNotFound;
1.379 +
1.380 + if (iInterfaceDspControl)
1.381 + {
1.382 + result = iInterfaceDspControl->MmdspcGetAudioPlaybackInfo(aSamplesPlayed,
1.383 + aSystemTime,
1.384 + aBytesDecoderConsumed,
1.385 + aBytesDecoderDecoded);
1.386 + }
1.387 +
1.388 + return result;
1.389 + }
1.390 +
1.391 +
1.392 +//
1.393 +// ImplementationTable
1.394 +//
1.395 +const TImplementationProxy ImplementationTable[] =
1.396 + {
1.397 + IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlMux, CMMFDspControlMux::NewL),
1.398 + IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceDspControlDeMux, CMMFDspControlDeMux::NewL),
1.399 + };
1.400 +
1.401 +//
1.402 +// ImplementationGroupProxy
1.403 +//
1.404 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
1.405 + {
1.406 + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
1.407 +
1.408 + return ImplementationTable;
1.409 + }
1.410 +