os/mm/mmhais/a3facl/src/shared/audioprocessingunit.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef AUDIOPROCESSINGUNIT_H
    21 #define AUDIOPROCESSINGUNIT_H
    22 
    23 #include <e32base.h>
    24 #include <ecom/ecom.h>
    25 #include <a3f/a3f_trace_utils.h>
    26 #include <a3f/audioprocessingunittypeuids.h>
    27 #include <a3f/maudioprocessingunit.h>
    28 #include <a3f/maudioprocessingunitobserver.h>
    29 
    30 #include "componentparameters.h"
    31 #include "mlogicalsettingsobserver.h"
    32 
    33 
    34 /**
    35 A generic AudioComponent base class implementation.
    36 @see MAudioProcessingUnit
    37 */
    38 class CAudioProcessingUnit: public CBase, 
    39 							public MAudioProcessingUnit
    40 	{
    41 
    42 public:
    43 
    44 	static CAudioProcessingUnit* NewL(TComponentParameters aParameters);
    45 
    46 	/**
    47 	Destructor.
    48 	Releases all resources and deletes all objects owned by this instance.
    49 	*/
    50 	virtual ~CAudioProcessingUnit();
    51 
    52 	// from base class MAudioProcessingUnit
    53 	virtual TAudioComponentId InstanceId() const;
    54 	virtual TAudioContextId ContextId() const;
    55 	virtual TBool IsTypeOf(TUid aTypeId) const;
    56 	virtual TAny* Interface(TUid aType);
    57 	virtual TInt RegisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver);
    58 	virtual void UnregisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver);
    59 
    60 	CAudioProcessingUnit(TAny* aParam);
    61 
    62 protected: // data
    63 	// Component type Uid
    64 	TUid iType;
    65 
    66 	// Audio context Id
    67 	TAudioContextId iContextId;
    68 
    69 	// Component instance Id
    70 	TAudioComponentId iInstanceId;
    71 
    72 	// Array of component observers.
    73 	RPointerArray<MAudioProcessingUnitObserver> iAudioProcessingUnitObservers;
    74 
    75 	// Settings observer
    76 	MLogicalSettingObserver* iSettingsObserver;
    77 
    78 private: // data
    79 	TUid iDtor_ID_Key;
    80 	};
    81 
    82 // Interface's (abstract base class's) destructor
    83 inline CAudioProcessingUnit::~CAudioProcessingUnit()
    84 	{
    85 	iAudioProcessingUnitObservers.Close();
    86 	REComSession::DestroyedImplementation(iDtor_ID_Key);
    87 	}
    88 
    89 // Interface's (abstract base class's) static factory method implementation.
    90 // Asks ECOM plugin framework to instantiate appropriate concret plugin
    91 // implementation.
    92 inline CAudioProcessingUnit* CAudioProcessingUnit::NewL(TComponentParameters aParameters)
    93 	{	
    94 	TAny* ptr = REComSession::CreateImplementationL( aParameters.iTypeUid , _FOFF(CAudioProcessingUnit, iDtor_ID_Key), static_cast<TAny*>(&aParameters));
    95 	return static_cast<CAudioProcessingUnit*>(ptr);
    96 	}
    97 
    98 inline CAudioProcessingUnit::CAudioProcessingUnit(TAny* aParam)
    99 	{
   100 	TComponentParameters* param = static_cast<TComponentParameters*>(aParam);
   101 	iType = param->iTypeUid;
   102 	iInstanceId = param->iInstanceId;
   103 	iContextId = param->iContextId;
   104 	iSettingsObserver = param->iSettingsObserver;
   105 	}
   106 
   107 // ---------------------------------------------------------------------------
   108 // from class MAudioProcessingUnit
   109 // CLogicalAudioCodec::GetContextId
   110 // ---------------------------------------------------------------------------
   111 inline TAudioContextId CAudioProcessingUnit::ContextId() const
   112 	{
   113 	return iContextId;
   114 	}
   115 
   116 inline TAudioComponentId CAudioProcessingUnit::InstanceId() const 
   117 	{
   118 	return iInstanceId;
   119 	}
   120 
   121 // ---------------------------------------------------------------------------
   122 // from class MAudioProcessingUnit
   123 // CLogicalAudioCodec::RegisterComponentObserver
   124 // ---------------------------------------------------------------------------
   125 inline TInt CAudioProcessingUnit::RegisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver)
   126 	{
   127 	TInt err = iAudioProcessingUnitObservers.Find(&aObserver);
   128 	if( err != KErrNotFound )
   129 		{
   130 		err = KErrAlreadyExists;
   131 		}
   132 	else
   133 		{
   134 		err = iAudioProcessingUnitObservers.Append(&aObserver);
   135 		}
   136 	return err;
   137 	}
   138 
   139 // ---------------------------------------------------------------------------
   140 // from class MAudioProcessingUnit
   141 // CLogicalAudioCodec::UnregisterComponentObserver
   142 // ---------------------------------------------------------------------------
   143 inline void CAudioProcessingUnit::UnregisterProcessingUnitObserver(MAudioProcessingUnitObserver& aObserver)
   144 	{
   145 	TInt idxOrErr = iAudioProcessingUnitObservers.Find(&aObserver);
   146 	if( idxOrErr != KErrNotFound )
   147 		{
   148 		iAudioProcessingUnitObservers.Remove(idxOrErr);
   149 		}
   150 	}
   151 
   152 inline TBool CAudioProcessingUnit::IsTypeOf(TUid) const {return EFalse;}
   153 inline TAny* CAudioProcessingUnit::Interface(TUid) { TAny* any(NULL); return any;}
   154 
   155 #endif // AUDIOPROCESSINGUNIT_H