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