os/mm/devsoundextensions/effects/SrcOrientation/SourceOrientationProxy/Src/SourceOrientationProxy.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/effects/SrcOrientation/SourceOrientationProxy/Src/SourceOrientationProxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,249 @@
1.4 +/*
1.5 +* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description: Implementation of the bassboost proxy class
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +
1.24 +// INCLUDE FILES
1.25 +
1.26 +#ifdef _DEBUG
1.27 +#include <e32svr.h>
1.28 +#endif
1.29 +
1.30 +#include "SourceOrientationProxy.h"
1.31 +#include "SourceOrientationEventObserver.h"
1.32 +#include <CustomInterfaceUtility.h>
1.33 +
1.34 +
1.35 +// ============================ MEMBER FUNCTIONS ===============================
1.36 +
1.37 +// -----------------------------------------------------------------------------
1.38 +// CSourceOrientationProxy::CSourceOrientationProxy
1.39 +// C++ default constructor can NOT contain any code, that
1.40 +// might leave.
1.41 +// -----------------------------------------------------------------------------
1.42 +//
1.43 +CSourceOrientationProxy::CSourceOrientationProxy(
1.44 + TMMFMessageDestinationPckg aMessageHandler,
1.45 + MCustomCommand& aCustomCommand,
1.46 + CCustomInterfaceUtility* aCustomInterfaceUtility )
1.47 + : iCustomCommand(&aCustomCommand),
1.48 + iMessageHandler(aMessageHandler),
1.49 + iCustomInterfaceUtility(aCustomInterfaceUtility)
1.50 +
1.51 + {
1.52 + }
1.53 +
1.54 +// Destructor
1.55 +CSourceOrientationProxy::~CSourceOrientationProxy()
1.56 + {
1.57 + // Remove the custom interface message handler before we destroy the proxy.
1.58 + if(iCustomInterfaceUtility)
1.59 + iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
1.60 + delete iSourceOrientationEventObserver;
1.61 + delete iCustomInterfaceUtility;
1.62 + }
1.63 +
1.64 +// -----------------------------------------------------------------------------
1.65 +// CSourceOrientationProxy::NewL
1.66 +// Static function for creating an instance of the SourceOrientation object.
1.67 +// -----------------------------------------------------------------------------
1.68 +//
1.69 +EXPORT_C CSourceOrientationProxy* CSourceOrientationProxy::NewL(
1.70 + TMMFMessageDestinationPckg aMessageHandler,
1.71 + MCustomCommand& aCustomCommand,
1.72 + CCustomInterfaceUtility* aCustomInterfaceUtility )
1.73 + {
1.74 + CSourceOrientationProxy* self = new (ELeave) CSourceOrientationProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
1.75 + CleanupStack::PushL(self);
1.76 + self->ConstructL();
1.77 + CleanupStack::Pop(self);
1.78 + return self;
1.79 + }
1.80 +
1.81 +// -----------------------------------------------------------------------------
1.82 +// CSourceOrientationProxy::ConstructL
1.83 +// -----------------------------------------------------------------------------
1.84 +//
1.85 +void CSourceOrientationProxy::ConstructL()
1.86 + {
1.87 + iSourceOrientationEventObserver = CSourceOrientationEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
1.88 + StartObserver();
1.89 +
1.90 + TEfOrientationDataPckg dataPckgFrom;
1.91 + // sends a message to fetch initial data.
1.92 + iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
1.93 + SetEffectData(dataPckgFrom);
1.94 + }
1.95 +
1.96 +
1.97 +// -----------------------------------------------------------------------------
1.98 +// CSourceOrientationProxy::ApplyL
1.99 +// Apply the bassboost settings.
1.100 +// -----------------------------------------------------------------------------
1.101 +//
1.102 +EXPORT_C void CSourceOrientationProxy::ApplyL()
1.103 + {
1.104 +#ifdef _DEBUG
1.105 + RDebug::Print(_L("CSourceOrientationProxy::Apply"));
1.106 +#endif
1.107 +
1.108 + if (iHaveUpdateRights )
1.109 + {
1.110 + iOrientationData.iEnabled = iEnabled;
1.111 + iOrientationData.iEnforced = iEnforced;
1.112 + iOrientationData.iHaveUpdateRights = iHaveUpdateRights;
1.113 +
1.114 + iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofApply, DoEffectData(), KNullDesC8);
1.115 + }
1.116 + else
1.117 + {
1.118 + User::Leave(KErrAccessDenied);
1.119 + }
1.120 + }
1.121 +
1.122 +// -----------------------------------------------------------------------------
1.123 +// CSourceOrientationProxy::StartObserver
1.124 +// Starts the event observer. The event observer monitors asynchronous events
1.125 +// from the message handler.
1.126 +// -----------------------------------------------------------------------------
1.127 +//
1.128 +void CSourceOrientationProxy::StartObserver()
1.129 + {
1.130 +#ifdef _DEBUG
1.131 + RDebug::Print(_L("CSourceOrientationProxy::StartObserver"));
1.132 +#endif
1.133 +
1.134 + iSourceOrientationEventObserver->Start();
1.135 + }
1.136 +
1.137 +// -----------------------------------------------------------------------------
1.138 +// CSourceOrientationProxy::SourceOrientationEvent
1.139 +// Checks which data member has changed and notify the observers.
1.140 +// -----------------------------------------------------------------------------
1.141 +//
1.142 +void CSourceOrientationProxy::SourceOrientationEvent(
1.143 + const TDesC8& aBuffer )
1.144 + {
1.145 +#ifdef _DEBUG
1.146 + RDebug::Print(_L("CSourceOrientationProxy::SourceOrientationEvent"));
1.147 +#endif
1.148 +
1.149 + TEfOrientationDataPckg dataPckgFrom;
1.150 + dataPckgFrom.Copy(aBuffer);
1.151 + TEfOrientation newOrientationData = dataPckgFrom();
1.152 +
1.153 + TUint8 event = 0;
1.154 +
1.155 + if ( newOrientationData.iEnabled != iOrientationData.iEnabled )
1.156 + {
1.157 + iOrientationData.iEnabled = newOrientationData.iEnabled;
1.158 + iEnabled = newOrientationData.iEnabled;
1.159 + if ( iOrientationData.iEnabled )
1.160 + {
1.161 + event = MAudioEffectObserver::KEnabled;
1.162 + }
1.163 + else
1.164 + {
1.165 + event = MAudioEffectObserver::KDisabled;
1.166 + }
1.167 + }
1.168 + else if ( newOrientationData.iEnforced != iOrientationData.iEnforced )
1.169 + {
1.170 + iOrientationData.iEnforced = newOrientationData.iEnforced;
1.171 + iEnforced = newOrientationData.iEnforced;
1.172 + if ( iOrientationData.iEnforced )
1.173 + {
1.174 + event = MAudioEffectObserver::KEnforced;
1.175 + }
1.176 + else
1.177 + {
1.178 + event = MAudioEffectObserver::KNotEnforced;
1.179 + }
1.180 + }
1.181 + else if ( newOrientationData.iHaveUpdateRights != iOrientationData.iHaveUpdateRights )
1.182 + {
1.183 + iOrientationData.iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
1.184 + iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
1.185 + if ( iOrientationData.iHaveUpdateRights )
1.186 + {
1.187 + event = MAudioEffectObserver::KGainedUpdateRights;
1.188 + }
1.189 + else
1.190 + {
1.191 + event = MAudioEffectObserver::KLostUpdateRights;
1.192 + }
1.193 + }
1.194 + else if ( newOrientationData.iHeading != iOrientationData.iHeading )
1.195 + {
1.196 + iOrientationData.iHeading = newOrientationData.iHeading;
1.197 + event = MSourceOrientationObserver::KOrientationChanged;
1.198 + }
1.199 + else if ( newOrientationData.iPitch != iOrientationData.iPitch )
1.200 + {
1.201 + iOrientationData.iPitch = newOrientationData.iPitch;
1.202 + event = MSourceOrientationObserver::KOrientationChanged;
1.203 + }
1.204 + else if ( newOrientationData.iRoll != iOrientationData.iRoll )
1.205 + {
1.206 + iOrientationData.iRoll = newOrientationData.iRoll;
1.207 + event = MSourceOrientationObserver::KOrientationChanged;
1.208 + }
1.209 + else if ( newOrientationData.iFrontX != iOrientationData.iFrontX )
1.210 + {
1.211 + iOrientationData.iFrontX = newOrientationData.iFrontX;
1.212 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.213 + }
1.214 + else if ( newOrientationData.iFrontY != iOrientationData.iFrontY )
1.215 + {
1.216 + iOrientationData.iFrontY = newOrientationData.iFrontY;
1.217 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.218 + }
1.219 + else if ( newOrientationData.iFrontZ != iOrientationData.iFrontZ )
1.220 + {
1.221 + iOrientationData.iFrontZ = newOrientationData.iFrontZ;
1.222 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.223 + }
1.224 + else if ( newOrientationData.iAboveX != iOrientationData.iAboveX )
1.225 + {
1.226 + iOrientationData.iAboveX = newOrientationData.iAboveX;
1.227 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.228 + }
1.229 + else if ( newOrientationData.iFrontY != iOrientationData.iAboveY )
1.230 + {
1.231 + iOrientationData.iAboveY = newOrientationData.iAboveY;
1.232 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.233 + }
1.234 + else if ( newOrientationData.iAboveZ != iOrientationData.iAboveZ )
1.235 + {
1.236 + iOrientationData.iAboveZ = newOrientationData.iAboveZ;
1.237 + event = MSourceOrientationObserver::KOrientationVectorsChanged;
1.238 + }
1.239 +
1.240 + if (!event)
1.241 + return;
1.242 +
1.243 + for ( TInt i = 0; i < iObservers.Count(); i++ )
1.244 + {
1.245 + iObservers[i]->EffectChanged(this, event);
1.246 + }
1.247 + }
1.248 +
1.249 +
1.250 +// ========================== OTHER EXPORTED FUNCTIONS =========================
1.251 +
1.252 +// End of File