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