1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmhais/a3facl/src/shared/audioprocessingunit.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,155 @@
1.4 +/*
1.5 +* Copyright (c) 2006-2009 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:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#ifndef AUDIOPROCESSINGUNIT_H
1.24 +#define AUDIOPROCESSINGUNIT_H
1.25 +
1.26 +#include <e32base.h>
1.27 +#include <ecom/ecom.h>
1.28 +#include <a3f/a3f_trace_utils.h>
1.29 +#include <a3f/audioprocessingunittypeuids.h>
1.30 +#include <a3f/maudioprocessingunit.h>
1.31 +#include <a3f/maudioprocessingunitobserver.h>
1.32 +
1.33 +#include "componentparameters.h"
1.34 +#include "mlogicalsettingsobserver.h"
1.35 +
1.36 +
1.37 +/**
1.38 +A generic AudioComponent base class implementation.
1.39 +@see MAudioProcessingUnit
1.40 +*/
1.41 +class CAudioProcessingUnit: public CBase,
1.42 + public MAudioProcessingUnit
1.43 + {
1.44 +
1.45 +public:
1.46 +
1.47 + static CAudioProcessingUnit* NewL(TComponentParameters aParameters);
1.48 +
1.49 + /**
1.50 + Destructor.
1.51 + Releases all resources and deletes all objects owned by this instance.
1.52 + */
1.53 + virtual ~CAudioProcessingUnit();
1.54 +
1.55 + // from base class MAudioProcessingUnit
1.56 + virtual TAudioComponentId InstanceId() const;
1.57 + virtual TAudioContextId ContextId() const;
1.58 + virtual TBool IsTypeOf(TUid aTypeId) const;
1.59 + virtual TAny* Interface(TUid aType);
1.60 + virtual TInt RegisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver);
1.61 + virtual void UnregisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver);
1.62 +
1.63 + CAudioProcessingUnit(TAny* aParam);
1.64 +
1.65 +protected: // data
1.66 + // Component type Uid
1.67 + TUid iType;
1.68 +
1.69 + // Audio context Id
1.70 + TAudioContextId iContextId;
1.71 +
1.72 + // Component instance Id
1.73 + TAudioComponentId iInstanceId;
1.74 +
1.75 + // Array of component observers.
1.76 + RPointerArray<MAudioProcessingUnitObserver> iAudioProcessingUnitObservers;
1.77 +
1.78 + // Settings observer
1.79 + MLogicalSettingObserver* iSettingsObserver;
1.80 +
1.81 +private: // data
1.82 + TUid iDtor_ID_Key;
1.83 + };
1.84 +
1.85 +// Interface's (abstract base class's) destructor
1.86 +inline CAudioProcessingUnit::~CAudioProcessingUnit()
1.87 + {
1.88 + iAudioProcessingUnitObservers.Close();
1.89 + REComSession::DestroyedImplementation(iDtor_ID_Key);
1.90 + }
1.91 +
1.92 +// Interface's (abstract base class's) static factory method implementation.
1.93 +// Asks ECOM plugin framework to instantiate appropriate concret plugin
1.94 +// implementation.
1.95 +inline CAudioProcessingUnit* CAudioProcessingUnit::NewL(TComponentParameters aParameters)
1.96 + {
1.97 + TAny* ptr = REComSession::CreateImplementationL( aParameters.iTypeUid , _FOFF(CAudioProcessingUnit, iDtor_ID_Key), static_cast<TAny*>(&aParameters));
1.98 + return static_cast<CAudioProcessingUnit*>(ptr);
1.99 + }
1.100 +
1.101 +inline CAudioProcessingUnit::CAudioProcessingUnit(TAny* aParam)
1.102 + {
1.103 + TComponentParameters* param = static_cast<TComponentParameters*>(aParam);
1.104 + iType = param->iTypeUid;
1.105 + iInstanceId = param->iInstanceId;
1.106 + iContextId = param->iContextId;
1.107 + iSettingsObserver = param->iSettingsObserver;
1.108 + }
1.109 +
1.110 +// ---------------------------------------------------------------------------
1.111 +// from class MAudioProcessingUnit
1.112 +// CLogicalAudioCodec::GetContextId
1.113 +// ---------------------------------------------------------------------------
1.114 +inline TAudioContextId CAudioProcessingUnit::ContextId() const
1.115 + {
1.116 + return iContextId;
1.117 + }
1.118 +
1.119 +inline TAudioComponentId CAudioProcessingUnit::InstanceId() const
1.120 + {
1.121 + return iInstanceId;
1.122 + }
1.123 +
1.124 +// ---------------------------------------------------------------------------
1.125 +// from class MAudioProcessingUnit
1.126 +// CLogicalAudioCodec::RegisterComponentObserver
1.127 +// ---------------------------------------------------------------------------
1.128 +inline TInt CAudioProcessingUnit::RegisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver)
1.129 + {
1.130 + TInt err = iAudioProcessingUnitObservers.Find(&aObserver);
1.131 + if( err != KErrNotFound )
1.132 + {
1.133 + err = KErrAlreadyExists;
1.134 + }
1.135 + else
1.136 + {
1.137 + err = iAudioProcessingUnitObservers.Append(&aObserver);
1.138 + }
1.139 + return err;
1.140 + }
1.141 +
1.142 +// ---------------------------------------------------------------------------
1.143 +// from class MAudioProcessingUnit
1.144 +// CLogicalAudioCodec::UnregisterComponentObserver
1.145 +// ---------------------------------------------------------------------------
1.146 +inline void CAudioProcessingUnit::UnregisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver)
1.147 + {
1.148 + TInt idxOrErr = iAudioProcessingUnitObservers.Find(&aObserver);
1.149 + if( idxOrErr != KErrNotFound )
1.150 + {
1.151 + iAudioProcessingUnitObservers.Remove(idxOrErr);
1.152 + }
1.153 + }
1.154 +
1.155 +inline TBool CAudioProcessingUnit::IsTypeOf(TUid) const {return EFalse;}
1.156 +inline TAny* CAudioProcessingUnit::Interface(TUid) { TAny* any(NULL); return any;}
1.157 +
1.158 +#endif // AUDIOPROCESSINGUNIT_H