os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtAudioServerStart.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/devsound/sounddevbt/PlatSec/src/Server/AudioServer/MmfBtAudioServerStart.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,99 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <e32std.h>
    1.20 +#include "MmfBtAudioServerStart.h"
    1.21 +#include "MmfBtAudioServer.h"
    1.22 +
    1.23 +#include "A2dpBTHeadsetAudioIfServerStart.h"
    1.24 +#include "A2dpBTHeadsetAudioIfServer.h"
    1.25 +
    1.26 +// EKA2 much simpler
    1.27 +// Just an E32Main and a MainL()
    1.28 +LOCAL_C void MainL()
    1.29 +/**
    1.30 + * Much simpler, uses the new Rendezvous() call to sync with the client
    1.31 + */
    1.32 + 	{
    1.33 +	// Leave the hooks in for platform security
    1.34 +#if (defined __DATA_CAGING__)
    1.35 +	RProcess().DataCaging(RProcess::EDataCagingOn);
    1.36 +	RProcess().SecureApi(RProcess::ESecureApiOn);
    1.37 +#endif
    1.38 +	CActiveScheduler* sched=NULL;
    1.39 +	sched=new(ELeave) CActiveScheduler;
    1.40 +	CActiveScheduler::Install(sched);
    1.41 +	CMMFAudioServer* server = NULL;
    1.42 +	TRAPD(err,server = CMMFAudioServer::NewL());
    1.43 +
    1.44 +	// Start BT audio server in its own thread here...
    1.45 +	// Assume that the server's not been started already
    1.46 +	// 
    1.47 +	RThread btServerThread;
    1.48 +	TThreadFunction btServerThreadFunc = CA2dpBTHeadsetAudioIfServer::StartThread;
    1.49 +	TName btServerName(KA2DPAudioServerName);
    1.50 +
    1.51 +
    1.52 +	err = btServerThread.Create(btServerName, btServerThreadFunc, KBTAudioServerStackSize,
    1.53 +								KBTAudioServerInitHeapSize, KBTAudioServerMaxHeapSize,
    1.54 +								NULL, EOwnerProcess);	// NULL => not passing any params to thread
    1.55 +
    1.56 +	if(!err)
    1.57 +		{
    1.58 +		// Synchronise with the server
    1.59 +		TRequestStatus reqStatus;
    1.60 +		btServerThread.Rendezvous(reqStatus);
    1.61 +
    1.62 +		if (reqStatus != KRequestPending)
    1.63 +			{
    1.64 +			btServerThread.Kill(0);
    1.65 +			}
    1.66 +		else 
    1.67 +			{
    1.68 +			// Start the thread
    1.69 +			btServerThread.Resume();
    1.70 +			// Server will call the reciprocal static synchronise call
    1.71 +			}
    1.72 +		User::WaitForRequest(reqStatus); // wait for start or death
    1.73 +		}
    1.74 +		
    1.75 +	if(!err)
    1.76 +		{
    1.77 +		// Sync with the client and enter the active scheduler
    1.78 +		RProcess::Rendezvous(KErrNone);
    1.79 +		sched->Start();
    1.80 +		}
    1.81 +	
    1.82 +	btServerThread.Close();
    1.83 +		
    1.84 +	delete server;
    1.85 +	delete sched;	
    1.86 +	
    1.87 +	}
    1.88 +
    1.89 +GLDEF_C TInt E32Main()
    1.90 +/**
    1.91 + * @return - Standard Epoc error code on exit
    1.92 + */
    1.93 +	{
    1.94 +	CTrapCleanup* cleanup = CTrapCleanup::New();
    1.95 +	if(cleanup == NULL)
    1.96 +		{
    1.97 +		return KErrNoMemory;
    1.98 +		}
    1.99 +	TRAP_IGNORE(MainL());
   1.100 +	delete cleanup;
   1.101 +	return KErrNone;
   1.102 +    }