devsound/devsoundpluginsupport/src/CustomInterfaces/underflowautostopcontrolci.cpp
changeset 0 79dd3e2336a0
equal deleted inserted replaced
-1:000000000000 0:79dd3e2336a0
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <ecom/implementationproxy.h>
       
    17 #include <ecom/implementationproxy.h>
       
    18 #include <ecom/ecom.h>
       
    19 #include <s32mem.h>
       
    20 
       
    21 #include "underflowautostopcontrolci.h"
       
    22 
       
    23 
       
    24 // MUX //
       
    25 
       
    26 TInt CMMFUnderflowAutoStopControlMux::OpenInterface(TUid /*aInterfaceId*/)
       
    27 	{
       
    28 	// attempt to open the interface link with the
       
    29 	// remote slave device
       
    30 	iRemoteHandle = -1;
       
    31 	TUid slaveId = {KMmfUidCustomInterfaceUnderflowAutoStopCtrlDeMux};
       
    32 
       
    33 	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
       
    34 	if (handle >= 0)
       
    35 		{
       
    36 		iRemoteHandle = handle;
       
    37 		}
       
    38 
       
    39 	return iRemoteHandle;
       
    40 	}
       
    41 
       
    42 
       
    43 void CMMFUnderflowAutoStopControlMux::Release()
       
    44 	{
       
    45 	// close the slave device if it exists
       
    46 	if (iRemoteHandle > 0)
       
    47 		{
       
    48 		// we assume the slave is closed correctly
       
    49 		iUtility->CloseSlave(iRemoteHandle);
       
    50 		}
       
    51 
       
    52 	TUid key = iKey;
       
    53 	delete this;
       
    54 
       
    55 	// tell ECom to destroy us
       
    56 	REComSession::DestroyedImplementation(key);
       
    57 	}
       
    58 
       
    59 
       
    60 void CMMFUnderflowAutoStopControlMux::PassDestructorKey(TUid aDestructorKey)
       
    61 	{
       
    62 	// store the destructor key
       
    63 	iKey = aDestructorKey;
       
    64 	}
       
    65 
       
    66 
       
    67 void CMMFUnderflowAutoStopControlMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
       
    68 	{
       
    69 	// store a pointer to the utility
       
    70 	iUtility = aCustomUtility;
       
    71 	}
       
    72 
       
    73 
       
    74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFUnderflowAutoStopControlMux::NewL()
       
    75 	{
       
    76 	CMMFUnderflowAutoStopControlMux* self = new (ELeave) CMMFUnderflowAutoStopControlMux;
       
    77 	return self;
       
    78 	}
       
    79 
       
    80 
       
    81 TAny* CMMFUnderflowAutoStopControlMux::CustomInterface(TUid /*aInterfaceId*/)
       
    82 	{
       
    83 	MMMFUnderflowAutoStopControl* interface = this;
       
    84 	return interface;
       
    85 	}
       
    86 
       
    87 
       
    88 CMMFUnderflowAutoStopControlMux::CMMFUnderflowAutoStopControlMux() :
       
    89 	iRemoteHandle(-1)
       
    90 	{
       
    91 	}
       
    92 
       
    93 
       
    94 CMMFUnderflowAutoStopControlMux::~CMMFUnderflowAutoStopControlMux()
       
    95 	{
       
    96 	}
       
    97 
       
    98 
       
    99 // from MMMFUnderflowAutoStopControl
       
   100 TInt CMMFUnderflowAutoStopControlMux::MmuascTurnOffUnderflowAutoStop ()
       
   101 	{
       
   102 	TInt result = KErrGeneral;
       
   103 
       
   104 	if (iRemoteHandle > 0)
       
   105 		{
       
   106 		// any return code other than zero is an error
       
   107 		result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
       
   108 												EMMFDevSoundCIUnderflowAutoStopCtrlTurnOffUnderflowAutoStop,
       
   109 												KNullDesC8);
       
   110 		}
       
   111 
       
   112 	return result;
       
   113 	}
       
   114 
       
   115 
       
   116 
       
   117 // DEMUX //	
       
   118 
       
   119 TInt CMMFUnderflowAutoStopControlDeMux::OpenInterface(TUid /*aInterfaceId*/)
       
   120 	{
       
   121 	return KErrNone;
       
   122 	}
       
   123 
       
   124 
       
   125 void CMMFUnderflowAutoStopControlDeMux::Release()
       
   126 	{
       
   127 	TUid key = iKey;
       
   128 
       
   129 	delete this;
       
   130 
       
   131 	// tell ECom to destroy us
       
   132 	REComSession::DestroyedImplementation(key);
       
   133 	}
       
   134 
       
   135 
       
   136 void CMMFUnderflowAutoStopControlDeMux::PassDestructorKey(TUid aDestructorKey)
       
   137 	{
       
   138 	// store the destructor key
       
   139 	iKey = aDestructorKey;
       
   140 	}
       
   141 
       
   142 
       
   143 void CMMFUnderflowAutoStopControlDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
       
   144 	{
       
   145 	iTarget = aTarget;
       
   146 	}
       
   147 
       
   148 
       
   149 void CMMFUnderflowAutoStopControlDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
       
   150 	{
       
   151 	// store a pointer to the utility
       
   152 	iUtility = aCustomUtility;
       
   153 	}
       
   154 
       
   155 
       
   156 void CMMFUnderflowAutoStopControlDeMux::RefreshL()
       
   157 	{
       
   158 	// refetch the UnderflowAutoStop Control  custom interface if we already have a target
       
   159 	if (iTarget)
       
   160 		{
       
   161 		iInterfaceUnderflowAutoStopCtrl = static_cast <MMMFUnderflowAutoStopControl*> (iTarget->CustomInterface(KUidUnderflowAutoStopControl));
       
   162 
       
   163 		if (!iInterfaceUnderflowAutoStopCtrl)
       
   164 			{
       
   165 			iInterfaceUnderflowAutoStopCtrl = NULL;
       
   166 			User::Leave(KErrNotSupported);
       
   167 			}
       
   168 		}
       
   169 	}
       
   170 
       
   171 
       
   172 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFUnderflowAutoStopControlDeMux::NewL()
       
   173 	{
       
   174 	CMMFUnderflowAutoStopControlDeMux* self = new (ELeave) CMMFUnderflowAutoStopControlDeMux;
       
   175 	return self;
       
   176 	}
       
   177 
       
   178 
       
   179 CMMFUnderflowAutoStopControlDeMux::CMMFUnderflowAutoStopControlDeMux()
       
   180 	{
       
   181 	}
       
   182 
       
   183 
       
   184 CMMFUnderflowAutoStopControlDeMux::~CMMFUnderflowAutoStopControlDeMux()
       
   185 	{
       
   186 	}
       
   187 
       
   188 
       
   189 TInt CMMFUnderflowAutoStopControlDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
       
   190 	{
       
   191 	// fetch the UnderflowAutoStop Control  Hw Device custom interface
       
   192 	iInterfaceUnderflowAutoStopCtrl = static_cast<MMMFUnderflowAutoStopControl*> (iTarget->CustomInterface(KUidUnderflowAutoStopControl)); 
       
   193 
       
   194 	if (!iInterfaceUnderflowAutoStopCtrl)
       
   195 		{
       
   196 		iInterfaceUnderflowAutoStopCtrl = NULL;
       
   197 		User::Leave(KErrNotSupported);
       
   198 		}
       
   199 
       
   200 	return KErrNone;
       
   201 	}
       
   202 
       
   203 
       
   204 void CMMFUnderflowAutoStopControlDeMux::DoCloseSlaveL(TInt /*aHandle*/)
       
   205 	{
       
   206 	// nothing to do
       
   207 	}
       
   208 
       
   209 
       
   210 // original RMessage is supplied so that remote demux plugin can extract necessary details
       
   211 // using DeMux utility
       
   212 TInt CMMFUnderflowAutoStopControlDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
       
   213 	{
       
   214 	TMMFDevSoundCIMessageData data;
       
   215 	TInt result = KErrGeneral;
       
   216 
       
   217 	// decode message
       
   218 	iUtility->GetSyncMessageDataL(aMessage, data);
       
   219 
       
   220 	switch (data.iCommand)
       
   221 		{
       
   222 		case EMMFDevSoundCIUnderflowAutoStopCtrlTurnOffUnderflowAutoStop:
       
   223 			{
       
   224 			result = DoMmuascTurnOffUnderflowAutoStopL();
       
   225 
       
   226 			break;
       
   227 			}
       
   228 		default:
       
   229 			{
       
   230 			User::Leave(KErrNotSupported);
       
   231 			}
       
   232 		}
       
   233 
       
   234 	return result;
       
   235 	}
       
   236 
       
   237 
       
   238 // original RMessage is supplied so that remote demux plugin can extract necessary details
       
   239 // using DeMux utility
       
   240 TInt CMMFUnderflowAutoStopControlDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
       
   241 	{
       
   242 	return KErrNone;
       
   243 	}
       
   244 
       
   245 
       
   246 void CMMFUnderflowAutoStopControlDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
       
   247 	{
       
   248 	// not used in this interface
       
   249 	}
       
   250 
       
   251 
       
   252 void CMMFUnderflowAutoStopControlDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
       
   253 	{
       
   254 	// not used in this interface
       
   255 	}
       
   256 
       
   257 
       
   258 TInt CMMFUnderflowAutoStopControlDeMux::DoMmuascTurnOffUnderflowAutoStopL()
       
   259 	{
       
   260 	TInt result = KErrNotFound;
       
   261 
       
   262 	if (iInterfaceUnderflowAutoStopCtrl)
       
   263 		{
       
   264 		result = iInterfaceUnderflowAutoStopCtrl->MmuascTurnOffUnderflowAutoStop();
       
   265 		}
       
   266 
       
   267 	return result;
       
   268 	}
       
   269 
       
   270 
       
   271 //
       
   272 // ImplementationTable
       
   273 //
       
   274 const TImplementationProxy ImplementationTable[] = 
       
   275 	{
       
   276 	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceUnderflowAutoStopCtrlMux,		CMMFUnderflowAutoStopControlMux::NewL),
       
   277 	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceUnderflowAutoStopCtrlDeMux,	CMMFUnderflowAutoStopControlDeMux::NewL),
       
   278 	};
       
   279 
       
   280 //
       
   281 // ImplementationGroupProxy
       
   282 //
       
   283 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   284 	{
       
   285 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   286 
       
   287 	return ImplementationTable;
       
   288 	}
       
   289