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 "mmfAudioPolicyProxy.h"
19 #include "MmfAudioPolicyStart.h"
20 #include "MmfBase.hrh"
21 #include "MmfDevSoundInfo.h"
22 #include "MmfAudioPolicyServer.h"
26 EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
28 ASSERT(aPolicyServerHandle.Handle());
30 // Server is already running and attempt to create a session
32 TInt err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
33 KMMFAudioPolicyMinorVersionNumber,
34 KMMFAudioPolicyBuildVersionNumber));
38 EXPORT_C TInt RMMFAudioPolicyProxy::CreateServer(RServer2& aPolicyServerHandle)
40 TServerStart start(aPolicyServerHandle);
41 TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
43 TInt err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
44 KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
45 &start, EOwnerProcess);
50 // Synchronise with the server
51 TRequestStatus reqStatus;
52 server.Rendezvous(reqStatus);
53 if (reqStatus!=KRequestPending)
59 // Start the test harness
61 // Server will call the reciprocal static synchronise call
63 User::WaitForRequest(reqStatus); // wait for start or death
65 if(reqStatus.Int() != KErrNone)
67 return reqStatus.Int();
72 EXPORT_C TInt RMMFAudioPolicyProxy::SetDevSoundInfo(TMMFDevSoundInfo& aDevSoundInfo)
74 TMMFDevSoundInfoPckg psPckg(aDevSoundInfo);
75 return SendReceive(EMMFPolicySetDevSoundInfo, psPckg);
78 EXPORT_C void RMMFAudioPolicyProxy::MakeRequest(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
80 iPsPckg().iState = aPrioritySettings.iState;
81 iPsPckg().iPref = aPrioritySettings.iPref;
82 iPsPckg().iPriority = aPrioritySettings.iPriority;
83 iPsPckg().iCapabilities = aPrioritySettings.iCapabilities;
84 SendReceive(EMMFPolicyMakeRequest, iPsPckg);
87 EXPORT_C TInt RMMFAudioPolicyProxy::UpdateState(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
89 TMMFAudioPolicyPrioritySettingsPckg psPckg(aPrioritySettings);
90 return SendReceive(EMMFPolicyUpdateState, psPckg);
93 EXPORT_C void RMMFAudioPolicyProxy::ReceiveEvents(TMMFAudioPolicyEventPckg& aEventPckg, TRequestStatus& aStatus)
95 SendReceiveResult(EMMFPolicyReceiveEvents, aEventPckg, aStatus);
98 EXPORT_C TInt RMMFAudioPolicyProxy::CancelReceiveEvents()
100 return SendReceive(EMMFPolicyCancelReceiveEvents);
103 EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aPlayFormatsSupported)
105 RMdaDevSound::TSoundFormatsSupportedBuf playFormatsSupported;
106 TInt err = SendReceiveResult(EMMFPolicyGetPlayFormatsSupported, playFormatsSupported);
108 aPlayFormatsSupported = playFormatsSupported;
112 EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aRecordFormatsSupported)
114 RMdaDevSound::TSoundFormatsSupportedBuf recordFormatsSupported;
115 TInt err = SendReceiveResult(EMMFPolicyGetRecordFormatsSupported, recordFormatsSupported);
117 aRecordFormatsSupported = recordFormatsSupported;
121 EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormat(RMdaDevSound::TCurrentSoundFormatBuf& aPlayFormat)
123 RMdaDevSound::TCurrentSoundFormatBuf playFormat;
124 TInt err = SendReceiveResult(EMMFPolicyGetPlayFormat, playFormat);
126 aPlayFormat = playFormat;
130 EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormat(RMdaDevSound::TCurrentSoundFormatBuf& aRecordFormat)
132 RMdaDevSound::TCurrentSoundFormatBuf recordFormat;
133 TInt err = SendReceiveResult(EMMFPolicyGetRecordFormat, recordFormat);
135 aRecordFormat = recordFormat;
139 EXPORT_C TInt RMMFAudioPolicyProxy::LaunchRequests()
141 return SendReceive(EMMFPolicyLaunchRequests);
144 EXPORT_C TInt RMMFAudioPolicyProxy::RequestResourceNotification(TUid aNotificationEventUid, const TDesC8& aNotificationDelay)
146 TUid eventType = KNullUid;
147 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
148 pckg().iNotificationUid = eventType;
149 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
150 eventType = pckg().iNotificationUid;
153 if(eventType != aNotificationEventUid )
155 pckg().iNotificationUid = aNotificationEventUid;
156 pckg().iNotificationDelay = aNotificationDelay;
157 return SendReceive(EMMFPolicyRequestResourceNotification, pckg);
161 return KErrAlreadyExists;
167 EXPORT_C TInt RMMFAudioPolicyProxy::CancelRequestResourceNotification(TUid aNotificationEventUid)
169 TUid eventType = KNullUid;
170 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
171 pckg().iNotificationUid = eventType;
172 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
173 eventType = pckg().iNotificationUid;
176 if(eventType == aNotificationEventUid )
178 pckg().iNotificationUid = aNotificationEventUid;
179 return SendReceive(EMMFPolicyCancelRequestResourceNotification, pckg);
189 EXPORT_C TInt RMMFAudioPolicyProxy::StopNotification()
191 return SendReceive(EMMFPolicyStopNotification);
194 EXPORT_C TInt RMMFAudioPolicyProxy::IsRegisteredResourceNotification(TUid aEventType)
196 TUid eventType = KNullUid;
197 TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
198 pckg().iNotificationUid = eventType;
199 TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
204 eventType = pckg().iNotificationUid;
205 if(eventType == aEventType)
209 return KErrNotSupported;