1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/sounddevbt/src/server/Policy/MmfBtAudioPolicyStart.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,96 @@
1.4 +// Copyright (c) 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 "MmfBtAudioPolicyStart.h"
1.21 +#include "MmfBtAudioPolicyServer.h"
1.22 +#include "mmfcontrollerframeworkbase.h"
1.23 +
1.24 +TInt TServerStart::Signal()
1.25 +//
1.26 +// Signal the owning thread that the server has started successfully
1.27 +//
1.28 + {
1.29 + RThread starter;
1.30 + TInt err = starter.Open(iId);
1.31 + if(err==KErrNone)
1.32 + {
1.33 + starter.RequestComplete(iStatus,KErrNone);
1.34 + starter.Close();
1.35 + }
1.36 + return(err);
1.37 + }
1.38 +
1.39 +LOCAL_C void DoStartThreadL(TServerStart* aParams)
1.40 + {
1.41 + //create the active scheduler
1.42 + CActiveScheduler* s = new(ELeave) CActiveScheduler();
1.43 + CleanupStack::PushL(s);
1.44 + CActiveScheduler::Install(s);
1.45 + //create the server & leave it on the cleanupstack
1.46 + CleanupStack::PushL(CMMFAudioPolicyServer::NewL());
1.47 + //initialisation complete - now signal the client
1.48 + User::LeaveIfError(aParams->Signal());
1.49 + //start the server running
1.50 + CActiveScheduler::Start();
1.51 + //now exiting the server so cleanup
1.52 + CleanupStack::PopAndDestroy(2);//scheduler and server
1.53 + }
1.54 +
1.55 +
1.56 +EXPORT_C TInt EntryPoint(TAny* aParam)
1.57 + {
1.58 + TInt err = KErrNone;
1.59 + __UHEAP_MARK;
1.60 + TServerStart* start = REINTERPRET_CAST(TServerStart*, aParam);
1.61 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.62 + if (!cleanup)
1.63 + err = KErrNoMemory;
1.64 + if (!err)
1.65 + {
1.66 + TRAP(err, DoStartThreadL(start));
1.67 + }
1.68 + delete cleanup;
1.69 + __UHEAP_MARKEND;
1.70 + return err;
1.71 + }
1.72 +
1.73 +
1.74 +TInt TServerStart::GetCommand()
1.75 +/**
1.76 +In EPOC, the EPOCEXE target is a process, and the server startup
1.77 +parameters are encoded in the command line
1.78 +**/
1.79 + {
1.80 + if (User::CommandLineLength()!=sizeof(TServerStart)/sizeof(TText))
1.81 + return KErrGeneral;
1.82 + TPtr ptr(reinterpret_cast<TText*>(this),0,sizeof(TServerStart)/sizeof(TText));
1.83 + User::CommandLine(ptr);
1.84 + return KErrNone;
1.85 + }
1.86 +
1.87 +TInt E32Main()
1.88 +/**
1.89 +Server process entry-point
1.90 +Recover the startup parameters and run the server
1.91 +**/
1.92 + {
1.93 + TServerStart start;
1.94 + TInt r=start.GetCommand();
1.95 + if (r==KErrNone)
1.96 + r=EntryPoint((TAny*)&start);
1.97 + return r;
1.98 + }
1.99 +