sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 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:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@test
|
sl@0
|
20 |
@internalComponent
|
sl@0
|
21 |
|
sl@0
|
22 |
This contains CT_MdaDevSoundData
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
// User includes
|
sl@0
|
26 |
#include "t_mdadevsounddata.h"
|
sl@0
|
27 |
#include "t_sounddriverserver.h"
|
sl@0
|
28 |
|
sl@0
|
29 |
/*@{*/
|
sl@0
|
30 |
/// Parameters
|
sl@0
|
31 |
|
sl@0
|
32 |
_LIT(KSoundFormatsSupportedObject, "SoundFormatsSupportedObject");
|
sl@0
|
33 |
_LIT(KCurrentSoundFormatObject, "CurrentSoundFormatObject");
|
sl@0
|
34 |
|
sl@0
|
35 |
_LIT(KUUnit, "unit");
|
sl@0
|
36 |
_LIT(KUUnitEnum, "UnitEnum");
|
sl@0
|
37 |
_LIT(KUToFile, "to_file");
|
sl@0
|
38 |
_LIT(KUBlockSize, "block_size");
|
sl@0
|
39 |
_LIT(KUVersion, "version");
|
sl@0
|
40 |
|
sl@0
|
41 |
_LIT(KUFromFile, "from_file");
|
sl@0
|
42 |
_LIT(KUDataSize, "data_size");
|
sl@0
|
43 |
_LIT(KUVolumeExpected, "volume_expected");
|
sl@0
|
44 |
_LIT(KUVolume, "volume");
|
sl@0
|
45 |
_LIT(KUBytesPlayed, "bytes_played");
|
sl@0
|
46 |
_LIT(KUCancel, "cancel");
|
sl@0
|
47 |
_LIT(KUFlush, "flush");
|
sl@0
|
48 |
|
sl@0
|
49 |
_LIT(KUSoundLevel, "sound_level");
|
sl@0
|
50 |
_LIT(KUSoundLevelExpected, "sound_level_expected");
|
sl@0
|
51 |
|
sl@0
|
52 |
_LIT(KUFileToDelete, "file_to_delete");
|
sl@0
|
53 |
|
sl@0
|
54 |
_LIT(KLDDName, "ldd");
|
sl@0
|
55 |
_LIT(KPDDName, "pdd");
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
|
sl@0
|
59 |
/*@{*/
|
sl@0
|
60 |
/// Commands
|
sl@0
|
61 |
_LIT(KCmdUtilityDeleteFile, "utilityDeleteFile");
|
sl@0
|
62 |
|
sl@0
|
63 |
_LIT(KCmdRecordData, "RecordData");
|
sl@0
|
64 |
_LIT(KCmdCancelRecordData, "CancelRecordData");
|
sl@0
|
65 |
_LIT(KCmdFlushRecordBuffer, "FlushRecordBuffer");
|
sl@0
|
66 |
_LIT(KCmdRecordLevel, "RecordLevel");
|
sl@0
|
67 |
_LIT(KCmdSetRecordLevel, "SetRecordLevel");
|
sl@0
|
68 |
_LIT(KCmdNotifyRecordError, "NotifyRecordError");
|
sl@0
|
69 |
_LIT(KCmdCancelNotifyRecordError, "CancelNotifyRecordError");
|
sl@0
|
70 |
|
sl@0
|
71 |
_LIT(KCmdPlayVolume, "PlayVolume");
|
sl@0
|
72 |
_LIT(KCmdSetPlayVolume, "SetPlayVolume");
|
sl@0
|
73 |
_LIT(KCmdPlayData, "PlayData");
|
sl@0
|
74 |
_LIT(KCmdCancelPlayData, "CancelPlayData");
|
sl@0
|
75 |
_LIT(KCmdFlushPlayBuffer, "FlushPlayBuffer");
|
sl@0
|
76 |
_LIT(KCmdNotifyPlayError, "NotifyPlayError");
|
sl@0
|
77 |
_LIT(KCmdCancelNotifyPlayError, "CancelNotifyPlayError");
|
sl@0
|
78 |
|
sl@0
|
79 |
_LIT(KCmdBytesPlayed, "BytesPlayed");
|
sl@0
|
80 |
_LIT(KCmdResetBytesPlayed, "ResetBytesPlayed");
|
sl@0
|
81 |
_LIT(KCmdPausePlayBuffer, "PausePlayBuffer");
|
sl@0
|
82 |
_LIT(KCmdResumePlaying, "ResumePlaying");
|
sl@0
|
83 |
|
sl@0
|
84 |
_LIT(KCmdPlayFormatsSupported, "PlayFormatsSupported");
|
sl@0
|
85 |
_LIT(KCmdGetPlayFormat, "GetPlayFormat");
|
sl@0
|
86 |
_LIT(KCmdSetPlayFormat, "SetPlayFormat");
|
sl@0
|
87 |
_LIT(KCmdRecordFormatsSupported, "RecordFormatsSupported");
|
sl@0
|
88 |
_LIT(KCmdGetRecordFormat, "GetRecordFormat");
|
sl@0
|
89 |
_LIT(KCmdSetRecordFormat, "SetRecordFormat");
|
sl@0
|
90 |
|
sl@0
|
91 |
_LIT(KCmdNew, "new");
|
sl@0
|
92 |
_LIT(KCmdOpen, "Open");
|
sl@0
|
93 |
_LIT(KCmdClose, "Close");
|
sl@0
|
94 |
_LIT(KCmdDestructor, "~");
|
sl@0
|
95 |
_LIT(KCmdIsMdaSound, "IsMdaSound");
|
sl@0
|
96 |
_LIT(KCmdVersionRequired, "VersionRequired");
|
sl@0
|
97 |
/*@}*/
|
sl@0
|
98 |
|
sl@0
|
99 |
/**
|
sl@0
|
100 |
* Two phase constructor
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
CT_MdaDevSoundData* CT_MdaDevSoundData::NewL(RMdaDevSound* aServerStore)
|
sl@0
|
103 |
{
|
sl@0
|
104 |
CT_MdaDevSoundData* ret = new (ELeave) CT_MdaDevSoundData(aServerStore);
|
sl@0
|
105 |
CleanupStack::PushL(ret);
|
sl@0
|
106 |
ret->ConstructL();
|
sl@0
|
107 |
CleanupStack::Pop(ret);
|
sl@0
|
108 |
return ret;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
/**
|
sl@0
|
112 |
* Protected constructor. First phase construction
|
sl@0
|
113 |
*/
|
sl@0
|
114 |
CT_MdaDevSoundData::CT_MdaDevSoundData(RMdaDevSound* aServerStore)
|
sl@0
|
115 |
:iServerStore(aServerStore)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
}
|
sl@0
|
118 |
|
sl@0
|
119 |
/**
|
sl@0
|
120 |
* Protected constructor. Second phase construction
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
void CT_MdaDevSoundData::ConstructL()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
/**
|
sl@0
|
127 |
* Destructor.
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
CT_MdaDevSoundData::~CT_MdaDevSoundData()
|
sl@0
|
130 |
{
|
sl@0
|
131 |
DoCleanup();
|
sl@0
|
132 |
|
sl@0
|
133 |
iNotifyPlayError.ResetAndDestroy();
|
sl@0
|
134 |
iNotifyRecordError.ResetAndDestroy();
|
sl@0
|
135 |
iPlay.ResetAndDestroy();
|
sl@0
|
136 |
iRecord.ResetAndDestroy();
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
/**
|
sl@0
|
140 |
* Contains cleanup implementation
|
sl@0
|
141 |
*/
|
sl@0
|
142 |
void CT_MdaDevSoundData::DoCleanup()
|
sl@0
|
143 |
{
|
sl@0
|
144 |
if(iMdaDevSound)
|
sl@0
|
145 |
{
|
sl@0
|
146 |
INFO_PRINTF1(_L("Deleting current RMdaDevSound"));
|
sl@0
|
147 |
delete iMdaDevSound;
|
sl@0
|
148 |
iMdaDevSound = NULL;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
/**
|
sl@0
|
153 |
* Return a pointer to the object that the data wraps
|
sl@0
|
154 |
*
|
sl@0
|
155 |
* @return pointer to the object that the data wraps
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
TAny* CT_MdaDevSoundData::GetObject()
|
sl@0
|
158 |
{
|
sl@0
|
159 |
return iMdaDevSound;
|
sl@0
|
160 |
}
|
sl@0
|
161 |
|
sl@0
|
162 |
/**
|
sl@0
|
163 |
* Set the wrapped data object with new value
|
sl@0
|
164 |
*/
|
sl@0
|
165 |
void CT_MdaDevSoundData::SetObjectL( TAny* aAny )
|
sl@0
|
166 |
{
|
sl@0
|
167 |
DoCleanup();
|
sl@0
|
168 |
iMdaDevSound = static_cast<RMdaDevSound*> ( aAny );
|
sl@0
|
169 |
*iServerStore = *iMdaDevSound;
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
/**
|
sl@0
|
173 |
* Clear the wrapped data object pointer w/o de-initialization
|
sl@0
|
174 |
*/
|
sl@0
|
175 |
void CT_MdaDevSoundData::DisownObjectL()
|
sl@0
|
176 |
{
|
sl@0
|
177 |
iMdaDevSound = NULL;
|
sl@0
|
178 |
iServerStore->SetHandle(KNullHandle);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
/**
|
sl@0
|
182 |
* Return static cleanup function
|
sl@0
|
183 |
*/
|
sl@0
|
184 |
inline TCleanupOperation CT_MdaDevSoundData::CleanupOperation()
|
sl@0
|
185 |
{
|
sl@0
|
186 |
return CleanupOperation;
|
sl@0
|
187 |
}
|
sl@0
|
188 |
|
sl@0
|
189 |
/**
|
sl@0
|
190 |
* Static cleanup function
|
sl@0
|
191 |
*/
|
sl@0
|
192 |
void CT_MdaDevSoundData::CleanupOperation( TAny* aAny )
|
sl@0
|
193 |
{
|
sl@0
|
194 |
RMdaDevSound* sound = static_cast<RMdaDevSound*> ( aAny );
|
sl@0
|
195 |
delete sound;
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
* Process a command read from the ini file
|
sl@0
|
200 |
*
|
sl@0
|
201 |
* @param aCommand the command to process
|
sl@0
|
202 |
* @param aSection the entry in the ini file requiring the command to be processed
|
sl@0
|
203 |
*
|
sl@0
|
204 |
* @return ETrue if the command is processed
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
TBool CT_MdaDevSoundData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
sl@0
|
207 |
{
|
sl@0
|
208 |
TBool ret=ETrue;
|
sl@0
|
209 |
if (aCommand == KCmdNew)
|
sl@0
|
210 |
{
|
sl@0
|
211 |
DoCmdNewL();
|
sl@0
|
212 |
}
|
sl@0
|
213 |
else if (aCommand == KCmdClose)
|
sl@0
|
214 |
{
|
sl@0
|
215 |
DoCmdClose();
|
sl@0
|
216 |
}
|
sl@0
|
217 |
else if (aCommand == KCmdDestructor)
|
sl@0
|
218 |
{
|
sl@0
|
219 |
DoCmdDestructor();
|
sl@0
|
220 |
}
|
sl@0
|
221 |
else if (aCommand == KCmdOpen)
|
sl@0
|
222 |
{
|
sl@0
|
223 |
DoCmdOpen(aSection);
|
sl@0
|
224 |
}
|
sl@0
|
225 |
else if (aCommand == KCmdIsMdaSound)
|
sl@0
|
226 |
{
|
sl@0
|
227 |
DoCmdIsMdaSound();
|
sl@0
|
228 |
}
|
sl@0
|
229 |
else if (aCommand == KCmdVersionRequired)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
DoCmdVersionRequired(aSection);
|
sl@0
|
232 |
}
|
sl@0
|
233 |
else if (aCommand == KCmdPlayFormatsSupported)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
DoCmdPlayFormatsSupportedL(aSection);
|
sl@0
|
236 |
}
|
sl@0
|
237 |
else if (aCommand == KCmdGetPlayFormat)
|
sl@0
|
238 |
{
|
sl@0
|
239 |
DoCmdGetPlayFormatL(aSection);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
else if (aCommand == KCmdSetPlayFormat)
|
sl@0
|
242 |
{
|
sl@0
|
243 |
DoCmdSetPlayFormatL(aSection);
|
sl@0
|
244 |
}
|
sl@0
|
245 |
else if (aCommand == KCmdRecordFormatsSupported)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
DoCmdRecordFormatsSupportedL(aSection);
|
sl@0
|
248 |
}
|
sl@0
|
249 |
else if (aCommand == KCmdGetRecordFormat)
|
sl@0
|
250 |
{
|
sl@0
|
251 |
DoCmdGetRecordFormatL(aSection);
|
sl@0
|
252 |
}
|
sl@0
|
253 |
else if (aCommand == KCmdSetRecordFormat)
|
sl@0
|
254 |
{
|
sl@0
|
255 |
DoCmdSetRecordFormatL(aSection);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
else if (aCommand == KCmdPlayVolume)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
DoCmdPlayVolume(aSection);
|
sl@0
|
260 |
}
|
sl@0
|
261 |
else if (aCommand == KCmdSetPlayVolume)
|
sl@0
|
262 |
{
|
sl@0
|
263 |
DoCmdSetPlayVolume(aSection);
|
sl@0
|
264 |
}
|
sl@0
|
265 |
else if (aCommand == KCmdPlayData)
|
sl@0
|
266 |
{
|
sl@0
|
267 |
DoCmdPlayDataL(aSection, aAsyncErrorIndex);
|
sl@0
|
268 |
}
|
sl@0
|
269 |
else if (aCommand == KCmdCancelPlayData)
|
sl@0
|
270 |
{
|
sl@0
|
271 |
DoCmdCancelPlayData();
|
sl@0
|
272 |
}
|
sl@0
|
273 |
else if (aCommand == KCmdFlushPlayBuffer)
|
sl@0
|
274 |
{
|
sl@0
|
275 |
DoCmdFlushPlayBuffer();
|
sl@0
|
276 |
}
|
sl@0
|
277 |
else if (aCommand == KCmdFlushPlayBuffer)
|
sl@0
|
278 |
{
|
sl@0
|
279 |
DoCmdNotifyPlayErrorL(aAsyncErrorIndex);
|
sl@0
|
280 |
}
|
sl@0
|
281 |
else if (aCommand == KCmdFlushPlayBuffer)
|
sl@0
|
282 |
{
|
sl@0
|
283 |
DoCmdCancelNotifyPlayError();
|
sl@0
|
284 |
}
|
sl@0
|
285 |
else if (aCommand == KCmdNotifyPlayError)
|
sl@0
|
286 |
{
|
sl@0
|
287 |
DoCmdNotifyPlayErrorL(aAsyncErrorIndex);
|
sl@0
|
288 |
}
|
sl@0
|
289 |
else if (aCommand == KCmdCancelNotifyPlayError)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
DoCmdCancelNotifyPlayError();
|
sl@0
|
292 |
}
|
sl@0
|
293 |
else if (aCommand == KCmdBytesPlayed)
|
sl@0
|
294 |
{
|
sl@0
|
295 |
DoCmdBytesPlayed(aSection);
|
sl@0
|
296 |
}
|
sl@0
|
297 |
else if (aCommand == KCmdResetBytesPlayed)
|
sl@0
|
298 |
{
|
sl@0
|
299 |
DoCmdResetBytesPlayed();
|
sl@0
|
300 |
}
|
sl@0
|
301 |
else if (aCommand == KCmdPausePlayBuffer)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
DoCmdPausePlayBuffer();
|
sl@0
|
304 |
}
|
sl@0
|
305 |
else if (aCommand == KCmdResumePlaying)
|
sl@0
|
306 |
{
|
sl@0
|
307 |
DoCmdResumePlaying();
|
sl@0
|
308 |
}
|
sl@0
|
309 |
else if (aCommand == KCmdRecordData)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
DoCmdRecordDataL(aSection, aAsyncErrorIndex);
|
sl@0
|
312 |
}
|
sl@0
|
313 |
else if (aCommand == KCmdCancelRecordData)
|
sl@0
|
314 |
{
|
sl@0
|
315 |
DoCmdCancelRecordData();
|
sl@0
|
316 |
}
|
sl@0
|
317 |
else if (aCommand == KCmdFlushRecordBuffer)
|
sl@0
|
318 |
{
|
sl@0
|
319 |
DoCmdFlushRecordBuffer();
|
sl@0
|
320 |
}
|
sl@0
|
321 |
else if (aCommand == KCmdRecordLevel)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
DoCmdRecordLevel(aSection);
|
sl@0
|
324 |
}
|
sl@0
|
325 |
else if (aCommand == KCmdSetRecordLevel)
|
sl@0
|
326 |
{
|
sl@0
|
327 |
DoCmdSetRecordLevel(aSection);
|
sl@0
|
328 |
}
|
sl@0
|
329 |
else if (aCommand == KCmdNotifyRecordError)
|
sl@0
|
330 |
{
|
sl@0
|
331 |
DoCmdNotifyRecordErrorL(aAsyncErrorIndex);
|
sl@0
|
332 |
}
|
sl@0
|
333 |
else if (aCommand == KCmdCancelNotifyRecordError)
|
sl@0
|
334 |
{
|
sl@0
|
335 |
DoCmdCancelNotifyRecordError();
|
sl@0
|
336 |
}
|
sl@0
|
337 |
else if (aCommand == KCmdUtilityDeleteFile)
|
sl@0
|
338 |
{
|
sl@0
|
339 |
DoCmdUtilityDeleteFileL(aSection);
|
sl@0
|
340 |
}
|
sl@0
|
341 |
else
|
sl@0
|
342 |
{
|
sl@0
|
343 |
ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
|
sl@0
|
344 |
}
|
sl@0
|
345 |
|
sl@0
|
346 |
return ret;
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
/**
|
sl@0
|
350 |
* Creates new RMdaDevSound class instance
|
sl@0
|
351 |
*/
|
sl@0
|
352 |
void CT_MdaDevSoundData::DoCmdNewL()
|
sl@0
|
353 |
{
|
sl@0
|
354 |
INFO_PRINTF1(_L("Create new RMdaDevSound class instance"));
|
sl@0
|
355 |
|
sl@0
|
356 |
//Deletes previous RMdaDevsound class instance if it was already created.
|
sl@0
|
357 |
DoCleanup();
|
sl@0
|
358 |
|
sl@0
|
359 |
// do create
|
sl@0
|
360 |
TRAPD(err, iMdaDevSound = new (ELeave) RMdaDevSound());
|
sl@0
|
361 |
if ( err!=KErrNone )
|
sl@0
|
362 |
{
|
sl@0
|
363 |
ERR_PRINTF2(_L("new error %d"), err);
|
sl@0
|
364 |
SetError( err );
|
sl@0
|
365 |
}
|
sl@0
|
366 |
}
|
sl@0
|
367 |
|
sl@0
|
368 |
/**
|
sl@0
|
369 |
* Close RMdaDevSound handle
|
sl@0
|
370 |
*/
|
sl@0
|
371 |
void CT_MdaDevSoundData::DoCmdClose()
|
sl@0
|
372 |
{
|
sl@0
|
373 |
INFO_PRINTF1(_L("Closing RMdaDevSound"));
|
sl@0
|
374 |
iServerStore->SetHandle(KNullHandle);
|
sl@0
|
375 |
iMdaDevSound->Close();
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
/**
|
sl@0
|
379 |
* Destroy RMdaDevSound the object
|
sl@0
|
380 |
*/
|
sl@0
|
381 |
void CT_MdaDevSoundData::DoCmdDestructor()
|
sl@0
|
382 |
{
|
sl@0
|
383 |
INFO_PRINTF1(_L("Destroying the RMdaDevSound object"));
|
sl@0
|
384 |
//close RMdaDevSound first
|
sl@0
|
385 |
iServerStore->SetHandle(KNullHandle);
|
sl@0
|
386 |
iMdaDevSound->Close();
|
sl@0
|
387 |
DoCleanup();
|
sl@0
|
388 |
}
|
sl@0
|
389 |
|
sl@0
|
390 |
/**
|
sl@0
|
391 |
* Connects a client to the sound driver server
|
sl@0
|
392 |
*
|
sl@0
|
393 |
* @param aSection section name which contains unit
|
sl@0
|
394 |
* KUUnit - unit to open
|
sl@0
|
395 |
*
|
sl@0
|
396 |
* @return void
|
sl@0
|
397 |
*
|
sl@0
|
398 |
* @leave no
|
sl@0
|
399 |
*/
|
sl@0
|
400 |
void CT_MdaDevSoundData::DoCmdOpen(const TDesC& aSection)
|
sl@0
|
401 |
{
|
sl@0
|
402 |
//Loading device drivers
|
sl@0
|
403 |
TPtrC lddName;
|
sl@0
|
404 |
TPtrC pddName;
|
sl@0
|
405 |
if(GET_OPTIONAL_STRING_PARAMETER(KLDDName(), aSection, lddName) &&
|
sl@0
|
406 |
GET_OPTIONAL_STRING_PARAMETER(KPDDName(), aSection, pddName))
|
sl@0
|
407 |
{
|
sl@0
|
408 |
TInt err = TSoundUtil::LoadSoundDrivers(lddName, pddName);
|
sl@0
|
409 |
if( (err != KErrNone) && (err != KErrAlreadyExists ))
|
sl@0
|
410 |
{
|
sl@0
|
411 |
ERR_PRINTF4(_L("Open() -> LoadSoundDrivers(%S, %S) error %d"), &lddName, &pddName, err);
|
sl@0
|
412 |
SetError( err );
|
sl@0
|
413 |
}
|
sl@0
|
414 |
}
|
sl@0
|
415 |
//Finish Loading device drivers
|
sl@0
|
416 |
|
sl@0
|
417 |
TInt unit = KNullUnit;
|
sl@0
|
418 |
TPtrC unitName;
|
sl@0
|
419 |
if (GET_OPTIONAL_STRING_PARAMETER(KUUnit(), aSection, unitName))
|
sl@0
|
420 |
{
|
sl@0
|
421 |
GetHexFromConfig(KUUnitEnum(), unitName, unit );
|
sl@0
|
422 |
}
|
sl@0
|
423 |
TInt err = iMdaDevSound->Open(unit);
|
sl@0
|
424 |
*iServerStore = *iMdaDevSound;
|
sl@0
|
425 |
INFO_PRINTF2(_L("Call Open(unit = %d)"), unit);
|
sl@0
|
426 |
|
sl@0
|
427 |
if ( err!=KErrNone )
|
sl@0
|
428 |
{
|
sl@0
|
429 |
ERR_PRINTF2(_L("Open() error %d"), err);
|
sl@0
|
430 |
SetError( err );
|
sl@0
|
431 |
}
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
|
sl@0
|
435 |
|
sl@0
|
436 |
|
sl@0
|
437 |
/**
|
sl@0
|
438 |
* Checks if driver is MdaSound
|
sl@0
|
439 |
*/
|
sl@0
|
440 |
void CT_MdaDevSoundData::DoCmdIsMdaSound()
|
sl@0
|
441 |
{
|
sl@0
|
442 |
INFO_PRINTF1(_L("CT_MdaDevSoundData::DoCmdIsMdaSound Called"));
|
sl@0
|
443 |
|
sl@0
|
444 |
TInt err = iMdaDevSound->IsMdaSound();
|
sl@0
|
445 |
if(err!=KErrNone)
|
sl@0
|
446 |
{
|
sl@0
|
447 |
ERR_PRINTF2(_L("IsMdaSound() error %d"), err);
|
sl@0
|
448 |
SetError(err);
|
sl@0
|
449 |
}
|
sl@0
|
450 |
|
sl@0
|
451 |
}
|
sl@0
|
452 |
|
sl@0
|
453 |
/**
|
sl@0
|
454 |
* Checks driver version required
|
sl@0
|
455 |
*
|
sl@0
|
456 |
* @param aSection section name with expected version
|
sl@0
|
457 |
* KUVersion - version expected
|
sl@0
|
458 |
*
|
sl@0
|
459 |
* @return void
|
sl@0
|
460 |
*
|
sl@0
|
461 |
* @leave no
|
sl@0
|
462 |
*/
|
sl@0
|
463 |
void CT_MdaDevSoundData::DoCmdVersionRequired(const TDesC& aSection)
|
sl@0
|
464 |
{
|
sl@0
|
465 |
INFO_PRINTF1(_L("CT_MdaDevSoundData::VersionRequired Called"));
|
sl@0
|
466 |
|
sl@0
|
467 |
TVersion version = iMdaDevSound->VersionRequired();
|
sl@0
|
468 |
TPtrC versionNameFromSystem = version.Name();
|
sl@0
|
469 |
TPtrC versionName;
|
sl@0
|
470 |
if(GET_MANDATORY_STRING_PARAMETER(KUVersion(), aSection, versionName))
|
sl@0
|
471 |
{
|
sl@0
|
472 |
if(versionNameFromSystem != versionName)
|
sl@0
|
473 |
{
|
sl@0
|
474 |
ERR_PRINTF1(_L("iMdaDevSound->VersionRequired() != expected"));
|
sl@0
|
475 |
ERR_PRINTF3(_L("version.Name()=%S, expected=%S"), &versionNameFromSystem, &versionName);
|
sl@0
|
476 |
SetBlockResult(EFail);
|
sl@0
|
477 |
}
|
sl@0
|
478 |
else
|
sl@0
|
479 |
{
|
sl@0
|
480 |
INFO_PRINTF1(_L("iMdaDevSound->VersionRequired() == expected"));
|
sl@0
|
481 |
}
|
sl@0
|
482 |
}
|
sl@0
|
483 |
|
sl@0
|
484 |
}
|
sl@0
|
485 |
|
sl@0
|
486 |
/**
|
sl@0
|
487 |
* Gets PlayFormatsSupported
|
sl@0
|
488 |
*
|
sl@0
|
489 |
* @param aSection Section name which contains SoundFormatsSupported
|
sl@0
|
490 |
* object name
|
sl@0
|
491 |
* KSoundFormatsSupportedObject - SoundFormatsSupported
|
sl@0
|
492 |
* object name
|
sl@0
|
493 |
*
|
sl@0
|
494 |
* @return void
|
sl@0
|
495 |
*
|
sl@0
|
496 |
* @leave System wide error
|
sl@0
|
497 |
*/
|
sl@0
|
498 |
void CT_MdaDevSoundData::DoCmdPlayFormatsSupportedL(const TDesC& aSection)
|
sl@0
|
499 |
{
|
sl@0
|
500 |
INFO_PRINTF1(_L("Getting PlayFormatsSupported!"));
|
sl@0
|
501 |
|
sl@0
|
502 |
TPtrC objectName;
|
sl@0
|
503 |
if (GET_MANDATORY_STRING_PARAMETER(KSoundFormatsSupportedObject, aSection, objectName))
|
sl@0
|
504 |
{
|
sl@0
|
505 |
RMdaDevSound::TSoundFormatsSupported* soundFormat = static_cast<RMdaDevSound::TSoundFormatsSupported*>(GetDataObjectL(objectName));
|
sl@0
|
506 |
RMdaDevSound::TSoundFormatsSupportedBuf soundFormatsSupportedBuf(*soundFormat);
|
sl@0
|
507 |
iMdaDevSound->PlayFormatsSupported(soundFormatsSupportedBuf);
|
sl@0
|
508 |
*soundFormat = soundFormatsSupportedBuf();
|
sl@0
|
509 |
}
|
sl@0
|
510 |
}
|
sl@0
|
511 |
|
sl@0
|
512 |
/**
|
sl@0
|
513 |
* Gets current PlayFormat
|
sl@0
|
514 |
*
|
sl@0
|
515 |
* @param aSection Section name which contains CurrentSoundFormat
|
sl@0
|
516 |
* object name
|
sl@0
|
517 |
* KCurrentSoundFormatObject - CurrentSoundFormat
|
sl@0
|
518 |
* object name
|
sl@0
|
519 |
*
|
sl@0
|
520 |
* @return void
|
sl@0
|
521 |
*
|
sl@0
|
522 |
* @leave System wide error
|
sl@0
|
523 |
*/
|
sl@0
|
524 |
void CT_MdaDevSoundData::DoCmdGetPlayFormatL(const TDesC& aSection)
|
sl@0
|
525 |
{
|
sl@0
|
526 |
INFO_PRINTF1(_L("Getting PlayFormat!"));
|
sl@0
|
527 |
|
sl@0
|
528 |
TPtrC objectName;
|
sl@0
|
529 |
if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
|
sl@0
|
530 |
{
|
sl@0
|
531 |
RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
|
sl@0
|
532 |
RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
|
sl@0
|
533 |
iMdaDevSound->GetPlayFormat(currentSoundFormatBuf);
|
sl@0
|
534 |
*soundFormat = currentSoundFormatBuf();
|
sl@0
|
535 |
}
|
sl@0
|
536 |
}
|
sl@0
|
537 |
|
sl@0
|
538 |
/**
|
sl@0
|
539 |
* Sets current PlayFormat
|
sl@0
|
540 |
*
|
sl@0
|
541 |
* @param aSection Section name which contains CurrentSoundFormat
|
sl@0
|
542 |
* object name
|
sl@0
|
543 |
* KCurrentSoundFormatObject - CurrentSoundFormat
|
sl@0
|
544 |
* object name
|
sl@0
|
545 |
*
|
sl@0
|
546 |
* @return void
|
sl@0
|
547 |
*
|
sl@0
|
548 |
* @leave System wide error
|
sl@0
|
549 |
*/
|
sl@0
|
550 |
void CT_MdaDevSoundData::DoCmdSetPlayFormatL(const TDesC& aSection)
|
sl@0
|
551 |
{
|
sl@0
|
552 |
INFO_PRINTF1(_L("Setting PlayFormat!"));
|
sl@0
|
553 |
|
sl@0
|
554 |
TPtrC objectName;
|
sl@0
|
555 |
if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
|
sl@0
|
556 |
{
|
sl@0
|
557 |
RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
|
sl@0
|
558 |
RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
|
sl@0
|
559 |
TInt err = iMdaDevSound->SetPlayFormat(currentSoundFormatBuf);
|
sl@0
|
560 |
if(err != KErrNone)
|
sl@0
|
561 |
{
|
sl@0
|
562 |
ERR_PRINTF2(_L("error in SetPlayFormatL %d"), err);
|
sl@0
|
563 |
SetError( err );
|
sl@0
|
564 |
}
|
sl@0
|
565 |
else
|
sl@0
|
566 |
{
|
sl@0
|
567 |
*soundFormat = currentSoundFormatBuf();
|
sl@0
|
568 |
}
|
sl@0
|
569 |
}
|
sl@0
|
570 |
}
|
sl@0
|
571 |
|
sl@0
|
572 |
/**
|
sl@0
|
573 |
* Gets RecordFormatsSupported
|
sl@0
|
574 |
*
|
sl@0
|
575 |
* @param aSection Section name which contains SoundFormatsSupported
|
sl@0
|
576 |
* object name
|
sl@0
|
577 |
* KSoundFormatsSupportedObject - SoundFormatsSupported
|
sl@0
|
578 |
* object name
|
sl@0
|
579 |
*
|
sl@0
|
580 |
* @return void
|
sl@0
|
581 |
*
|
sl@0
|
582 |
* @leave System wide error
|
sl@0
|
583 |
*/
|
sl@0
|
584 |
void CT_MdaDevSoundData::DoCmdRecordFormatsSupportedL(const TDesC& aSection)
|
sl@0
|
585 |
{
|
sl@0
|
586 |
INFO_PRINTF1(_L("Getting RecordFormatsSupported!"));
|
sl@0
|
587 |
|
sl@0
|
588 |
TPtrC objectName;
|
sl@0
|
589 |
if (GET_MANDATORY_STRING_PARAMETER(KSoundFormatsSupportedObject, aSection, objectName))
|
sl@0
|
590 |
{
|
sl@0
|
591 |
RMdaDevSound::TSoundFormatsSupported* soundFormat = static_cast<RMdaDevSound::TSoundFormatsSupported*>(GetDataObjectL(objectName));
|
sl@0
|
592 |
RMdaDevSound::TSoundFormatsSupportedBuf soundFormatsSupportedBuf(*soundFormat);
|
sl@0
|
593 |
iMdaDevSound->RecordFormatsSupported(soundFormatsSupportedBuf);
|
sl@0
|
594 |
*soundFormat = soundFormatsSupportedBuf();
|
sl@0
|
595 |
}
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
/**
|
sl@0
|
599 |
* Gets current RecordFormat
|
sl@0
|
600 |
*
|
sl@0
|
601 |
* @param aSection Section name which contains CurrentSoundFormat
|
sl@0
|
602 |
* object name
|
sl@0
|
603 |
* KCurrentSoundFormatObject - CurrentSoundFormat
|
sl@0
|
604 |
* object name
|
sl@0
|
605 |
*
|
sl@0
|
606 |
* @return void
|
sl@0
|
607 |
*
|
sl@0
|
608 |
* @leave System wide error
|
sl@0
|
609 |
*/
|
sl@0
|
610 |
void CT_MdaDevSoundData::DoCmdGetRecordFormatL(const TDesC& aSection)
|
sl@0
|
611 |
{
|
sl@0
|
612 |
INFO_PRINTF1(_L("Getting RecordFormat!"));
|
sl@0
|
613 |
|
sl@0
|
614 |
TPtrC objectName;
|
sl@0
|
615 |
if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
|
sl@0
|
616 |
{
|
sl@0
|
617 |
RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
|
sl@0
|
618 |
RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
|
sl@0
|
619 |
iMdaDevSound->GetRecordFormat(currentSoundFormatBuf);
|
sl@0
|
620 |
*soundFormat = currentSoundFormatBuf();
|
sl@0
|
621 |
}
|
sl@0
|
622 |
}
|
sl@0
|
623 |
|
sl@0
|
624 |
/**
|
sl@0
|
625 |
* Sets current RecordFormat
|
sl@0
|
626 |
*
|
sl@0
|
627 |
* @param aSection Section name which contains CurrentSoundFormat
|
sl@0
|
628 |
* object name
|
sl@0
|
629 |
* KCurrentSoundFormatObject - CurrentSoundFormat
|
sl@0
|
630 |
* object name
|
sl@0
|
631 |
*
|
sl@0
|
632 |
* @return void
|
sl@0
|
633 |
*
|
sl@0
|
634 |
* @leave System wide error
|
sl@0
|
635 |
*/
|
sl@0
|
636 |
void CT_MdaDevSoundData::DoCmdSetRecordFormatL(const TDesC& aSection)
|
sl@0
|
637 |
{
|
sl@0
|
638 |
INFO_PRINTF1(_L("Setting RecordFormat!"));
|
sl@0
|
639 |
|
sl@0
|
640 |
TPtrC objectName;
|
sl@0
|
641 |
if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
|
sl@0
|
642 |
{
|
sl@0
|
643 |
RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
|
sl@0
|
644 |
RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
|
sl@0
|
645 |
TInt err = iMdaDevSound->SetRecordFormat(currentSoundFormatBuf);
|
sl@0
|
646 |
if(err != KErrNone)
|
sl@0
|
647 |
{
|
sl@0
|
648 |
ERR_PRINTF2(_L("error in SetRecordFormatL %d"), err);
|
sl@0
|
649 |
SetError( err );
|
sl@0
|
650 |
}
|
sl@0
|
651 |
else
|
sl@0
|
652 |
{
|
sl@0
|
653 |
*soundFormat = currentSoundFormatBuf();
|
sl@0
|
654 |
}
|
sl@0
|
655 |
}
|
sl@0
|
656 |
}
|
sl@0
|
657 |
|
sl@0
|
658 |
/**
|
sl@0
|
659 |
* Gets current PlayVolume
|
sl@0
|
660 |
*
|
sl@0
|
661 |
* @param aSection Section name which contains expected value
|
sl@0
|
662 |
* KUVolumeExpected - expected volume level
|
sl@0
|
663 |
*
|
sl@0
|
664 |
* @return void
|
sl@0
|
665 |
*
|
sl@0
|
666 |
* @leave no
|
sl@0
|
667 |
*/
|
sl@0
|
668 |
void CT_MdaDevSoundData::DoCmdPlayVolume(const TDesC& aSection)
|
sl@0
|
669 |
{
|
sl@0
|
670 |
TInt volume = 0;
|
sl@0
|
671 |
INFO_PRINTF2(_L("calling PlayVolume(), value before execution = %d"), volume);
|
sl@0
|
672 |
volume = iMdaDevSound->PlayVolume();
|
sl@0
|
673 |
|
sl@0
|
674 |
TInt expected;
|
sl@0
|
675 |
if (GET_OPTIONAL_INT_PARAMETER(KUVolumeExpected(), aSection, expected))
|
sl@0
|
676 |
{
|
sl@0
|
677 |
if(volume != expected)
|
sl@0
|
678 |
{
|
sl@0
|
679 |
ERR_PRINTF3(_L("Expected result != volume, expected = %d, volume = %d"),
|
sl@0
|
680 |
expected, volume);
|
sl@0
|
681 |
SetBlockResult(EFail);
|
sl@0
|
682 |
}
|
sl@0
|
683 |
else
|
sl@0
|
684 |
{
|
sl@0
|
685 |
INFO_PRINTF2(_L("volume = %d"), volume);
|
sl@0
|
686 |
}
|
sl@0
|
687 |
}
|
sl@0
|
688 |
else
|
sl@0
|
689 |
{
|
sl@0
|
690 |
INFO_PRINTF2(_L("volume = %d"), volume);
|
sl@0
|
691 |
}
|
sl@0
|
692 |
}
|
sl@0
|
693 |
|
sl@0
|
694 |
/**
|
sl@0
|
695 |
* Sets current PlayVolume
|
sl@0
|
696 |
*
|
sl@0
|
697 |
* @param aSection Section name which contains value to set
|
sl@0
|
698 |
* KUVolume - volume to set
|
sl@0
|
699 |
*
|
sl@0
|
700 |
* @return void
|
sl@0
|
701 |
*
|
sl@0
|
702 |
* @leave no
|
sl@0
|
703 |
*/
|
sl@0
|
704 |
void CT_MdaDevSoundData::DoCmdSetPlayVolume(const TDesC& aSection)
|
sl@0
|
705 |
{
|
sl@0
|
706 |
TInt volume = 0;
|
sl@0
|
707 |
INFO_PRINTF2(_L("calling SetPlayVolume(), value before execution = %d"), volume);
|
sl@0
|
708 |
if (GET_OPTIONAL_INT_PARAMETER(KUVolume(), aSection, volume))
|
sl@0
|
709 |
{
|
sl@0
|
710 |
iMdaDevSound->SetPlayVolume(volume);
|
sl@0
|
711 |
INFO_PRINTF2(_L("after execution value = %d"), volume);
|
sl@0
|
712 |
}
|
sl@0
|
713 |
else
|
sl@0
|
714 |
{
|
sl@0
|
715 |
INFO_PRINTF2(_L("volume after execution = %d"), volume);
|
sl@0
|
716 |
}
|
sl@0
|
717 |
}
|
sl@0
|
718 |
|
sl@0
|
719 |
/**
|
sl@0
|
720 |
* Play audio from file. DoCmdPlayDataL is asynchronous function
|
sl@0
|
721 |
*
|
sl@0
|
722 |
* @param aSection Section name which can contain values to set
|
sl@0
|
723 |
* KUDataSize - data size,
|
sl@0
|
724 |
* KUFromFile - file name to play,
|
sl@0
|
725 |
* KUBlockSize - block size
|
sl@0
|
726 |
*
|
sl@0
|
727 |
*
|
sl@0
|
728 |
* @return void
|
sl@0
|
729 |
*
|
sl@0
|
730 |
* @leave System wide error
|
sl@0
|
731 |
*/
|
sl@0
|
732 |
void CT_MdaDevSoundData::DoCmdPlayDataL(const TDesC& aSection,
|
sl@0
|
733 |
const TInt aAsyncErrorIndex)
|
sl@0
|
734 |
{
|
sl@0
|
735 |
INFO_PRINTF1(_L("calling PlayData()"));
|
sl@0
|
736 |
|
sl@0
|
737 |
CT_SoundActiveCallback* active = CT_SoundActiveCallback::NewL(*this);
|
sl@0
|
738 |
iPlay.Append(active);
|
sl@0
|
739 |
|
sl@0
|
740 |
active->iSoundData = new(ELeave) TSoundUtil::RAudioBuffer();
|
sl@0
|
741 |
TSoundUtil::RAudioBuffer* soundData = active->iSoundData;
|
sl@0
|
742 |
|
sl@0
|
743 |
TInt dataSize = TSoundUtil::KAudioBufferMaxSize;
|
sl@0
|
744 |
GET_OPTIONAL_INT_PARAMETER(KUDataSize, aSection, dataSize);
|
sl@0
|
745 |
soundData->Close();
|
sl@0
|
746 |
soundData->CreateL(dataSize);
|
sl@0
|
747 |
|
sl@0
|
748 |
TPtrC fileName;
|
sl@0
|
749 |
TInt err = KErrNone;
|
sl@0
|
750 |
if (GET_OPTIONAL_STRING_PARAMETER(KUFromFile, aSection, fileName))
|
sl@0
|
751 |
{
|
sl@0
|
752 |
err = soundData->LoadAudioDataL(fileName);
|
sl@0
|
753 |
if (err)
|
sl@0
|
754 |
{
|
sl@0
|
755 |
SetBlockResult(EFail);
|
sl@0
|
756 |
ERR_PRINTF2(_L("Audio file loading failed with error code %d"), err);
|
sl@0
|
757 |
}
|
sl@0
|
758 |
}
|
sl@0
|
759 |
|
sl@0
|
760 |
if (!err)
|
sl@0
|
761 |
{
|
sl@0
|
762 |
active->SetSection(aSection);
|
sl@0
|
763 |
IncOutstanding();
|
sl@0
|
764 |
|
sl@0
|
765 |
TInt blockSize = TSoundUtil::KDefaultBlockSize;
|
sl@0
|
766 |
GET_OPTIONAL_INT_PARAMETER(KUBlockSize, aSection, blockSize);
|
sl@0
|
767 |
blockSize = Min(blockSize, soundData->Length());
|
sl@0
|
768 |
active->iBufferBlock.Set(&soundData->operator[](0), blockSize, blockSize);
|
sl@0
|
769 |
iMdaDevSound->PlayData(active->iStatus, active->iBufferBlock);
|
sl@0
|
770 |
active->Activate(aAsyncErrorIndex);
|
sl@0
|
771 |
TBool stopPlay = EFalse;
|
sl@0
|
772 |
if (GET_OPTIONAL_BOOL_PARAMETER(KUCancel, aSection, stopPlay))
|
sl@0
|
773 |
{
|
sl@0
|
774 |
if ( stopPlay )
|
sl@0
|
775 |
{
|
sl@0
|
776 |
iMdaDevSound->CancelPlayData();
|
sl@0
|
777 |
INFO_PRINTF1(_L("CancelPlayData() executed"));
|
sl@0
|
778 |
}
|
sl@0
|
779 |
}
|
sl@0
|
780 |
if (GET_OPTIONAL_BOOL_PARAMETER(KUFlush, aSection, stopPlay))
|
sl@0
|
781 |
{
|
sl@0
|
782 |
if ( stopPlay )
|
sl@0
|
783 |
{
|
sl@0
|
784 |
iMdaDevSound->FlushPlayBuffer();
|
sl@0
|
785 |
INFO_PRINTF1(_L("FlushPlayBuffer() executed"));
|
sl@0
|
786 |
}
|
sl@0
|
787 |
}
|
sl@0
|
788 |
}
|
sl@0
|
789 |
}
|
sl@0
|
790 |
|
sl@0
|
791 |
/**
|
sl@0
|
792 |
* Cancel playing
|
sl@0
|
793 |
*/
|
sl@0
|
794 |
void CT_MdaDevSoundData::DoCmdCancelPlayData()
|
sl@0
|
795 |
{
|
sl@0
|
796 |
INFO_PRINTF1(_L("calling CancelPlayData()"));
|
sl@0
|
797 |
|
sl@0
|
798 |
if (iPlay.Count() > 0)
|
sl@0
|
799 |
{
|
sl@0
|
800 |
INFO_PRINTF2(_L("CancelPlayData called on active object with iStatus == %d"),
|
sl@0
|
801 |
iPlay[iPlay.Count() - 1]->iStatus.Int());
|
sl@0
|
802 |
}
|
sl@0
|
803 |
else
|
sl@0
|
804 |
{
|
sl@0
|
805 |
INFO_PRINTF1(_L("No active objects found"));
|
sl@0
|
806 |
}
|
sl@0
|
807 |
|
sl@0
|
808 |
iMdaDevSound->CancelPlayData();
|
sl@0
|
809 |
}
|
sl@0
|
810 |
|
sl@0
|
811 |
/**
|
sl@0
|
812 |
* Flush play buffer
|
sl@0
|
813 |
*/
|
sl@0
|
814 |
void CT_MdaDevSoundData::DoCmdFlushPlayBuffer()
|
sl@0
|
815 |
{
|
sl@0
|
816 |
INFO_PRINTF1(_L("calling FlushPlayBuffer()"));
|
sl@0
|
817 |
|
sl@0
|
818 |
if (iPlay.Count() > 0)
|
sl@0
|
819 |
{
|
sl@0
|
820 |
INFO_PRINTF2(_L("FLushPlayBuffer called on active object with iStatus == %d"),
|
sl@0
|
821 |
iPlay[iPlay.Count() - 1]->iStatus.Int());
|
sl@0
|
822 |
}
|
sl@0
|
823 |
else
|
sl@0
|
824 |
{
|
sl@0
|
825 |
INFO_PRINTF1(_L("No active objects found"));
|
sl@0
|
826 |
}
|
sl@0
|
827 |
|
sl@0
|
828 |
iMdaDevSound->FlushPlayBuffer();
|
sl@0
|
829 |
}
|
sl@0
|
830 |
|
sl@0
|
831 |
/**
|
sl@0
|
832 |
* Asynchronous function that starts notifying play error
|
sl@0
|
833 |
*/
|
sl@0
|
834 |
void CT_MdaDevSoundData::DoCmdNotifyPlayErrorL(const TInt aAsyncErrorIndex)
|
sl@0
|
835 |
{
|
sl@0
|
836 |
INFO_PRINTF1(_L("calling NotifyPlayError()"));
|
sl@0
|
837 |
|
sl@0
|
838 |
CActiveCallback* active = CActiveCallback::NewL(*this);
|
sl@0
|
839 |
iNotifyPlayError.Append(active);
|
sl@0
|
840 |
iMdaDevSound->NotifyPlayError(active->iStatus);
|
sl@0
|
841 |
|
sl@0
|
842 |
//acitvate callback object
|
sl@0
|
843 |
active->Activate(aAsyncErrorIndex);
|
sl@0
|
844 |
IncOutstanding();
|
sl@0
|
845 |
}
|
sl@0
|
846 |
|
sl@0
|
847 |
/**
|
sl@0
|
848 |
* Cancel notifying play error
|
sl@0
|
849 |
*/
|
sl@0
|
850 |
void CT_MdaDevSoundData::DoCmdCancelNotifyPlayError()
|
sl@0
|
851 |
{
|
sl@0
|
852 |
INFO_PRINTF1(_L("calling CancelNotifyPlayError()"));
|
sl@0
|
853 |
|
sl@0
|
854 |
iMdaDevSound->CancelNotifyPlayError();
|
sl@0
|
855 |
}
|
sl@0
|
856 |
|
sl@0
|
857 |
/**
|
sl@0
|
858 |
* Gets bytes played
|
sl@0
|
859 |
*
|
sl@0
|
860 |
* @param aSection Section name which can contain expected value
|
sl@0
|
861 |
* KUBytesPlayed - bytes played
|
sl@0
|
862 |
*
|
sl@0
|
863 |
* @return void
|
sl@0
|
864 |
*
|
sl@0
|
865 |
* @leave no
|
sl@0
|
866 |
*/
|
sl@0
|
867 |
void CT_MdaDevSoundData::DoCmdBytesPlayed(const TDesC& aSection)
|
sl@0
|
868 |
{
|
sl@0
|
869 |
INFO_PRINTF1(_L("calling BytesPlayed()"));
|
sl@0
|
870 |
|
sl@0
|
871 |
TInt bytesPlayed = iMdaDevSound->BytesPlayed();
|
sl@0
|
872 |
INFO_PRINTF2(_L("Bytes played: %d"), bytesPlayed);
|
sl@0
|
873 |
|
sl@0
|
874 |
TInt expected = 0;
|
sl@0
|
875 |
if (GET_OPTIONAL_INT_PARAMETER(KUBytesPlayed, aSection, expected))
|
sl@0
|
876 |
{
|
sl@0
|
877 |
if (expected != bytesPlayed)
|
sl@0
|
878 |
{
|
sl@0
|
879 |
ERR_PRINTF3(_L("Bytes played %d != %d expected"), bytesPlayed, expected);
|
sl@0
|
880 |
SetBlockResult(EFail);
|
sl@0
|
881 |
}
|
sl@0
|
882 |
}
|
sl@0
|
883 |
}
|
sl@0
|
884 |
|
sl@0
|
885 |
/**
|
sl@0
|
886 |
* Resets bytes played
|
sl@0
|
887 |
*/
|
sl@0
|
888 |
void CT_MdaDevSoundData::DoCmdResetBytesPlayed()
|
sl@0
|
889 |
{
|
sl@0
|
890 |
INFO_PRINTF1(_L("calling ResetBytesPlayed()"));
|
sl@0
|
891 |
|
sl@0
|
892 |
iMdaDevSound->ResetBytesPlayed();
|
sl@0
|
893 |
}
|
sl@0
|
894 |
|
sl@0
|
895 |
/**
|
sl@0
|
896 |
* Pause playing
|
sl@0
|
897 |
*/
|
sl@0
|
898 |
void CT_MdaDevSoundData::DoCmdPausePlayBuffer()
|
sl@0
|
899 |
{
|
sl@0
|
900 |
INFO_PRINTF1(_L("calling PausePlayBuffer()"));
|
sl@0
|
901 |
|
sl@0
|
902 |
iMdaDevSound->PausePlayBuffer();
|
sl@0
|
903 |
}
|
sl@0
|
904 |
|
sl@0
|
905 |
/**
|
sl@0
|
906 |
* Resume playing
|
sl@0
|
907 |
*/
|
sl@0
|
908 |
void CT_MdaDevSoundData::DoCmdResumePlaying()
|
sl@0
|
909 |
{
|
sl@0
|
910 |
INFO_PRINTF1(_L("calling ResumePlaying()"));
|
sl@0
|
911 |
|
sl@0
|
912 |
iMdaDevSound->ResumePlaying();
|
sl@0
|
913 |
}
|
sl@0
|
914 |
|
sl@0
|
915 |
/**
|
sl@0
|
916 |
* DoCmdRecordDataL is asynchronous function to record audio.
|
sl@0
|
917 |
*
|
sl@0
|
918 |
* @param aSection Section name which can contain value to set
|
sl@0
|
919 |
* KUDataSize - data size to record,
|
sl@0
|
920 |
* KUToFile - file to record audio,
|
sl@0
|
921 |
* KUBlockSize - block size
|
sl@0
|
922 |
*
|
sl@0
|
923 |
* @return void
|
sl@0
|
924 |
*
|
sl@0
|
925 |
* @leave System wide error
|
sl@0
|
926 |
*/
|
sl@0
|
927 |
void CT_MdaDevSoundData::DoCmdRecordDataL(const TDesC& aSection, const TInt aAsyncErrorIndex)
|
sl@0
|
928 |
{
|
sl@0
|
929 |
INFO_PRINTF1(_L("calling RecordData()"));
|
sl@0
|
930 |
|
sl@0
|
931 |
CT_SoundActiveCallback* active = CT_SoundActiveCallback::NewL(*this);
|
sl@0
|
932 |
iRecord.Append(active);
|
sl@0
|
933 |
|
sl@0
|
934 |
active->iSoundData = new(ELeave) TSoundUtil::RAudioBuffer();
|
sl@0
|
935 |
TSoundUtil::RAudioBuffer* soundData = active->iSoundData;
|
sl@0
|
936 |
|
sl@0
|
937 |
TInt dataSize = TSoundUtil::KAudioBufferMaxSize;
|
sl@0
|
938 |
GET_OPTIONAL_INT_PARAMETER(KUDataSize, aSection, dataSize);
|
sl@0
|
939 |
soundData->Close();
|
sl@0
|
940 |
soundData->CreateL(dataSize);
|
sl@0
|
941 |
soundData->SetLength(dataSize);
|
sl@0
|
942 |
|
sl@0
|
943 |
TInt blockSize = TSoundUtil::KDefaultBlockSize;
|
sl@0
|
944 |
GET_OPTIONAL_INT_PARAMETER(KUBlockSize, aSection, blockSize);
|
sl@0
|
945 |
active->iBufferBlock.Set(&soundData->operator[](0), 0, Min(blockSize, soundData->Length()));
|
sl@0
|
946 |
iMdaDevSound->RecordData(active->iStatus, active->iBufferBlock);
|
sl@0
|
947 |
|
sl@0
|
948 |
active->SetSection(aSection);
|
sl@0
|
949 |
IncOutstanding();
|
sl@0
|
950 |
active->Activate(aAsyncErrorIndex);
|
sl@0
|
951 |
TBool stopRecord = EFalse;
|
sl@0
|
952 |
if (GET_OPTIONAL_BOOL_PARAMETER(KUCancel, aSection, stopRecord))
|
sl@0
|
953 |
{
|
sl@0
|
954 |
if ( stopRecord )
|
sl@0
|
955 |
{
|
sl@0
|
956 |
iMdaDevSound->CancelPlayData();
|
sl@0
|
957 |
INFO_PRINTF1(_L("CancelRecordData() executed"));
|
sl@0
|
958 |
}
|
sl@0
|
959 |
}
|
sl@0
|
960 |
if (GET_OPTIONAL_BOOL_PARAMETER(KUFlush, aSection, stopRecord))
|
sl@0
|
961 |
{
|
sl@0
|
962 |
if ( stopRecord )
|
sl@0
|
963 |
{
|
sl@0
|
964 |
iMdaDevSound->FlushRecordBuffer();
|
sl@0
|
965 |
INFO_PRINTF1(_L("FlushRecordBuffer() executed"));
|
sl@0
|
966 |
}
|
sl@0
|
967 |
}
|
sl@0
|
968 |
}
|
sl@0
|
969 |
|
sl@0
|
970 |
/**
|
sl@0
|
971 |
* Cancels recording in progress
|
sl@0
|
972 |
*/
|
sl@0
|
973 |
void CT_MdaDevSoundData::DoCmdCancelRecordData()
|
sl@0
|
974 |
{
|
sl@0
|
975 |
INFO_PRINTF1(_L("calling CancelRecordData()"));
|
sl@0
|
976 |
|
sl@0
|
977 |
if (iRecord.Count() > 0)
|
sl@0
|
978 |
{
|
sl@0
|
979 |
INFO_PRINTF2(_L("CancelRecordData called on active object with iStatus == %d"),
|
sl@0
|
980 |
iRecord[iRecord.Count() - 1]->iStatus.Int());
|
sl@0
|
981 |
}
|
sl@0
|
982 |
else
|
sl@0
|
983 |
{
|
sl@0
|
984 |
INFO_PRINTF1(_L("No active objects found"));
|
sl@0
|
985 |
}
|
sl@0
|
986 |
|
sl@0
|
987 |
iMdaDevSound->CancelRecordData();
|
sl@0
|
988 |
}
|
sl@0
|
989 |
|
sl@0
|
990 |
/**
|
sl@0
|
991 |
* Flushes record buffer
|
sl@0
|
992 |
*/
|
sl@0
|
993 |
void CT_MdaDevSoundData::DoCmdFlushRecordBuffer()
|
sl@0
|
994 |
{
|
sl@0
|
995 |
INFO_PRINTF1(_L("calling FlushRecordBuffer()"));
|
sl@0
|
996 |
|
sl@0
|
997 |
if (iRecord.Count() > 0)
|
sl@0
|
998 |
{
|
sl@0
|
999 |
INFO_PRINTF2(_L("FlushRecordBuffer called on active object with iStatus == %d"),
|
sl@0
|
1000 |
iRecord[iRecord.Count() - 1]->iStatus.Int());
|
sl@0
|
1001 |
}
|
sl@0
|
1002 |
else
|
sl@0
|
1003 |
{
|
sl@0
|
1004 |
INFO_PRINTF1(_L("No active objects found"));
|
sl@0
|
1005 |
}
|
sl@0
|
1006 |
|
sl@0
|
1007 |
iMdaDevSound->FlushRecordBuffer();
|
sl@0
|
1008 |
}
|
sl@0
|
1009 |
|
sl@0
|
1010 |
/**
|
sl@0
|
1011 |
* Gets record volume level
|
sl@0
|
1012 |
*
|
sl@0
|
1013 |
* @param aSection Section name which can contain expected value
|
sl@0
|
1014 |
* KUSoundLevelExpected - expected sound level
|
sl@0
|
1015 |
*
|
sl@0
|
1016 |
* @return void
|
sl@0
|
1017 |
*
|
sl@0
|
1018 |
* @leave no
|
sl@0
|
1019 |
*/
|
sl@0
|
1020 |
void CT_MdaDevSoundData::DoCmdRecordLevel(const TDesC& aSection)
|
sl@0
|
1021 |
{
|
sl@0
|
1022 |
TInt level = 0;
|
sl@0
|
1023 |
INFO_PRINTF1(_L("calling RecordLevel()"));
|
sl@0
|
1024 |
level = iMdaDevSound->RecordLevel();
|
sl@0
|
1025 |
|
sl@0
|
1026 |
TInt expected;
|
sl@0
|
1027 |
if (GET_OPTIONAL_INT_PARAMETER(KUSoundLevelExpected(), aSection, expected))
|
sl@0
|
1028 |
{
|
sl@0
|
1029 |
if(level != expected)
|
sl@0
|
1030 |
{
|
sl@0
|
1031 |
ERR_PRINTF3(_L("Expected result != level, expected = %d, level = %d"),
|
sl@0
|
1032 |
expected, level);
|
sl@0
|
1033 |
SetBlockResult(EFail);
|
sl@0
|
1034 |
}
|
sl@0
|
1035 |
else
|
sl@0
|
1036 |
{
|
sl@0
|
1037 |
INFO_PRINTF2(_L("level = %d"), level);
|
sl@0
|
1038 |
}
|
sl@0
|
1039 |
}
|
sl@0
|
1040 |
else
|
sl@0
|
1041 |
{
|
sl@0
|
1042 |
INFO_PRINTF2(_L("level = %d"), level);
|
sl@0
|
1043 |
}
|
sl@0
|
1044 |
}
|
sl@0
|
1045 |
|
sl@0
|
1046 |
/**
|
sl@0
|
1047 |
* Sets record volume level
|
sl@0
|
1048 |
*
|
sl@0
|
1049 |
* @param aSection Section name which can contain value to set
|
sl@0
|
1050 |
* KUSoundLevel - sound level to set
|
sl@0
|
1051 |
*
|
sl@0
|
1052 |
* @return void
|
sl@0
|
1053 |
*
|
sl@0
|
1054 |
* @leave no
|
sl@0
|
1055 |
*/
|
sl@0
|
1056 |
void CT_MdaDevSoundData::DoCmdSetRecordLevel(const TDesC& aSection)
|
sl@0
|
1057 |
{
|
sl@0
|
1058 |
TInt level = 0;
|
sl@0
|
1059 |
INFO_PRINTF2(_L("calling SetRecordLevel(), level before execution = %d"), level);
|
sl@0
|
1060 |
|
sl@0
|
1061 |
if(GET_OPTIONAL_INT_PARAMETER(KUSoundLevel, aSection, level))
|
sl@0
|
1062 |
{
|
sl@0
|
1063 |
iMdaDevSound->SetRecordLevel(level);
|
sl@0
|
1064 |
INFO_PRINTF2(_L("after execution level = %d"), level);
|
sl@0
|
1065 |
}
|
sl@0
|
1066 |
else
|
sl@0
|
1067 |
{
|
sl@0
|
1068 |
INFO_PRINTF2(_L("level after execution = %d"), level);
|
sl@0
|
1069 |
}
|
sl@0
|
1070 |
}
|
sl@0
|
1071 |
|
sl@0
|
1072 |
/**
|
sl@0
|
1073 |
* DoCmdNotifyRecordErrorL is asynchronous function that starts notifying recording
|
sl@0
|
1074 |
* error
|
sl@0
|
1075 |
*/
|
sl@0
|
1076 |
void CT_MdaDevSoundData::DoCmdNotifyRecordErrorL(const TInt aAsyncErrorIndex)
|
sl@0
|
1077 |
{
|
sl@0
|
1078 |
INFO_PRINTF1(_L("calling NotifyRecordError()"));
|
sl@0
|
1079 |
|
sl@0
|
1080 |
CActiveCallback* active = CActiveCallback::NewL(*this);
|
sl@0
|
1081 |
iNotifyRecordError.Append(active);
|
sl@0
|
1082 |
|
sl@0
|
1083 |
iMdaDevSound->NotifyRecordError(active->iStatus);
|
sl@0
|
1084 |
|
sl@0
|
1085 |
//acitvate callback object
|
sl@0
|
1086 |
active->Activate(aAsyncErrorIndex);
|
sl@0
|
1087 |
IncOutstanding();
|
sl@0
|
1088 |
}
|
sl@0
|
1089 |
|
sl@0
|
1090 |
/**
|
sl@0
|
1091 |
* Cancels notifying recording error
|
sl@0
|
1092 |
*/
|
sl@0
|
1093 |
void CT_MdaDevSoundData::DoCmdCancelNotifyRecordError()
|
sl@0
|
1094 |
{
|
sl@0
|
1095 |
INFO_PRINTF1(_L("calling CancelNotifyRecordError()"));
|
sl@0
|
1096 |
|
sl@0
|
1097 |
iMdaDevSound->CancelNotifyRecordError();
|
sl@0
|
1098 |
}
|
sl@0
|
1099 |
|
sl@0
|
1100 |
/**
|
sl@0
|
1101 |
* Deletes file specified
|
sl@0
|
1102 |
*
|
sl@0
|
1103 |
* @param aSection Section name which contains file name to delete
|
sl@0
|
1104 |
* KUFileToDelete - File to delete
|
sl@0
|
1105 |
*
|
sl@0
|
1106 |
* @return void
|
sl@0
|
1107 |
*
|
sl@0
|
1108 |
* @leave System wide error
|
sl@0
|
1109 |
*/
|
sl@0
|
1110 |
void CT_MdaDevSoundData::DoCmdUtilityDeleteFileL(const TDesC& aSection)
|
sl@0
|
1111 |
{
|
sl@0
|
1112 |
INFO_PRINTF1(_L("DoCmdUtilityDeleteFileL called!"));
|
sl@0
|
1113 |
|
sl@0
|
1114 |
TPtrC file;
|
sl@0
|
1115 |
if (GET_MANDATORY_STRING_PARAMETER(KUFileToDelete, aSection, file))
|
sl@0
|
1116 |
{
|
sl@0
|
1117 |
TInt err;
|
sl@0
|
1118 |
err = TSoundUtil::DeleteFileL(file);
|
sl@0
|
1119 |
if(err != KErrNone)
|
sl@0
|
1120 |
{
|
sl@0
|
1121 |
ERR_PRINTF2(_L("Deleting file failed with error code %d"), err);
|
sl@0
|
1122 |
SetBlockResult(EFail);
|
sl@0
|
1123 |
}
|
sl@0
|
1124 |
else
|
sl@0
|
1125 |
{
|
sl@0
|
1126 |
INFO_PRINTF1(_L("File deleted successfully"));
|
sl@0
|
1127 |
}
|
sl@0
|
1128 |
}
|
sl@0
|
1129 |
}
|
sl@0
|
1130 |
|
sl@0
|
1131 |
/**
|
sl@0
|
1132 |
* Handle asynchronous events here
|
sl@0
|
1133 |
*/
|
sl@0
|
1134 |
void CT_MdaDevSoundData::RunL(CActive* aActive, TInt aIndex)
|
sl@0
|
1135 |
{
|
sl@0
|
1136 |
INFO_PRINTF1(_L("CT_MdaDevSoundData::RunL Called"));
|
sl@0
|
1137 |
TBool foundActiveObject = EFalse;
|
sl@0
|
1138 |
TInt index=0;
|
sl@0
|
1139 |
TInt count=0;
|
sl@0
|
1140 |
TBool completed=ETrue;
|
sl@0
|
1141 |
|
sl@0
|
1142 |
// See if it is in iNotifyPlayError
|
sl@0
|
1143 |
count=iNotifyPlayError.Count();
|
sl@0
|
1144 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1145 |
{
|
sl@0
|
1146 |
if( aActive == iNotifyPlayError[index] )
|
sl@0
|
1147 |
{
|
sl@0
|
1148 |
INFO_PRINTF1(_L("RunL iNotifyPlayError called"));
|
sl@0
|
1149 |
foundActiveObject = ETrue;
|
sl@0
|
1150 |
iNotifyPlayError.Remove(index);
|
sl@0
|
1151 |
}
|
sl@0
|
1152 |
}
|
sl@0
|
1153 |
|
sl@0
|
1154 |
// See if it is in iNotifyRecordError
|
sl@0
|
1155 |
count=iNotifyRecordError.Count();
|
sl@0
|
1156 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1157 |
{
|
sl@0
|
1158 |
if( aActive == iNotifyRecordError[index] )
|
sl@0
|
1159 |
{
|
sl@0
|
1160 |
INFO_PRINTF1(_L("RunL iNotifyRecordError called"));
|
sl@0
|
1161 |
foundActiveObject = ETrue;
|
sl@0
|
1162 |
iNotifyRecordError.Remove(index);
|
sl@0
|
1163 |
}
|
sl@0
|
1164 |
}
|
sl@0
|
1165 |
|
sl@0
|
1166 |
// See if it is in iPlay
|
sl@0
|
1167 |
count=iPlay.Count();
|
sl@0
|
1168 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1169 |
{
|
sl@0
|
1170 |
if( aActive == iPlay[index] )
|
sl@0
|
1171 |
{
|
sl@0
|
1172 |
foundActiveObject = ETrue;
|
sl@0
|
1173 |
INFO_PRINTF1(_L("RunL iPlay called"));
|
sl@0
|
1174 |
|
sl@0
|
1175 |
TSoundUtil::RAudioBuffer* soundData = iPlay[index]->iSoundData;
|
sl@0
|
1176 |
|
sl@0
|
1177 |
iPlay[index]->iDataPosition += iPlay[index]->iBufferBlock.Length();
|
sl@0
|
1178 |
INFO_PRINTF3(_L("Played %d bytes, %d bytes played total"), iPlay[index]->iBufferBlock.Length(),
|
sl@0
|
1179 |
iPlay[index]->iDataPosition);
|
sl@0
|
1180 |
|
sl@0
|
1181 |
if ( ( iPlay[index]->iDataPosition >= soundData->Length() ) || aActive->iStatus.Int() )
|
sl@0
|
1182 |
{
|
sl@0
|
1183 |
iPlay.Remove(index);
|
sl@0
|
1184 |
}
|
sl@0
|
1185 |
else
|
sl@0
|
1186 |
{
|
sl@0
|
1187 |
TInt blockSize = TSoundUtil::KDefaultBlockSize;
|
sl@0
|
1188 |
GET_OPTIONAL_INT_PARAMETER(KUBlockSize, *(iPlay[index]->iSection), blockSize);
|
sl@0
|
1189 |
blockSize = Min(blockSize, soundData->Length() - iPlay[index]->iDataPosition);
|
sl@0
|
1190 |
iPlay[index]->iBufferBlock.Set(&soundData->operator[](iPlay[index]->iDataPosition), blockSize, blockSize);
|
sl@0
|
1191 |
iMdaDevSound->PlayData(iPlay[index]->iStatus, iPlay[index]->iBufferBlock);
|
sl@0
|
1192 |
iPlay[index]->Activate(aIndex);
|
sl@0
|
1193 |
completed = EFalse;
|
sl@0
|
1194 |
}
|
sl@0
|
1195 |
}
|
sl@0
|
1196 |
}
|
sl@0
|
1197 |
|
sl@0
|
1198 |
// See if it is in iRecord
|
sl@0
|
1199 |
count=iRecord.Count();
|
sl@0
|
1200 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1201 |
{
|
sl@0
|
1202 |
if( aActive == iRecord[index] )
|
sl@0
|
1203 |
{
|
sl@0
|
1204 |
foundActiveObject = ETrue;
|
sl@0
|
1205 |
INFO_PRINTF1(_L("RunL iRecord called"));
|
sl@0
|
1206 |
iRecord[index]->iDataPosition += iRecord[index]->iBufferBlock.Length();
|
sl@0
|
1207 |
INFO_PRINTF3(_L("Stored %d bytes, %d bytes total"),
|
sl@0
|
1208 |
iRecord[index]->iBufferBlock.Length(),
|
sl@0
|
1209 |
iRecord[index]->iDataPosition);
|
sl@0
|
1210 |
|
sl@0
|
1211 |
TSoundUtil::RAudioBuffer* buffer = iRecord[index]->iSoundData;
|
sl@0
|
1212 |
|
sl@0
|
1213 |
TInt err = aActive->iStatus.Int();
|
sl@0
|
1214 |
if( err == KErrNone )
|
sl@0
|
1215 |
{
|
sl@0
|
1216 |
if(iRecord[index]->iDataPosition >= buffer->Length() ||
|
sl@0
|
1217 |
iRecord[index]->iBufferBlock.Length() == 0)
|
sl@0
|
1218 |
{
|
sl@0
|
1219 |
TPtrC fileName;
|
sl@0
|
1220 |
if(GET_OPTIONAL_STRING_PARAMETER(KUToFile, *(iRecord[index]->iSection), fileName))
|
sl@0
|
1221 |
{
|
sl@0
|
1222 |
TInt err;
|
sl@0
|
1223 |
err = buffer->SaveAudioDataL(fileName);
|
sl@0
|
1224 |
if (err)
|
sl@0
|
1225 |
{
|
sl@0
|
1226 |
SetBlockResult(EFail);
|
sl@0
|
1227 |
ERR_PRINTF2(_L("Saving to file failed with error code %d"), err);
|
sl@0
|
1228 |
}
|
sl@0
|
1229 |
}
|
sl@0
|
1230 |
iRecord.Remove(index);
|
sl@0
|
1231 |
}
|
sl@0
|
1232 |
else
|
sl@0
|
1233 |
{
|
sl@0
|
1234 |
TInt blockSize = TSoundUtil::KDefaultBlockSize;
|
sl@0
|
1235 |
//if specified in INI file get block size
|
sl@0
|
1236 |
GET_OPTIONAL_INT_PARAMETER(KUBlockSize, *(iRecord[index]->iSection), blockSize);
|
sl@0
|
1237 |
iRecord[index]->iBufferBlock.Set(&buffer->operator[](iRecord[index]->iDataPosition), 0, Min(blockSize, buffer->Length() - iRecord[index]->iDataPosition));
|
sl@0
|
1238 |
iMdaDevSound->RecordData(iRecord[index]->iStatus, iRecord[index]->iBufferBlock);
|
sl@0
|
1239 |
iRecord[index]->Activate(aIndex);
|
sl@0
|
1240 |
completed = EFalse;
|
sl@0
|
1241 |
}
|
sl@0
|
1242 |
}//err == KErrNone
|
sl@0
|
1243 |
else
|
sl@0
|
1244 |
{
|
sl@0
|
1245 |
iRecord.Remove(index);
|
sl@0
|
1246 |
}
|
sl@0
|
1247 |
}//aActive == iRecord[index]
|
sl@0
|
1248 |
}//for
|
sl@0
|
1249 |
|
sl@0
|
1250 |
if( foundActiveObject )
|
sl@0
|
1251 |
{
|
sl@0
|
1252 |
if ( completed )
|
sl@0
|
1253 |
{
|
sl@0
|
1254 |
if (aActive)
|
sl@0
|
1255 |
{
|
sl@0
|
1256 |
TInt err = aActive->iStatus.Int();
|
sl@0
|
1257 |
if( err != KErrNone )
|
sl@0
|
1258 |
{
|
sl@0
|
1259 |
ERR_PRINTF2(_L("RunL Error %d"), err);
|
sl@0
|
1260 |
SetAsyncError( aIndex, err );
|
sl@0
|
1261 |
}
|
sl@0
|
1262 |
}
|
sl@0
|
1263 |
|
sl@0
|
1264 |
// Reset the outstanding request state
|
sl@0
|
1265 |
delete aActive;
|
sl@0
|
1266 |
DecOutstanding();
|
sl@0
|
1267 |
}
|
sl@0
|
1268 |
}
|
sl@0
|
1269 |
else
|
sl@0
|
1270 |
{
|
sl@0
|
1271 |
ERR_PRINTF1(_L("An unchecked active object completed"));
|
sl@0
|
1272 |
SetBlockResult(EFail);
|
sl@0
|
1273 |
}
|
sl@0
|
1274 |
}
|
sl@0
|
1275 |
|
sl@0
|
1276 |
/**
|
sl@0
|
1277 |
* Cancels asynchronous events
|
sl@0
|
1278 |
*/
|
sl@0
|
1279 |
void CT_MdaDevSoundData::DoCancel(CActive* aActive, TInt aIndex)
|
sl@0
|
1280 |
{
|
sl@0
|
1281 |
TBool foundActiveObject = EFalse;
|
sl@0
|
1282 |
|
sl@0
|
1283 |
TInt index=0;
|
sl@0
|
1284 |
TInt count=0;
|
sl@0
|
1285 |
|
sl@0
|
1286 |
// See if it is in iNotifyPlayError
|
sl@0
|
1287 |
count=iNotifyPlayError.Count();
|
sl@0
|
1288 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1289 |
{
|
sl@0
|
1290 |
if( aActive == iNotifyPlayError[index] )
|
sl@0
|
1291 |
{
|
sl@0
|
1292 |
INFO_PRINTF1(_L("DoCancel iNotifyPlayError called"));
|
sl@0
|
1293 |
foundActiveObject = ETrue;
|
sl@0
|
1294 |
iNotifyPlayError.Remove(index);
|
sl@0
|
1295 |
}
|
sl@0
|
1296 |
}
|
sl@0
|
1297 |
|
sl@0
|
1298 |
// See if it is in iNotifyRecordError
|
sl@0
|
1299 |
count=iNotifyRecordError.Count();
|
sl@0
|
1300 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1301 |
{
|
sl@0
|
1302 |
if( aActive == iNotifyRecordError[index] )
|
sl@0
|
1303 |
{
|
sl@0
|
1304 |
INFO_PRINTF1(_L("DoCancel iNotifyRecordError called"));
|
sl@0
|
1305 |
foundActiveObject = ETrue;
|
sl@0
|
1306 |
iNotifyRecordError.Remove(index);
|
sl@0
|
1307 |
}
|
sl@0
|
1308 |
}
|
sl@0
|
1309 |
|
sl@0
|
1310 |
// See if it is in iPlay
|
sl@0
|
1311 |
count=iPlay.Count();
|
sl@0
|
1312 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1313 |
{
|
sl@0
|
1314 |
if( aActive == iPlay[index] )
|
sl@0
|
1315 |
{
|
sl@0
|
1316 |
INFO_PRINTF1(_L("DoCancel iPlay called"));
|
sl@0
|
1317 |
foundActiveObject = ETrue;
|
sl@0
|
1318 |
iPlay.Remove(index);
|
sl@0
|
1319 |
}
|
sl@0
|
1320 |
}
|
sl@0
|
1321 |
|
sl@0
|
1322 |
// See if it is in iRecord
|
sl@0
|
1323 |
count=iRecord.Count();
|
sl@0
|
1324 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
sl@0
|
1325 |
{
|
sl@0
|
1326 |
if( aActive == iRecord[index] )
|
sl@0
|
1327 |
{
|
sl@0
|
1328 |
INFO_PRINTF1(_L("DoCancel iRecord called"));
|
sl@0
|
1329 |
foundActiveObject = ETrue;
|
sl@0
|
1330 |
iRecord.Remove(index);
|
sl@0
|
1331 |
}
|
sl@0
|
1332 |
}
|
sl@0
|
1333 |
|
sl@0
|
1334 |
if( foundActiveObject )
|
sl@0
|
1335 |
{
|
sl@0
|
1336 |
if (aActive)
|
sl@0
|
1337 |
{
|
sl@0
|
1338 |
TInt err = aActive->iStatus.Int();
|
sl@0
|
1339 |
if( err != KErrNone )
|
sl@0
|
1340 |
{
|
sl@0
|
1341 |
ERR_PRINTF2(_L("DoCancel Error %d"), err);
|
sl@0
|
1342 |
SetAsyncError( aIndex, err );
|
sl@0
|
1343 |
}
|
sl@0
|
1344 |
}
|
sl@0
|
1345 |
|
sl@0
|
1346 |
// Reset the outstanding request state
|
sl@0
|
1347 |
delete aActive;
|
sl@0
|
1348 |
DecOutstanding();
|
sl@0
|
1349 |
}
|
sl@0
|
1350 |
else
|
sl@0
|
1351 |
{
|
sl@0
|
1352 |
ERR_PRINTF1(_L("An unchecked active object canceled"));
|
sl@0
|
1353 |
SetBlockResult(EFail);
|
sl@0
|
1354 |
}
|
sl@0
|
1355 |
}
|