devsoundextensions/effects/SrcDoppler/SourceDopplerProxy/Src/SourceDopplerEventObserver.cpp
Bug 3673 - Seeking via grabbing the Music Player progress bar does not work.
/*
* 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 "SourceDopplerEventObserver.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CDopplerEventObserver::CDopplerEventObserver
// C++ default constructor can NOT contain any code, that
// might leave.
// -----------------------------------------------------------------------------
//
CSourceDopplerEventObserver::CSourceDopplerEventObserver()
: CActive(CActive::EPriorityStandard),
iStopped(EFalse)
{
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CSourceDopplerEventObserver::ConstructL(
TMMFMessageDestinationPckg aMessageHandler,
MCustomCommand& aCustomCommand,
MSourceDopplerCallback& aCallback )
{
CActiveScheduler::Add(this);
iMessageHandler = aMessageHandler;
iCustomCommand = &aCustomCommand;
iCallback = &aCallback;
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::NewL
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CSourceDopplerEventObserver* CSourceDopplerEventObserver::NewL(
TMMFMessageDestinationPckg aMessageHandler,
MCustomCommand& aCustomCommand,
MSourceDopplerCallback& aCallback )
{
CSourceDopplerEventObserver* self = new(ELeave) CSourceDopplerEventObserver();
CleanupStack::PushL(self);
self->ConstructL(aMessageHandler, aCustomCommand, aCallback);
CleanupStack::Pop(self);
return self;
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::~CDopplerEventObserver
// Destructor
// -----------------------------------------------------------------------------
//
CSourceDopplerEventObserver::~CSourceDopplerEventObserver()
{
// We should not have to cancel the outstanding request because the message
// handler will complete our request with KErrCancel in its destructor.
Cancel();
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::Start
// Kickoff the event observer by issuing the first observation message.
// -----------------------------------------------------------------------------
//
void CSourceDopplerEventObserver::Start()
{
if( !iStopped && !IsActive() )
{
iCustomCommand->CustomCommandAsync(iMessageHandler, (TInt)ESourceDopplerOfObserve, KNullDesC8, KNullDesC8, iDataPckgFrom, iStatus);
iStopped = EFalse;
SetActive();
}
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::Stop
// -----------------------------------------------------------------------------
//
void CSourceDopplerEventObserver::Stop()
{
iStopped = ETrue;
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::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 CSourceDopplerEventObserver::RunL()
{
#ifdef _DEBUG
RDebug::Print(_L("CSourceDopplerEventObserver::RunL()\n"));
#endif
if( iStatus == KErrNone )
{
iCallback->SourceDopplerEvent(iDataPckgFrom);
Start();
}
else
{
iStopped = ETrue;
}
}
// -----------------------------------------------------------------------------
// CDopplerEventObserver::DoCancel
// Cancels the current and any on going requests/tasks.
// -----------------------------------------------------------------------------
//
void CSourceDopplerEventObserver::DoCancel()
{
#ifdef _DEBUG
RDebug::Print(_L("CSourceDopplerEventObserver::DoCancel()\n"));
#endif
iStopped = ETrue;
}
// End of file