devsound/a3fdevsound/src/mmfaudioserverfactory/mmfaudioserverfactory.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "mmfaudioserverfactory.h"
       
    20 #include <a3f/mmfaudiosvrservice.hrh>
       
    21 #include <mm/mmpluginutils.h>
       
    22 #include <mm/mmcleanup.h>
       
    23 #include <badesca.h>
       
    24 
       
    25 /**
       
    26  * CMMFAudioServerFactory::CMMFAudioServerFactory
       
    27  * C++ default constructor.
       
    28  */
       
    29 CMMFAudioServerFactory::CMMFAudioServerFactory()
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34  * CMMFAudioServerFactory::ConstructL
       
    35  * Symbian 2nd phase constructor.
       
    36  */
       
    37 void CMMFAudioServerFactory::ConstructL()
       
    38 	{
       
    39 	TUid KAudioServiceInterfaceDefinitionUid = {KUidA3fAudioServicePlugin};
       
    40 	RImplInfoPtrArray ecomArray;
       
    41 	CleanupResetAndDestroyPushL(ecomArray);
       
    42 	
       
    43 	MmPluginUtils::FindImplementationsL(KAudioServiceInterfaceDefinitionUid, ecomArray);
       
    44 	
       
    45 	TInt count = ecomArray.Count();
       
    46 	
       
    47 	for (TInt i=0; i<count; i++)
       
    48 		{
       
    49 		TUid destructorKey;
       
    50 		TUid implementationUid = ecomArray[i]->ImplementationUid();
       
    51 		
       
    52 		TAny* ptr = REComSession::CreateImplementationL( implementationUid,destructorKey,NULL);
       
    53 		MAudioSvrService* audioservice = (static_cast <MAudioSvrService*>(ptr));
       
    54 		audioservice->PassDestructorKey(destructorKey);
       
    55 		CleanupReleasePushL(*audioservice);
       
    56 		iAudioServList.AppendL(audioservice);
       
    57 		CleanupStack::Pop(audioservice);
       
    58 		User::LeaveIfError(audioservice->Load());
       
    59 		}
       
    60 		
       
    61 	CleanupStack::PopAndDestroy(&ecomArray);
       
    62 	}
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CMMFAudioServerFactory::NewL
       
    66 // Two-phased constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C CMMFAudioServerFactory* CMMFAudioServerFactory::NewL()
       
    70 	{
       
    71 	CMMFAudioServerFactory* self = new (ELeave)CMMFAudioServerFactory;
       
    72 	CleanupStack::PushL(self);
       
    73 	self->ConstructL();
       
    74 	CleanupStack::Pop(self);
       
    75 	return self;
       
    76 	}
       
    77 
       
    78 // Destructor
       
    79 EXPORT_C CMMFAudioServerFactory::~CMMFAudioServerFactory()
       
    80 	{
       
    81 	TInt audioservicecount = iAudioServList.Count();
       
    82 	for(TInt i= 0;i<audioservicecount;i++ )
       
    83 		{
       
    84 		iAudioServList[i]->Release();
       
    85 		}
       
    86 	iAudioServList.Close();
       
    87 	}
       
    88 
       
    89 /**
       
    90  * CMMFAudioServerFactory::StartL
       
    91  * Called by Audio Server when Audio Server is started
       
    92  * (other items were commented in a header).
       
    93  */
       
    94 EXPORT_C void CMMFAudioServerFactory::StartL(
       
    95 								const CMMFAudioServer& /*aAudioServer*/)
       
    96 	{
       
    97 	TInt audioservicecount = iAudioServList.Count();
       
    98 	for (TInt i=0; i<audioservicecount; i++)
       
    99 		{
       
   100 		User::LeaveIfError(iAudioServList[i]->Start());
       
   101 		}
       
   102 	
       
   103 	}
       
   104 
       
   105 /**
       
   106  * CMMFAudioServerFactory::Stop
       
   107  * Called by Audio Server when Audio Server is shutting down
       
   108  */
       
   109 EXPORT_C void CMMFAudioServerFactory::Stop(
       
   110 								const CMMFAudioServer& /*aAudioServer*/)
       
   111 	{
       
   112 	TInt audioservicecount = iAudioServList.Count();
       
   113 	for(TInt i= 0;i<audioservicecount;i++ )
       
   114 		{
       
   115 		iAudioServList[i]->Stop();
       
   116 		}
       
   117 	
       
   118 	}
       
   119 
       
   120 // End of File