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