os/mm/mmhais/a3facl/src/shared/audiostreammanager.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2004-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 AUDIOSTREAMMANAGER_H
    21 #define AUDIOSTREAMMANAGER_H
    22 
    23 #include <e32base.h>
    24 #include <ecom/ecom.h>
    25 #include <a3f/a3f_trace_utils.h>
    26 #include <a3f/a3fbase.h>
    27 #include <a3f/maudiostream.h>
    28 
    29 /**
    30 	A generic AudioComponent base class implementation.
    31 	@see MAudioProcessingUnit
    32 */
    33 NONSHARABLE_CLASS(CAudioStreamManager) :	public CBase,
    34 											public MAudioStream
    35 	{
    36 public:
    37 	static CAudioStreamManager* NewL(TUid aImplementationUid);
    38 	/**
    39 		Destructor.
    40 		Releases all resources and deletes all objects owned by this instance.
    41 	*/
    42 	virtual ~CAudioStreamManager();
    43 
    44 	//From MAudioStream
    45 	virtual TInt RegisterAudioStreamObserver(MAudioStreamObserver& aObserver);
    46 	virtual void UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver);
    47 	virtual TInt SetAudioType(const TAudioTypeSettings& aAudioTypeSettings);
    48 	virtual void GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const;
    49 	virtual TAudioStreamId InstanceId() const;
    50 	CAudioStreamManager();
    51 
    52 protected: // data
    53 	TAudioStreamId iAudioStreamId;
    54 	TAudioTypeSettings  iAudioTypeSettings;
    55 	RPointerArray<MAudioStreamObserver> iAudioStreamObserver;
    56 
    57 private:
    58 	TUid iDtor_ID_Key;
    59 
    60 	};
    61 
    62 
    63 // Interface's (abstract base class's) destructor
    64 inline CAudioStreamManager::~CAudioStreamManager()
    65 	{
    66 	iAudioStreamObserver.Close();
    67 	REComSession::DestroyedImplementation(iDtor_ID_Key);
    68 	}
    69 
    70 // Interface's (abstract base class's) static factory method implementation.
    71 // Asks ECOM plugin framework to instantiate appropriate concret plugin
    72 // implementation.
    73 inline CAudioStreamManager* CAudioStreamManager::NewL(TUid aImplementationUid)
    74 	{
    75 	TAny* ptr = REComSession::CreateImplementationL( aImplementationUid , _FOFF(CAudioStreamManager, iDtor_ID_Key));
    76 	return static_cast<CAudioStreamManager*>(ptr);
    77 	}
    78 
    79 inline CAudioStreamManager::CAudioStreamManager()
    80 	{
    81 	//iAudioStreamId
    82 	}
    83 
    84 // ---------------------------------------------------------------------------
    85 // CAudioStreamManager::RegisterAudioStreamObserver
    86 // ---------------------------------------------------------------------------
    87 inline TInt CAudioStreamManager::RegisterAudioStreamObserver(MAudioStreamObserver& aObserver)
    88 	{
    89 	TInt err = iAudioStreamObserver.Find(&aObserver);
    90 	if(err == KErrNotFound)
    91 		{
    92 		err = iAudioStreamObserver.Append(&aObserver);
    93 		}
    94 	else
    95 		{
    96 		err = KErrAlreadyExists;
    97 		}
    98 	return err;
    99 	}
   100 
   101 // ---------------------------------------------------------------------------
   102 // CAudioStreamManager::UnregisterAudioStreamObserver
   103 // ---------------------------------------------------------------------------
   104 inline void CAudioStreamManager::UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver)
   105 	{
   106 	TInt idxOrErr = iAudioStreamObserver.Find(&aObserver);
   107 	if( idxOrErr != KErrNotFound )
   108 		{
   109 		iAudioStreamObserver.Remove(idxOrErr);
   110 		}
   111 	}
   112 
   113 // ---------------------------------------------------------------------------
   114 // CAudioStreamManager::InstanceId
   115 // ---------------------------------------------------------------------------
   116 inline TAudioStreamId CAudioStreamManager::InstanceId() const
   117 	{
   118 	return iAudioStreamId;
   119 	}
   120 
   121 // ---------------------------------------------------------------------------
   122 // CAudioStreamManager::SetAudioType
   123 // ---------------------------------------------------------------------------
   124 inline TInt CAudioStreamManager::SetAudioType(const TAudioTypeSettings& aAudioTypeSettings)
   125 	{
   126 	TInt err(KErrNone);
   127 	iAudioTypeSettings = aAudioTypeSettings;
   128 	return err;
   129 	}
   130 
   131 // ---------------------------------------------------------------------------
   132 // CAudioStreamManager::GetAudioType
   133 // ---------------------------------------------------------------------------
   134 inline void CAudioStreamManager::GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const
   135 	{
   136 	aAudioTypeSettings = iAudioTypeSettings;
   137 	}
   138 #endif // CAUDIOSTREAMFACTORY_H