os/mm/devsound/devsoundrefplugin/src/platsec/server/Policy/MmfAudioPolicyStart.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 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 #include <e32std.h>
    17 #include <ecom/ecom.h>
    18 #include "MmfAudioPolicyServer.h"
    19 
    20 _LIT(KMMFAudioPolicyServerName,"MMFAudioPolicyServer");
    21 
    22 EXPORT_C TInt CMMFAudioPolicyServer::StartThread(TAny* aParms)
    23 /**
    24 Thread entry-point function.
    25 The TServerStart objects is passed as the thread parameter
    26 **/
    27 	{
    28 	TInt err = KErrNone;
    29 	__UHEAP_MARK;
    30 	//This line will be used if parameters need to be passed.
    31 	TServerStart* start = reinterpret_cast<TServerStart*>(aParms);
    32 	CTrapCleanup* cleanup = CTrapCleanup::New();
    33 	if (!cleanup)
    34 		{
    35 		err = KErrNoMemory;
    36 		}
    37 	else
    38 		{
    39 		TRAP(err, StartThreadL(*start));
    40 		}
    41 	delete cleanup;
    42 
    43 	REComSession::FinalClose();
    44 	__UHEAP_MARKEND;
    45 	return err;
    46 	}
    47 
    48 void CMMFAudioPolicyServer::StartThreadL(TServerStart& aStart)
    49 	{
    50 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
    51 	CleanupStack::PushL(sched);
    52 	
    53 	CActiveScheduler::Install(sched);
    54 	//Rename Audio Policy server name
    55 	RThread audioPolicyThread;
    56 	TName name;
    57     name.Append(KMMFAudioPolicyServerName);
    58 	//We are ignoring the error code returned from User::RenameThread
    59 	//as it is not important here, may be for profiling
    60 	User::RenameThread(name);
    61 	CMMFAudioPolicyServer* server = CMMFAudioPolicyServer::NewL();
    62 	CleanupStack::PushL(server);
    63 	
    64 	aStart.iPolicyServerHandle = server->Server();
    65 	// Sync with the client and enter the active scheduler
    66 	RThread::Rendezvous(KErrNone);
    67 	sched->Start();
    68 
    69 	CleanupStack::PopAndDestroy(2, sched); // sched, server
    70 	}
    71