Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
22 #include "mmfaudioserverproxy.h"
23 #include "mmfaudioserverdecs.h"
24 #include <a3f/mmfaudiosvruids.hrh>
27 static const TUid KUidAudioServer = {KUidA3fAudioServerUID};
28 const TInt KRetries = 5;
29 const TInt KInitialTime = 100000; //100ms
30 const TInt KTimeIncrement = 50000; // 50ms
32 _LIT_SECURITY_POLICY_C1(KServerHasDRMRights, ECapabilityDRM);
34 // -----------------------------------------------------------------------------
35 // RMMFAudioServerProxy::OpenSessionToTrustedAudioServer
37 // -----------------------------------------------------------------------------
39 TInt RMMFAudioServerProxy::OpenSessionToTrustedAudioServer()
41 return CreateSession(KAudioServerName,
42 TVersion(KMMFAudioServerVersion,
43 KMMFAudioServerMinorVersionNumber,
44 KMMFAudioServerBuildVersionNumber),
46 EIpcSession_Unsharable,
48 NULL); // NULL required for synchronous behaviour
51 // -----------------------------------------------------------------------------
52 // RMMFAudioServerProxy::Open
54 // -----------------------------------------------------------------------------
56 EXPORT_C TInt RMMFAudioServerProxy::Open()
58 const TUidType serverUid(KNullUid,KNullUid,KUidAudioServer);
59 // Assume the server is already running and attempt to create a session
60 TInt err = OpenSessionToTrustedAudioServer();
62 if(err == KErrNotFound)
65 // Construct the server binary name
70 err = server.Create(KAudioServerFileName, KEmpty, serverUid);
75 // Synchronise with the server
76 TRequestStatus reqStatus;
77 server.Rendezvous(reqStatus);
79 if (reqStatus!=KRequestPending)
85 // Start the test harness
87 // Server will call the reciprocal static synchronise call
90 User::WaitForRequest(reqStatus); // wait for rendezvous or death
92 TInt reqStatusValue = reqStatus.Int();
94 if(reqStatusValue != KErrNone)
96 if(reqStatusValue == KErrNoMemory || reqStatusValue == KErrNotFound)
98 // All error codes except KErrNoMemory and KErrNotFound are assumed
99 // to be a duplicate server instance dying, then keep trying
100 // connection to the server. This can happen when two servers
101 // attempt to start at the same time.
102 return reqStatusValue;
104 //Wait for sometime, then retry and creation session
105 TInt waitTime = KInitialTime;
106 for(TInt retries=0;retries<KRetries;retries++)
108 User::After(waitTime);
109 waitTime+=KTimeIncrement;
110 err = OpenSessionToTrustedAudioServer();
114 //Session created successfully
121 // Create the root server session
122 err = OpenSessionToTrustedAudioServer();
128 // -----------------------------------------------------------------------------
129 // RMMFAudioServerProxy::SetDevSoundInfo
131 // -----------------------------------------------------------------------------
133 EXPORT_C TInt RMMFAudioServerProxy::SetDevSoundInfo()
135 return SendReceive(EMMFAudioLaunchRequests);
138 // -----------------------------------------------------------------------------
139 // RMMFAudioServerProxy::GetDevSoundSessionHandle
141 // -----------------------------------------------------------------------------
143 EXPORT_C TInt RMMFAudioServerProxy::GetDevSoundSessionHandle()
145 return SendReceive(EMMFDevSoundSessionHandle);