devsoundextensions/effects/BassBoost/BassBoostProxy/Src/BassBoostEventObserver.cpp
/*
* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: Implementation of the active event observer.
*
*/
// INCLUDE FILES
#ifdef _DEBUG
#include <e32svr.h>
#endif
#include "BassBoostEventObserver.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::CBassBoostEventObserver
// C++ default constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CBassBoostEventObserver::CBassBoostEventObserver()
: CActive(CActive::EPriorityStandard),
iStopped(EFalse)
{
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CBassBoostEventObserver::ConstructL(
TMMFMessageDestinationPckg aMessageHandler,
MCustomCommand& aCustomCommand,
MBassBoostCallback& aCallback )
{
CActiveScheduler::Add(this);
iMessageHandler = aMessageHandler;
iCustomCommand = &aCustomCommand;
iCallback = &aCallback;
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CBassBoostEventObserver* CBassBoostEventObserver::NewL(
TMMFMessageDestinationPckg aMessageHandler,
MCustomCommand& aCustomCommand,
MBassBoostCallback& aCallback )
{
CBassBoostEventObserver* self = new(ELeave) CBassBoostEventObserver();
CleanupStack::PushL(self);
self->ConstructL(aMessageHandler, aCustomCommand, aCallback);
CleanupStack::Pop(self);
return self;
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::~CBassBoostEventObserver
// Destructor
// -----------------------------------------------------------------------------
//
CBassBoostEventObserver::~CBassBoostEventObserver()
{
// We should not have to cancel the outstanding request because the message
// handler will complete our request with KErrCancel in its destructor.
Cancel();
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::Start
// Kickoff the event observer by issuing the first observation message.
// -----------------------------------------------------------------------------
//
void CBassBoostEventObserver::Start()
{
if( !iStopped && !IsActive() )
{
iCustomCommand->CustomCommandAsync(iMessageHandler, (TInt)EBfObserve, KNullDesC8, KNullDesC8, iDataPckgFrom, iStatus);
iStopped = EFalse;
SetActive();
}
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::Stop
// -----------------------------------------------------------------------------
//
void CBassBoostEventObserver::Stop()
{
iStopped = ETrue;
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::RunL
// Invoke by the active scheduler when a request completes, In this case, our
// observation message has completed.
// The proxy is notified. Afterwards, reissue the request to continue observation.
// -----------------------------------------------------------------------------
//
void CBassBoostEventObserver::RunL()
{
#ifdef _DEBUG
RDebug::Print(_L("CBassBoostEventObserver::RunL()\n"));
#endif
if( iStatus == KErrNone )
{
iCallback->BassBoostEvent(iDataPckgFrom);
Start();
}
else
{
iStopped = ETrue;
}
}
// -----------------------------------------------------------------------------
// CBassBoostEventObserver::DoCancel
// Cancels the current and any on going requests/tasks.
// -----------------------------------------------------------------------------
//
void CBassBoostEventObserver::DoCancel()
{
#ifdef _DEBUG
RDebug::Print(_L("CBassBoostEventObserver::DoCancel()\n"));
#endif
iStopped = ETrue;
}
// End of file