os/mm/devsound/sounddevbt/PlatSec/src/Server/Policy/MmfBtAudioPolicyStart.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 // MmfAudioPolicyStart.cpp
    15 //
    16 
    17 #include <e32std.h>
    18 #include <ecom/ecom.h>
    19 #include "MmfBtAudioPolicyStart.h"
    20 #include "MmfBtAudioPolicyServer.h"
    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 		err = KErrNoMemory;
    35 	if (!err)
    36 		{
    37 		CActiveScheduler* sched=NULL;
    38 		TRAP(err, sched=new(ELeave) CActiveScheduler);
    39 		if (!err)
    40 			{
    41 			CActiveScheduler::Install(sched);
    42 			CMMFAudioPolicyServer* server = NULL;
    43 			TRAPD(err,server = CMMFAudioPolicyServer::NewL());
    44 			
    45 			if(!err)
    46 				{
    47 				start->iPolicyServerHandle = server->Server();
    48 				// Sync with the client and enter the active scheduler
    49 				RThread::Rendezvous(KErrNone);
    50 				sched->Start();
    51 				}
    52 			delete server;
    53 			delete sched;	
    54 			}
    55 		}
    56 	delete cleanup;
    57 	REComSession::FinalClose();
    58 	__UHEAP_MARKEND;
    59 	return err;
    60 	}