os/mm/devsoundextensions/effects/SrcOrientation/SourceOrientationProxy/Src/SourceOrientationProxy.cpp
Update contrib.
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Implementation of the bassboost proxy class
27 #include "SourceOrientationProxy.h"
28 #include "SourceOrientationEventObserver.h"
29 #include <CustomInterfaceUtility.h>
32 // ============================ MEMBER FUNCTIONS ===============================
34 // -----------------------------------------------------------------------------
35 // CSourceOrientationProxy::CSourceOrientationProxy
36 // C++ default constructor can NOT contain any code, that
38 // -----------------------------------------------------------------------------
40 CSourceOrientationProxy::CSourceOrientationProxy(
41 TMMFMessageDestinationPckg aMessageHandler,
42 MCustomCommand& aCustomCommand,
43 CCustomInterfaceUtility* aCustomInterfaceUtility )
44 : iCustomCommand(&aCustomCommand),
45 iMessageHandler(aMessageHandler),
46 iCustomInterfaceUtility(aCustomInterfaceUtility)
52 CSourceOrientationProxy::~CSourceOrientationProxy()
54 // Remove the custom interface message handler before we destroy the proxy.
55 if(iCustomInterfaceUtility)
56 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
57 delete iSourceOrientationEventObserver;
58 delete iCustomInterfaceUtility;
61 // -----------------------------------------------------------------------------
62 // CSourceOrientationProxy::NewL
63 // Static function for creating an instance of the SourceOrientation object.
64 // -----------------------------------------------------------------------------
66 EXPORT_C CSourceOrientationProxy* CSourceOrientationProxy::NewL(
67 TMMFMessageDestinationPckg aMessageHandler,
68 MCustomCommand& aCustomCommand,
69 CCustomInterfaceUtility* aCustomInterfaceUtility )
71 CSourceOrientationProxy* self = new (ELeave) CSourceOrientationProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
72 CleanupStack::PushL(self);
74 CleanupStack::Pop(self);
78 // -----------------------------------------------------------------------------
79 // CSourceOrientationProxy::ConstructL
80 // -----------------------------------------------------------------------------
82 void CSourceOrientationProxy::ConstructL()
84 iSourceOrientationEventObserver = CSourceOrientationEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
87 TEfOrientationDataPckg dataPckgFrom;
88 // sends a message to fetch initial data.
89 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
90 SetEffectData(dataPckgFrom);
94 // -----------------------------------------------------------------------------
95 // CSourceOrientationProxy::ApplyL
96 // Apply the bassboost settings.
97 // -----------------------------------------------------------------------------
99 EXPORT_C void CSourceOrientationProxy::ApplyL()
102 RDebug::Print(_L("CSourceOrientationProxy::Apply"));
105 if (iHaveUpdateRights )
107 iOrientationData.iEnabled = iEnabled;
108 iOrientationData.iEnforced = iEnforced;
109 iOrientationData.iHaveUpdateRights = iHaveUpdateRights;
111 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESofApply, DoEffectData(), KNullDesC8);
115 User::Leave(KErrAccessDenied);
119 // -----------------------------------------------------------------------------
120 // CSourceOrientationProxy::StartObserver
121 // Starts the event observer. The event observer monitors asynchronous events
122 // from the message handler.
123 // -----------------------------------------------------------------------------
125 void CSourceOrientationProxy::StartObserver()
128 RDebug::Print(_L("CSourceOrientationProxy::StartObserver"));
131 iSourceOrientationEventObserver->Start();
134 // -----------------------------------------------------------------------------
135 // CSourceOrientationProxy::SourceOrientationEvent
136 // Checks which data member has changed and notify the observers.
137 // -----------------------------------------------------------------------------
139 void CSourceOrientationProxy::SourceOrientationEvent(
140 const TDesC8& aBuffer )
143 RDebug::Print(_L("CSourceOrientationProxy::SourceOrientationEvent"));
146 TEfOrientationDataPckg dataPckgFrom;
147 dataPckgFrom.Copy(aBuffer);
148 TEfOrientation newOrientationData = dataPckgFrom();
152 if ( newOrientationData.iEnabled != iOrientationData.iEnabled )
154 iOrientationData.iEnabled = newOrientationData.iEnabled;
155 iEnabled = newOrientationData.iEnabled;
156 if ( iOrientationData.iEnabled )
158 event = MAudioEffectObserver::KEnabled;
162 event = MAudioEffectObserver::KDisabled;
165 else if ( newOrientationData.iEnforced != iOrientationData.iEnforced )
167 iOrientationData.iEnforced = newOrientationData.iEnforced;
168 iEnforced = newOrientationData.iEnforced;
169 if ( iOrientationData.iEnforced )
171 event = MAudioEffectObserver::KEnforced;
175 event = MAudioEffectObserver::KNotEnforced;
178 else if ( newOrientationData.iHaveUpdateRights != iOrientationData.iHaveUpdateRights )
180 iOrientationData.iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
181 iHaveUpdateRights = newOrientationData.iHaveUpdateRights;
182 if ( iOrientationData.iHaveUpdateRights )
184 event = MAudioEffectObserver::KGainedUpdateRights;
188 event = MAudioEffectObserver::KLostUpdateRights;
191 else if ( newOrientationData.iHeading != iOrientationData.iHeading )
193 iOrientationData.iHeading = newOrientationData.iHeading;
194 event = MSourceOrientationObserver::KOrientationChanged;
196 else if ( newOrientationData.iPitch != iOrientationData.iPitch )
198 iOrientationData.iPitch = newOrientationData.iPitch;
199 event = MSourceOrientationObserver::KOrientationChanged;
201 else if ( newOrientationData.iRoll != iOrientationData.iRoll )
203 iOrientationData.iRoll = newOrientationData.iRoll;
204 event = MSourceOrientationObserver::KOrientationChanged;
206 else if ( newOrientationData.iFrontX != iOrientationData.iFrontX )
208 iOrientationData.iFrontX = newOrientationData.iFrontX;
209 event = MSourceOrientationObserver::KOrientationVectorsChanged;
211 else if ( newOrientationData.iFrontY != iOrientationData.iFrontY )
213 iOrientationData.iFrontY = newOrientationData.iFrontY;
214 event = MSourceOrientationObserver::KOrientationVectorsChanged;
216 else if ( newOrientationData.iFrontZ != iOrientationData.iFrontZ )
218 iOrientationData.iFrontZ = newOrientationData.iFrontZ;
219 event = MSourceOrientationObserver::KOrientationVectorsChanged;
221 else if ( newOrientationData.iAboveX != iOrientationData.iAboveX )
223 iOrientationData.iAboveX = newOrientationData.iAboveX;
224 event = MSourceOrientationObserver::KOrientationVectorsChanged;
226 else if ( newOrientationData.iFrontY != iOrientationData.iAboveY )
228 iOrientationData.iAboveY = newOrientationData.iAboveY;
229 event = MSourceOrientationObserver::KOrientationVectorsChanged;
231 else if ( newOrientationData.iAboveZ != iOrientationData.iAboveZ )
233 iOrientationData.iAboveZ = newOrientationData.iAboveZ;
234 event = MSourceOrientationObserver::KOrientationVectorsChanged;
240 for ( TInt i = 0; i < iObservers.Count(); i++ )
242 iObservers[i]->EffectChanged(this, event);
247 // ========================== OTHER EXPORTED FUNCTIONS =========================