sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description: Audio output msg handler implementation
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
// INCLUDE FILES
|
sl@0
|
21 |
#include "AudioOutput.h"
|
sl@0
|
22 |
#include "AudioOutputMessageHandler.h"
|
sl@0
|
23 |
#include "AudioOutputMessageTypes.h"
|
sl@0
|
24 |
#include "MAudioOutputObserver.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
//reason for defining this secure id here but not using from the mmfbase.hrh is that
|
sl@0
|
27 |
//lot of macros in mmfbase.hrh collide with base.hrh
|
sl@0
|
28 |
#define KUidMmfDrmPluginServerDefine 0x10283439
|
sl@0
|
29 |
|
sl@0
|
30 |
// ================= MEMBER FUNCTIONS =======================
|
sl@0
|
31 |
|
sl@0
|
32 |
// C++ default constructor can NOT contain any code, that
|
sl@0
|
33 |
// might leave.
|
sl@0
|
34 |
//
|
sl@0
|
35 |
CAudioOutputMessageHandler::CAudioOutputMessageHandler(CAudioOutput* aAudioOutput,
|
sl@0
|
36 |
CMMFObjectContainer& aContainer) :
|
sl@0
|
37 |
CMMFObject(KUidAudioOutput),
|
sl@0
|
38 |
iContainer(aContainer)
|
sl@0
|
39 |
{
|
sl@0
|
40 |
iAudioOutput = aAudioOutput;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
// Two-phased constructor.
|
sl@0
|
44 |
EXPORT_C CAudioOutputMessageHandler* CAudioOutputMessageHandler::NewL(TAny* aCustomInterface,
|
sl@0
|
45 |
CMMFObjectContainer& aContainer)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
CAudioOutput* audioOutput = (CAudioOutput*)aCustomInterface;
|
sl@0
|
48 |
CAudioOutputMessageHandler* self = new (ELeave) CAudioOutputMessageHandler(audioOutput,
|
sl@0
|
49 |
aContainer);
|
sl@0
|
50 |
|
sl@0
|
51 |
self->ConstructL();
|
sl@0
|
52 |
return self;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
|
sl@0
|
56 |
// Destructor
|
sl@0
|
57 |
CAudioOutputMessageHandler::~CAudioOutputMessageHandler()
|
sl@0
|
58 |
{
|
sl@0
|
59 |
delete iAudioOutput;
|
sl@0
|
60 |
delete iCallbackMessage;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
|
sl@0
|
63 |
|
sl@0
|
64 |
// ---------------------------------------------------------
|
sl@0
|
65 |
// CAudioOutputMessageHandler::AudioOutputL
|
sl@0
|
66 |
// ?implementation_description
|
sl@0
|
67 |
// (other items were commented in a header).
|
sl@0
|
68 |
// ---------------------------------------------------------
|
sl@0
|
69 |
//
|
sl@0
|
70 |
EXPORT_C TUid CAudioOutputMessageHandler::Uid()
|
sl@0
|
71 |
{
|
sl@0
|
72 |
return KUidAudioOutput;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
|
sl@0
|
75 |
// ---------------------------------------------------------
|
sl@0
|
76 |
// CAudioOutputMessageHandler::SetAudioOutputL
|
sl@0
|
77 |
// ?implementation_description
|
sl@0
|
78 |
// (other items were commented in a header).
|
sl@0
|
79 |
// ---------------------------------------------------------
|
sl@0
|
80 |
//
|
sl@0
|
81 |
void CAudioOutputMessageHandler::HandleRequest(TMMFMessage& aMessage)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
ASSERT(aMessage.Destination().InterfaceId() == KUidAudioOutput);
|
sl@0
|
84 |
TRAPD(error,DoHandleRequestL(aMessage));
|
sl@0
|
85 |
if(error)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
aMessage.Complete(error);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
}
|
sl@0
|
90 |
|
sl@0
|
91 |
// ---------------------------------------------------------
|
sl@0
|
92 |
// CAudioOutputMessageHandler::DoHandleRequestL
|
sl@0
|
93 |
// ?implementation_description
|
sl@0
|
94 |
// (other items were commented in a header).
|
sl@0
|
95 |
// ---------------------------------------------------------
|
sl@0
|
96 |
//
|
sl@0
|
97 |
void CAudioOutputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
|
sl@0
|
100 |
switch(aMessage.Function())
|
sl@0
|
101 |
{
|
sl@0
|
102 |
case EAofDelete:
|
sl@0
|
103 |
{
|
sl@0
|
104 |
DoDeleteL(aMessage);
|
sl@0
|
105 |
break;
|
sl@0
|
106 |
}
|
sl@0
|
107 |
case EAofRegisterObserver:
|
sl@0
|
108 |
{
|
sl@0
|
109 |
iCallbackMessage = new (ELeave) TMMFMessage( aMessage );
|
sl@0
|
110 |
DoRegisterObserverL();
|
sl@0
|
111 |
break;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
case EAofSetAudioOutput:
|
sl@0
|
114 |
{
|
sl@0
|
115 |
DoSetAudioOutputL(aMessage);
|
sl@0
|
116 |
break;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
case EAofGetAudioOutput:
|
sl@0
|
119 |
{
|
sl@0
|
120 |
DoGetAudioOutputL(aMessage);
|
sl@0
|
121 |
break;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
case EAofSetSecureOutput:
|
sl@0
|
124 |
{
|
sl@0
|
125 |
DoSetSecureOutputL(aMessage);
|
sl@0
|
126 |
break;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
case EAofUnregisterObserver:
|
sl@0
|
129 |
{
|
sl@0
|
130 |
DoUnregisterObserverL(aMessage);
|
sl@0
|
131 |
break;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
default:
|
sl@0
|
134 |
{
|
sl@0
|
135 |
aMessage.Complete(KErrNotSupported);
|
sl@0
|
136 |
}
|
sl@0
|
137 |
}
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
// ---------------------------------------------------------
|
sl@0
|
141 |
// CAudioOutputMessageHandler::DoDeleteL
|
sl@0
|
142 |
// ?implementation_description
|
sl@0
|
143 |
// (other items were commented in a header).
|
sl@0
|
144 |
// ---------------------------------------------------------
|
sl@0
|
145 |
//
|
sl@0
|
146 |
void CAudioOutputMessageHandler::DoDeleteL(TMMFMessage& aMessage)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
aMessage.Complete(KErrNone);
|
sl@0
|
149 |
iContainer.RemoveAndDestroyMMFObject(*this);
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
// ---------------------------------------------------------
|
sl@0
|
153 |
// CAudioOutputMessageHandler::DoRegisterObserverL
|
sl@0
|
154 |
// ?implementation_description
|
sl@0
|
155 |
// (other items were commented in a header).
|
sl@0
|
156 |
// ---------------------------------------------------------
|
sl@0
|
157 |
//
|
sl@0
|
158 |
void CAudioOutputMessageHandler::DoRegisterObserverL()
|
sl@0
|
159 |
{
|
sl@0
|
160 |
iAudioOutput->RegisterObserverL(*this);
|
sl@0
|
161 |
}
|
sl@0
|
162 |
|
sl@0
|
163 |
// ---------------------------------------------------------
|
sl@0
|
164 |
// CAudioOutputMessageHandler::DoSetAudioOutputL
|
sl@0
|
165 |
// ?implementation_description
|
sl@0
|
166 |
// (other items were commented in a header).
|
sl@0
|
167 |
// ---------------------------------------------------------
|
sl@0
|
168 |
//
|
sl@0
|
169 |
void CAudioOutputMessageHandler::DoSetAudioOutputL(TMMFMessage& aMessage)
|
sl@0
|
170 |
{
|
sl@0
|
171 |
TPckgBuf<CAudioOutput::TAudioOutputPreference> outputPckg;
|
sl@0
|
172 |
aMessage.ReadData1FromClient(outputPckg);
|
sl@0
|
173 |
CAudioOutput::TAudioOutputPreference output = outputPckg();
|
sl@0
|
174 |
iAudioOutput->SetAudioOutputL(output);
|
sl@0
|
175 |
aMessage.Complete(KErrNone);
|
sl@0
|
176 |
}
|
sl@0
|
177 |
|
sl@0
|
178 |
// ---------------------------------------------------------
|
sl@0
|
179 |
// CAudioOutputMessageHandler::DoSetSecureOutputL
|
sl@0
|
180 |
// ?implementation_description
|
sl@0
|
181 |
// (other items were commented in a header).
|
sl@0
|
182 |
// ---------------------------------------------------------
|
sl@0
|
183 |
//
|
sl@0
|
184 |
void CAudioOutputMessageHandler::DoSetSecureOutputL(TMMFMessage& aMessage)
|
sl@0
|
185 |
{
|
sl@0
|
186 |
//Since we allow the creation of CAudioOutput from Custom interface builder.
|
sl@0
|
187 |
//We have to make sure that this message is blocked in case we are running in Secure DRM process
|
sl@0
|
188 |
const TSecureId KSecureDRMSID(KUidMmfDrmPluginServerDefine);
|
sl@0
|
189 |
RThread currentThread;
|
sl@0
|
190 |
RProcess currentProcess;
|
sl@0
|
191 |
CleanupClosePushL(currentThread);
|
sl@0
|
192 |
CleanupClosePushL(currentProcess);
|
sl@0
|
193 |
User::LeaveIfError(currentThread.Process(currentProcess));
|
sl@0
|
194 |
TSecureId curProcessSID = currentProcess.SecureId();
|
sl@0
|
195 |
CleanupStack::PopAndDestroy();//calls currentThread.Close()
|
sl@0
|
196 |
CleanupStack::PopAndDestroy();//calls currentProcess.Close()
|
sl@0
|
197 |
if (curProcessSID == KSecureDRMSID)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
//since we are in secure DRM process, completing request with KErrPermissionDenied.
|
sl@0
|
200 |
aMessage.Complete(KErrPermissionDenied);
|
sl@0
|
201 |
return;
|
sl@0
|
202 |
}
|
sl@0
|
203 |
TPckgBuf<TBool> secureOutputPckg;
|
sl@0
|
204 |
aMessage.ReadData1FromClient(secureOutputPckg);
|
sl@0
|
205 |
TBool secureOutput = secureOutputPckg();
|
sl@0
|
206 |
iAudioOutput->SetSecureOutputL(secureOutput);
|
sl@0
|
207 |
aMessage.Complete(KErrNone);
|
sl@0
|
208 |
}
|
sl@0
|
209 |
|
sl@0
|
210 |
// ---------------------------------------------------------
|
sl@0
|
211 |
// CAudioOutputMessageHandler::DoUnregisterObserverL
|
sl@0
|
212 |
// ?implementation_description
|
sl@0
|
213 |
// (other items were commented in a header).
|
sl@0
|
214 |
// ---------------------------------------------------------
|
sl@0
|
215 |
//
|
sl@0
|
216 |
void CAudioOutputMessageHandler::DoUnregisterObserverL(TMMFMessage& aMessage)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
iAudioOutput->UnregisterObserver(*this);
|
sl@0
|
219 |
if ( iCallbackMessage )
|
sl@0
|
220 |
{
|
sl@0
|
221 |
if ( !iCallbackMessage->IsCompleted() )
|
sl@0
|
222 |
{
|
sl@0
|
223 |
iCallbackMessage->Complete(KErrNone);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
}
|
sl@0
|
226 |
aMessage.Complete(KErrNone);
|
sl@0
|
227 |
delete iCallbackMessage;
|
sl@0
|
228 |
iCallbackMessage = NULL;
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
// ---------------------------------------------------------
|
sl@0
|
233 |
// CAudioOutputMessageHandler::DefaultAudioOutputChanged
|
sl@0
|
234 |
// ?implementation_description
|
sl@0
|
235 |
// (other items were commented in a header).
|
sl@0
|
236 |
// ---------------------------------------------------------
|
sl@0
|
237 |
//
|
sl@0
|
238 |
void CAudioOutputMessageHandler::DefaultAudioOutputChanged( CAudioOutput& /*aAudioOutput*/,
|
sl@0
|
239 |
CAudioOutput::TAudioOutputPreference aNewDefault )
|
sl@0
|
240 |
{
|
sl@0
|
241 |
TPckgBuf<CAudioOutput::TAudioOutputPreference> outputPckg(aNewDefault);
|
sl@0
|
242 |
|
sl@0
|
243 |
if ( iCallbackMessage )
|
sl@0
|
244 |
{
|
sl@0
|
245 |
if ( !iCallbackMessage->IsCompleted() )
|
sl@0
|
246 |
{
|
sl@0
|
247 |
iCallbackMessage->WriteDataToClient( outputPckg );
|
sl@0
|
248 |
iCallbackMessage->Complete( KErrNone );
|
sl@0
|
249 |
}
|
sl@0
|
250 |
}
|
sl@0
|
251 |
delete iCallbackMessage;
|
sl@0
|
252 |
iCallbackMessage = NULL;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
|
sl@0
|
256 |
// -----------------------------------------------------------------------------
|
sl@0
|
257 |
// CAudioOutputMessageHandler::ConstructL
|
sl@0
|
258 |
// Symbian 2nd phase constructor can leave.
|
sl@0
|
259 |
// -----------------------------------------------------------------------------
|
sl@0
|
260 |
//
|
sl@0
|
261 |
void CAudioOutputMessageHandler::ConstructL()
|
sl@0
|
262 |
{
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
// ---------------------------------------------------------
|
sl@0
|
266 |
// CAudioOutputMessageHandler::DoSetAudioOutputL
|
sl@0
|
267 |
// ?implementation_description
|
sl@0
|
268 |
// (other items were commented in a header).
|
sl@0
|
269 |
// ---------------------------------------------------------
|
sl@0
|
270 |
//
|
sl@0
|
271 |
void CAudioOutputMessageHandler::DoGetAudioOutputL(TMMFMessage& aMessage)
|
sl@0
|
272 |
{
|
sl@0
|
273 |
#ifdef _DEBUG
|
sl@0
|
274 |
RDebug::Print(_L("CAudioOutputMessageHandler::DoGetAudioOutputL"));
|
sl@0
|
275 |
#endif
|
sl@0
|
276 |
CAudioOutput::TAudioOutputPreference outPut = iAudioOutput->AudioOutput();
|
sl@0
|
277 |
TPckgBuf<CAudioOutput::TAudioOutputPreference> outPutPckg(outPut);
|
sl@0
|
278 |
aMessage.WriteDataToClient(outPutPckg);
|
sl@0
|
279 |
aMessage.Complete(KErrNone);
|
sl@0
|
280 |
}
|
sl@0
|
281 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
sl@0
|
282 |
|
sl@0
|
283 |
|
sl@0
|
284 |
|
sl@0
|
285 |
// End of File
|