sl@0
|
1 |
// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <f32file.h>
|
sl@0
|
17 |
#include <e32math.h>
|
sl@0
|
18 |
#include "MmfBtAudioPolicyProxy.h"
|
sl@0
|
19 |
#include "MmfBtAudioPolicyStart.h"
|
sl@0
|
20 |
#include "../../../inc/common/mmfBtBase.hrh"
|
sl@0
|
21 |
#include "mdasound.h"
|
sl@0
|
22 |
#include "MmfBtDevSoundInfo.h"
|
sl@0
|
23 |
#include "MmfBtAudioPolicyServer.h"
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
|
sl@0
|
27 |
EXPORT_C TInt RMMFAudioPolicyProxy::Open(RServer2& aPolicyServerHandle)
|
sl@0
|
28 |
{
|
sl@0
|
29 |
TServerStart start(aPolicyServerHandle);
|
sl@0
|
30 |
TInt err = KErrNone;
|
sl@0
|
31 |
if(aPolicyServerHandle.Handle())
|
sl@0
|
32 |
{
|
sl@0
|
33 |
// Server is already running and attempt to create a session
|
sl@0
|
34 |
// 4 message slots
|
sl@0
|
35 |
err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
|
sl@0
|
36 |
KMMFAudioPolicyMinorVersionNumber,
|
sl@0
|
37 |
KMMFAudioPolicyBuildVersionNumber));
|
sl@0
|
38 |
if(err != KErrNone)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
return err;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
}
|
sl@0
|
43 |
else
|
sl@0
|
44 |
{
|
sl@0
|
45 |
TThreadFunction serverFunc = CMMFAudioPolicyServer::StartThread;
|
sl@0
|
46 |
RThread server;
|
sl@0
|
47 |
err = server.Create(_L(""),serverFunc, KAudioPolicyServerStackSize,
|
sl@0
|
48 |
KAudioPolicyServerInitHeapSize, KAudioPolicyServerMaxHeapSize,
|
sl@0
|
49 |
&start, EOwnerProcess);
|
sl@0
|
50 |
if(err != KErrNone)
|
sl@0
|
51 |
return err;
|
sl@0
|
52 |
// Synchronise with the server
|
sl@0
|
53 |
TRequestStatus reqStatus;
|
sl@0
|
54 |
server.Rendezvous(reqStatus);
|
sl@0
|
55 |
if (reqStatus!=KRequestPending)
|
sl@0
|
56 |
{
|
sl@0
|
57 |
server.Kill(0);
|
sl@0
|
58 |
}
|
sl@0
|
59 |
else
|
sl@0
|
60 |
{
|
sl@0
|
61 |
// Start the test harness
|
sl@0
|
62 |
server.Resume();
|
sl@0
|
63 |
// Server will call the reciprocal static synchronise call
|
sl@0
|
64 |
}
|
sl@0
|
65 |
User::WaitForRequest(reqStatus); // wait for start or death
|
sl@0
|
66 |
server.Close();
|
sl@0
|
67 |
if(reqStatus.Int() != KErrNone)
|
sl@0
|
68 |
{
|
sl@0
|
69 |
return reqStatus.Int();
|
sl@0
|
70 |
}
|
sl@0
|
71 |
err = CreateSession(aPolicyServerHandle, TVersion(KMMFAudioPolicyVersion,
|
sl@0
|
72 |
KMMFAudioPolicyMinorVersionNumber,
|
sl@0
|
73 |
KMMFAudioPolicyBuildVersionNumber));
|
sl@0
|
74 |
}
|
sl@0
|
75 |
return err;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
EXPORT_C TInt RMMFAudioPolicyProxy::SetDevSoundInfo(TMMFDevSoundInfo& aDevSoundInfo)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
TMMFDevSoundInfoPckg psPckg(aDevSoundInfo);
|
sl@0
|
81 |
return SendReceive(EMMFPolicySetDevSoundInfo, psPckg);
|
sl@0
|
82 |
}
|
sl@0
|
83 |
|
sl@0
|
84 |
EXPORT_C void RMMFAudioPolicyProxy::MakeRequest(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
|
sl@0
|
85 |
{
|
sl@0
|
86 |
iPsPckg().iState = aPrioritySettings.iState;
|
sl@0
|
87 |
iPsPckg().iPref = aPrioritySettings.iPref;
|
sl@0
|
88 |
iPsPckg().iPriority = aPrioritySettings.iPriority;
|
sl@0
|
89 |
iPsPckg().iCapabilities = aPrioritySettings.iCapabilities;
|
sl@0
|
90 |
SendReceive(EMMFPolicyMakeRequest, iPsPckg);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
|
sl@0
|
93 |
EXPORT_C TInt RMMFAudioPolicyProxy::UpdateState(TMMFAudioPolicyPrioritySettings& aPrioritySettings)
|
sl@0
|
94 |
{
|
sl@0
|
95 |
TMMFAudioPolicyPrioritySettingsPckg psPckg(aPrioritySettings);
|
sl@0
|
96 |
return SendReceive(EMMFPolicyUpdateState, psPckg);
|
sl@0
|
97 |
}
|
sl@0
|
98 |
|
sl@0
|
99 |
EXPORT_C void RMMFAudioPolicyProxy::ReceiveEvents(TMMFAudioPolicyEventPckg& aEventPckg, TRequestStatus& aStatus)
|
sl@0
|
100 |
{
|
sl@0
|
101 |
SendReceiveResult(EMMFPolicyReceiveEvents, aEventPckg, aStatus);
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
EXPORT_C TInt RMMFAudioPolicyProxy::CancelReceiveEvents()
|
sl@0
|
105 |
{
|
sl@0
|
106 |
return SendReceive(EMMFPolicyCancelReceiveEvents);
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aPlayFormatsSupported)
|
sl@0
|
110 |
{
|
sl@0
|
111 |
RMdaDevSound::TSoundFormatsSupportedBuf playFormatsSupported;
|
sl@0
|
112 |
TInt err = SendReceiveResult(EMMFPolicyGetPlayFormatsSupported, playFormatsSupported);
|
sl@0
|
113 |
if (!err)
|
sl@0
|
114 |
aPlayFormatsSupported = playFormatsSupported;
|
sl@0
|
115 |
return err;
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormatsSupported(RMdaDevSound::TSoundFormatsSupportedBuf& aRecordFormatsSupported)
|
sl@0
|
119 |
{
|
sl@0
|
120 |
RMdaDevSound::TSoundFormatsSupportedBuf recordFormatsSupported;
|
sl@0
|
121 |
TInt err = SendReceiveResult(EMMFPolicyGetRecordFormatsSupported, recordFormatsSupported);
|
sl@0
|
122 |
if (!err)
|
sl@0
|
123 |
aRecordFormatsSupported = recordFormatsSupported;
|
sl@0
|
124 |
return err;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
|
sl@0
|
127 |
EXPORT_C TInt RMMFAudioPolicyProxy::GetPlayFormat(RMdaDevSound::TCurrentSoundFormatBuf& aPlayFormat)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
RMdaDevSound::TCurrentSoundFormatBuf playFormat;
|
sl@0
|
130 |
TInt err = SendReceiveResult(EMMFPolicyGetPlayFormat, playFormat);
|
sl@0
|
131 |
if (!err)
|
sl@0
|
132 |
aPlayFormat = playFormat;
|
sl@0
|
133 |
return err;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
EXPORT_C TInt RMMFAudioPolicyProxy::GetRecordFormat(RMdaDevSound::TCurrentSoundFormatBuf& aRecordFormat)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
RMdaDevSound::TCurrentSoundFormatBuf recordFormat;
|
sl@0
|
139 |
TInt err = SendReceiveResult(EMMFPolicyGetRecordFormat, recordFormat);
|
sl@0
|
140 |
if (!err)
|
sl@0
|
141 |
aRecordFormat = recordFormat;
|
sl@0
|
142 |
return err;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
|
sl@0
|
145 |
EXPORT_C TInt RMMFAudioPolicyProxy::LaunchRequests()
|
sl@0
|
146 |
{
|
sl@0
|
147 |
return SendReceive(EMMFPolicyLaunchRequests);
|
sl@0
|
148 |
}
|
sl@0
|
149 |
|
sl@0
|
150 |
EXPORT_C TInt RMMFAudioPolicyProxy::RequestResourceNotification(TUid aNotificationEventUid, const TDesC8& aNotificationDelay)
|
sl@0
|
151 |
{
|
sl@0
|
152 |
TUid eventType = KNullUid;
|
sl@0
|
153 |
TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
|
sl@0
|
154 |
pckg().iNotificationUid = eventType;
|
sl@0
|
155 |
TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
|
sl@0
|
156 |
eventType = pckg().iNotificationUid;
|
sl@0
|
157 |
if(!err)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
if(eventType != aNotificationEventUid )
|
sl@0
|
160 |
{
|
sl@0
|
161 |
pckg().iNotificationUid = aNotificationEventUid;
|
sl@0
|
162 |
pckg().iNotificationDelay = aNotificationDelay;
|
sl@0
|
163 |
return SendReceive(EMMFPolicyRequestResourceNotification, pckg);
|
sl@0
|
164 |
}
|
sl@0
|
165 |
else
|
sl@0
|
166 |
{
|
sl@0
|
167 |
return KErrAlreadyExists;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
}
|
sl@0
|
170 |
return err;
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
EXPORT_C TInt RMMFAudioPolicyProxy::CancelRequestResourceNotification(TUid aNotificationEventUid)
|
sl@0
|
174 |
{
|
sl@0
|
175 |
TUid eventType = KNullUid;
|
sl@0
|
176 |
TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
|
sl@0
|
177 |
pckg().iNotificationUid = eventType;
|
sl@0
|
178 |
TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
|
sl@0
|
179 |
eventType = pckg().iNotificationUid;
|
sl@0
|
180 |
if(!err)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
if(eventType == aNotificationEventUid )
|
sl@0
|
183 |
{
|
sl@0
|
184 |
pckg().iNotificationUid = aNotificationEventUid;
|
sl@0
|
185 |
return SendReceive(EMMFPolicyCancelRequestResourceNotification, pckg);
|
sl@0
|
186 |
}
|
sl@0
|
187 |
else
|
sl@0
|
188 |
{
|
sl@0
|
189 |
return KErrCancel;
|
sl@0
|
190 |
}
|
sl@0
|
191 |
}
|
sl@0
|
192 |
return err;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
EXPORT_C TInt RMMFAudioPolicyProxy::StopNotification()
|
sl@0
|
196 |
{
|
sl@0
|
197 |
return SendReceive(EMMFPolicyStopNotification);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
EXPORT_C TInt RMMFAudioPolicyProxy::IsRegisteredResourceNotification(TUid aEventType)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
TUid eventType = KNullUid;
|
sl@0
|
203 |
TMMFAudioPolicyResourceNotificationSettingsPckg pckg;
|
sl@0
|
204 |
pckg().iNotificationUid = eventType;
|
sl@0
|
205 |
TInt err = SendReceiveResult(EMMFPolicyGetResourceNotificationEvent, pckg);
|
sl@0
|
206 |
if(err != KErrNone)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
return err;
|
sl@0
|
209 |
}
|
sl@0
|
210 |
eventType = pckg().iNotificationUid;
|
sl@0
|
211 |
if(eventType == aEventType)
|
sl@0
|
212 |
{
|
sl@0
|
213 |
return KErrNone;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
return KErrNotSupported;
|
sl@0
|
216 |
}
|
sl@0
|
217 |
|