sl@0
|
1 |
// Copyright (c) 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 "MmfBtAudioPolicyStart.h"
|
sl@0
|
18 |
#include "MmfBtAudioPolicyServer.h"
|
sl@0
|
19 |
#include "mmfcontrollerframeworkbase.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
TInt TServerStart::Signal()
|
sl@0
|
22 |
//
|
sl@0
|
23 |
// Signal the owning thread that the server has started successfully
|
sl@0
|
24 |
//
|
sl@0
|
25 |
{
|
sl@0
|
26 |
RThread starter;
|
sl@0
|
27 |
TInt err = starter.Open(iId);
|
sl@0
|
28 |
if(err==KErrNone)
|
sl@0
|
29 |
{
|
sl@0
|
30 |
starter.RequestComplete(iStatus,KErrNone);
|
sl@0
|
31 |
starter.Close();
|
sl@0
|
32 |
}
|
sl@0
|
33 |
return(err);
|
sl@0
|
34 |
}
|
sl@0
|
35 |
|
sl@0
|
36 |
LOCAL_C void DoStartThreadL(TServerStart* aParams)
|
sl@0
|
37 |
{
|
sl@0
|
38 |
//create the active scheduler
|
sl@0
|
39 |
CActiveScheduler* s = new(ELeave) CActiveScheduler();
|
sl@0
|
40 |
CleanupStack::PushL(s);
|
sl@0
|
41 |
CActiveScheduler::Install(s);
|
sl@0
|
42 |
//create the server & leave it on the cleanupstack
|
sl@0
|
43 |
CleanupStack::PushL(CMMFAudioPolicyServer::NewL());
|
sl@0
|
44 |
//initialisation complete - now signal the client
|
sl@0
|
45 |
User::LeaveIfError(aParams->Signal());
|
sl@0
|
46 |
//start the server running
|
sl@0
|
47 |
CActiveScheduler::Start();
|
sl@0
|
48 |
//now exiting the server so cleanup
|
sl@0
|
49 |
CleanupStack::PopAndDestroy(2);//scheduler and server
|
sl@0
|
50 |
}
|
sl@0
|
51 |
|
sl@0
|
52 |
|
sl@0
|
53 |
EXPORT_C TInt EntryPoint(TAny* aParam)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
TInt err = KErrNone;
|
sl@0
|
56 |
__UHEAP_MARK;
|
sl@0
|
57 |
TServerStart* start = REINTERPRET_CAST(TServerStart*, aParam);
|
sl@0
|
58 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
59 |
if (!cleanup)
|
sl@0
|
60 |
err = KErrNoMemory;
|
sl@0
|
61 |
if (!err)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
TRAP(err, DoStartThreadL(start));
|
sl@0
|
64 |
}
|
sl@0
|
65 |
delete cleanup;
|
sl@0
|
66 |
__UHEAP_MARKEND;
|
sl@0
|
67 |
return err;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
TInt TServerStart::GetCommand()
|
sl@0
|
72 |
/**
|
sl@0
|
73 |
In EPOC, the EPOCEXE target is a process, and the server startup
|
sl@0
|
74 |
parameters are encoded in the command line
|
sl@0
|
75 |
**/
|
sl@0
|
76 |
{
|
sl@0
|
77 |
if (User::CommandLineLength()!=sizeof(TServerStart)/sizeof(TText))
|
sl@0
|
78 |
return KErrGeneral;
|
sl@0
|
79 |
TPtr ptr(reinterpret_cast<TText*>(this),0,sizeof(TServerStart)/sizeof(TText));
|
sl@0
|
80 |
User::CommandLine(ptr);
|
sl@0
|
81 |
return KErrNone;
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
TInt E32Main()
|
sl@0
|
85 |
/**
|
sl@0
|
86 |
Server process entry-point
|
sl@0
|
87 |
Recover the startup parameters and run the server
|
sl@0
|
88 |
**/
|
sl@0
|
89 |
{
|
sl@0
|
90 |
TServerStart start;
|
sl@0
|
91 |
TInt r=start.GetCommand();
|
sl@0
|
92 |
if (r==KErrNone)
|
sl@0
|
93 |
r=EntryPoint((TAny*)&start);
|
sl@0
|
94 |
return r;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|