os/mm/mmhais/a3facl/src/shared/audiostreammanager.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmhais/a3facl/src/shared/audiostreammanager.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,138 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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 AUDIOSTREAMMANAGER_H
    1.24 +#define AUDIOSTREAMMANAGER_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/a3fbase.h>
    1.30 +#include <a3f/maudiostream.h>
    1.31 +
    1.32 +/**
    1.33 +	A generic AudioComponent base class implementation.
    1.34 +	@see MAudioProcessingUnit
    1.35 +*/
    1.36 +NONSHARABLE_CLASS(CAudioStreamManager) :	public CBase,
    1.37 +											public MAudioStream
    1.38 +	{
    1.39 +public:
    1.40 +	static CAudioStreamManager* NewL(TUid aImplementationUid);
    1.41 +	/**
    1.42 +		Destructor.
    1.43 +		Releases all resources and deletes all objects owned by this instance.
    1.44 +	*/
    1.45 +	virtual ~CAudioStreamManager();
    1.46 +
    1.47 +	//From MAudioStream
    1.48 +	virtual TInt RegisterAudioStreamObserver(MAudioStreamObserver& aObserver);
    1.49 +	virtual void UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver);
    1.50 +	virtual TInt SetAudioType(const TAudioTypeSettings& aAudioTypeSettings);
    1.51 +	virtual void GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const;
    1.52 +	virtual TAudioStreamId InstanceId() const;
    1.53 +	CAudioStreamManager();
    1.54 +
    1.55 +protected: // data
    1.56 +	TAudioStreamId iAudioStreamId;
    1.57 +	TAudioTypeSettings  iAudioTypeSettings;
    1.58 +	RPointerArray<MAudioStreamObserver> iAudioStreamObserver;
    1.59 +
    1.60 +private:
    1.61 +	TUid iDtor_ID_Key;
    1.62 +
    1.63 +	};
    1.64 +
    1.65 +
    1.66 +// Interface's (abstract base class's) destructor
    1.67 +inline CAudioStreamManager::~CAudioStreamManager()
    1.68 +	{
    1.69 +	iAudioStreamObserver.Close();
    1.70 +	REComSession::DestroyedImplementation(iDtor_ID_Key);
    1.71 +	}
    1.72 +
    1.73 +// Interface's (abstract base class's) static factory method implementation.
    1.74 +// Asks ECOM plugin framework to instantiate appropriate concret plugin
    1.75 +// implementation.
    1.76 +inline CAudioStreamManager* CAudioStreamManager::NewL(TUid aImplementationUid)
    1.77 +	{
    1.78 +	TAny* ptr = REComSession::CreateImplementationL( aImplementationUid , _FOFF(CAudioStreamManager, iDtor_ID_Key));
    1.79 +	return static_cast<CAudioStreamManager*>(ptr);
    1.80 +	}
    1.81 +
    1.82 +inline CAudioStreamManager::CAudioStreamManager()
    1.83 +	{
    1.84 +	//iAudioStreamId
    1.85 +	}
    1.86 +
    1.87 +// ---------------------------------------------------------------------------
    1.88 +// CAudioStreamManager::RegisterAudioStreamObserver
    1.89 +// ---------------------------------------------------------------------------
    1.90 +inline TInt CAudioStreamManager::RegisterAudioStreamObserver(MAudioStreamObserver& aObserver)
    1.91 +	{
    1.92 +	TInt err = iAudioStreamObserver.Find(&aObserver);
    1.93 +	if(err == KErrNotFound)
    1.94 +		{
    1.95 +		err = iAudioStreamObserver.Append(&aObserver);
    1.96 +		}
    1.97 +	else
    1.98 +		{
    1.99 +		err = KErrAlreadyExists;
   1.100 +		}
   1.101 +	return err;
   1.102 +	}
   1.103 +
   1.104 +// ---------------------------------------------------------------------------
   1.105 +// CAudioStreamManager::UnregisterAudioStreamObserver
   1.106 +// ---------------------------------------------------------------------------
   1.107 +inline void CAudioStreamManager::UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver)
   1.108 +	{
   1.109 +	TInt idxOrErr = iAudioStreamObserver.Find(&aObserver);
   1.110 +	if( idxOrErr != KErrNotFound )
   1.111 +		{
   1.112 +		iAudioStreamObserver.Remove(idxOrErr);
   1.113 +		}
   1.114 +	}
   1.115 +
   1.116 +// ---------------------------------------------------------------------------
   1.117 +// CAudioStreamManager::InstanceId
   1.118 +// ---------------------------------------------------------------------------
   1.119 +inline TAudioStreamId CAudioStreamManager::InstanceId() const
   1.120 +	{
   1.121 +	return iAudioStreamId;
   1.122 +	}
   1.123 +
   1.124 +// ---------------------------------------------------------------------------
   1.125 +// CAudioStreamManager::SetAudioType
   1.126 +// ---------------------------------------------------------------------------
   1.127 +inline TInt CAudioStreamManager::SetAudioType(const TAudioTypeSettings& aAudioTypeSettings)
   1.128 +	{
   1.129 +	TInt err(KErrNone);
   1.130 +	iAudioTypeSettings = aAudioTypeSettings;
   1.131 +	return err;
   1.132 +	}
   1.133 +
   1.134 +// ---------------------------------------------------------------------------
   1.135 +// CAudioStreamManager::GetAudioType
   1.136 +// ---------------------------------------------------------------------------
   1.137 +inline void CAudioStreamManager::GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const
   1.138 +	{
   1.139 +	aAudioTypeSettings = iAudioTypeSettings;
   1.140 +	}
   1.141 +#endif // CAUDIOSTREAMFACTORY_H