1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsoundextensions/effects/BassBoost/BassBoostProxy/Src/BassBoostProxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,204 @@
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 "BassBoostProxy.h"
1.31 +#include "BassBoostEventObserver.h"
1.32 +#include <CustomInterfaceUtility.h>
1.33 +
1.34 +
1.35 +// ============================ MEMBER FUNCTIONS ===============================
1.36 +
1.37 +// -----------------------------------------------------------------------------
1.38 +// CBassBoostProxy::CBassBoostProxy
1.39 +// C++ default constructor can NOT contain any code, that
1.40 +// might leave.
1.41 +// -----------------------------------------------------------------------------
1.42 +//
1.43 +CBassBoostProxy::CBassBoostProxy(
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 +CBassBoostProxy::~CBassBoostProxy()
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 iBassBoostEventObserver;
1.61 + delete iCustomInterfaceUtility;
1.62 + }
1.63 +
1.64 +// -----------------------------------------------------------------------------
1.65 +// CBassBoostProxy::NewL
1.66 +// Static function for creating an instance of the BassBoost object.
1.67 +// -----------------------------------------------------------------------------
1.68 +//
1.69 +EXPORT_C CBassBoostProxy* CBassBoostProxy::NewL(
1.70 + TMMFMessageDestinationPckg aMessageHandler,
1.71 + MCustomCommand& aCustomCommand,
1.72 + CCustomInterfaceUtility* aCustomInterfaceUtility )
1.73 + {
1.74 + CBassBoostProxy* self = new (ELeave) CBassBoostProxy(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 +// CBassBoostProxy::ConstructL
1.83 +// -----------------------------------------------------------------------------
1.84 +//
1.85 +void CBassBoostProxy::ConstructL()
1.86 + {
1.87 + iBassBoostEventObserver = CBassBoostEventObserver::NewL(iMessageHandler, *iCustomCommand, *this);
1.88 + StartObserver();
1.89 +
1.90 + TEfBassBoostDataPckg dataPckgFrom;
1.91 + // sends a message to fetch initial data.
1.92 + iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfInitialize, KNullDesC8, KNullDesC8, dataPckgFrom);
1.93 + SetEffectData(dataPckgFrom);
1.94 + }
1.95 +
1.96 +
1.97 +// -----------------------------------------------------------------------------
1.98 +// CBassBoostProxy::ApplyL
1.99 +// Apply the bassboost settings.
1.100 +// -----------------------------------------------------------------------------
1.101 +//
1.102 +EXPORT_C void CBassBoostProxy::ApplyL()
1.103 + {
1.104 +#ifdef _DEBUG
1.105 + RDebug::Print(_L("CBassBoostProxy::Apply"));
1.106 +#endif
1.107 +
1.108 + if (iHaveUpdateRights )
1.109 + {
1.110 + iBassBoostData.iEnabled = iEnabled;
1.111 + iBassBoostData.iEnforced = iEnforced;
1.112 + iBassBoostData.iHaveUpdateRights = iHaveUpdateRights;
1.113 +
1.114 + iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EBfApply, DoEffectData(), KNullDesC8);
1.115 + }
1.116 + else
1.117 + {
1.118 + User::Leave(KErrAccessDenied);
1.119 + }
1.120 + }
1.121 +
1.122 +// -----------------------------------------------------------------------------
1.123 +// CBassBoostProxy::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 CBassBoostProxy::StartObserver()
1.129 + {
1.130 +#ifdef _DEBUG
1.131 + RDebug::Print(_L("CBassBoostProxy::StartObserver"));
1.132 +#endif
1.133 +
1.134 + iBassBoostEventObserver->Start();
1.135 + }
1.136 +
1.137 +// -----------------------------------------------------------------------------
1.138 +// CBassBoostProxy::BassBoostEvent
1.139 +// Checks which data member has changed and notify the observers.
1.140 +// -----------------------------------------------------------------------------
1.141 +//
1.142 +void CBassBoostProxy::BassBoostEvent(
1.143 + const TDesC8& aBuffer )
1.144 + {
1.145 +#ifdef _DEBUG
1.146 + RDebug::Print(_L("CBassBoostProxy::BassBoostEvent"));
1.147 +#endif
1.148 +
1.149 + TEfBassBoostDataPckg dataPckgFrom;
1.150 + dataPckgFrom.Copy(aBuffer);
1.151 + TEfBassBoostData newBassBoostData = dataPckgFrom();
1.152 +
1.153 + TUint8 event = 0;
1.154 +
1.155 + if ( newBassBoostData.iEnabled != iBassBoostData.iEnabled )
1.156 + {
1.157 + iBassBoostData.iEnabled = newBassBoostData.iEnabled;
1.158 + iEnabled = newBassBoostData.iEnabled;
1.159 + if ( iBassBoostData.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 ( newBassBoostData.iEnforced != iBassBoostData.iEnforced )
1.169 + {
1.170 + iBassBoostData.iEnforced = newBassBoostData.iEnforced;
1.171 + iEnforced = newBassBoostData.iEnforced;
1.172 + if ( iBassBoostData.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 ( newBassBoostData.iHaveUpdateRights != iBassBoostData.iHaveUpdateRights )
1.182 + {
1.183 + iBassBoostData.iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
1.184 + iHaveUpdateRights = newBassBoostData.iHaveUpdateRights;
1.185 + if ( iBassBoostData.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 +
1.195 + if (!event)
1.196 + return;
1.197 +
1.198 + for ( TInt i = 0; i < iObservers.Count(); i++ )
1.199 + {
1.200 + iObservers[i]->EffectChanged(this, event);
1.201 + }
1.202 + }
1.203 +
1.204 +
1.205 +// ========================== OTHER EXPORTED FUNCTIONS =========================
1.206 +
1.207 +