os/mm/devsoundextensions/effects/SrcDoppler/SourceDopplerProxy/Src/SourceDopplerProxy.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 Source Doppler Proxy class
27 #include "SourceDopplerProxy.h"
28 #include "SourceDopplerEventObserver.h"
29 #include <CustomInterfaceUtility.h>
32 // ============================ MEMBER FUNCTIONS ===============================
34 // -----------------------------------------------------------------------------
35 // CSourceDopplerProxy::CSourceDopplerProxy
36 // C++ default constructor can NOT contain any code, that
38 // -----------------------------------------------------------------------------
40 CSourceDopplerProxy::CSourceDopplerProxy(
41 TMMFMessageDestinationPckg aMessageHandler,
42 MCustomCommand& aCustomCommand,
43 CCustomInterfaceUtility* aCustomInterfaceUtility )
44 : iCustomCommand(&aCustomCommand),
45 iMessageHandler(aMessageHandler),
46 iCustomInterfaceUtility(aCustomInterfaceUtility)
52 CSourceDopplerProxy::~CSourceDopplerProxy()
54 // Remove the custom interface message handler before we destroy the proxy.
55 if(iCustomInterfaceUtility)
56 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler);
57 delete iDopplerEventObserver;
58 delete iCustomInterfaceUtility;
61 // -----------------------------------------------------------------------------
62 // CSourceDopplerProxy::NewL
63 // Static function for creating an instance of the SourceDoppler object.
64 // -----------------------------------------------------------------------------
66 EXPORT_C CSourceDopplerProxy* CSourceDopplerProxy::NewL(
67 TMMFMessageDestinationPckg aMessageHandler,
68 MCustomCommand& aCustomCommand,
69 CCustomInterfaceUtility* aCustomInterfaceUtility )
71 CSourceDopplerProxy* self = new (ELeave) CSourceDopplerProxy(aMessageHandler, aCustomCommand, aCustomInterfaceUtility);
72 CleanupStack::PushL(self);
74 CleanupStack::Pop(self);
78 // -----------------------------------------------------------------------------
79 // CSourceDopplerProxy::ConstructL
80 // -----------------------------------------------------------------------------
82 void CSourceDopplerProxy::ConstructL()
84 iDopplerEventObserver = CSourceDopplerEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
87 TEfDopplerDataPckg dataPckgFrom;
88 // sends a message to fetch initial data.
89 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
90 SetEffectData(dataPckgFrom);
94 // -----------------------------------------------------------------------------
95 // CSourceDopplerProxy::ApplyL
96 // Apply the SourceDoppler settings.
97 // -----------------------------------------------------------------------------
99 EXPORT_C void CSourceDopplerProxy::ApplyL()
102 RDebug::Print(_L("CSourceDopplerProxy::Apply"));
105 if (iHaveUpdateRights )
107 iDopplerData.iEnabled = iEnabled;
108 iDopplerData.iEnforced = iEnforced;
109 iDopplerData.iHaveUpdateRights = iHaveUpdateRights;
111 iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)ESourceDopplerOfApply, DoEffectData(), KNullDesC8);
115 User::Leave(KErrAccessDenied);
119 // -----------------------------------------------------------------------------
120 // CSourceDopplerProxy::StartObserver
121 // Starts the event observer. The event observer monitors asynchronous events
122 // from the message handler.
123 // -----------------------------------------------------------------------------
125 void CSourceDopplerProxy::StartObserver()
128 RDebug::Print(_L("CSourceDopplerProxy::StartObserver"));
131 iDopplerEventObserver->Start();
134 // -----------------------------------------------------------------------------
135 // CSourceDopplerProxy::DopplerEvent
136 // Checks which data member has changed and notify the observers.
137 // -----------------------------------------------------------------------------
139 void CSourceDopplerProxy::SourceDopplerEvent(
140 const TDesC8& aBuffer )
143 RDebug::Print(_L("CSourceDopplerProxy::SourceDopplerEvent"));
146 TEfDopplerDataPckg dataPckgFrom;
147 dataPckgFrom.Copy(aBuffer);
148 TEfDoppler newDopplerData = dataPckgFrom();
152 if ( newDopplerData.iEnabled != iDopplerData.iEnabled )
154 iDopplerData.iEnabled = newDopplerData.iEnabled;
155 iEnabled = newDopplerData.iEnabled;
156 if ( iDopplerData.iEnabled )
158 event = MAudioEffectObserver::KEnabled;
162 event = MAudioEffectObserver::KDisabled;
165 else if ( newDopplerData.iEnforced != iDopplerData.iEnforced )
167 iDopplerData.iEnforced = newDopplerData.iEnforced;
168 iEnforced = newDopplerData.iEnforced;
169 if ( iDopplerData.iEnforced )
171 event = MAudioEffectObserver::KEnforced;
175 event = MAudioEffectObserver::KNotEnforced;
178 else if ( newDopplerData.iHaveUpdateRights != iDopplerData.iHaveUpdateRights )
180 iDopplerData.iHaveUpdateRights = newDopplerData.iHaveUpdateRights;
181 iHaveUpdateRights = newDopplerData.iHaveUpdateRights;
182 if ( iDopplerData.iHaveUpdateRights )
184 event = MAudioEffectObserver::KGainedUpdateRights;
188 event = MAudioEffectObserver::KLostUpdateRights;
192 else if ( newDopplerData.iVelocityX != iDopplerData.iVelocityX )
194 iDopplerData.iVelocityX = newDopplerData.iVelocityX;
195 event = MSourceDopplerObserver::KCartesianVelocityChanged;
197 else if ( newDopplerData.iVelocityY != iDopplerData.iVelocityY )
199 iDopplerData.iVelocityY = newDopplerData.iVelocityY;
200 event = MSourceDopplerObserver::KCartesianVelocityChanged;
202 else if ( newDopplerData.iVelocityZ != iDopplerData.iVelocityZ )
204 iDopplerData.iVelocityZ = newDopplerData.iVelocityZ;
205 event = MSourceDopplerObserver::KCartesianVelocityChanged;
207 else if ( newDopplerData.iAzimuth != iDopplerData.iAzimuth )
209 iDopplerData.iAzimuth = newDopplerData.iAzimuth;
210 event = MSourceDopplerObserver::KSphericalVelocityChanged;
212 else if ( newDopplerData.iElevation != iDopplerData.iElevation )
214 iDopplerData.iElevation = newDopplerData.iElevation;
215 event = MSourceDopplerObserver::KSphericalVelocityChanged;
217 else if ( newDopplerData.iRadius != iDopplerData.iRadius )
219 iDopplerData.iRadius = newDopplerData.iRadius;
220 event = MSourceDopplerObserver::KSphericalVelocityChanged;
222 else if ( newDopplerData.iFactor != iDopplerData.iFactor )
224 iDopplerData.iFactor = newDopplerData.iFactor;
225 event = MSourceDopplerObserver::KFactorChanged;
227 else if ( newDopplerData.iMaxFactor != iDopplerData.iMaxFactor )
229 iDopplerData.iMaxFactor = newDopplerData.iMaxFactor;
230 event = MSourceDopplerObserver::KMaxFactorChanged;
237 for ( TInt i = 0; i < iObservers.Count(); i++ )
239 iObservers[i]->EffectChanged(this, event);
244 // ========================== OTHER EXPORTED FUNCTIONS =========================