os/mm/devsound/a3fdevsound/src/mmfaudioserverfactory/mmfaudioserverfactory.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/a3fdevsound/src/mmfaudioserverfactory/mmfaudioserverfactory.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,120 @@
     1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +// INCLUDE FILES
    1.22 +#include "mmfaudioserverfactory.h"
    1.23 +#include <a3f/mmfaudiosvrservice.hrh>
    1.24 +#include <mm/mmpluginutils.h>
    1.25 +#include <mm/mmcleanup.h>
    1.26 +#include <badesca.h>
    1.27 +
    1.28 +/**
    1.29 + * CMMFAudioServerFactory::CMMFAudioServerFactory
    1.30 + * C++ default constructor.
    1.31 + */
    1.32 +CMMFAudioServerFactory::CMMFAudioServerFactory()
    1.33 +	{
    1.34 +	}
    1.35 +
    1.36 +/**
    1.37 + * CMMFAudioServerFactory::ConstructL
    1.38 + * Symbian 2nd phase constructor.
    1.39 + */
    1.40 +void CMMFAudioServerFactory::ConstructL()
    1.41 +	{
    1.42 +	TUid KAudioServiceInterfaceDefinitionUid = {KUidA3fAudioServicePlugin};
    1.43 +	RImplInfoPtrArray ecomArray;
    1.44 +	CleanupResetAndDestroyPushL(ecomArray);
    1.45 +	
    1.46 +	MmPluginUtils::FindImplementationsL(KAudioServiceInterfaceDefinitionUid, ecomArray);
    1.47 +	
    1.48 +	TInt count = ecomArray.Count();
    1.49 +	
    1.50 +	for (TInt i=0; i<count; i++)
    1.51 +		{
    1.52 +		TUid destructorKey;
    1.53 +		TUid implementationUid = ecomArray[i]->ImplementationUid();
    1.54 +		
    1.55 +		TAny* ptr = REComSession::CreateImplementationL( implementationUid,destructorKey,NULL);
    1.56 +		MAudioSvrService* audioservice = (static_cast <MAudioSvrService*>(ptr));
    1.57 +		audioservice->PassDestructorKey(destructorKey);
    1.58 +		CleanupReleasePushL(*audioservice);
    1.59 +		iAudioServList.AppendL(audioservice);
    1.60 +		CleanupStack::Pop(audioservice);
    1.61 +		User::LeaveIfError(audioservice->Load());
    1.62 +		}
    1.63 +		
    1.64 +	CleanupStack::PopAndDestroy(&ecomArray);
    1.65 +	}
    1.66 +
    1.67 +// -----------------------------------------------------------------------------
    1.68 +// CMMFAudioServerFactory::NewL
    1.69 +// Two-phased constructor.
    1.70 +// -----------------------------------------------------------------------------
    1.71 +//
    1.72 +EXPORT_C CMMFAudioServerFactory* CMMFAudioServerFactory::NewL()
    1.73 +	{
    1.74 +	CMMFAudioServerFactory* self = new (ELeave)CMMFAudioServerFactory;
    1.75 +	CleanupStack::PushL(self);
    1.76 +	self->ConstructL();
    1.77 +	CleanupStack::Pop(self);
    1.78 +	return self;
    1.79 +	}
    1.80 +
    1.81 +// Destructor
    1.82 +EXPORT_C CMMFAudioServerFactory::~CMMFAudioServerFactory()
    1.83 +	{
    1.84 +	TInt audioservicecount = iAudioServList.Count();
    1.85 +	for(TInt i= 0;i<audioservicecount;i++ )
    1.86 +		{
    1.87 +		iAudioServList[i]->Release();
    1.88 +		}
    1.89 +	iAudioServList.Close();
    1.90 +	}
    1.91 +
    1.92 +/**
    1.93 + * CMMFAudioServerFactory::StartL
    1.94 + * Called by Audio Server when Audio Server is started
    1.95 + * (other items were commented in a header).
    1.96 + */
    1.97 +EXPORT_C void CMMFAudioServerFactory::StartL(
    1.98 +								const CMMFAudioServer& /*aAudioServer*/)
    1.99 +	{
   1.100 +	TInt audioservicecount = iAudioServList.Count();
   1.101 +	for (TInt i=0; i<audioservicecount; i++)
   1.102 +		{
   1.103 +		User::LeaveIfError(iAudioServList[i]->Start());
   1.104 +		}
   1.105 +	
   1.106 +	}
   1.107 +
   1.108 +/**
   1.109 + * CMMFAudioServerFactory::Stop
   1.110 + * Called by Audio Server when Audio Server is shutting down
   1.111 + */
   1.112 +EXPORT_C void CMMFAudioServerFactory::Stop(
   1.113 +								const CMMFAudioServer& /*aAudioServer*/)
   1.114 +	{
   1.115 +	TInt audioservicecount = iAudioServList.Count();
   1.116 +	for(TInt i= 0;i<audioservicecount;i++ )
   1.117 +		{
   1.118 +		iAudioServList[i]->Stop();
   1.119 +		}
   1.120 +	
   1.121 +	}
   1.122 +
   1.123 +// End of File