sl@0: // Copyright (c) 2005-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 sl@0: #include sl@0: sl@0: #include "MmfBtAudioServerProxy.h" sl@0: #include "MmfBtAudioServerStart.h" sl@0: #include "../../../inc/common/mmfBtBase.hrh" sl@0: #include "MmfBtAudioClientServer.h" sl@0: sl@0: #define KMaxServerNameLength 256 sl@0: sl@0: static const TUid KUidAudioServer = {KUidMmfBtAudioServerDllUnicodeDefine}; sl@0: sl@0: sl@0: EXPORT_C TInt RMMFAudioServerProxy::Open() sl@0: { sl@0: sl@0: const TUidType serverUid(KNullUid,KNullUid,KUidAudioServer); sl@0: sl@0: // Assume the server is already running and attempt to create a session sl@0: // 4 message slots sl@0: TInt err = CreateSession(KAudioServerName, TVersion(KMMFAudioServerVersion, sl@0: KMMFAudioServerMinorVersionNumber, sl@0: KMMFAudioServerBuildVersionNumber)); sl@0: if(err == KErrNotFound) sl@0: { sl@0: // Server not running sl@0: // Construct the server binary name sl@0: TBuf serverFile; sl@0: RProcess server; sl@0: sl@0: _LIT(KEmpty,""); sl@0: sl@0: err = server.Create(KAudioServerFileName, KEmpty, serverUid); sl@0: if(err != KErrNone) sl@0: return err; sl@0: // Synchronise with the server sl@0: TRequestStatus reqStatus; sl@0: server.Rendezvous(reqStatus); sl@0: sl@0: if (reqStatus!=KRequestPending) sl@0: { sl@0: server.Kill(0); sl@0: } sl@0: else sl@0: { sl@0: // Start the test harness sl@0: server.Resume(); sl@0: // Server will call the reciprocal static synchronise call sl@0: } sl@0: User::WaitForRequest(reqStatus); // wait for rendezvous or death sl@0: server.Close(); sl@0: if(reqStatus.Int() != KErrNone) sl@0: return reqStatus.Int(); sl@0: sl@0: // Create the root server session sl@0: err = CreateSession(KAudioServerName, TVersion(KMMFAudioServerVersion, sl@0: KMMFAudioServerMinorVersionNumber, sl@0: KMMFAudioServerBuildVersionNumber)); sl@0: } sl@0: return err; sl@0: sl@0: } sl@0: sl@0: EXPORT_C TInt RMMFAudioServerProxy::SetDevSoundInfo() sl@0: { sl@0: return SendReceive(EMMFAudioLaunchRequests); sl@0: } sl@0: sl@0: EXPORT_C HBufC* RMMFAudioServerProxy::GetDevSoundServerNameL() sl@0: { sl@0: TInt len = GetDevSoundServerNameLengthL(); sl@0: len++; sl@0: HBufC8* devSoundServerName = HBufC8::NewLC(len); sl@0: TPtr8 devSoundServerNamePtr = devSoundServerName->Des(); sl@0: User::LeaveIfError(SendReceiveResult(EMMFDevSoundServerName, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: devSoundServerNamePtr)); sl@0: sl@0: RDesReadStream stream; sl@0: stream.Open(*devSoundServerName); sl@0: CleanupClosePushL(stream); sl@0: sl@0: HBufC* devSoundServerNameFlat = HBufC::NewL(stream, KMaxTInt); sl@0: sl@0: CleanupStack::PopAndDestroy();//stream sl@0: CleanupStack::PopAndDestroy(devSoundServerName); sl@0: sl@0: return devSoundServerNameFlat; sl@0: } sl@0: sl@0: sl@0: TInt RMMFAudioServerProxy::GetDevSoundServerNameLengthL() sl@0: { sl@0: TPckgBuf descriptorSizePckg; sl@0: User::LeaveIfError(SendReceiveResult(EMMFDevSoundServerNameLength, sl@0: KNullDesC8, sl@0: KNullDesC8, sl@0: descriptorSizePckg)); sl@0: sl@0: return descriptorSizePckg(); sl@0: } sl@0: sl@0: