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