Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "MmfBtAudioPolicyProxy.h"
19 #include "MmfBtAudioPolicyStart.h"
20 #include "../../../inc/common/mmfBtBase.hrh"
22 #include "MmfBtDevSoundInfo.h"
23 #include "MmfBtAudioPolicyServer.h"
27 EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
29 TServerStart start(aPolicyServerHandle);
31 if(aPolicyServerHandle.Handle())
33 // Server is already running and attempt to create a session
35 err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
36 KMMFAudioPolicyMinorVersionNumber,
37 KMMFAudioPolicyBuildVersionNumber));
45 TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
47 err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
48 KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
49 &start, EOwnerProcess);
52 // Synchronise with the server
53 TRequestStatus reqStatus;
54 server.Rendezvous(reqStatus);
55 if (reqStatus!=KRequestPending)
61 // Start the test harness
63 // Server will call the reciprocal static synchronise call
65 User::WaitForRequest(reqStatus); // wait for start or death
67 if(reqStatus.Int() != KErrNone)
69 return reqStatus.Int();
71 err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
72 KMMFAudioPolicyMinorVersionNumber,
73 KMMFAudioPolicyBuildVersionNumber));
78 EXPORT_C TInt RMMFAudioPolicyProxy::SetDevSoundInfo(TMMFDevSoundInfo& aDevSoundInfo)
80 TMMFDevSoundInfoPckg psPckg(aDevSoundInfo);
81 return SendReceive(EMMFPolicySetDevSoundInfo, psPckg);
84 EXPORT_C void RMMFAudioPolicyProxy::MakeRequest(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
86 iPsPckg().iState = aPrioritySettings.iState;
87 iPsPckg().iPref = aPrioritySettings.iPref;
88 iPsPckg().iPriority = aPrioritySettings.iPriority;
89 iPsPckg().iCapabilities = aPrioritySettings.iCapabilities;
90 SendReceive(EMMFPolicyMakeRequest, iPsPckg);
93 EXPORT_C TInt RMMFAudioPolicyProxy::UpdateState(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
95 TMMFAudioPolicyPrioritySettingsPckg psPckg(aPrioritySettings);
96 return SendReceive(EMMFPolicyUpdateState, psPckg);
99 EXPORT_C void RMMFAudioPolicyProxy::ReceiveEvents(TMMFAudioPolicyEventPckg& aEventPckg, TRequestStatus& aStatus)
101 SendReceiveResult(EMMFPolicyReceiveEvents, aEventPckg, aStatus);
104 EXPORT_C TInt RMMFAudioPolicyProxy::CancelReceiveEvents()
106 return SendReceive(EMMFPolicyCancelReceiveEvents);
109 EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aPlayFormatsSupported)
111 RMdaDevSound::TSoundFormatsSupportedBuf playFormatsSupported;
112 TInt err = SendReceiveResult(EMMFPolicyGetPlayFormatsSupported, playFormatsSupported);
114 aPlayFormatsSupported = playFormatsSupported;
118 EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aRecordFormatsSupported)
120 RMdaDevSound::TSoundFormatsSupportedBuf recordFormatsSupported;
121 TInt err = SendReceiveResult(EMMFPolicyGetRecordFormatsSupported, recordFormatsSupported);
123 aRecordFormatsSupported = recordFormatsSupported;
127 EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormat(RMdaDevSound::TCurrentSoundFormatBuf& aPlayFormat)
129 RMdaDevSound::TCurrentSoundFormatBuf playFormat;
130 TInt err = SendReceiveResult(EMMFPolicyGetPlayFormat, playFormat);
132 aPlayFormat = playFormat;
136 EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormat(RMdaDevSound::TCurrentSoundFormatBuf& aRecordFormat)
138 RMdaDevSound::TCurrentSoundFormatBuf recordFormat;
139 TInt err = SendReceiveResult(EMMFPolicyGetRecordFormat, recordFormat);
141 aRecordFormat = recordFormat;
145 EXPORT_C TInt RMMFAudioPolicyProxy::LaunchRequests()
147 return SendReceive(EMMFPolicyLaunchRequests);
150 EXPORT_C TInt RMMFAudioPolicyProxy::RequestResourceNotification(TUid aNotificationEventUid, const TDesC8& aNotificationDelay)
152 TUid eventType = KNullUid;
153 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
154 pckg().iNotificationUid = eventType;
155 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
156 eventType = pckg().iNotificationUid;
159 if(eventType != aNotificationEventUid )
161 pckg().iNotificationUid = aNotificationEventUid;
162 pckg().iNotificationDelay = aNotificationDelay;
163 return SendReceive(EMMFPolicyRequestResourceNotification, pckg);
167 return KErrAlreadyExists;
173 EXPORT_C TInt RMMFAudioPolicyProxy::CancelRequestResourceNotification(TUid aNotificationEventUid)
175 TUid eventType = KNullUid;
176 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
177 pckg().iNotificationUid = eventType;
178 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
179 eventType = pckg().iNotificationUid;
182 if(eventType == aNotificationEventUid )
184 pckg().iNotificationUid = aNotificationEventUid;
185 return SendReceive(EMMFPolicyCancelRequestResourceNotification, pckg);
195 EXPORT_C TInt RMMFAudioPolicyProxy::StopNotification()
197 return SendReceive(EMMFPolicyStopNotification);
200 EXPORT_C TInt RMMFAudioPolicyProxy::IsRegisteredResourceNotification(TUid aEventType)
202 TUid eventType = KNullUid;
203 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
204 pckg().iNotificationUid = eventType;
205 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
210 eventType = pckg().iNotificationUid;
211 if(eventType == aEventType)
215 return KErrNotSupported;