os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/cmmfdevsoundcifileblocklength.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/cmmfdevsoundcifileblocklength.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,294 @@
     1.4 +// Copyright (c) 2006-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 "cmmfdevsoundcifileblocklengthimpluid.hrh"
    1.20 +
    1.21 +#include <ecom/implementationproxy.h>
    1.22 +#include <ecom/implementationproxy.h>
    1.23 +#include <ecom/ecom.h>
    1.24 +#include <s32mem.h>
    1.25 +
    1.26 +#include "cmmfdevsoundcifileblocklength.h"
    1.27 +
    1.28 +// __________________________________________________________________________
    1.29 +// Implementation
    1.30 +
    1.31 +// MUX //
    1.32 +
    1.33 +TInt CMMFDevSoundCIFileBlockLengthMux::OpenInterface(TUid /*aInterfaceId*/)
    1.34 +	{
    1.35 +	// attempt to open the interface link with the
    1.36 +	// remote slave device
    1.37 +	iRemoteHandle = -1;
    1.38 +	TUid slaveId = {KMmfUidCIFileBlockLengthDeMux};
    1.39 +		
    1.40 +	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
    1.41 +	if (handle >= 0)
    1.42 +		{
    1.43 +		iRemoteHandle = handle;
    1.44 +		}
    1.45 +		
    1.46 +	return iRemoteHandle;
    1.47 +	}
    1.48 +
    1.49 +void CMMFDevSoundCIFileBlockLengthMux::Release()
    1.50 +	{
    1.51 +	// close the slave device if it exists
    1.52 +	if (iRemoteHandle != -1)
    1.53 +		{
    1.54 +		// we assume the slave is closed correctly
    1.55 +		iUtility->CloseSlave(iRemoteHandle);
    1.56 +		}
    1.57 +	
    1.58 +	TUid key = iKey;
    1.59 +	delete this;
    1.60 +	
    1.61 +	// tell ECom to destroy us
    1.62 +	REComSession::DestroyedImplementation(key);
    1.63 +	}
    1.64 +	
    1.65 +void CMMFDevSoundCIFileBlockLengthMux::PassDestructorKey(TUid aDestructorKey)
    1.66 +	{
    1.67 +	// store the destructor key
    1.68 +	iKey = aDestructorKey;
    1.69 +	}
    1.70 +
    1.71 +void CMMFDevSoundCIFileBlockLengthMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
    1.72 +	{
    1.73 +	// store a pointer to the utility
    1.74 +	iUtility = aCustomUtility;
    1.75 +	}
    1.76 +	
    1.77 +MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDevSoundCIFileBlockLengthMux::NewL()
    1.78 +	{
    1.79 +	CMMFDevSoundCIFileBlockLengthMux* self = new (ELeave) CMMFDevSoundCIFileBlockLengthMux;
    1.80 +	return self;
    1.81 +	}
    1.82 +	
    1.83 +TAny* CMMFDevSoundCIFileBlockLengthMux::CustomInterface(TUid /*aInterfaceId*/)
    1.84 +	{
    1.85 +	MMMFDevSoundCustomInterfaceFileBlockLength* interface = this;
    1.86 +	return interface;
    1.87 +	}
    1.88 +	
    1.89 +CMMFDevSoundCIFileBlockLengthMux::CMMFDevSoundCIFileBlockLengthMux() :
    1.90 +	iRemoteHandle(-1)
    1.91 +	{	
    1.92 +	}
    1.93 +
    1.94 +CMMFDevSoundCIFileBlockLengthMux::~CMMFDevSoundCIFileBlockLengthMux()
    1.95 +	{	
    1.96 +	}
    1.97 +
    1.98 +// from MMMFDevSoundCustomInterfaceFileBlockLength
    1.99 +
   1.100 +void CMMFDevSoundCIFileBlockLengthMux::SetFileBlockLength(TUint aBlockAlign)
   1.101 +	{
   1.102 +	if (iRemoteHandle == -1)
   1.103 +		{
   1.104 +		return;
   1.105 +		}
   1.106 +	
   1.107 +	// send the BlockAlign in the sync command
   1.108 +	TPckgBuf<TUint> blockAlignBuffer(aBlockAlign);
   1.109 +	
   1.110 +	iUtility->SendSlaveSyncCommand(iRemoteHandle, EMMFDevSoundCIBlockLengthSetFileBlockLength, blockAlignBuffer);
   1.111 +	}
   1.112 +
   1.113 +// DEMUX //	
   1.114 +	
   1.115 +
   1.116 +TInt CMMFDevSoundCIFileBlockLengthDeMux::OpenInterface(TUid /*aInterfaceId*/)
   1.117 +	{
   1.118 +	return KErrNone;
   1.119 +	}
   1.120 +	
   1.121 +void CMMFDevSoundCIFileBlockLengthDeMux::Release()
   1.122 +	{
   1.123 +	TUid key = iKey;
   1.124 +	
   1.125 +	delete this;
   1.126 +	
   1.127 +	// tell ECom to destroy us
   1.128 +	REComSession::DestroyedImplementation(key);
   1.129 +	}
   1.130 +	
   1.131 +void CMMFDevSoundCIFileBlockLengthDeMux::PassDestructorKey(TUid aDestructorKey)
   1.132 +	{
   1.133 +	// store the destructor key
   1.134 +	iKey = aDestructorKey;
   1.135 +	}
   1.136 +	
   1.137 +void CMMFDevSoundCIFileBlockLengthDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
   1.138 +	{
   1.139 +	iTarget = aTarget;
   1.140 +	}
   1.141 +	
   1.142 +void CMMFDevSoundCIFileBlockLengthDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
   1.143 +	{
   1.144 +	// store a pointer to the utility
   1.145 +	iUtility = aCustomUtility;
   1.146 +	}
   1.147 +
   1.148 +void CMMFDevSoundCIFileBlockLengthDeMux::RefreshL()
   1.149 +	{
   1.150 +	// refetch the fileblocklength custom interface if we already have a target
   1.151 +	if (iTarget)
   1.152 +		{
   1.153 +		MMMFDevSoundCustomInterfaceFileBlockLength* ptr = NULL;
   1.154 +		ptr = static_cast<MMMFDevSoundCustomInterfaceFileBlockLength*>(iTarget->CustomInterface(KUidCustomInterfaceDevSoundFileBlockLength));
   1.155 +	
   1.156 +		if (!ptr)
   1.157 +			{
   1.158 +			iFileBlockLengthInterface = NULL;
   1.159 +			User::Leave(KErrNotSupported);
   1.160 +			}
   1.161 +		else
   1.162 +			{
   1.163 +			iFileBlockLengthInterface = ptr;
   1.164 +			}	
   1.165 +		}
   1.166 +	}
   1.167 +
   1.168 +
   1.169 +MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDevSoundCIFileBlockLengthDeMux::NewL()
   1.170 +	{
   1.171 +	CMMFDevSoundCIFileBlockLengthDeMux* self = new (ELeave) CMMFDevSoundCIFileBlockLengthDeMux;
   1.172 +	return self;
   1.173 +	}
   1.174 +	
   1.175 +CMMFDevSoundCIFileBlockLengthDeMux::CMMFDevSoundCIFileBlockLengthDeMux()
   1.176 +	{
   1.177 +	}
   1.178 +
   1.179 +CMMFDevSoundCIFileBlockLengthDeMux::~CMMFDevSoundCIFileBlockLengthDeMux()
   1.180 +	{
   1.181 +	}
   1.182 +
   1.183 +
   1.184 +TInt CMMFDevSoundCIFileBlockLengthDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
   1.185 +	{
   1.186 +	// fetch the fileblocklength custom interface
   1.187 +	MMMFDevSoundCustomInterfaceFileBlockLength* ptr = NULL;
   1.188 +	ptr = static_cast <MMMFDevSoundCustomInterfaceFileBlockLength*> (iTarget->CustomInterface(KUidCustomInterfaceDevSoundFileBlockLength));
   1.189 +	
   1.190 +	if (!ptr)
   1.191 +		{
   1.192 +		iFileBlockLengthInterface = NULL;
   1.193 +		User::Leave(KErrNotSupported);
   1.194 +		}
   1.195 +	else
   1.196 +		{
   1.197 +		iFileBlockLengthInterface = ptr;
   1.198 +		}
   1.199 +	return KErrNone;
   1.200 +	}
   1.201 +	
   1.202 +void CMMFDevSoundCIFileBlockLengthDeMux::DoCloseSlaveL(TInt /*aHandle*/)
   1.203 +	{
   1.204 +	// nothing to do
   1.205 +	}
   1.206 +
   1.207 +// original RMessage is supplied so that remote demux plugin can extract necessary details
   1.208 +// using DeMux utility
   1.209 +TInt CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
   1.210 +	{
   1.211 +	TMMFDevSoundCIMessageData data;
   1.212 +	
   1.213 +	// decode message
   1.214 +	iUtility->GetSyncMessageDataL(aMessage, data);
   1.215 +	TInt retVal = -1;
   1.216 +	
   1.217 +	switch (data.iCommand)
   1.218 +		{
   1.219 +		case EMMFDevSoundCIBlockLengthSetFileBlockLength:
   1.220 +			{
   1.221 +			// we know that offset 2 contains a TInt
   1.222 +			TPckgBuf<TUint> blockAlignBuffer;
   1.223 +			iUtility->ReadFromInputDesL(aMessage, &blockAlignBuffer);
   1.224 +			
   1.225 +			DoSetFileBlockLengthL(blockAlignBuffer());
   1.226 +			retVal = KErrNone;
   1.227 +			break;
   1.228 +			}
   1.229 +	
   1.230 +		default:
   1.231 +			{
   1.232 +			User::Leave(KErrNotSupported);
   1.233 +			}
   1.234 +		}
   1.235 +		
   1.236 +	return retVal;
   1.237 +	}
   1.238 +	
   1.239 +TInt CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
   1.240 +	{
   1.241 +	return KErrNotSupported;
   1.242 +	}
   1.243 +	
   1.244 +void CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
   1.245 +	{
   1.246 +	// not used in this interface
   1.247 +	}
   1.248 +	
   1.249 +void CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
   1.250 +	{
   1.251 +	// not used in this interface
   1.252 +	}
   1.253 +
   1.254 +void CMMFDevSoundCIFileBlockLengthDeMux::DoSetFileBlockLengthL(TUint aBlockAlign)
   1.255 +	{
   1.256 +	if (!iFileBlockLengthInterface)
   1.257 +		{
   1.258 +		User::Leave(KErrNotReady);
   1.259 +		}
   1.260 +			
   1.261 +	// set the block length		
   1.262 +	iFileBlockLengthInterface->SetFileBlockLength(aBlockAlign);
   1.263 +	}
   1.264 +
   1.265 +
   1.266 +
   1.267 +//
   1.268 +// ImplementationTable
   1.269 +//
   1.270 +
   1.271 +const TImplementationProxy ImplementationTable[] = 
   1.272 +	{
   1.273 +	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCIFileBlockLengthMux,	CMMFDevSoundCIFileBlockLengthMux::NewL),
   1.274 +	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCIFileBlockLengthDeMux, CMMFDevSoundCIFileBlockLengthDeMux::NewL),
   1.275 +	};
   1.276 +
   1.277 +
   1.278 +//
   1.279 +// ImplementationGroupProxy
   1.280 +//
   1.281 +//
   1.282 +
   1.283 +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
   1.284 +	{
   1.285 +	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
   1.286 +
   1.287 +	return ImplementationTable;
   1.288 +	}
   1.289 +
   1.290 +#ifndef EKA2
   1.291 +/** DLL Entry point */
   1.292 +GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
   1.293 +	{
   1.294 +	return(KErrNone);
   1.295 +	}
   1.296 +#endif
   1.297 +