os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtAudioServerStart.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2005-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 "MmfBtAudioServerStart.h"
    18 #include "MmfBtAudioServer.h"
    19 
    20 #include "A2dpBTHeadsetAudioIfServerStart.h"
    21 #include "A2dpBTHeadsetAudioIfServer.h"
    22 
    23 // EKA2 much simpler
    24 // Just an E32Main and a MainL()
    25 LOCAL_C void MainL()
    26 /**
    27  * Much simpler, uses the new Rendezvous() call to sync with the client
    28  */
    29  	{
    30 	// Leave the hooks in for platform security
    31 #if (defined __DATA_CAGING__)
    32 	RProcess().DataCaging(RProcess::EDataCagingOn);
    33 	RProcess().SecureApi(RProcess::ESecureApiOn);
    34 #endif
    35 	CActiveScheduler* sched=NULL;
    36 	sched=new(ELeave) CActiveScheduler;
    37 	CActiveScheduler::Install(sched);
    38 	CMMFAudioServer* server = NULL;
    39 	TRAPD(err,server = CMMFAudioServer::NewL());
    40 
    41 	// Start BT audio server in its own thread here...
    42 	// Assume that the server's not been started already
    43 	// 
    44 	RThread btServerThread;
    45 	TThreadFunction btServerThreadFunc = CA2dpBTHeadsetAudioIfServer::StartThread;
    46 	TName btServerName(KA2DPAudioServerName);
    47 
    48 
    49 	err = btServerThread.Create(btServerName, btServerThreadFunc, KBTAudioServerStackSize,
    50 								KBTAudioServerInitHeapSize, KBTAudioServerMaxHeapSize,
    51 								NULL, EOwnerProcess);	// NULL => not passing any params to thread
    52 
    53 	if(!err)
    54 		{
    55 		// Synchronise with the server
    56 		TRequestStatus reqStatus;
    57 		btServerThread.Rendezvous(reqStatus);
    58 
    59 		if (reqStatus != KRequestPending)
    60 			{
    61 			btServerThread.Kill(0);
    62 			}
    63 		else 
    64 			{
    65 			// Start the thread
    66 			btServerThread.Resume();
    67 			// Server will call the reciprocal static synchronise call
    68 			}
    69 		User::WaitForRequest(reqStatus); // wait for start or death
    70 		}
    71 		
    72 	if(!err)
    73 		{
    74 		// Sync with the client and enter the active scheduler
    75 		RProcess::Rendezvous(KErrNone);
    76 		sched->Start();
    77 		}
    78 	
    79 	btServerThread.Close();
    80 		
    81 	delete server;
    82 	delete sched;	
    83 	
    84 	}
    85 
    86 GLDEF_C TInt E32Main()
    87 /**
    88  * @return - Standard Epoc error code on exit
    89  */
    90 	{
    91 	CTrapCleanup* cleanup = CTrapCleanup::New();
    92 	if(cleanup == NULL)
    93 		{
    94 		return KErrNoMemory;
    95 		}
    96 	TRAP_IGNORE(MainL());
    97 	delete cleanup;
    98 	return KErrNone;
    99     }