26
|
1 |
// Copyright (c) 2006-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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include "cmmfdevsoundcifileblocklengthimpluid.hrh"
|
|
17 |
|
|
18 |
#include <ecom/implementationproxy.h>
|
|
19 |
#include <ecom/implementationproxy.h>
|
|
20 |
#include <ecom/ecom.h>
|
|
21 |
#include <s32mem.h>
|
|
22 |
|
|
23 |
#include "cmmfdevsoundcifileblocklength.h"
|
|
24 |
|
|
25 |
// __________________________________________________________________________
|
|
26 |
// Implementation
|
|
27 |
|
|
28 |
// MUX //
|
|
29 |
|
|
30 |
TInt CMMFDevSoundCIFileBlockLengthMux::OpenInterface(TUid /*aInterfaceId*/)
|
|
31 |
{
|
|
32 |
// attempt to open the interface link with the
|
|
33 |
// remote slave device
|
|
34 |
iRemoteHandle = -1;
|
|
35 |
TUid slaveId = {KMmfUidCIFileBlockLengthDeMux};
|
|
36 |
|
|
37 |
TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
|
|
38 |
if (handle >= 0)
|
|
39 |
{
|
|
40 |
iRemoteHandle = handle;
|
|
41 |
}
|
|
42 |
|
|
43 |
return iRemoteHandle;
|
|
44 |
}
|
|
45 |
|
|
46 |
void CMMFDevSoundCIFileBlockLengthMux::Release()
|
|
47 |
{
|
|
48 |
// close the slave device if it exists
|
|
49 |
if (iRemoteHandle != -1)
|
|
50 |
{
|
|
51 |
// we assume the slave is closed correctly
|
|
52 |
iUtility->CloseSlave(iRemoteHandle);
|
|
53 |
}
|
|
54 |
|
|
55 |
TUid key = iKey;
|
|
56 |
delete this;
|
|
57 |
|
|
58 |
// tell ECom to destroy us
|
|
59 |
REComSession::DestroyedImplementation(key);
|
|
60 |
}
|
|
61 |
|
|
62 |
void CMMFDevSoundCIFileBlockLengthMux::PassDestructorKey(TUid aDestructorKey)
|
|
63 |
{
|
|
64 |
// store the destructor key
|
|
65 |
iKey = aDestructorKey;
|
|
66 |
}
|
|
67 |
|
|
68 |
void CMMFDevSoundCIFileBlockLengthMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
|
|
69 |
{
|
|
70 |
// store a pointer to the utility
|
|
71 |
iUtility = aCustomUtility;
|
|
72 |
}
|
|
73 |
|
|
74 |
MMMFDevSoundCustomInterfaceMuxPlugin* CMMFDevSoundCIFileBlockLengthMux::NewL()
|
|
75 |
{
|
|
76 |
CMMFDevSoundCIFileBlockLengthMux* self = new (ELeave) CMMFDevSoundCIFileBlockLengthMux;
|
|
77 |
return self;
|
|
78 |
}
|
|
79 |
|
|
80 |
TAny* CMMFDevSoundCIFileBlockLengthMux::CustomInterface(TUid /*aInterfaceId*/)
|
|
81 |
{
|
|
82 |
MMMFDevSoundCustomInterfaceFileBlockLength* interface = this;
|
|
83 |
return interface;
|
|
84 |
}
|
|
85 |
|
|
86 |
CMMFDevSoundCIFileBlockLengthMux::CMMFDevSoundCIFileBlockLengthMux() :
|
|
87 |
iRemoteHandle(-1)
|
|
88 |
{
|
|
89 |
}
|
|
90 |
|
|
91 |
CMMFDevSoundCIFileBlockLengthMux::~CMMFDevSoundCIFileBlockLengthMux()
|
|
92 |
{
|
|
93 |
}
|
|
94 |
|
|
95 |
// from MMMFDevSoundCustomInterfaceFileBlockLength
|
|
96 |
|
|
97 |
void CMMFDevSoundCIFileBlockLengthMux::SetFileBlockLength(TUint aBlockAlign)
|
|
98 |
{
|
|
99 |
if (iRemoteHandle == -1)
|
|
100 |
{
|
|
101 |
return;
|
|
102 |
}
|
|
103 |
|
|
104 |
// send the BlockAlign in the sync command
|
|
105 |
TPckgBuf<TUint> blockAlignBuffer(aBlockAlign);
|
|
106 |
|
|
107 |
iUtility->SendSlaveSyncCommand(iRemoteHandle, EMMFDevSoundCIBlockLengthSetFileBlockLength, blockAlignBuffer);
|
|
108 |
}
|
|
109 |
|
|
110 |
// DEMUX //
|
|
111 |
|
|
112 |
|
|
113 |
TInt CMMFDevSoundCIFileBlockLengthDeMux::OpenInterface(TUid /*aInterfaceId*/)
|
|
114 |
{
|
|
115 |
return KErrNone;
|
|
116 |
}
|
|
117 |
|
|
118 |
void CMMFDevSoundCIFileBlockLengthDeMux::Release()
|
|
119 |
{
|
|
120 |
TUid key = iKey;
|
|
121 |
|
|
122 |
delete this;
|
|
123 |
|
|
124 |
// tell ECom to destroy us
|
|
125 |
REComSession::DestroyedImplementation(key);
|
|
126 |
}
|
|
127 |
|
|
128 |
void CMMFDevSoundCIFileBlockLengthDeMux::PassDestructorKey(TUid aDestructorKey)
|
|
129 |
{
|
|
130 |
// store the destructor key
|
|
131 |
iKey = aDestructorKey;
|
|
132 |
}
|
|
133 |
|
|
134 |
void CMMFDevSoundCIFileBlockLengthDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
|
|
135 |
{
|
|
136 |
iTarget = aTarget;
|
|
137 |
}
|
|
138 |
|
|
139 |
void CMMFDevSoundCIFileBlockLengthDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
|
|
140 |
{
|
|
141 |
// store a pointer to the utility
|
|
142 |
iUtility = aCustomUtility;
|
|
143 |
}
|
|
144 |
|
|
145 |
void CMMFDevSoundCIFileBlockLengthDeMux::RefreshL()
|
|
146 |
{
|
|
147 |
// refetch the fileblocklength custom interface if we already have a target
|
|
148 |
if (iTarget)
|
|
149 |
{
|
|
150 |
MMMFDevSoundCustomInterfaceFileBlockLength* ptr = NULL;
|
|
151 |
ptr = static_cast<MMMFDevSoundCustomInterfaceFileBlockLength*>(iTarget->CustomInterface(KUidCustomInterfaceDevSoundFileBlockLength));
|
|
152 |
|
|
153 |
if (!ptr)
|
|
154 |
{
|
|
155 |
iFileBlockLengthInterface = NULL;
|
|
156 |
User::Leave(KErrNotSupported);
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iFileBlockLengthInterface = ptr;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
|
|
166 |
MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFDevSoundCIFileBlockLengthDeMux::NewL()
|
|
167 |
{
|
|
168 |
CMMFDevSoundCIFileBlockLengthDeMux* self = new (ELeave) CMMFDevSoundCIFileBlockLengthDeMux;
|
|
169 |
return self;
|
|
170 |
}
|
|
171 |
|
|
172 |
CMMFDevSoundCIFileBlockLengthDeMux::CMMFDevSoundCIFileBlockLengthDeMux()
|
|
173 |
{
|
|
174 |
}
|
|
175 |
|
|
176 |
CMMFDevSoundCIFileBlockLengthDeMux::~CMMFDevSoundCIFileBlockLengthDeMux()
|
|
177 |
{
|
|
178 |
}
|
|
179 |
|
|
180 |
|
|
181 |
TInt CMMFDevSoundCIFileBlockLengthDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
|
|
182 |
{
|
|
183 |
// fetch the fileblocklength custom interface
|
|
184 |
MMMFDevSoundCustomInterfaceFileBlockLength* ptr = NULL;
|
|
185 |
ptr = static_cast <MMMFDevSoundCustomInterfaceFileBlockLength*> (iTarget->CustomInterface(KUidCustomInterfaceDevSoundFileBlockLength));
|
|
186 |
|
|
187 |
if (!ptr)
|
|
188 |
{
|
|
189 |
iFileBlockLengthInterface = NULL;
|
|
190 |
User::Leave(KErrNotSupported);
|
|
191 |
}
|
|
192 |
else
|
|
193 |
{
|
|
194 |
iFileBlockLengthInterface = ptr;
|
|
195 |
}
|
|
196 |
return KErrNone;
|
|
197 |
}
|
|
198 |
|
|
199 |
void CMMFDevSoundCIFileBlockLengthDeMux::DoCloseSlaveL(TInt /*aHandle*/)
|
|
200 |
{
|
|
201 |
// nothing to do
|
|
202 |
}
|
|
203 |
|
|
204 |
// original RMessage is supplied so that remote demux plugin can extract necessary details
|
|
205 |
// using DeMux utility
|
|
206 |
TInt CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
|
|
207 |
{
|
|
208 |
TMMFDevSoundCIMessageData data;
|
|
209 |
|
|
210 |
// decode message
|
|
211 |
iUtility->GetSyncMessageDataL(aMessage, data);
|
|
212 |
TInt retVal = -1;
|
|
213 |
|
|
214 |
switch (data.iCommand)
|
|
215 |
{
|
|
216 |
case EMMFDevSoundCIBlockLengthSetFileBlockLength:
|
|
217 |
{
|
|
218 |
// we know that offset 2 contains a TInt
|
|
219 |
TPckgBuf<TUint> blockAlignBuffer;
|
|
220 |
iUtility->ReadFromInputDesL(aMessage, &blockAlignBuffer);
|
|
221 |
|
|
222 |
DoSetFileBlockLengthL(blockAlignBuffer());
|
|
223 |
retVal = KErrNone;
|
|
224 |
break;
|
|
225 |
}
|
|
226 |
|
|
227 |
default:
|
|
228 |
{
|
|
229 |
User::Leave(KErrNotSupported);
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
return retVal;
|
|
234 |
}
|
|
235 |
|
|
236 |
TInt CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
|
|
237 |
{
|
|
238 |
return KErrNotSupported;
|
|
239 |
}
|
|
240 |
|
|
241 |
void CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
|
|
242 |
{
|
|
243 |
// not used in this interface
|
|
244 |
}
|
|
245 |
|
|
246 |
void CMMFDevSoundCIFileBlockLengthDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
|
|
247 |
{
|
|
248 |
// not used in this interface
|
|
249 |
}
|
|
250 |
|
|
251 |
void CMMFDevSoundCIFileBlockLengthDeMux::DoSetFileBlockLengthL(TUint aBlockAlign)
|
|
252 |
{
|
|
253 |
if (!iFileBlockLengthInterface)
|
|
254 |
{
|
|
255 |
User::Leave(KErrNotReady);
|
|
256 |
}
|
|
257 |
|
|
258 |
// set the block length
|
|
259 |
iFileBlockLengthInterface->SetFileBlockLength(aBlockAlign);
|
|
260 |
}
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
//
|
|
265 |
// ImplementationTable
|
|
266 |
//
|
|
267 |
|
|
268 |
const TImplementationProxy ImplementationTable[] =
|
|
269 |
{
|
|
270 |
IMPLEMENTATION_PROXY_ENTRY(KMmfUidCIFileBlockLengthMux, CMMFDevSoundCIFileBlockLengthMux::NewL),
|
|
271 |
IMPLEMENTATION_PROXY_ENTRY(KMmfUidCIFileBlockLengthDeMux, CMMFDevSoundCIFileBlockLengthDeMux::NewL),
|
|
272 |
};
|
|
273 |
|
|
274 |
|
|
275 |
//
|
|
276 |
// ImplementationGroupProxy
|
|
277 |
//
|
|
278 |
//
|
|
279 |
|
|
280 |
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
|
|
281 |
{
|
|
282 |
aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
|
|
283 |
|
|
284 |
return ImplementationTable;
|
|
285 |
}
|
|
286 |
|
|
287 |
#ifndef EKA2
|
|
288 |
/** DLL Entry point */
|
|
289 |
GLDEF_C TInt E32Dll(TDllReason /*aReason*/)
|
|
290 |
{
|
|
291 |
return(KErrNone);
|
|
292 |
}
|
|
293 |
#endif
|
|
294 |
|