sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #ifndef AUDIOSTREAMMANAGER_H sl@0: #define AUDIOSTREAMMANAGER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: A generic AudioComponent base class implementation. sl@0: @see MAudioProcessingUnit sl@0: */ sl@0: NONSHARABLE_CLASS(CAudioStreamManager) : public CBase, sl@0: public MAudioStream sl@0: { sl@0: public: sl@0: static CAudioStreamManager* NewL(TUid aImplementationUid); sl@0: /** sl@0: Destructor. sl@0: Releases all resources and deletes all objects owned by this instance. sl@0: */ sl@0: virtual ~CAudioStreamManager(); sl@0: sl@0: //From MAudioStream sl@0: virtual TInt RegisterAudioStreamObserver(MAudioStreamObserver& aObserver); sl@0: virtual void UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver); sl@0: virtual TInt SetAudioType(const TAudioTypeSettings& aAudioTypeSettings); sl@0: virtual void GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const; sl@0: virtual TAudioStreamId InstanceId() const; sl@0: CAudioStreamManager(); sl@0: sl@0: protected: // data sl@0: TAudioStreamId iAudioStreamId; sl@0: TAudioTypeSettings iAudioTypeSettings; sl@0: RPointerArray iAudioStreamObserver; sl@0: sl@0: private: sl@0: TUid iDtor_ID_Key; sl@0: sl@0: }; sl@0: sl@0: sl@0: // Interface's (abstract base class's) destructor sl@0: inline CAudioStreamManager::~CAudioStreamManager() sl@0: { sl@0: iAudioStreamObserver.Close(); sl@0: REComSession::DestroyedImplementation(iDtor_ID_Key); sl@0: } sl@0: sl@0: // Interface's (abstract base class's) static factory method implementation. sl@0: // Asks ECOM plugin framework to instantiate appropriate concret plugin sl@0: // implementation. sl@0: inline CAudioStreamManager* CAudioStreamManager::NewL(TUid aImplementationUid) sl@0: { sl@0: TAny* ptr = REComSession::CreateImplementationL( aImplementationUid , _FOFF(CAudioStreamManager, iDtor_ID_Key)); sl@0: return static_cast(ptr); sl@0: } sl@0: sl@0: inline CAudioStreamManager::CAudioStreamManager() sl@0: { sl@0: //iAudioStreamId sl@0: } sl@0: sl@0: // --------------------------------------------------------------------------- sl@0: // CAudioStreamManager::RegisterAudioStreamObserver sl@0: // --------------------------------------------------------------------------- sl@0: inline TInt CAudioStreamManager::RegisterAudioStreamObserver(MAudioStreamObserver& aObserver) sl@0: { sl@0: TInt err = iAudioStreamObserver.Find(&aObserver); sl@0: if(err == KErrNotFound) sl@0: { sl@0: err = iAudioStreamObserver.Append(&aObserver); sl@0: } sl@0: else sl@0: { sl@0: err = KErrAlreadyExists; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: // --------------------------------------------------------------------------- sl@0: // CAudioStreamManager::UnregisterAudioStreamObserver sl@0: // --------------------------------------------------------------------------- sl@0: inline void CAudioStreamManager::UnregisterAudioStreamObserver(MAudioStreamObserver& aObserver) sl@0: { sl@0: TInt idxOrErr = iAudioStreamObserver.Find(&aObserver); sl@0: if( idxOrErr != KErrNotFound ) sl@0: { sl@0: iAudioStreamObserver.Remove(idxOrErr); sl@0: } sl@0: } sl@0: sl@0: // --------------------------------------------------------------------------- sl@0: // CAudioStreamManager::InstanceId sl@0: // --------------------------------------------------------------------------- sl@0: inline TAudioStreamId CAudioStreamManager::InstanceId() const sl@0: { sl@0: return iAudioStreamId; sl@0: } sl@0: sl@0: // --------------------------------------------------------------------------- sl@0: // CAudioStreamManager::SetAudioType sl@0: // --------------------------------------------------------------------------- sl@0: inline TInt CAudioStreamManager::SetAudioType(const TAudioTypeSettings& aAudioTypeSettings) sl@0: { sl@0: TInt err(KErrNone); sl@0: iAudioTypeSettings = aAudioTypeSettings; sl@0: return err; sl@0: } sl@0: sl@0: // --------------------------------------------------------------------------- sl@0: // CAudioStreamManager::GetAudioType sl@0: // --------------------------------------------------------------------------- sl@0: inline void CAudioStreamManager::GetAudioType(TAudioTypeSettings& aAudioTypeSettings) const sl@0: { sl@0: aAudioTypeSettings = iAudioTypeSettings; sl@0: } sl@0: #endif // CAUDIOSTREAMFACTORY_H