sl@0: // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "MmfBtAudioPolicyStart.h" sl@0: #include "MmfBtAudioPolicyServer.h" sl@0: #include "mmfcontrollerframeworkbase.h" sl@0: sl@0: TInt TServerStart::Signal() sl@0: // sl@0: // Signal the owning thread that the server has started successfully sl@0: // sl@0: { sl@0: RThread starter; sl@0: TInt err = starter.Open(iId); sl@0: if(err==KErrNone) sl@0: { sl@0: starter.RequestComplete(iStatus,KErrNone); sl@0: starter.Close(); sl@0: } sl@0: return(err); sl@0: } sl@0: sl@0: LOCAL_C void DoStartThreadL(TServerStart* aParams) sl@0: { sl@0: //create the active scheduler sl@0: CActiveScheduler* s = new(ELeave) CActiveScheduler(); sl@0: CleanupStack::PushL(s); sl@0: CActiveScheduler::Install(s); sl@0: //create the server & leave it on the cleanupstack sl@0: CleanupStack::PushL(CMMFAudioPolicyServer::NewL()); sl@0: //initialisation complete - now signal the client sl@0: User::LeaveIfError(aParams->Signal()); sl@0: //start the server running sl@0: CActiveScheduler::Start(); sl@0: //now exiting the server so cleanup sl@0: CleanupStack::PopAndDestroy(2);//scheduler and server sl@0: } sl@0: sl@0: sl@0: EXPORT_C TInt EntryPoint(TAny* aParam) sl@0: { sl@0: TInt err = KErrNone; sl@0: __UHEAP_MARK; sl@0: TServerStart* start = REINTERPRET_CAST(TServerStart*, aParam); sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: if (!cleanup) sl@0: err = KErrNoMemory; sl@0: if (!err) sl@0: { sl@0: TRAP(err, DoStartThreadL(start)); sl@0: } sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: return err; sl@0: } sl@0: sl@0: sl@0: TInt TServerStart::GetCommand() sl@0: /** sl@0: In EPOC, the EPOCEXE target is a process, and the server startup sl@0: parameters are encoded in the command line sl@0: **/ sl@0: { sl@0: if (User::CommandLineLength()!=sizeof(TServerStart)/sizeof(TText)) sl@0: return KErrGeneral; sl@0: TPtr ptr(reinterpret_cast(this),0,sizeof(TServerStart)/sizeof(TText)); sl@0: User::CommandLine(ptr); sl@0: return KErrNone; sl@0: } sl@0: sl@0: TInt E32Main() sl@0: /** sl@0: Server process entry-point sl@0: Recover the startup parameters and run the server sl@0: **/ sl@0: { sl@0: TServerStart start; sl@0: TInt r=start.GetCommand(); sl@0: if (r==KErrNone) sl@0: r=EntryPoint((TAny*)&start); sl@0: return r; sl@0: } sl@0: