sl@0
|
1 |
// Copyright (c) 2006-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 |
// INCLUDE FILES
|
sl@0
|
15 |
//
|
sl@0
|
16 |
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "sounddevicebody.h"
|
sl@0
|
20 |
#include <a3f/mmfdevsoundcustominterfaceextensions.h>
|
sl@0
|
21 |
#include <mmf/plugin/mmfdevsoundcustominterface.hrh>
|
sl@0
|
22 |
#include <mm/mmpluginutils.h>
|
sl@0
|
23 |
|
sl@0
|
24 |
/*
|
sl@0
|
25 |
* Default Constructor.
|
sl@0
|
26 |
*/
|
sl@0
|
27 |
CMMFDevSound::CBody::CBody()
|
sl@0
|
28 |
{
|
sl@0
|
29 |
}
|
sl@0
|
30 |
|
sl@0
|
31 |
/*
|
sl@0
|
32 |
* Destructor.
|
sl@0
|
33 |
*
|
sl@0
|
34 |
* Deletes all objects and releases all resource owned by this
|
sl@0
|
35 |
* instance.
|
sl@0
|
36 |
*/
|
sl@0
|
37 |
CMMFDevSound::CBody::~CBody()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
// Clear the array of custom interfaces
|
sl@0
|
40 |
TInt numIfs = iCustomInterfaceArray.Count();
|
sl@0
|
41 |
for (TInt i = 0; i < numIfs; i++)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
if(iCustomInterfaceArray[i].iInterface)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
iCustomInterfaceArray[i].iInterface->Release();
|
sl@0
|
46 |
}
|
sl@0
|
47 |
}
|
sl@0
|
48 |
iCustomInterfaceArray.Reset();
|
sl@0
|
49 |
iCustomInterfaceArray.Close();
|
sl@0
|
50 |
|
sl@0
|
51 |
// Delete the MUX utility
|
sl@0
|
52 |
delete iMuxUtility;
|
sl@0
|
53 |
|
sl@0
|
54 |
if (iDevSoundProxy)
|
sl@0
|
55 |
{
|
sl@0
|
56 |
iDevSoundProxy->Close();
|
sl@0
|
57 |
delete iDevSoundProxy;
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
// Delete the CI extension
|
sl@0
|
61 |
if (iCIExtension)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
iCIExtension->Release();
|
sl@0
|
64 |
}
|
sl@0
|
65 |
}
|
sl@0
|
66 |
|
sl@0
|
67 |
/*
|
sl@0
|
68 |
* Constructs, and returns a pointer to, a new CMMFDevSound::CBody object.
|
sl@0
|
69 |
*
|
sl@0
|
70 |
* Leaves on failure.
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
CMMFDevSound::CBody* CMMFDevSound::CBody::NewL()
|
sl@0
|
73 |
{
|
sl@0
|
74 |
CBody* self = new (ELeave) CBody;
|
sl@0
|
75 |
CleanupStack::PushL(self);
|
sl@0
|
76 |
self->ConstructL();
|
sl@0
|
77 |
CleanupStack::Pop(self);
|
sl@0
|
78 |
return self;
|
sl@0
|
79 |
}
|
sl@0
|
80 |
|
sl@0
|
81 |
/*
|
sl@0
|
82 |
* Second phase constructor.
|
sl@0
|
83 |
*/
|
sl@0
|
84 |
void CMMFDevSound::CBody::ConstructL()
|
sl@0
|
85 |
{
|
sl@0
|
86 |
// all these data properties should be NULL, but add ASSERTs to verify.
|
sl@0
|
87 |
ASSERT(!iDevSoundProxy);
|
sl@0
|
88 |
iDevSoundProxy = new (ELeave) RMMFDevSoundProxy();
|
sl@0
|
89 |
TInt err = iDevSoundProxy->Open();
|
sl@0
|
90 |
User::LeaveIfError(err);
|
sl@0
|
91 |
|
sl@0
|
92 |
User::LeaveIfError(iDevSoundProxy->PostOpen());
|
sl@0
|
93 |
|
sl@0
|
94 |
// create Custom Interface MUX utility
|
sl@0
|
95 |
iMuxUtility = CMMFDevSoundCIMuxUtility::NewL(this);
|
sl@0
|
96 |
|
sl@0
|
97 |
// Create Custom Interface extension
|
sl@0
|
98 |
RImplInfoPtrArray pluginArray;
|
sl@0
|
99 |
CleanupResetAndDestroyPushL(pluginArray);
|
sl@0
|
100 |
TUid interfaceUid = {KUidDevSoundCIClientExtension};
|
sl@0
|
101 |
REComSession::ListImplementationsL(interfaceUid, pluginArray);
|
sl@0
|
102 |
TUid destructorKey;
|
sl@0
|
103 |
if (pluginArray.Count() > 0)
|
sl@0
|
104 |
{
|
sl@0
|
105 |
// One or more exists - use the 1st one found
|
sl@0
|
106 |
iCIExtension = static_cast<MDevSoundCIClientExtension*>
|
sl@0
|
107 |
(REComSession::CreateImplementationL(pluginArray[0]->ImplementationUid(), destructorKey));
|
sl@0
|
108 |
}
|
sl@0
|
109 |
CleanupStack::PopAndDestroy(&pluginArray);
|
sl@0
|
110 |
if (iCIExtension)
|
sl@0
|
111 |
{
|
sl@0
|
112 |
// Extension exists. Complete the setup
|
sl@0
|
113 |
iCIExtension->PassDestructorKey(destructorKey);
|
sl@0
|
114 |
User::LeaveIfError(iCIExtension->Setup(*iDevSoundProxy));
|
sl@0
|
115 |
}
|
sl@0
|
116 |
}
|
sl@0
|
117 |
|
sl@0
|
118 |
/*
|
sl@0
|
119 |
* CMMFDevSound::InitializeL
|
sl@0
|
120 |
*
|
sl@0
|
121 |
* Initializes CMMFDevSound object. On completion of Initialization will
|
sl@0
|
122 |
* call InitializeComplete() on aDevSoundObserver.
|
sl@0
|
123 |
*
|
sl@0
|
124 |
* Leaves on failure.
|
sl@0
|
125 |
*
|
sl@0
|
126 |
* @param MDevSoundObserver&
|
sl@0
|
127 |
* A reference to the DevSound Observer instance.
|
sl@0
|
128 |
*
|
sl@0
|
129 |
* @param TMMFState
|
sl@0
|
130 |
* A mode for which this object will be used.
|
sl@0
|
131 |
*/
|
sl@0
|
132 |
void CMMFDevSound::CBody::InitializeL(MDevSoundObserver& aDevSoundObserver,
|
sl@0
|
133 |
TMMFState aMode)
|
sl@0
|
134 |
|
sl@0
|
135 |
{
|
sl@0
|
136 |
|
sl@0
|
137 |
ASSERT(iDevSoundProxy);
|
sl@0
|
138 |
iDevSoundProxy->InitializeL(aDevSoundObserver, aMode, *this);
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
/*
|
sl@0
|
142 |
* CMMFDevSound::InitializeL
|
sl@0
|
143 |
*
|
sl@0
|
144 |
* Initializes CMMFDevSound object with hardware device with hardware
|
sl@0
|
145 |
* device's FourCC code. On completion of Initialization will call
|
sl@0
|
146 |
* InitializeComplete() on aDevSoundObserver.
|
sl@0
|
147 |
*
|
sl@0
|
148 |
* Leaves on failure.
|
sl@0
|
149 |
*
|
sl@0
|
150 |
* @param MDevSoundObserver&
|
sl@0
|
151 |
* A reference to the DevSound Observer instance.
|
sl@0
|
152 |
*
|
sl@0
|
153 |
* @param TFourCC
|
sl@0
|
154 |
* CMMFHwDevice implementation FourCC.
|
sl@0
|
155 |
*
|
sl@0
|
156 |
* @param TMMFState
|
sl@0
|
157 |
* A mode for which this object will be used.
|
sl@0
|
158 |
*
|
sl@0
|
159 |
*/
|
sl@0
|
160 |
void CMMFDevSound::CBody::InitializeL(MDevSoundObserver& aDevSoundObserver,
|
sl@0
|
161 |
TFourCC aDesiredFourCC,
|
sl@0
|
162 |
TMMFState aMode)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
ASSERT(iDevSoundProxy);
|
sl@0
|
165 |
iDevSoundProxy->InitializeL(aDevSoundObserver, aDesiredFourCC, aMode, *this);
|
sl@0
|
166 |
}
|
sl@0
|
167 |
|
sl@0
|
168 |
/**
|
sl@0
|
169 |
* CMMFDevSound::CBody::CustomInterface
|
sl@0
|
170 |
*
|
sl@0
|
171 |
* Returns custom interface proxy object created by Proxy Custom Interface
|
sl@0
|
172 |
* Utility.
|
sl@0
|
173 |
*
|
sl@0
|
174 |
* @param TUid
|
sl@0
|
175 |
* UID of the custom interface object to be started.
|
sl@0
|
176 |
*
|
sl@0
|
177 |
* @return TAny*
|
sl@0
|
178 |
* Pointer to the Interface Returned by the DevSoundProxy member.
|
sl@0
|
179 |
*/
|
sl@0
|
180 |
TAny* CMMFDevSound::CBody::CustomInterface(TUid aInterfaceId)
|
sl@0
|
181 |
{
|
sl@0
|
182 |
// check if this UID refers to CancelInitialize()
|
sl@0
|
183 |
if (aInterfaceId == KMmfUidDevSoundCancelInitializeCustomInterface)
|
sl@0
|
184 |
{
|
sl@0
|
185 |
MMMFDevSoundCancelInitialize* result = this;
|
sl@0
|
186 |
return result;
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
// check if this UID refers to EmptyBuffers()
|
sl@0
|
190 |
if (aInterfaceId == KMmfUidDevSoundEmptyBuffersCustomInterface)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
MMMFDevSoundEmptyBuffers* result = this;
|
sl@0
|
193 |
return result;
|
sl@0
|
194 |
}
|
sl@0
|
195 |
|
sl@0
|
196 |
if (aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
|
sl@0
|
197 |
{
|
sl@0
|
198 |
MAutoPauseResumeSupport* result = this;
|
sl@0
|
199 |
return result;
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|
sl@0
|
202 |
if (aInterfaceId == KMmfUidDevSoundTimePlayedCustomInterface)
|
sl@0
|
203 |
{
|
sl@0
|
204 |
MMMFDevSoundTimePlayed* result = this;
|
sl@0
|
205 |
return result;
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
if (aInterfaceId == KMmfUidDevSoundQueryIgnoresUnderflowCustomInterface)
|
sl@0
|
209 |
{
|
sl@0
|
210 |
MMMFDevSoundQueryIgnoresUnderflow* result = this;
|
sl@0
|
211 |
return result;
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
if (aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
|
sl@0
|
215 |
{
|
sl@0
|
216 |
MAudioClientThreadInfo* result = this;
|
sl@0
|
217 |
return result;
|
sl@0
|
218 |
}
|
sl@0
|
219 |
|
sl@0
|
220 |
if (aInterfaceId == KMmfUidDevSoundTruePauseCustomInterface)
|
sl@0
|
221 |
{
|
sl@0
|
222 |
MMMFDevSoundTruePause* result = this;
|
sl@0
|
223 |
return result;
|
sl@0
|
224 |
}
|
sl@0
|
225 |
|
sl@0
|
226 |
// first check if we already have resolved a custom interface of this type
|
sl@0
|
227 |
TInt index = FindCustomInterface(aInterfaceId);
|
sl@0
|
228 |
|
sl@0
|
229 |
MMMFDevSoundCustomInterfaceMuxPlugin* ptr = NULL;
|
sl@0
|
230 |
|
sl@0
|
231 |
// if we found the interface, take a copy of this instead
|
sl@0
|
232 |
if (index != KNullHandle)
|
sl@0
|
233 |
{
|
sl@0
|
234 |
// check our index is valid
|
sl@0
|
235 |
ptr = iCustomInterfaceArray[index-1].iInterface;
|
sl@0
|
236 |
if (ptr)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
return ptr->CustomInterface(aInterfaceId);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
}
|
sl@0
|
241 |
else
|
sl@0
|
242 |
{
|
sl@0
|
243 |
// else try and instantiate a plugin tunnelling
|
sl@0
|
244 |
// pair to support this Custom Interface
|
sl@0
|
245 |
TRAPD(err, ptr = iMuxUtility->CreateCustomInterfaceMuxL(aInterfaceId));
|
sl@0
|
246 |
|
sl@0
|
247 |
if (ptr && (err == KErrNone))
|
sl@0
|
248 |
{
|
sl@0
|
249 |
TMMFDevSoundCustomInterfaceData data;
|
sl@0
|
250 |
data.iInterface = ptr;
|
sl@0
|
251 |
data.iId = aInterfaceId;
|
sl@0
|
252 |
|
sl@0
|
253 |
// attempt to open remote demux
|
sl@0
|
254 |
// this will store a handle in the mux plugin if successful
|
sl@0
|
255 |
// and also return it here - invalid handle = -1
|
sl@0
|
256 |
data.iHandle = ptr->OpenInterface(aInterfaceId);
|
sl@0
|
257 |
|
sl@0
|
258 |
// if the handle is greater than zero then we know we have
|
sl@0
|
259 |
// successfully opened the interface
|
sl@0
|
260 |
if (data.iHandle > KNullHandle)
|
sl@0
|
261 |
{
|
sl@0
|
262 |
// append this to the current interface list
|
sl@0
|
263 |
TInt err = KErrNone;
|
sl@0
|
264 |
err = iCustomInterfaceArray.Append(data);
|
sl@0
|
265 |
if (err == KErrNone)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
// return the custom interface on the ptr
|
sl@0
|
268 |
return ptr->CustomInterface(aInterfaceId);
|
sl@0
|
269 |
}
|
sl@0
|
270 |
}
|
sl@0
|
271 |
|
sl@0
|
272 |
// no memory or other problem so shut down interface
|
sl@0
|
273 |
ptr->Release();
|
sl@0
|
274 |
ptr = NULL;
|
sl@0
|
275 |
}
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
if (iCIExtension)
|
sl@0
|
279 |
{
|
sl@0
|
280 |
// CI Extension exists, see if it supports the interface
|
sl@0
|
281 |
TAny* interface;
|
sl@0
|
282 |
TInt err = iCIExtension->CustomInterfaceExtension(aInterfaceId, interface);
|
sl@0
|
283 |
if (err == KErrNone)
|
sl@0
|
284 |
{
|
sl@0
|
285 |
return interface;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
}
|
sl@0
|
288 |
// No Mux/DeMux support & no support from CI Extension, if here
|
sl@0
|
289 |
// So, its not supported
|
sl@0
|
290 |
return NULL;
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
TInt CMMFDevSound::CBody::FindCustomInterface(TUid aInterfaceId)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
TInt index = KNullHandle;
|
sl@0
|
296 |
TInt count = iCustomInterfaceArray.Count();
|
sl@0
|
297 |
for (TInt i = 0; i < count; i++)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
if (iCustomInterfaceArray[i].iId == aInterfaceId)
|
sl@0
|
300 |
{
|
sl@0
|
301 |
index = i+1; // use index+1 as the handle, so 0 is undefined/not-found
|
sl@0
|
302 |
break;
|
sl@0
|
303 |
}
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
return index;
|
sl@0
|
307 |
}
|
sl@0
|
308 |
|
sl@0
|
309 |
void CMMFDevSound::CBody::CloseCustomInterface(TInt aIndex)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
TInt count = iCustomInterfaceArray.Count();
|
sl@0
|
312 |
for (TInt i = 0; i < count; i++)
|
sl@0
|
313 |
{
|
sl@0
|
314 |
if(iCustomInterfaceArray[i].iHandle == aIndex)
|
sl@0
|
315 |
{
|
sl@0
|
316 |
iCustomInterfaceArray[i].iInterface->Release();
|
sl@0
|
317 |
iCustomInterfaceArray.Remove(i);
|
sl@0
|
318 |
break;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
}
|
sl@0
|
321 |
}
|
sl@0
|
322 |
|
sl@0
|
323 |
TInt CMMFDevSound::CBody::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
|
sl@0
|
324 |
{
|
sl@0
|
325 |
return iDevSoundProxy->GetTimePlayed(aTime);
|
sl@0
|
326 |
}
|
sl@0
|
327 |
|
sl@0
|
328 |
TBool CMMFDevSound::CBody::QueryIgnoresUnderflow()
|
sl@0
|
329 |
{
|
sl@0
|
330 |
return ETrue;
|
sl@0
|
331 |
}
|
sl@0
|
332 |
|
sl@0
|
333 |
TInt CMMFDevSound::CBody::SetClientThreadInfo(TThreadId aTid)
|
sl@0
|
334 |
{
|
sl@0
|
335 |
return iDevSoundProxy->SetClientThreadInfo(aTid);
|
sl@0
|
336 |
}
|
sl@0
|
337 |
// End of File
|