|
1 /* |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "t_cmmfdevsounddata.h" |
|
21 |
|
22 /*@{*/ |
|
23 //Constants for HwDevice |
|
24 const TInt KHwDeviceDefaultDataLength = 9; |
|
25 const TInt KFourCCLength = 4; |
|
26 //Supported Input Data Types |
|
27 const TInt KFourCCMaxBitDisplacement = 24; |
|
28 const TInt K8Bits = 8; |
|
29 const TInt KTFourCC = 4; |
|
30 /*@}*/ |
|
31 |
|
32 /*@{*/ |
|
33 //Command literals |
|
34 _LIT(KCmdNewL, "NewL"); |
|
35 _LIT(KCmdNewLLoopL, "NewLLoopL"); |
|
36 _LIT(KCmdDestructor, "~"); |
|
37 _LIT(KCmdCapabilities, "Capabilities"); |
|
38 _LIT(KCmdConfig, "Config"); |
|
39 _LIT(KCmdMaxGain, "MaxGain"); |
|
40 _LIT(KCmdMaxVolume, "MaxVolume"); |
|
41 _LIT(KCmdGetPlayBalanceL, "GetPlayBalanceL"); |
|
42 _LIT(KCmdGetRecordBalanceL, "GetRecordBalanceL"); |
|
43 _LIT(KCmdGetSupportedInputDataTypesL, "GetSupportedInputDataTypesL"); |
|
44 _LIT(KCmdGetSupportedOutputDataTypesL, "GetSupportedOutputDataTypesL"); |
|
45 _LIT(KCmdSamplesPlayed, "SamplesPlayed"); |
|
46 _LIT(KCmdSamplesRecorded, "SamplesRecorded"); |
|
47 _LIT(KCmdVolume, "Volume"); |
|
48 _LIT(KCmdGain, "Gain"); |
|
49 _LIT(KCmdFixedSequenceCount, "FixedSequenceCount"); |
|
50 _LIT(KCmdFixedSequenceName, "FixedSequenceName"); |
|
51 _LIT(KCmdSetConfigL, "SetConfigL"); |
|
52 _LIT(KCmdSetDTMFLengths, "SetDTMFLengths"); |
|
53 _LIT(KCmdSetGain, "SetGain"); |
|
54 _LIT(KCmdSetPlayBalanceL, "SetPlayBalanceL"); |
|
55 _LIT(KCmdSetPrioritySettings, "SetPrioritySettings"); |
|
56 _LIT(KCmdSetRecordBalanceL, "SetRecordBalanceL"); |
|
57 _LIT(KCmdSetToneRepeats, "SetToneRepeats"); |
|
58 _LIT(KCmdSetVolume, "SetVolume"); |
|
59 _LIT(KCmdSetVolumeRamp, "SetVolumeRamp"); |
|
60 _LIT(KCmdInitializeL, "InitializeL"); |
|
61 _LIT(KCmdPlayDTMFStringL, "PlayDTMFStringL"); |
|
62 _LIT(KCmdPlayData, "PlayData"); |
|
63 _LIT(KCmdPlayDualToneL, "PlayDualToneL"); |
|
64 _LIT(KCmdPlayInitL, "PlayInitL"); |
|
65 _LIT(KCmdPlayToneL, "PlayToneL"); |
|
66 _LIT(KCmdPlayToneSequenceL, "PlayToneSequenceL"); |
|
67 _LIT(KCmdRecordData, "RecordData"); |
|
68 _LIT(KCmdRecordInitL, "RecordInitL"); |
|
69 _LIT(KCmdStop, "Stop"); |
|
70 _LIT(KCmdErrorConceal, "ErrorConceal"); |
|
71 _LIT(KCmdSetVolumeLoop, "SetVolumeLoop"); |
|
72 /*@}*/ |
|
73 |
|
74 /*@{*/ |
|
75 //Utility literals |
|
76 _LIT(KCmdUtilityReplaceFile, "ReplaceFile"); |
|
77 _LIT(KCmdUtilityOpenFile, "OpenFile"); |
|
78 _LIT(KCmdUtilityCloseFile, "CloseFile"); |
|
79 _LIT(KCmdUtilityFileStartPosition, "FileStartPosition"); |
|
80 /*@}*/ |
|
81 |
|
82 /*@{*/ |
|
83 //INI Section name literals |
|
84 _LIT(KGainValue, "Gain"); |
|
85 _LIT(KVolumeValue, "Volume"); |
|
86 _LIT(KLeftPercentage, "LeftPercentage"); |
|
87 _LIT(KRightPercentage, "RightPercentage"); |
|
88 _LIT(KSequenceNumber, "SequenceNumber"); |
|
89 _LIT(KRate, "Rate"); |
|
90 _LIT(KEncoding, "Encoding"); |
|
91 _LIT(KChannels, "Channels"); |
|
92 _LIT(KBufferSize, "BufferSize"); |
|
93 _LIT(KToneOnLength, "ToneOnLength"); |
|
94 _LIT(KToneOffLength, "ToneOffLength"); |
|
95 _LIT(KPause, "Pause"); |
|
96 _LIT(KPauseLength, "PauseLength"); |
|
97 _LIT(KPriority, "Priority"); |
|
98 _LIT(KPreference, "Preference"); |
|
99 _LIT(KPriorityState, "PriorityState"); |
|
100 _LIT(KRepeatCount, "RepeatCount"); |
|
101 _LIT(KRepeatTrailingSilence, "RepeatTrailingSilence"); |
|
102 _LIT(KRampDuration, "RampDuration"); |
|
103 _LIT(KMode, "Mode"); |
|
104 _LIT(KHwDevice, "HwDevice"); |
|
105 _LIT(KFourCC, "FourCC"); |
|
106 _LIT(KFilename, "Filename"); |
|
107 _LIT(KDTMFString, "DTMFString"); |
|
108 _LIT(KFrequency, "Frequency"); |
|
109 _LIT(KFrequencyOne, "FrequencyOne"); |
|
110 _LIT(KFrequencyTwo, "FrequencyTwo"); |
|
111 _LIT(KDuration, "Duration"); |
|
112 _LIT(KLoop, "Loop"); |
|
113 _LIT(KAllowedError, "AllowedError"); |
|
114 _LIT(KVolumeList, "VolumeList"); |
|
115 _LIT(KVolumeLoop, "VolumeLoop"); |
|
116 /*@}*/ |
|
117 |
|
118 /*@{*/ |
|
119 //Literals for iEnumChannels |
|
120 _LIT(KEMMFStereo, "EMMFStereo"); |
|
121 _LIT(KEMMFMono, "EMMFMono"); |
|
122 /*@}*/ |
|
123 |
|
124 const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumChannels[] = |
|
125 { |
|
126 {KEMMFMono, EMMFMono}, |
|
127 {KEMMFStereo, EMMFStereo} |
|
128 }; |
|
129 |
|
130 /*@{*/ |
|
131 //Literals for iEnumSampleRate |
|
132 _LIT(KEMMFSampleRate8000Hz, "EMMFSampleRate8000Hz"); |
|
133 _LIT(KEMMFSampleRate11025Hz, "EMMFSampleRate11025Hz"); |
|
134 _LIT(KEMMFSampleRate16000Hz, "EMMFSampleRate16000Hz"); |
|
135 _LIT(KEMMFSampleRate22050Hz, "EMMFSampleRate22050Hz"); |
|
136 _LIT(KEMMFSampleRate32000Hz, "EMMFSampleRate32000Hz"); |
|
137 _LIT(KEMMFSampleRate44100Hz, "EMMFSampleRate44100Hz"); |
|
138 _LIT(KEMMFSampleRate48000Hz, "EMMFSampleRate48000Hz"); |
|
139 _LIT(KEMMFSampleRate88200Hz, "EMMFSampleRate88200Hz"); |
|
140 _LIT(KEMMFSampleRate96000Hz, "EMMFSampleRate96000Hz"); |
|
141 _LIT(KEMMFSampleRate12000Hz, "EMMFSampleRate12000Hz"); |
|
142 _LIT(KEMMFSampleRate24000Hz, "EMMFSampleRate24000Hz"); |
|
143 _LIT(KEMMFSampleRate64000Hz, "EMMFSampleRate64000Hz"); |
|
144 /*@}*/ |
|
145 |
|
146 const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumSampleRate[] = |
|
147 { |
|
148 {KEMMFSampleRate8000Hz, EMMFSampleRate8000Hz}, |
|
149 {KEMMFSampleRate11025Hz, EMMFSampleRate11025Hz}, |
|
150 {KEMMFSampleRate16000Hz, EMMFSampleRate16000Hz}, |
|
151 {KEMMFSampleRate22050Hz, EMMFSampleRate22050Hz}, |
|
152 {KEMMFSampleRate32000Hz, EMMFSampleRate32000Hz}, |
|
153 {KEMMFSampleRate44100Hz, EMMFSampleRate44100Hz}, |
|
154 {KEMMFSampleRate48000Hz, EMMFSampleRate48000Hz}, |
|
155 {KEMMFSampleRate88200Hz, EMMFSampleRate88200Hz}, |
|
156 {KEMMFSampleRate96000Hz, EMMFSampleRate96000Hz}, |
|
157 {KEMMFSampleRate12000Hz, EMMFSampleRate12000Hz}, |
|
158 {KEMMFSampleRate24000Hz, EMMFSampleRate24000Hz}, |
|
159 {KEMMFSampleRate64000Hz, EMMFSampleRate64000Hz} |
|
160 }; |
|
161 |
|
162 /*@{*/ |
|
163 //Literal for iEnumMode |
|
164 _LIT(KEMMFStateIdle, "EMMFStateIdle"); |
|
165 _LIT(KEMMFStatePlaying, "EMMFStatePlaying"); |
|
166 _LIT(KEMMFStateTonePlaying, "EMMFStateTonePlaying"); |
|
167 _LIT(KEMMFStateRecording, "EMMFStateRecording"); |
|
168 _LIT(KEMMFStatePlayingRecording, "EMMFStatePlayingRecording"); |
|
169 _LIT(KEMMFStateConverting, "EMMFStateConverting"); |
|
170 /*@}*/ |
|
171 |
|
172 const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumMode[] = |
|
173 { |
|
174 {KEMMFStateIdle, EMMFStateIdle}, |
|
175 {KEMMFStatePlaying, EMMFStatePlaying}, |
|
176 {KEMMFStateRecording, EMMFStateRecording}, |
|
177 {KEMMFStateTonePlaying, EMMFStateTonePlaying}, |
|
178 {KEMMFStatePlayingRecording, EMMFStatePlayingRecording}, |
|
179 {KEMMFStateConverting, EMMFStateConverting} |
|
180 }; |
|
181 |
|
182 /*@{*/ |
|
183 //Literals for iEnumInitializeLType |
|
184 _LIT(KEInitializeState, "EInitializeState"); |
|
185 _LIT(KEInitializeHwDeviceMode, "EInitializeHwDeviceMode"); |
|
186 _LIT(KEInitializeFourCCMode, "EInitializeFourCCMode"); |
|
187 /*@}*/ |
|
188 |
|
189 enum TMMFInitializeMode |
|
190 { |
|
191 EInitializeState, |
|
192 EInitializeHwDeviceMode, |
|
193 EInitializeFourCCMode |
|
194 }; |
|
195 |
|
196 const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumInitializeLType[] = |
|
197 { |
|
198 {KEInitializeState, EInitializeState}, |
|
199 {KEInitializeHwDeviceMode, EInitializeHwDeviceMode}, |
|
200 {KEInitializeFourCCMode, EInitializeFourCCMode} |
|
201 }; |
|
202 |
|
203 /** |
|
204 * Two phase constructor |
|
205 * |
|
206 * @leave system wide error |
|
207 */ |
|
208 CT_CMMFDevSoundData* CT_CMMFDevSoundData::NewL() |
|
209 { |
|
210 CT_CMMFDevSoundData* ret = new (ELeave) CT_CMMFDevSoundData(); |
|
211 CleanupStack::PushL(ret); |
|
212 ret->ConstructL(); |
|
213 CleanupStack::Pop(ret); |
|
214 return ret; |
|
215 } |
|
216 |
|
217 /** |
|
218 * Private constructor. First phase construction |
|
219 */ |
|
220 CT_CMMFDevSoundData::CT_CMMFDevSoundData() |
|
221 : |
|
222 iDevSound(NULL), |
|
223 iPrioritySettings(), |
|
224 iCapabilities(), |
|
225 iVolumeValue(0), |
|
226 iGainValue(0), |
|
227 iLeftPercentage(0), |
|
228 iRightPercentage(0), |
|
229 iFs(), |
|
230 iToneFile(), |
|
231 iAudiofile(), |
|
232 iBuffer(NULL), |
|
233 iLastSample(0), |
|
234 iPaused(EFalse), |
|
235 iErrorConceal(EFalse), |
|
236 iEndFile(EFalse), |
|
237 iToneSequence(), |
|
238 iRecordErrorIndex(0), |
|
239 iPlayErrorIndex(0), |
|
240 iToneErrorIndex(0), |
|
241 iInitializeErrorIndex(0) |
|
242 { |
|
243 } |
|
244 |
|
245 /** |
|
246 * Second phase construction |
|
247 * @internalComponent |
|
248 * @return N/A |
|
249 * @pre None |
|
250 * @post None |
|
251 * @leave system wide error |
|
252 */ |
|
253 void CT_CMMFDevSoundData::ConstructL() |
|
254 { |
|
255 iFs.Connect(); |
|
256 } |
|
257 |
|
258 /** |
|
259 * Public destructor |
|
260 */ |
|
261 CT_CMMFDevSoundData::~CT_CMMFDevSoundData() |
|
262 { |
|
263 iFs.Close(); |
|
264 DestroyData(); |
|
265 } |
|
266 |
|
267 /** |
|
268 * Helper Destructor |
|
269 */ |
|
270 void CT_CMMFDevSoundData::DestroyData() |
|
271 { |
|
272 if(iDevSound) |
|
273 { |
|
274 delete iDevSound; |
|
275 iDevSound = NULL; |
|
276 } |
|
277 } |
|
278 |
|
279 /** |
|
280 * Return a pointer to the object that the data wraps |
|
281 * |
|
282 * @return pointer to the object that the data wraps |
|
283 */ |
|
284 TAny* CT_CMMFDevSoundData::GetObject() |
|
285 { |
|
286 return iDevSound; |
|
287 } |
|
288 |
|
289 /** |
|
290 * Process a command read from the Ini file |
|
291 * @param aCommand - The command to process |
|
292 * @param aSection - The section get from the *.ini file of the project T_Wlan |
|
293 * @param aAsyncErrorIndex - Command index dor async calls to returns errors to |
|
294 * @return TBool - ETrue if the command is process |
|
295 * @leave - system wide error |
|
296 */ |
|
297 TBool CT_CMMFDevSoundData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
298 { |
|
299 TBool ret = ETrue; |
|
300 |
|
301 if (aCommand == KCmdNewL) |
|
302 { |
|
303 DoCmdNewL(); |
|
304 } |
|
305 else if(aCommand == KCmdNewLLoopL) |
|
306 { |
|
307 DoCmdNewLLoopL(aSection); |
|
308 } |
|
309 else if (aCommand == KCmdDestructor) |
|
310 { |
|
311 DoCmdDestructor(); |
|
312 } |
|
313 else if (aCommand == KCmdUtilityReplaceFile) |
|
314 { |
|
315 DoCmdUtilityReplaceFile(aSection); |
|
316 } |
|
317 else if (aCommand == KCmdUtilityOpenFile) |
|
318 { |
|
319 DoCmdUtilityOpenFile(aSection); |
|
320 } |
|
321 else if (aCommand == KCmdUtilityCloseFile) |
|
322 { |
|
323 DoCmdUtilityCloseFile(); |
|
324 } |
|
325 else if (aCommand == KCmdUtilityFileStartPosition) |
|
326 { |
|
327 DoCmdUtilityFileStartPosition(); |
|
328 } |
|
329 else if (aCommand == KCmdCapabilities) |
|
330 { |
|
331 DoCmdCapabilities(); |
|
332 } |
|
333 else if (aCommand == KCmdConfig) |
|
334 { |
|
335 DoCmdConfig(); |
|
336 } |
|
337 else if (aCommand == KCmdMaxGain) |
|
338 { |
|
339 DoCmdMaxGain(aSection); |
|
340 } |
|
341 else if (aCommand == KCmdMaxVolume) |
|
342 { |
|
343 DoCmdMaxVolume(aSection); |
|
344 } |
|
345 else if (aCommand == KCmdGetPlayBalanceL) |
|
346 { |
|
347 DoCmdGetPlayBalanceL(aSection); |
|
348 } |
|
349 else if (aCommand == KCmdGetRecordBalanceL) |
|
350 { |
|
351 DoCmdGetRecordBalanceL(aSection); |
|
352 } |
|
353 else if (aCommand == KCmdGetSupportedInputDataTypesL) |
|
354 { |
|
355 DoCmdGetSupportedInputDataTypesL(); |
|
356 } |
|
357 else if (aCommand == KCmdGetSupportedOutputDataTypesL) |
|
358 { |
|
359 DoCmdGetSupportedOutputDataTypesL(); |
|
360 } |
|
361 else if (aCommand == KCmdSamplesPlayed) |
|
362 { |
|
363 DoCmdSamplesPlayed(); |
|
364 } |
|
365 else if (aCommand == KCmdSamplesRecorded) |
|
366 { |
|
367 DoCmdSamplesRecorded(); |
|
368 } |
|
369 else if (aCommand == KCmdVolume) |
|
370 { |
|
371 DoCmdVolume(aSection); |
|
372 } |
|
373 else if (aCommand == KCmdGain) |
|
374 { |
|
375 DoCmdGain(aSection); |
|
376 } |
|
377 else if (aCommand == KCmdFixedSequenceCount) |
|
378 { |
|
379 DoCmdFixedSequenceCount(); |
|
380 } |
|
381 else if (aCommand == KCmdFixedSequenceName) |
|
382 { |
|
383 DoCmdFixedSequenceName(aSection); |
|
384 } |
|
385 else if (aCommand == KCmdSetConfigL) |
|
386 { |
|
387 DoCmdSetConfigL(aSection); |
|
388 } |
|
389 else if (aCommand == KCmdSetDTMFLengths) |
|
390 { |
|
391 DoCmdSetDTMFLengths(aSection); |
|
392 } |
|
393 else if (aCommand == KCmdSetGain) |
|
394 { |
|
395 DoCmdSetGain(aSection); |
|
396 } |
|
397 else if (aCommand == KCmdSetPlayBalanceL) |
|
398 { |
|
399 DoCmdSetPlayBalanceL(aSection); |
|
400 } |
|
401 else if (aCommand == KCmdSetPrioritySettings) |
|
402 { |
|
403 DoCmdSetPrioritySettings(aSection); |
|
404 } |
|
405 else if (aCommand == KCmdSetRecordBalanceL) |
|
406 { |
|
407 DoCmdSetRecordBalanceL(aSection); |
|
408 } |
|
409 else if (aCommand == KCmdSetToneRepeats) |
|
410 { |
|
411 DoCmdSetToneRepeats(aSection); |
|
412 } |
|
413 else if (aCommand == KCmdSetVolume) |
|
414 { |
|
415 DoCmdSetVolume(aSection); |
|
416 } |
|
417 else if (aCommand == KCmdSetVolumeLoop) |
|
418 { |
|
419 DoCmdSetVolumeLoop(aSection); |
|
420 } |
|
421 else if (aCommand == KCmdSetVolumeRamp) |
|
422 { |
|
423 DoCmdSetVolumeRamp(aSection); |
|
424 } |
|
425 else if (aCommand == KCmdInitializeL) |
|
426 { |
|
427 DoCmdInitializeL(aSection,aAsyncErrorIndex); |
|
428 } |
|
429 else if (aCommand == KCmdPlayDTMFStringL) |
|
430 { |
|
431 DoCmdPlayDTMFStringL(aSection, aAsyncErrorIndex); |
|
432 } |
|
433 else if (aCommand == KCmdPlayData) |
|
434 { |
|
435 DoCmdPlayData(); |
|
436 } |
|
437 else if (aCommand == KCmdPlayDualToneL) |
|
438 { |
|
439 DoCmdPlayDualToneL(aSection, aAsyncErrorIndex); |
|
440 } |
|
441 else if (aCommand == KCmdPlayInitL) |
|
442 { |
|
443 DoCmdPlayInitL(aAsyncErrorIndex); |
|
444 } |
|
445 else if (aCommand == KCmdPlayToneL) |
|
446 { |
|
447 DoCmdPlayToneL(aSection, aAsyncErrorIndex); |
|
448 } |
|
449 else if (aCommand == KCmdPlayToneSequenceL) |
|
450 { |
|
451 DoCmdPlayToneSequenceL(aSection,aAsyncErrorIndex); |
|
452 } |
|
453 else if (aCommand == KCmdRecordData) |
|
454 { |
|
455 DoCmdRecordData(); |
|
456 } |
|
457 else if (aCommand == KCmdRecordInitL) |
|
458 { |
|
459 DoCmdRecordInitL(aAsyncErrorIndex); |
|
460 } |
|
461 else if (aCommand == KCmdStop) |
|
462 { |
|
463 DoCmdStop(aSection); |
|
464 } |
|
465 else if(aCommand == KCmdErrorConceal) |
|
466 { |
|
467 DoCmdUtilityErrorConceal(); |
|
468 } |
|
469 else |
|
470 { |
|
471 ERR_PRINTF1(_L("Unknown command.")); |
|
472 ret=EFalse; |
|
473 } |
|
474 return ret; |
|
475 } |
|
476 |
|
477 /** |
|
478 * Handles initialization completion event. |
|
479 * CMMFDevSound object calls this function when its InitializeL() function |
|
480 * completes. |
|
481 * @param aError - Error code. KErrNone if successful. Other values are possible |
|
482 * indicating a problem initializing CMMFDevSound object. |
|
483 * @return void |
|
484 */ |
|
485 |
|
486 void CT_CMMFDevSoundData::InitializeComplete(TInt aError) |
|
487 { |
|
488 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::InitializeComplete")); |
|
489 if(KErrNone != aError) |
|
490 { |
|
491 ERR_PRINTF2(_L("InitializeComplete callback failed with error %d"), aError); |
|
492 SetAsyncError(iInitializeErrorIndex, aError); |
|
493 iInitializeErrorIndex = 0; |
|
494 } |
|
495 |
|
496 DecOutstanding(); |
|
497 |
|
498 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::InitializeComplete")); |
|
499 } |
|
500 |
|
501 /** |
|
502 * It's needed for playing o converting |
|
503 * @param aBuffer - Buffer into which data should be read. The amount of data that is |
|
504 * needed is specified in CMMFBuffer::RequestSize(). |
|
505 */ |
|
506 void CT_CMMFDevSoundData::BufferToBeFilled(CMMFBuffer* aBuffer) |
|
507 { |
|
508 if (!aBuffer) |
|
509 { |
|
510 ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!")); |
|
511 SetBlockResult(EFail); |
|
512 } |
|
513 else |
|
514 { |
|
515 TBool dataOk = ETrue; |
|
516 iBuffer = aBuffer; |
|
517 iBuffer->SetLastBuffer(EFalse); |
|
518 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
519 if (iPaused) |
|
520 { |
|
521 iPaused=EFalse; |
|
522 TInt error = iAudiofile.Read(iLastSample,buffer->Data()); |
|
523 if (error != KErrNone) |
|
524 { |
|
525 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), error); |
|
526 SetBlockResult(EFail); |
|
527 dataOk = EFalse; |
|
528 } |
|
529 } |
|
530 else |
|
531 { |
|
532 TInt error = iAudiofile.Read(buffer->Data()); |
|
533 if (error != KErrNone) |
|
534 { |
|
535 ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), error); |
|
536 SetBlockResult(EFail); |
|
537 dataOk =EFalse; |
|
538 } |
|
539 } |
|
540 if(dataOk) |
|
541 { |
|
542 if (buffer->Data().Length() != buffer->RequestSize()) |
|
543 { |
|
544 iBuffer->SetLastBuffer(ETrue); |
|
545 } |
|
546 if (iErrorConceal) |
|
547 { |
|
548 iErrorConceal=EFalse; |
|
549 buffer->Data().Zero(); |
|
550 INFO_PRINTF1(_L("buffer->Data().Zero()")); |
|
551 } |
|
552 PlayData(); |
|
553 TInt pos=0; |
|
554 iLastSample=iAudiofile.Seek(ESeekCurrent ,pos); |
|
555 INFO_PRINTF2(_L("Number of samples played so far: %d"), pos); |
|
556 iLastSample=pos; |
|
557 } |
|
558 } |
|
559 } |
|
560 |
|
561 /** |
|
562 * Handles play completion or cancel event. |
|
563 * |
|
564 * CMMFDevSound object calls this function when an attempt to play audio sample |
|
565 * has completed, successfully or otherwise. |
|
566 * |
|
567 * @param aError - Error code. The status of playback. KErrUnderflow playing of the |
|
568 * audio sample is complete. KErrAccessDenied the sound device is in |
|
569 * use by another higher priority client. |
|
570 */ |
|
571 void CT_CMMFDevSoundData::PlayError(TInt aError) |
|
572 { |
|
573 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::PlayError")); |
|
574 |
|
575 DecOutstanding(); |
|
576 |
|
577 if(aError != KErrNone && aError != KErrUnderflow) |
|
578 { |
|
579 ERR_PRINTF2(_L("Playback completed with error %d"), aError); |
|
580 SetAsyncError(iPlayErrorIndex, aError); |
|
581 iPlayErrorIndex = 0; |
|
582 } |
|
583 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::PlayError")); |
|
584 } |
|
585 |
|
586 |
|
587 /** |
|
588 * Handles tone play completion event. |
|
589 * |
|
590 * |
|
591 * CMMFDevSound object calls this function when an attempt to play tone has |
|
592 * completed, successfully or otherwise. |
|
593 * |
|
594 * The following are the play tone functions; PlayToneL(), PlayDMTFStringL(), |
|
595 * PlayToneSequenceL(), and PlayFixedSequenceL(). |
|
596 * |
|
597 * @param aError - Error code. The status of tone playback. KErrUnderflow playing of |
|
598 * the tone is complete. KErrAccessDenied the sound device is in use by |
|
599 * another higher priority client. KErrCancel playing of the audio |
|
600 * sample is stopped by DevSound client another higher priority client. |
|
601 * |
|
602 */ |
|
603 |
|
604 void CT_CMMFDevSoundData::ToneFinished(TInt aError) |
|
605 { |
|
606 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::ToneFinished")); |
|
607 |
|
608 DecOutstanding(); |
|
609 |
|
610 if(aError != KErrNone) |
|
611 { |
|
612 ERR_PRINTF2(_L("Tone finished with error %d"), aError); |
|
613 SetAsyncError(iToneErrorIndex, aError); |
|
614 iToneErrorIndex = 0; |
|
615 } |
|
616 iToneFile.Close(); |
|
617 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::ToneFinished")); |
|
618 } |
|
619 |
|
620 /** |
|
621 * Handles CMMFDevSound object's data request event. |
|
622 * |
|
623 * CMMFDevSound object calls this function when the buffer, aBuffer gets filled |
|
624 * while recording or converting. The observer should notify CMMFDevSound |
|
625 * object as quickly as possible after data in the buffer is processed by |
|
626 * calling RecordData(), otherwise the implementation might callback |
|
627 * the function RecordError() on derived class object with error code KErrOverflow. |
|
628 * |
|
629 * @param aBuffer - Buffer containing processed (recorded or converted) data. The amount |
|
630 * of data that is available is specified in CMMFBuffer::RequestSize(). |
|
631 */ |
|
632 |
|
633 void CT_CMMFDevSoundData::BufferToBeEmptied(CMMFBuffer* aBuffer) |
|
634 { |
|
635 if (!aBuffer) |
|
636 { |
|
637 INFO_PRINTF1(_L("BufferToBeEmptied callback received a NULL CMMFBuffer")); |
|
638 SetBlockResult(EFail); |
|
639 } |
|
640 else |
|
641 { |
|
642 iBuffer = aBuffer; |
|
643 CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer); |
|
644 TInt error = iAudiofile.Write(buffer->Data()); |
|
645 if(error == KErrNone) |
|
646 { |
|
647 if (!aBuffer->LastBuffer()) |
|
648 { |
|
649 RecordData(); |
|
650 } |
|
651 else{ |
|
652 Stop(); |
|
653 } |
|
654 } |
|
655 else |
|
656 { |
|
657 ERR_PRINTF2(_L("iFile.Write() returned the error %d"), error); |
|
658 SetBlockResult(EFail); |
|
659 } |
|
660 } |
|
661 } |
|
662 |
|
663 /** |
|
664 * Stops the ongoing operation (Play, Record, TonePlay, Convert). |
|
665 * This function should be synchronous and invoke no callbacks through MDevSoundObserver. |
|
666 */ |
|
667 void CT_CMMFDevSoundData::Stop() |
|
668 { |
|
669 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::Stop()")); |
|
670 iDevSound->Stop(); |
|
671 |
|
672 DecOutstanding(); |
|
673 |
|
674 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::Stop()")); |
|
675 } |
|
676 |
|
677 /** |
|
678 * Handles record completion or cancel event. |
|
679 * |
|
680 * CMMFDevSound object calls this function when an attempt to record audio sample |
|
681 * has completed, successfully or otherwise. |
|
682 * |
|
683 * @param aError - Error code. The status of recording. KErrOverflow audio devices |
|
684 * runs out of internal buffer. KErrAccessDenied the sound device is |
|
685 * in use by another higher priority client. |
|
686 * |
|
687 */ |
|
688 |
|
689 void CT_CMMFDevSoundData::RecordError(TInt aError) |
|
690 { |
|
691 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::RecordError")); |
|
692 if(aError != KErrNone) |
|
693 { |
|
694 ERR_PRINTF2(_L("Record failed with error %d"), aError); |
|
695 SetAsyncError(iRecordErrorIndex , aError); |
|
696 iRecordErrorIndex = 0; |
|
697 } |
|
698 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::RecordError")); |
|
699 } |
|
700 |
|
701 |
|
702 /** |
|
703 * Handles conversion completion or cancel event. |
|
704 * |
|
705 * CMMFDevSound object calls this function when an attempt to convert data from |
|
706 * source format to destination format has completed, successfully or otherwise. |
|
707 * |
|
708 * @param aError - Error code. KErrCancel conversion operation is cancelled. KErrNone |
|
709 * conversion is complete. Other values are possible indicating a |
|
710 * problem converting data. |
|
711 */ |
|
712 |
|
713 void CT_CMMFDevSoundData::ConvertError(TInt aError) |
|
714 { |
|
715 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::ConvertError")); |
|
716 ERR_PRINTF1(_L("Invalid Callback call")); |
|
717 if (aError == KErrNone) |
|
718 { |
|
719 INFO_PRINTF1(_L("Data conversion completed successfully.")); |
|
720 } |
|
721 if (aError == KErrCancel) |
|
722 { |
|
723 INFO_PRINTF1(_L("Data conversion operation was cancelled.")); |
|
724 } |
|
725 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::ConvertError")); |
|
726 } |
|
727 |
|
728 /** |
|
729 * Handles device event. |
|
730 * |
|
731 * CMMFDevSound object calls this function when a message is received from the |
|
732 * audio hardware device. |
|
733 * |
|
734 * @param aMessageType - Defines the type of message. Used to determine how to |
|
735 * interpret the contents of aMsg. |
|
736 * @param aMsg - Message that is packed in the Descriptor format. |
|
737 */ |
|
738 |
|
739 |
|
740 void CT_CMMFDevSoundData::DeviceMessage(TUid aMessageType, const TDesC8& aMsg) |
|
741 { |
|
742 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DeviceMessage")); |
|
743 INFO_PRINTF2(_L("Message type: %d"), aMessageType.iUid); |
|
744 INFO_PRINTF2(_L("Message type: %S"), &aMsg); |
|
745 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DeviceMessage")); |
|
746 } |
|
747 |
|
748 |
|
749 /** |
|
750 * Create a new or Replace the existing file |
|
751 * |
|
752 */ |
|
753 void CT_CMMFDevSoundData::DoCmdUtilityReplaceFile(const TTEFSectionName& aSection) |
|
754 { |
|
755 INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityReplaceFile()")); |
|
756 TPtrC fileName; |
|
757 TBool dataOk = ETrue; |
|
758 if (!GetStringFromConfig(aSection, KFilename, fileName)) |
|
759 { |
|
760 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename); |
|
761 SetBlockResult(EFail); |
|
762 dataOk =EFalse; |
|
763 } |
|
764 if(dataOk) |
|
765 { |
|
766 TInt error = iAudiofile.Replace(iFs, fileName, EFileRead); |
|
767 if (error != KErrNone) |
|
768 { |
|
769 ERR_PRINTF2(_L("Could not open input file. Error = %d"), error); |
|
770 SetError(error); |
|
771 } |
|
772 } |
|
773 |
|
774 INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityReplaceFile()")); |
|
775 } |
|
776 |
|
777 /** |
|
778 * Open a file |
|
779 */ |
|
780 void CT_CMMFDevSoundData::DoCmdUtilityOpenFile(const TTEFSectionName& aSection) |
|
781 { |
|
782 |
|
783 INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityOpenFile()")); |
|
784 TPtrC fileName; |
|
785 TBool dataOk = ETrue; |
|
786 if (!GetStringFromConfig(aSection, KFilename, fileName)) |
|
787 { |
|
788 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename); |
|
789 SetBlockResult(EFail); |
|
790 dataOk =EFalse; |
|
791 } |
|
792 if(dataOk) |
|
793 { |
|
794 TInt error = iAudiofile.Open(iFs, fileName, EFileRead); |
|
795 if (error != KErrNone) |
|
796 { |
|
797 ERR_PRINTF2(_L("Could not open input file. Error = %d"), error); |
|
798 iFs.Close(); |
|
799 SetError(error); |
|
800 } |
|
801 } |
|
802 INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityOpenFile()")); |
|
803 } |
|
804 |
|
805 /** |
|
806 * Close the opened file |
|
807 */ |
|
808 void CT_CMMFDevSoundData::DoCmdUtilityCloseFile() |
|
809 { |
|
810 INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityCloseFile()")); |
|
811 iAudiofile.Close(); |
|
812 INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityCloseFile()")); |
|
813 } |
|
814 |
|
815 /** |
|
816 * Place the the pointer file at the begining |
|
817 * |
|
818 */ |
|
819 void CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition() |
|
820 { |
|
821 INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition()")); |
|
822 TInt filePosition = 0; |
|
823 TBool dataOk = ETrue; |
|
824 TInt error = iAudiofile.Seek(ESeekStart, filePosition); |
|
825 if (error != KErrNone) |
|
826 { |
|
827 ERR_PRINTF2(_L("Could not set file to the start position. Error = %d"), error); |
|
828 SetError(error); |
|
829 dataOk =EFalse; |
|
830 } |
|
831 if(dataOk) |
|
832 { |
|
833 INFO_PRINTF2(_L("File Position: %d"), filePosition); |
|
834 } |
|
835 INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition()")); |
|
836 } |
|
837 |
|
838 |
|
839 /** |
|
840 * Creates "n" instance of CMMFDevSound |
|
841 * @param aSection - Section to read from the ini file |
|
842 * @return void |
|
843 */ |
|
844 void CT_CMMFDevSoundData::DoCmdNewLLoopL(const TTEFSectionName&aSection) |
|
845 { |
|
846 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdNewLLoopL")); |
|
847 CMMFDevSound* devSound = NULL; |
|
848 TBool dataOk = ETrue; |
|
849 TInt loop= 0; |
|
850 if (!GetIntFromConfig(aSection, KLoop, loop)) |
|
851 { |
|
852 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLoop); |
|
853 SetBlockResult(EFail); |
|
854 dataOk = EFalse; |
|
855 } |
|
856 TInt allowedError=0; |
|
857 if ( !GetIntFromConfig(aSection, KAllowedError, allowedError) ) |
|
858 { |
|
859 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KAllowedError); |
|
860 SetBlockResult(EFail); |
|
861 dataOk = EFalse; |
|
862 } |
|
863 if(dataOk) |
|
864 { |
|
865 for(TInt i=0; i<loop; i++) |
|
866 { |
|
867 TRAPD(error,devSound = CMMFDevSound::NewL()); |
|
868 if(error == KErrNone) |
|
869 { |
|
870 INFO_PRINTF2(_L("Instance %d of DevSound was created"),i); |
|
871 CleanupStack::PushL(devSound); |
|
872 iObjectsDevSound.AppendL(devSound); |
|
873 CleanupStack::Pop(devSound); |
|
874 } |
|
875 else if(error == allowedError) |
|
876 { |
|
877 INFO_PRINTF2(_L(" Allowing Error: %d"), error); |
|
878 ERR_PRINTF2(_L(" Could not create CMMFDevSound due to error: %d"), error); |
|
879 i = loop; |
|
880 } |
|
881 else if((error != KErrNone) && (error!=allowedError)) |
|
882 { |
|
883 ERR_PRINTF2(_L("> Could not create CMMFDevSound: %d"), error); |
|
884 SetError(error); |
|
885 } |
|
886 } |
|
887 iObjectsDevSound.ResetAndDestroy(); |
|
888 INFO_PRINTF2(_L("%d DevSound instances were deleted"),loop); |
|
889 } |
|
890 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdNewLLoopL")); |
|
891 } |
|
892 |
|
893 |
|
894 /** |
|
895 * Create an instance of CMMFDevSound |
|
896 */ |
|
897 void CT_CMMFDevSoundData::DoCmdNewL() |
|
898 { |
|
899 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdNewL")); |
|
900 DestroyData(); |
|
901 TRAPD(error,iDevSound = CMMFDevSound::NewL()); |
|
902 if(error!= KErrNone) |
|
903 { |
|
904 ERR_PRINTF2(_L("> Could not create CMMFDevSound: %d"), error); |
|
905 SetError(error); |
|
906 } |
|
907 else |
|
908 { |
|
909 iPaused= EFalse; |
|
910 iErrorConceal = EFalse; |
|
911 } |
|
912 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdNewL")); |
|
913 } |
|
914 /** |
|
915 * Destroy an instance of CMMFDevSound |
|
916 */ |
|
917 |
|
918 void CT_CMMFDevSoundData::DoCmdDestructor() |
|
919 { |
|
920 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdDestroyData")); |
|
921 DestroyData(); |
|
922 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdDestroyData")); |
|
923 } |
|
924 |
|
925 /** |
|
926 * Show the supported Audio settings ie. encoding, sample rates, mono/stereo operation, buffer |
|
927 * size, etc. |
|
928 * @param none |
|
929 * @return none |
|
930 */ |
|
931 void CT_CMMFDevSoundData::DoCmdCapabilities() |
|
932 { |
|
933 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdCapabilities")); |
|
934 iCapabilities = iDevSound->Capabilities(); |
|
935 INFO_PRINTF5(_L("Supported Audio settings: buffsize=%d, channels=0x%x, encoding=0x%x and rate=0x%x"), |
|
936 iCapabilities.iBufferSize, |
|
937 iCapabilities.iChannels, |
|
938 iCapabilities.iEncoding, |
|
939 iCapabilities.iRate); |
|
940 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdCapabilities")); |
|
941 } |
|
942 |
|
943 |
|
944 /** |
|
945 * Shows the current device configuration. |
|
946 * @params none |
|
947 * @return none |
|
948 */ |
|
949 void CT_CMMFDevSoundData::DoCmdConfig() |
|
950 { |
|
951 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdConfig")); |
|
952 TMMFCapabilities currentConfiguration = iDevSound->Config(); |
|
953 INFO_PRINTF5(_L("Current device configuration: buffsize=%d, channels=0x%x, encoding=0x%x and rate=0x%x"), |
|
954 currentConfiguration.iBufferSize, |
|
955 currentConfiguration.iChannels, |
|
956 currentConfiguration.iEncoding, |
|
957 currentConfiguration.iRate); |
|
958 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdConfig")); |
|
959 } |
|
960 |
|
961 |
|
962 /** |
|
963 * Shows an integer representing the maximum gain the device supports. |
|
964 * This is the maximum value which can be passed to CMMFDevSound::SetGain. |
|
965 * @param aSection - The section to read the params from the ini file |
|
966 * @return none |
|
967 */ |
|
968 |
|
969 void CT_CMMFDevSoundData::DoCmdMaxGain(const TTEFSectionName& aSection) |
|
970 { |
|
971 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdMaxGain")); |
|
972 TBool dataOk = ETrue; |
|
973 TInt expectedGainValue=0; |
|
974 if (!GetIntFromConfig(aSection, KGainValue, expectedGainValue)) |
|
975 { |
|
976 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KGainValue); |
|
977 SetBlockResult(EFail); |
|
978 dataOk = EFalse; |
|
979 } |
|
980 if(dataOk) |
|
981 { |
|
982 iGainValue = iDevSound->MaxGain(); |
|
983 INFO_PRINTF2(_L("Retrieved maximum gain value: %d"), iGainValue); |
|
984 if (expectedGainValue != iGainValue) |
|
985 { |
|
986 ERR_PRINTF3(_L("Expected gain value %d is different from retrieved gain value %d"), expectedGainValue, iGainValue); |
|
987 SetBlockResult(EFail); |
|
988 } |
|
989 } |
|
990 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdMaxGain")); |
|
991 } |
|
992 |
|
993 /** |
|
994 * Shows an integer representing the maximum volume device supports. |
|
995 * This is the maximum value which can be passed to CMMFDevSound::SetVolume. |
|
996 * @param aSection - Section to read params from the ini file |
|
997 * @return none |
|
998 */ |
|
999 |
|
1000 void CT_CMMFDevSoundData::DoCmdMaxVolume(const TTEFSectionName& aSection) |
|
1001 { |
|
1002 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdMaxVolume")); |
|
1003 TBool dataOk = ETrue; |
|
1004 TInt expectedVolumeValue=0; |
|
1005 if(!GetIntFromConfig(aSection, KVolumeValue, expectedVolumeValue)) |
|
1006 { |
|
1007 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeValue); |
|
1008 SetBlockResult(EFail); |
|
1009 dataOk = EFalse; |
|
1010 } |
|
1011 if(dataOk) |
|
1012 { |
|
1013 iVolumeValue = iDevSound->MaxVolume(); |
|
1014 INFO_PRINTF2(_L("Retrieved maximum volume value: %d"), iVolumeValue); |
|
1015 if(expectedVolumeValue != iVolumeValue) |
|
1016 { |
|
1017 ERR_PRINTF3(_L("Expected volume value %d is different from retrieved volume value %d"), expectedVolumeValue, iVolumeValue); |
|
1018 SetBlockResult(EFail); |
|
1019 } |
|
1020 } |
|
1021 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdMaxVolume")); |
|
1022 } |
|
1023 |
|
1024 /** |
|
1025 * Shows the speaker balance set for playing. |
|
1026 * @param aSection - Section to read params from the ini file |
|
1027 * @return none |
|
1028 */ |
|
1029 |
|
1030 void CT_CMMFDevSoundData::DoCmdGetPlayBalanceL(const TTEFSectionName& aSection) |
|
1031 { |
|
1032 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetPlayBalanceL")); |
|
1033 TBool dataOk = ETrue; |
|
1034 TInt expectedLeftPercentage=0; |
|
1035 if (!GetIntFromConfig(aSection, KLeftPercentage, expectedLeftPercentage)) |
|
1036 { |
|
1037 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLeftPercentage); |
|
1038 SetBlockResult(EFail); |
|
1039 dataOk = EFalse; |
|
1040 } |
|
1041 TInt expectedRightPercentage=0; |
|
1042 if (!GetIntFromConfig(aSection, KRightPercentage, expectedRightPercentage)) |
|
1043 { |
|
1044 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRightPercentage); |
|
1045 SetBlockResult(EFail); |
|
1046 dataOk = EFalse; |
|
1047 } |
|
1048 if(dataOk) |
|
1049 { |
|
1050 TRAPD(error, iDevSound->GetPlayBalanceL(iLeftPercentage, iRightPercentage)); |
|
1051 if (error != KErrNone) |
|
1052 { |
|
1053 ERR_PRINTF2(_L("GetPlayBalanceL left with error %d"), error); |
|
1054 SetError(error); |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 INFO_PRINTF3(_L("> Retrieved play balance values are left: %d, right:%d"), iLeftPercentage, iRightPercentage); |
|
1059 if (expectedLeftPercentage !=iLeftPercentage) |
|
1060 { |
|
1061 ERR_PRINTF3(_L("Expected left percentage value %d is different from retrieved value %d"), expectedLeftPercentage, iLeftPercentage); |
|
1062 SetBlockResult(EFail); |
|
1063 } |
|
1064 if (expectedRightPercentage !=iRightPercentage) |
|
1065 { |
|
1066 ERR_PRINTF3(_L("Expected right percentage value %d is different from retrieved value %d"), expectedRightPercentage, iRightPercentage); |
|
1067 SetBlockResult(EFail); |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetPlayBalanceL")); |
|
1073 } |
|
1074 |
|
1075 |
|
1076 /** |
|
1077 * Shows the microphone gain balance set for recording. |
|
1078 * @param aSection - Section to read params from the ini file |
|
1079 * @return none |
|
1080 */ |
|
1081 void CT_CMMFDevSoundData::DoCmdGetRecordBalanceL(const TTEFSectionName& aSection) |
|
1082 { |
|
1083 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetRecordBalanceL")); |
|
1084 TBool dataOk = ETrue; |
|
1085 TInt expectedLeftPercentage=0; |
|
1086 if(!GetIntFromConfig(aSection, KLeftPercentage, expectedLeftPercentage)) |
|
1087 { |
|
1088 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLeftPercentage); |
|
1089 SetBlockResult(EFail); |
|
1090 dataOk = EFalse; |
|
1091 } |
|
1092 TInt expectedRightPercentage=0; |
|
1093 if(!GetIntFromConfig(aSection, KRightPercentage, expectedRightPercentage)) |
|
1094 { |
|
1095 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRightPercentage); |
|
1096 SetBlockResult(EFail); |
|
1097 dataOk = EFalse; |
|
1098 } |
|
1099 if(dataOk) |
|
1100 { |
|
1101 TRAPD(error, iDevSound->GetRecordBalanceL(iLeftPercentage, iRightPercentage)); |
|
1102 if (error != KErrNone) |
|
1103 { |
|
1104 ERR_PRINTF2(_L("GetRecordBalanceL left with error %d"), error); |
|
1105 SetError(error); |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 INFO_PRINTF3(_L("> Retrieved record balance values are left: %d, right:%d"), iLeftPercentage, iRightPercentage); |
|
1110 if(expectedLeftPercentage !=iLeftPercentage) |
|
1111 { |
|
1112 ERR_PRINTF3(_L("Expected left percentage value %d is different from retrieved value %d"), expectedLeftPercentage, iLeftPercentage); |
|
1113 SetBlockResult(EFail); |
|
1114 } |
|
1115 if(expectedRightPercentage !=iRightPercentage) |
|
1116 { |
|
1117 ERR_PRINTF3(_L("Expected right ercentage value %d is different from retrieved value %d"), expectedRightPercentage, iRightPercentage); |
|
1118 SetBlockResult(EFail); |
|
1119 } |
|
1120 } |
|
1121 |
|
1122 } |
|
1123 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetRecordBalanceL")); |
|
1124 } |
|
1125 |
|
1126 /** |
|
1127 * Shows a list of the supported input datatypes that can be sent to DevSound for playing audio. |
|
1128 * The datatypes returned are those that the DevSound supports given the priority settings passed |
|
1129 * in aPrioritySettings. |
|
1130 * @params none |
|
1131 * @return none |
|
1132 */ |
|
1133 void CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL() |
|
1134 { |
|
1135 TUid outputUid= {0x0}; |
|
1136 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL")); |
|
1137 RArray< TFourCC > supportedDataTypes; |
|
1138 TRAPD(error, iDevSound->GetSupportedInputDataTypesL(supportedDataTypes, iPrioritySettings)); |
|
1139 if (error != KErrNone) |
|
1140 { |
|
1141 ERR_PRINTF2(_L("GetSupportedInputDataTypesL left with error %d"), error); |
|
1142 SetError(error); |
|
1143 } |
|
1144 else |
|
1145 { |
|
1146 INFO_PRINTF1(_L("List of the supported input datatypes that can be sent to DevSound for playing audio.")); |
|
1147 for (TInt i=0; i<supportedDataTypes.Count(); i++) |
|
1148 { |
|
1149 TFourCC fourCC = supportedDataTypes[i]; |
|
1150 TBuf<4> name; |
|
1151 for(TInt j=0; j<= KFourCCMaxBitDisplacement; j+=K8Bits) |
|
1152 { |
|
1153 name.Append((TUint8)(fourCC.FourCC() >> j)); |
|
1154 } |
|
1155 INFO_PRINTF3(_L("Supported Input Data types: 0x%x %S "), fourCC.FourCC(), &name); |
|
1156 UtilityFourCCToHwDeviceUidL(name,EDecoder, outputUid); |
|
1157 if(outputUid.iUid != 0) |
|
1158 { |
|
1159 INFO_PRINTF3(_L("\nHwDevice Uid=0x%08x for %S"),outputUid.iUid,&name); |
|
1160 } |
|
1161 else |
|
1162 { |
|
1163 INFO_PRINTF1(_L("Not Found")); |
|
1164 } |
|
1165 } |
|
1166 supportedDataTypes.Reset(); |
|
1167 } |
|
1168 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL")); |
|
1169 } |
|
1170 |
|
1171 /** |
|
1172 * Shows a list of the supported output dataypes that can be received from DevSound for |
|
1173 * recording audio. The datatypes returned are those that the DevSound supports given the priority |
|
1174 * settings passed in aPrioritySettings. |
|
1175 * @param none |
|
1176 * @return none |
|
1177 */ |
|
1178 void CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL() |
|
1179 { |
|
1180 TUid outputUid= {0x0}; |
|
1181 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL")); |
|
1182 RArray< TFourCC > supportedDataTypes; |
|
1183 TRAPD(error, iDevSound->GetSupportedOutputDataTypesL(supportedDataTypes, iPrioritySettings)); |
|
1184 if (error != KErrNone) |
|
1185 { |
|
1186 ERR_PRINTF2(_L("GetSupportedOutputDataTypesL left with error %d"), error); |
|
1187 SetError(error); |
|
1188 } |
|
1189 else |
|
1190 { |
|
1191 INFO_PRINTF1(_L("List of the supported output dataypes that can be received from DevSound for recording audio.")); |
|
1192 for (TInt i=0; i<supportedDataTypes.Count(); i++) |
|
1193 { |
|
1194 TFourCC fourCC = supportedDataTypes[i]; |
|
1195 TBuf<4> name; |
|
1196 for(TInt j=0; j<=KFourCCMaxBitDisplacement; j+=K8Bits) |
|
1197 { |
|
1198 name.Append((TUint8)(fourCC.FourCC() >> j)); |
|
1199 } |
|
1200 INFO_PRINTF3(_L("Supported Output Data types: 0x%x %S "), fourCC.FourCC(), &name); |
|
1201 UtilityFourCCToHwDeviceUidL(name, EEncoder, outputUid); |
|
1202 if(outputUid.iUid != 0) |
|
1203 { |
|
1204 INFO_PRINTF3(_L("\nHwDevice Uid=0x%08x for %S"),outputUid.iUid,&name); |
|
1205 } |
|
1206 else |
|
1207 { |
|
1208 INFO_PRINTF1(_L("Not Found")); |
|
1209 } |
|
1210 } |
|
1211 supportedDataTypes.Reset(); |
|
1212 } |
|
1213 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL")); |
|
1214 } |
|
1215 |
|
1216 /** |
|
1217 * Shows the number of samples played |
|
1218 * @param none |
|
1219 * @return none |
|
1220 */ |
|
1221 void CT_CMMFDevSoundData::DoCmdSamplesPlayed() |
|
1222 { |
|
1223 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSamplesPlayed")); |
|
1224 INFO_PRINTF2(_L("Number of samples played so far: %d"),iDevSound->SamplesPlayed()); |
|
1225 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSamplesPlayed")); |
|
1226 } |
|
1227 |
|
1228 /** |
|
1229 * Shows the number of samples recorded |
|
1230 * @param none |
|
1231 * @return none |
|
1232 */ |
|
1233 void CT_CMMFDevSoundData::DoCmdSamplesRecorded() |
|
1234 { |
|
1235 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSamplesRecorded")); |
|
1236 INFO_PRINTF2(_L("Number of samples recorded so far: %d"), iDevSound->SamplesRecorded()); |
|
1237 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSamplesRecorded")); |
|
1238 } |
|
1239 |
|
1240 /** |
|
1241 * Shows an integer representing the current volume. |
|
1242 * @param aSection - Section to read param from the ini file |
|
1243 * @return none |
|
1244 */ |
|
1245 void CT_CMMFDevSoundData::DoCmdVolume(const TTEFSectionName& aSection) |
|
1246 { |
|
1247 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdVolume")); |
|
1248 TBool dataOk = ETrue; |
|
1249 TInt expectedVolumeValue=0; |
|
1250 if(!GetIntFromConfig(aSection, KVolumeValue, expectedVolumeValue)) |
|
1251 { |
|
1252 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeValue); |
|
1253 SetBlockResult(EFail); |
|
1254 dataOk = EFalse; |
|
1255 } |
|
1256 if(dataOk) |
|
1257 { |
|
1258 iVolumeValue = iDevSound->Volume(); |
|
1259 INFO_PRINTF2(_L("Retrieved volume value: %d"), iVolumeValue); |
|
1260 if(expectedVolumeValue != iVolumeValue) |
|
1261 { |
|
1262 ERR_PRINTF3(_L("Expected volume value %d is different from retrieved volume value %d"), expectedVolumeValue, iVolumeValue); |
|
1263 SetBlockResult(EFail); |
|
1264 } |
|
1265 } |
|
1266 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdVolume")); |
|
1267 } |
|
1268 |
|
1269 /** |
|
1270 * Shows an integer representing the current gain. |
|
1271 * @param aSection - Section to read param from the ini file |
|
1272 * @return none |
|
1273 */ |
|
1274 void CT_CMMFDevSoundData::DoCmdGain(const TTEFSectionName& aSection) |
|
1275 { |
|
1276 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGain")); |
|
1277 TBool dataOk = ETrue; |
|
1278 TInt expectedGainValue=0; |
|
1279 if(!GetIntFromConfig(aSection, KGainValue, expectedGainValue)) |
|
1280 { |
|
1281 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KGainValue); |
|
1282 SetBlockResult(EFail); |
|
1283 dataOk = EFalse; |
|
1284 } |
|
1285 if(dataOk) |
|
1286 { |
|
1287 iGainValue = iDevSound->Gain(); |
|
1288 INFO_PRINTF2(_L("Retrieved gain value: %d"), iGainValue); |
|
1289 if(expectedGainValue != iGainValue) |
|
1290 { |
|
1291 ERR_PRINTF3(_L("Expected gain value %d is different from retrieved gain value %d"), expectedGainValue, iGainValue); |
|
1292 SetBlockResult(EFail); |
|
1293 } |
|
1294 } |
|
1295 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGain")); |
|
1296 } |
|
1297 |
|
1298 /** |
|
1299 * Shows the number of available pre-defined tone sequences |
|
1300 * @param none |
|
1301 * @return none |
|
1302 */ |
|
1303 void CT_CMMFDevSoundData::DoCmdFixedSequenceCount() |
|
1304 { |
|
1305 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdFixedSequenceCount")); |
|
1306 INFO_PRINTF2(_L("Number of available pre-defined tone sequences: %d"), iDevSound->FixedSequenceCount()); |
|
1307 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdFixedSequenceCount")); |
|
1308 } |
|
1309 |
|
1310 /** |
|
1311 * Shows the name assigned to a specific pre-defined tone sequence. |
|
1312 * This is the number of the fixed sequence supported by DevSound by default. |
|
1313 * @param aSection - Section to read params from the ini file |
|
1314 * @return none |
|
1315 */ |
|
1316 void CT_CMMFDevSoundData::DoCmdFixedSequenceName(const TTEFSectionName& aSection) |
|
1317 { |
|
1318 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdFixedSequenceName")); |
|
1319 TBool dataOk =ETrue; |
|
1320 TInt sequenceNumber=0; |
|
1321 if(!GetIntFromConfig(aSection, KSequenceNumber, sequenceNumber)) |
|
1322 { |
|
1323 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSequenceNumber); |
|
1324 SetBlockResult(EFail); |
|
1325 dataOk =EFalse; |
|
1326 } |
|
1327 if(dataOk) |
|
1328 { |
|
1329 INFO_PRINTF2(_L("Name assigned to a specific pre-defined tone sequence returned: %S"), |
|
1330 &iDevSound->FixedSequenceName(sequenceNumber)); |
|
1331 } |
|
1332 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdFixedSequenceName")); |
|
1333 } |
|
1334 |
|
1335 |
|
1336 /** |
|
1337 * Configure CMMFDevSound object with the settings in aConfig. |
|
1338 * Use this to set sampling rate, encoding and mono/stereo. |
|
1339 * @param aSection - Section to read params from the ini file |
|
1340 * @return none |
|
1341 */ |
|
1342 void CT_CMMFDevSoundData::DoCmdSetConfigL(const TTEFSectionName& aSection) |
|
1343 { |
|
1344 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetConfigL")); |
|
1345 |
|
1346 TInt rate=0; |
|
1347 INFO_PRINTF1(_L("To use default values run Capabilities before SetConfigL")); |
|
1348 if (!GetEnumFromConfig(aSection, KRate, iEnumSampleRate, rate)) |
|
1349 { |
|
1350 INFO_PRINTF2(_L("Rate value was not overwritten, using default value %d."), iCapabilities.iRate); |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 iCapabilities.iRate = rate; |
|
1355 } |
|
1356 |
|
1357 TInt encoding=0; |
|
1358 if (!GetIntFromConfig(aSection, KEncoding, encoding)) |
|
1359 { |
|
1360 INFO_PRINTF2(_L("Encoding value was not overwritten, using default value %d."), iCapabilities.iEncoding); |
|
1361 } |
|
1362 else |
|
1363 { |
|
1364 iCapabilities.iEncoding = encoding; |
|
1365 } |
|
1366 |
|
1367 TInt channels=0; |
|
1368 if (!GetEnumFromConfig(aSection, KChannels, iEnumChannels, channels)) |
|
1369 { |
|
1370 INFO_PRINTF2(_L("Channels value was not overwritten, using default value %d ."), iCapabilities.iChannels); |
|
1371 } |
|
1372 else |
|
1373 { |
|
1374 iCapabilities.iChannels = channels; |
|
1375 } |
|
1376 |
|
1377 TInt bufferSize=0; |
|
1378 if (!GetIntFromConfig(aSection, KBufferSize, bufferSize)) |
|
1379 { |
|
1380 INFO_PRINTF2(_L("BufferSize value was not overwritten, using default value %d"), iCapabilities.iBufferSize); |
|
1381 } |
|
1382 else |
|
1383 { |
|
1384 iCapabilities.iBufferSize = bufferSize; |
|
1385 } |
|
1386 TRAPD(error,iDevSound->SetConfigL(iCapabilities)) |
|
1387 if(error != KErrNone) |
|
1388 { |
|
1389 ERR_PRINTF2(_L("SetConfigL left with error %d"), error); |
|
1390 SetError(error); |
|
1391 } |
|
1392 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetConfigL")); |
|
1393 } |
|
1394 |
|
1395 |
|
1396 /** |
|
1397 * Defines the duration of tone on, tone off and tone pause to be used during the |
|
1398 * DTMF tone playback operation. |
|
1399 * Supported only during tone playing. |
|
1400 * @param aSection - Section to read param from the ini file |
|
1401 * @return none |
|
1402 */ |
|
1403 void CT_CMMFDevSoundData::DoCmdSetDTMFLengths(const TTEFSectionName& aSection) |
|
1404 { |
|
1405 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetDTMFLengths")); |
|
1406 TInt time=0; |
|
1407 TBool dataOk = ETrue; |
|
1408 if (!GetIntFromConfig(aSection, KToneOnLength, time)) |
|
1409 { |
|
1410 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KToneOnLength); |
|
1411 SetBlockResult(EFail); |
|
1412 dataOk = EFalse; |
|
1413 } |
|
1414 TTimeIntervalMicroSeconds32 toneOnLength(time); |
|
1415 |
|
1416 if (!GetIntFromConfig(aSection, KToneOffLength, time)) |
|
1417 { |
|
1418 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KToneOffLength); |
|
1419 SetBlockResult(EFail); |
|
1420 dataOk = EFalse; |
|
1421 } |
|
1422 TTimeIntervalMicroSeconds32 toneOffLength(time); |
|
1423 |
|
1424 if (!GetIntFromConfig(aSection, KPauseLength, time)) |
|
1425 { |
|
1426 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPauseLength); |
|
1427 SetBlockResult(EFail); |
|
1428 dataOk = EFalse; |
|
1429 } |
|
1430 TTimeIntervalMicroSeconds32 pauseLength(time); |
|
1431 if(dataOk) |
|
1432 { |
|
1433 iDevSound->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength); |
|
1434 } |
|
1435 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetDTMFLengths")); |
|
1436 } |
|
1437 |
|
1438 |
|
1439 /** |
|
1440 * Changes the current recording gain to a specified value. |
|
1441 * The gain can be changed before or during recording and is effective |
|
1442 * immediately. |
|
1443 * @params aSection - Section to read param from the ini file |
|
1444 */ |
|
1445 void CT_CMMFDevSoundData::DoCmdSetGain(const TTEFSectionName& aSection) |
|
1446 { |
|
1447 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetGain")); |
|
1448 TInt gainValue = iGainValue; |
|
1449 if(!GetIntFromConfig(aSection, KGainValue, gainValue)) |
|
1450 { |
|
1451 INFO_PRINTF1(_L("The Gain value was not found in the ini file, using default value")); |
|
1452 } |
|
1453 INFO_PRINTF2(_L("Setting gain value to %d"), gainValue); |
|
1454 iDevSound->SetGain(gainValue); |
|
1455 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetGain")); |
|
1456 } |
|
1457 |
|
1458 /** |
|
1459 * Sets the speaker balance for playing. |
|
1460 * The speaker balance can be changed before or during playback and is |
|
1461 * effective immediately. |
|
1462 * @param aSection - The section to read params from the ini file |
|
1463 * @return none |
|
1464 */ |
|
1465 void CT_CMMFDevSoundData::DoCmdSetPlayBalanceL(const TTEFSectionName& aSection) |
|
1466 { |
|
1467 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetPlayBalanceL")); |
|
1468 TInt leftPercentage = iLeftPercentage; |
|
1469 if(!GetIntFromConfig(aSection, KLeftPercentage, leftPercentage)) |
|
1470 { |
|
1471 INFO_PRINTF1(_L("The Left percentage was not found in the ini file, using default value")); |
|
1472 } |
|
1473 TInt rightPercentage = iRightPercentage; |
|
1474 if(!GetIntFromConfig(aSection, KRightPercentage, rightPercentage)) |
|
1475 { |
|
1476 INFO_PRINTF1(_L("The Right percentage was not found in the ini file, using default value")); |
|
1477 } |
|
1478 INFO_PRINTF3(_L("Setting play balance to left: %d, right: %d values"), leftPercentage, rightPercentage); |
|
1479 TRAPD(error, iDevSound->SetPlayBalanceL(leftPercentage, rightPercentage)); |
|
1480 if(error != KErrNone) |
|
1481 { |
|
1482 ERR_PRINTF2(_L("SetPlayBalanceL left with error %d"), error); |
|
1483 SetError(error); |
|
1484 } |
|
1485 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetPlayBalanceL")); |
|
1486 } |
|
1487 |
|
1488 /** |
|
1489 * Defines the priority settings that should be used for this instance. |
|
1490 * @param aSection - Section to read params from the ini file |
|
1491 * @return none |
|
1492 */ |
|
1493 void CT_CMMFDevSoundData::DoCmdSetPrioritySettings(const TTEFSectionName& aSection) |
|
1494 { |
|
1495 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetPrioritySettings")); |
|
1496 TBool dataOk = ETrue; |
|
1497 if(!GetIntFromConfig(aSection, KPriority, iPrioritySettings.iPriority)) |
|
1498 { |
|
1499 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPriority); |
|
1500 SetBlockResult(EFail); |
|
1501 dataOk = EFalse; |
|
1502 } |
|
1503 TInt preference=0; |
|
1504 if (!GetHexFromConfig(aSection, KPreference, preference)) |
|
1505 { |
|
1506 ERR_PRINTF2(_L("%S parameter was not found in INI file"), &KPreference); |
|
1507 SetBlockResult(EFail); |
|
1508 dataOk = EFalse; |
|
1509 } |
|
1510 iPrioritySettings.iPref = (TMdaPriorityPreference)preference; |
|
1511 TInt state=0; |
|
1512 if (!GetEnumFromConfig(aSection, KPriorityState, iEnumMode, state)) |
|
1513 { |
|
1514 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPriorityState); |
|
1515 SetBlockResult(EFail); |
|
1516 dataOk = EFalse; |
|
1517 } |
|
1518 iPrioritySettings.iState = (TMMFState)state; |
|
1519 if(dataOk) |
|
1520 { |
|
1521 iDevSound->SetPrioritySettings(iPrioritySettings); |
|
1522 } |
|
1523 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetPrioritySettings")); |
|
1524 } |
|
1525 |
|
1526 /** |
|
1527 * Sets the microphone gain balance for recording. |
|
1528 * The microphone gain balance can be changed before or during recording and |
|
1529 * is effective immediately. |
|
1530 * @param aSection - Section to read params from the ini file |
|
1531 * @return none |
|
1532 */ |
|
1533 void CT_CMMFDevSoundData::DoCmdSetRecordBalanceL(const TTEFSectionName& aSection) |
|
1534 { |
|
1535 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetRecordBalanceL")); |
|
1536 TInt leftPercentage = iLeftPercentage; |
|
1537 if (!GetIntFromConfig(aSection, KLeftPercentage, leftPercentage)) |
|
1538 { |
|
1539 INFO_PRINTF1(_L("The Left value was not found in the ini file, using default value")); |
|
1540 } |
|
1541 TInt rightPercentage = iRightPercentage; |
|
1542 if (!GetIntFromConfig(aSection, KRightPercentage, rightPercentage)) |
|
1543 { |
|
1544 INFO_PRINTF1(_L("The Right value was not found in the ini file, using default value")); |
|
1545 } |
|
1546 INFO_PRINTF3(_L("Setting record balance to left: %d, right: %d values"), leftPercentage, rightPercentage); |
|
1547 TRAPD(error, iDevSound->SetRecordBalanceL(leftPercentage, rightPercentage)); |
|
1548 if (KErrNone != error) |
|
1549 { |
|
1550 ERR_PRINTF2(_L("SetRecordBalanceL left with error %d"), error); |
|
1551 SetError(error); |
|
1552 } |
|
1553 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetRecordBalanceL")); |
|
1554 } |
|
1555 |
|
1556 /** |
|
1557 * Defines the number of times the audio is to be repeated during the tone |
|
1558 * playback operation. |
|
1559 * A period of silence can follow each playing of a tone. The tone playing can |
|
1560 * be repeated indefinitely. |
|
1561 * @param aSection - Section to read params from the ini file |
|
1562 * @return none |
|
1563 */ |
|
1564 void CT_CMMFDevSoundData::DoCmdSetToneRepeats(const TTEFSectionName& aSection) |
|
1565 { |
|
1566 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetToneRepeats")); |
|
1567 TInt repeatCount=0; |
|
1568 TBool dataOk = ETrue; |
|
1569 if (!GetIntFromConfig(aSection, KRepeatCount, repeatCount)) |
|
1570 { |
|
1571 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRepeatCount); |
|
1572 SetBlockResult(EFail); |
|
1573 dataOk = EFalse; |
|
1574 } |
|
1575 |
|
1576 TInt tempValue=0; |
|
1577 if (!GetIntFromConfig(aSection, KRepeatTrailingSilence, tempValue)) |
|
1578 { |
|
1579 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRepeatTrailingSilence); |
|
1580 SetBlockResult(EFail); |
|
1581 dataOk = EFalse; |
|
1582 } |
|
1583 TTimeIntervalMicroSeconds repeatTrailingSilence(tempValue); |
|
1584 |
|
1585 if(dataOk) |
|
1586 { |
|
1587 iDevSound->SetToneRepeats(repeatCount, repeatTrailingSilence); |
|
1588 } |
|
1589 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetToneRepeats")); |
|
1590 } |
|
1591 |
|
1592 /** |
|
1593 * Defines the period over which the volume level is to rise smoothly from |
|
1594 * nothing to the normal volume level. |
|
1595 * The function is only available while the tone is playing. |
|
1596 * @param aSection - Section to read params from the ini file |
|
1597 * @return none |
|
1598 */ |
|
1599 void CT_CMMFDevSoundData::DoCmdSetVolume(const TTEFSectionName& aSection) |
|
1600 { |
|
1601 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolume")); |
|
1602 TInt volume = iVolumeValue; |
|
1603 if(!GetIntFromConfig(aSection, KVolumeValue, volume)) |
|
1604 { |
|
1605 INFO_PRINTF1(_L("The Volume value was not found in the ini file, using default value")); |
|
1606 } |
|
1607 INFO_PRINTF2(_L("Setting volume value to %d"), volume); |
|
1608 iDevSound->SetVolume(volume); |
|
1609 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolume")); |
|
1610 } |
|
1611 |
|
1612 /** |
|
1613 * Defines the loop over which the volume level is to rise smoothly from |
|
1614 * nothing to the normal volume level. |
|
1615 * @param aSection - Section to read params from the ini file |
|
1616 * @return none |
|
1617 */ |
|
1618 void CT_CMMFDevSoundData::DoCmdSetVolumeLoop(const TTEFSectionName& aSection) |
|
1619 { |
|
1620 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolumeLoop")); |
|
1621 TInt volLoop=0; |
|
1622 TBool dataOk = ETrue; |
|
1623 if (!GetIntFromConfig(aSection, KVolumeLoop, volLoop)) |
|
1624 { |
|
1625 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeLoop); |
|
1626 SetBlockResult(EFail); |
|
1627 dataOk = EFalse; |
|
1628 } |
|
1629 if(dataOk) |
|
1630 { |
|
1631 TPtrC parVolume; |
|
1632 TInt volumeValue=0; |
|
1633 RPointerArray<HBufC> volumeList; |
|
1634 for (TInt i=0; i<volLoop; i++) |
|
1635 { |
|
1636 if (!GetArrayRectFromConfig(aSection, KVolumeList, volumeList)) |
|
1637 { |
|
1638 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeList); |
|
1639 volumeList.ResetAndDestroy(); |
|
1640 SetBlockResult(EFail); |
|
1641 dataOk = EFalse; |
|
1642 } |
|
1643 if(dataOk) |
|
1644 { |
|
1645 for (TInt j=0; j<volumeList.Count(); j++) |
|
1646 { |
|
1647 parVolume.Set(*volumeList[j]); |
|
1648 TLex lex(parVolume); |
|
1649 TInt error = lex.Val(volumeValue); |
|
1650 if (error != KErrNone) |
|
1651 { |
|
1652 ERR_PRINTF2(_L("Obtaining volume value failed with error %d"), error); |
|
1653 SetError(error); |
|
1654 volumeList.ResetAndDestroy(); |
|
1655 } |
|
1656 else |
|
1657 { |
|
1658 INFO_PRINTF3(_L("Setting volume number %d in the iteration number %d"), j, i); |
|
1659 iDevSound->SetVolume(volumeValue); |
|
1660 } |
|
1661 } |
|
1662 } |
|
1663 } |
|
1664 volumeList.ResetAndDestroy(); |
|
1665 } |
|
1666 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolumeLoop")); |
|
1667 } |
|
1668 |
|
1669 /** |
|
1670 * Defines the period over which the volume level is to rise smoothly from |
|
1671 * nothing to the normal volume level. |
|
1672 * The function is only available while the tone is playing. |
|
1673 * @param aSection - Section to read param from the ini file |
|
1674 * @return none |
|
1675 */ |
|
1676 void CT_CMMFDevSoundData::DoCmdSetVolumeRamp(const TTEFSectionName& aSection) |
|
1677 { |
|
1678 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolumeRamp")); |
|
1679 TInt tempValue=0; |
|
1680 TBool dataOk = ETrue; |
|
1681 if (!GetIntFromConfig(aSection, KRampDuration, tempValue)) |
|
1682 { |
|
1683 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRampDuration); |
|
1684 SetBlockResult(EFail); |
|
1685 dataOk = EFalse; |
|
1686 } |
|
1687 TTimeIntervalMicroSeconds rampDuration(tempValue); |
|
1688 |
|
1689 if(dataOk) |
|
1690 { |
|
1691 iDevSound->SetVolumeRamp(rampDuration); |
|
1692 } |
|
1693 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolumeRamp")); |
|
1694 } |
|
1695 |
|
1696 /** |
|
1697 * Initializes DevSound object for the mode aMode for processing audio data |
|
1698 * with hardware device aHWDev and supporting FourCC. |
|
1699 * Too Initializes CMMFDevSound object to play and record PCM16 raw audio data |
|
1700 * with sampling rate of 8 KHz. |
|
1701 * @param aSection - Section to read params from the ini file |
|
1702 */ |
|
1703 void CT_CMMFDevSoundData::DoCmdInitializeL(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
1704 { |
|
1705 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdInitializeL")); |
|
1706 TBool dataOk = ETrue; |
|
1707 TInt mode=0; |
|
1708 if (!GetEnumFromConfig(aSection, KMode, iEnumMode, mode)) |
|
1709 { |
|
1710 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMode); |
|
1711 SetBlockResult(EFail); |
|
1712 dataOk = EFalse; |
|
1713 } |
|
1714 else |
|
1715 { |
|
1716 TInt hwDeviceInt=0; |
|
1717 if (!GetHexFromConfig(aSection, KHwDevice, hwDeviceInt)) |
|
1718 { |
|
1719 INFO_PRINTF2(_L("%S parameter was not found in INI file"), &KHwDevice); |
|
1720 TPtrC fourCCIniString; |
|
1721 if (!GetStringFromConfig(aSection, KFourCC, fourCCIniString)) |
|
1722 { |
|
1723 INFO_PRINTF2(_L("%S parameter was not found in INI file"), &KFourCC); |
|
1724 if (dataOk) |
|
1725 { |
|
1726 INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TMMFState aMode)")); |
|
1727 TRAPD(error, iDevSound->InitializeL(*this, (TMMFState)mode)); |
|
1728 if(KErrNone != error) |
|
1729 { |
|
1730 ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, mode) left with error %d"), error); |
|
1731 SetError(error); |
|
1732 } |
|
1733 } |
|
1734 } |
|
1735 else |
|
1736 { |
|
1737 if (fourCCIniString.Length() > KTFourCC) |
|
1738 { |
|
1739 ERR_PRINTF2(_L("FourCC obtained from INI file exceeded the valid length in %d"), fourCCIniString.Length()); |
|
1740 SetBlockResult(EFail); |
|
1741 dataOk = EFalse; |
|
1742 } |
|
1743 if (dataOk) |
|
1744 { |
|
1745 TBuf<256> fourCCString; |
|
1746 fourCCString.Copy(fourCCIniString); |
|
1747 while (fourCCString.Length() < KTFourCC) |
|
1748 { |
|
1749 fourCCString.Insert(0, _L(" ")); |
|
1750 } |
|
1751 TFourCC fourCC; |
|
1752 fourCC = TFourCC(fourCCString[3] << 24 | fourCCString[2] << 16 | fourCCString[1] << 8 | fourCCString[0]); |
|
1753 INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode)")); |
|
1754 TRAPD(error, iDevSound->InitializeL(*this, fourCC, (TMMFState)mode)); |
|
1755 if(KErrNone!=error) |
|
1756 { |
|
1757 ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, fourCC, mode) left with error %d"), error); |
|
1758 ERR_PRINTF2(_L(" %S Not supported in this device"), &fourCCString); |
|
1759 SetError(error); |
|
1760 SetBlockResult(EFail); |
|
1761 } |
|
1762 } |
|
1763 } |
|
1764 } |
|
1765 else |
|
1766 { |
|
1767 if (dataOk) |
|
1768 { |
|
1769 TUid hwDevice; |
|
1770 hwDevice.iUid = hwDeviceInt; |
|
1771 INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TUid aHWDev, TMMFState aMode)")); |
|
1772 TRAPD(error, iDevSound->InitializeL(*this, hwDevice, (TMMFState)mode)); |
|
1773 if(KErrNone != error) |
|
1774 { |
|
1775 ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, hwDevice, mode) left with error %d"), error); |
|
1776 SetError(error); |
|
1777 } |
|
1778 } |
|
1779 } |
|
1780 } |
|
1781 |
|
1782 if (dataOk) |
|
1783 { |
|
1784 IncOutstanding(); |
|
1785 iInitializeErrorIndex = aAsyncErrorIndex; |
|
1786 } |
|
1787 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdInitializeL")); |
|
1788 } |
|
1789 |
|
1790 |
|
1791 /** |
|
1792 * Initializes the audio device and starts playing the DTMF string aDTMFString. |
|
1793 * @param aSection - Section to read param from the ini file |
|
1794 * @return none |
|
1795 */ |
|
1796 void CT_CMMFDevSoundData::DoCmdPlayDTMFStringL(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
1797 { |
|
1798 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayDTMFStringL")); |
|
1799 TBool dataOk = ETrue; |
|
1800 TPtrC dtmfString; |
|
1801 if (!GetStringFromConfig(aSection, KDTMFString, dtmfString) ) |
|
1802 { |
|
1803 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDTMFString); |
|
1804 SetBlockResult(EFail); |
|
1805 dataOk = EFalse; |
|
1806 } |
|
1807 if(dataOk) |
|
1808 { |
|
1809 TRAPD( error, iDevSound->PlayDTMFStringL(dtmfString) ); |
|
1810 if(error != KErrNone) |
|
1811 { |
|
1812 ERR_PRINTF2(_L("Play DTMF string failed with error: %d "), error); |
|
1813 SetError(error); |
|
1814 } |
|
1815 else |
|
1816 { |
|
1817 iToneErrorIndex = aAsyncErrorIndex; |
|
1818 IncOutstanding(); |
|
1819 } |
|
1820 } |
|
1821 |
|
1822 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayDTMFStringL")); |
|
1823 } |
|
1824 |
|
1825 /** |
|
1826 * Plays data in the buffer at the current volume. |
|
1827 * @param |
|
1828 * @return |
|
1829 */ |
|
1830 void CT_CMMFDevSoundData::DoCmdPlayData() |
|
1831 { |
|
1832 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayData")); |
|
1833 PlayData(); |
|
1834 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayData")); |
|
1835 } |
|
1836 |
|
1837 /** |
|
1838 * Helper for the DoCmdPlayData command |
|
1839 */ |
|
1840 void CT_CMMFDevSoundData::PlayData() |
|
1841 { |
|
1842 INFO_PRINTF1(_L("CT_CMMFDevSoundData::PlayData()")); |
|
1843 iDevSound->PlayData(); |
|
1844 } |
|
1845 |
|
1846 /** |
|
1847 * Initializes audio device and starts playing a dual tone. |
|
1848 * The generated tone consists of two sine waves of different frequencies summed together. |
|
1849 * Dual Tone is played with the specified frequencies and for the specified duration. |
|
1850 * @param aSection - Section to read params from the ini file. |
|
1851 * @return none |
|
1852 */ |
|
1853 void CT_CMMFDevSoundData::DoCmdPlayDualToneL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex) |
|
1854 { |
|
1855 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayDualToneL")); |
|
1856 TBool dataOk = ETrue; |
|
1857 TInt frequencyOne=0; |
|
1858 if (!GetIntFromConfig(aSection, KFrequencyOne, frequencyOne) ) |
|
1859 { |
|
1860 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequencyOne); |
|
1861 SetBlockResult(EFail); |
|
1862 dataOk = EFalse; |
|
1863 } |
|
1864 |
|
1865 TInt frequencyTwo=0; |
|
1866 if (!GetIntFromConfig(aSection, KFrequencyTwo, frequencyTwo) ) |
|
1867 { |
|
1868 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequencyTwo); |
|
1869 SetBlockResult(EFail); |
|
1870 dataOk = EFalse; |
|
1871 } |
|
1872 |
|
1873 TInt duration=0; |
|
1874 if (!GetIntFromConfig(aSection, KDuration, duration) ) |
|
1875 { |
|
1876 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDuration); |
|
1877 SetBlockResult(EFail); |
|
1878 dataOk = EFalse; |
|
1879 } |
|
1880 if(dataOk) |
|
1881 { |
|
1882 TRAPD( error, iDevSound->PlayDualToneL(frequencyOne, frequencyTwo, duration) ); |
|
1883 if(error != KErrNone) |
|
1884 { |
|
1885 ERR_PRINTF2(_L("Play dual tone failed with error %d"), error); |
|
1886 SetError(error); |
|
1887 } |
|
1888 else |
|
1889 { |
|
1890 iToneErrorIndex = aAsyncErrorIndex; |
|
1891 IncOutstanding(); |
|
1892 } |
|
1893 } |
|
1894 |
|
1895 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayDualToneL")); |
|
1896 } |
|
1897 |
|
1898 |
|
1899 /** |
|
1900 * Initializes the audio device and starts the play process. |
|
1901 * |
|
1902 * This function queries and acquires the audio policy before initializing audio device. If there was |
|
1903 * an error during policy initialization, PlayError() function will be called on the observer with |
|
1904 * error code KErrAccessDenied, otherwise BufferToBeFilled() function will be called with a buffer |
|
1905 * reference. After reading data into the buffer reference passed, the client should call PlayData() to play data. |
|
1906 * |
|
1907 * The amount of data that can be played is specified in CMMFBuffer::RequestSize(). Any data that is read into |
|
1908 * buffer beyond this size will be ignored. |
|
1909 * @param none |
|
1910 * @return none |
|
1911 */ |
|
1912 void CT_CMMFDevSoundData::DoCmdPlayInitL(const TInt aAsyncErrorIndex) |
|
1913 { |
|
1914 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayInitL")); |
|
1915 TRAPD(error, iDevSound->PlayInitL()); |
|
1916 if (error != KErrNone) |
|
1917 { |
|
1918 ERR_PRINTF2(_L("PlayInitL left with error %d"), error); |
|
1919 SetError(error); |
|
1920 } |
|
1921 else |
|
1922 { |
|
1923 iPlayErrorIndex = aAsyncErrorIndex; |
|
1924 IncOutstanding(); |
|
1925 } |
|
1926 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayInitL")); |
|
1927 } |
|
1928 |
|
1929 /** |
|
1930 * Initializes the audio device and starts playing a tone. The tone is played with the |
|
1931 * frequency and duration specified. |
|
1932 * @param aSection - Section to read params from the ini file |
|
1933 * @return none |
|
1934 */ |
|
1935 void CT_CMMFDevSoundData::DoCmdPlayToneL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex) |
|
1936 { |
|
1937 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayToneL")); |
|
1938 TBool dataOk = ETrue; |
|
1939 TInt frequency=0; |
|
1940 if (!GetIntFromConfig(aSection, KFrequency, frequency)) |
|
1941 { |
|
1942 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequency); |
|
1943 SetBlockResult(EFail); |
|
1944 dataOk = EFalse; |
|
1945 } |
|
1946 |
|
1947 TInt duration=0; |
|
1948 if (!GetIntFromConfig(aSection, KDuration, duration)) |
|
1949 { |
|
1950 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDuration); |
|
1951 SetBlockResult(EFail); |
|
1952 dataOk = EFalse; |
|
1953 } |
|
1954 if(dataOk) |
|
1955 { |
|
1956 TRAPD(error, iDevSound->PlayToneL(frequency, duration)); |
|
1957 if (error != KErrNone) |
|
1958 { |
|
1959 ERR_PRINTF2(_L("Play tone failed with error %d"), error); |
|
1960 SetError(error); |
|
1961 } |
|
1962 else |
|
1963 { |
|
1964 iToneErrorIndex = aAsyncErrorIndex; |
|
1965 IncOutstanding(); |
|
1966 } |
|
1967 } |
|
1968 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayToneL")); |
|
1969 } |
|
1970 |
|
1971 /** |
|
1972 * Initializes the audio device and starts playing a tone sequence. |
|
1973 * @param aSection - Section to read param from the ini file |
|
1974 * @return none |
|
1975 */ |
|
1976 void CT_CMMFDevSoundData::DoCmdPlayToneSequenceL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex) |
|
1977 { |
|
1978 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayToneSequenceL")); |
|
1979 TBool dataOk = ETrue; |
|
1980 TPtrC toneFileParameter; |
|
1981 if (!GetStringFromConfig(aSection, KFilename, toneFileParameter)) |
|
1982 { |
|
1983 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename); |
|
1984 SetBlockResult(EFail); |
|
1985 dataOk = EFalse; |
|
1986 } |
|
1987 if(dataOk) |
|
1988 { |
|
1989 TInt error = iToneFile.Open(iFs, toneFileParameter, EFileRead); |
|
1990 if (error != KErrNone) |
|
1991 { |
|
1992 ERR_PRINTF2(_L("Open file failed with error %d"), error); |
|
1993 SetError(EFail); |
|
1994 } |
|
1995 else |
|
1996 { |
|
1997 error = iToneFile.Read(iToneSequence); |
|
1998 if (error != KErrNone) |
|
1999 { |
|
2000 ERR_PRINTF2(_L("Read file failed with error %d"), error); |
|
2001 SetError(EFail); |
|
2002 } |
|
2003 else |
|
2004 { |
|
2005 TRAP(error, iDevSound->PlayToneSequenceL(iToneSequence)); |
|
2006 if (error != KErrNone) |
|
2007 { |
|
2008 ERR_PRINTF2(_L("Play tone sequence failed with error %d"), error); |
|
2009 SetError(error); |
|
2010 } |
|
2011 else |
|
2012 { |
|
2013 iToneErrorIndex = aAsyncErrorIndex; |
|
2014 IncOutstanding(); |
|
2015 } |
|
2016 } |
|
2017 } |
|
2018 } |
|
2019 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayToneSequenceL")); |
|
2020 } |
|
2021 |
|
2022 /** |
|
2023 * Contine the process of recording. |
|
2024 * |
|
2025 * Once the buffer is filled with recorded data, the Observer gets a reference to the buffer along |
|
2026 * with the callback function BufferToBeEmptied(). After processing the buffer (copying over to a |
|
2027 * different buffer or writing to file) the client should call this function to continue the |
|
2028 * recording process. |
|
2029 * @param none |
|
2030 * @return none |
|
2031 */ |
|
2032 void CT_CMMFDevSoundData::DoCmdRecordData() |
|
2033 { |
|
2034 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdRecordData")); |
|
2035 RecordData(); |
|
2036 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdRecordData")); |
|
2037 } |
|
2038 |
|
2039 /** |
|
2040 * Helper method to DoCmdRecordData command |
|
2041 */ |
|
2042 void CT_CMMFDevSoundData::RecordData() |
|
2043 { |
|
2044 iDevSound->RecordData(); |
|
2045 } |
|
2046 |
|
2047 /** |
|
2048 * Initializes audio device and starts the recording process. |
|
2049 * |
|
2050 * This command queries and acquires the audio policy before initializing audio device. If there |
|
2051 * was an error during policy initialization, RecordError() function will be called on the observer |
|
2052 * with error code KErrAccessDenied, otherwise BufferToBeEmptied() function will be called with a |
|
2053 * buffer reference. This buffer contains recorded or encoded data. After processing data in the |
|
2054 * buffer reference passed, the client should call RecordData() to continue recording process. |
|
2055 * |
|
2056 * The amount of data that is available is specified in CMMFBuffer::RequestSize(). |
|
2057 * @param none |
|
2058 * @return none |
|
2059 */ |
|
2060 void CT_CMMFDevSoundData::DoCmdRecordInitL(const TInt aAsyncErrorIndex) |
|
2061 { |
|
2062 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdRecordInitL")); |
|
2063 iRecordErrorIndex = aAsyncErrorIndex; |
|
2064 TRAPD(error, iDevSound->RecordInitL()); |
|
2065 if (error != KErrNone) |
|
2066 { |
|
2067 ERR_PRINTF2(_L("RecordInitL left with error %d"), error); |
|
2068 SetError(error); |
|
2069 } |
|
2070 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdRecordInitL")); |
|
2071 } |
|
2072 |
|
2073 |
|
2074 /** |
|
2075 * Conceal an error |
|
2076 * @param none |
|
2077 * @return none |
|
2078 */ |
|
2079 void CT_CMMFDevSoundData::DoCmdUtilityErrorConceal() |
|
2080 { |
|
2081 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdErrorConceal")); |
|
2082 iErrorConceal=ETrue; |
|
2083 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdErrorConceal")); |
|
2084 } |
|
2085 |
|
2086 /** |
|
2087 * Stop an audio file |
|
2088 * @param none |
|
2089 * @return none |
|
2090 */ |
|
2091 void CT_CMMFDevSoundData::DoCmdStop(const TTEFSectionName& aSection) |
|
2092 { |
|
2093 INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdStop")); |
|
2094 TBool pause; |
|
2095 if(!GetBoolFromConfig(aSection,KPause,pause)) |
|
2096 { |
|
2097 INFO_PRINTF1(_L("The DoCmdStop command will be execute")); |
|
2098 pause = EFalse; |
|
2099 } |
|
2100 iPaused=pause; |
|
2101 if(iPaused) |
|
2102 { |
|
2103 INFO_PRINTF1(_L("a Pause was required")); |
|
2104 } |
|
2105 Stop(); |
|
2106 INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdStop")); |
|
2107 } |
|
2108 |
|
2109 |
|
2110 |
|
2111 |
|
2112 /** |
|
2113 * Utility for get the HwDevice for play and recording |
|
2114 */ |
|
2115 |
|
2116 void CT_CMMFDevSoundData::UtilityFourCCToHwDeviceUidL(const TDesC& aFourCC, THwDeviceType aType, TUid& aHwDeviceUid) |
|
2117 { |
|
2118 TPtrC8 fourCCPtr(0,0); |
|
2119 TPtrC8 fourCCP16Ptr(0,0); |
|
2120 RImplInfoPtrArray impArray; |
|
2121 CleanupResetAndDestroyPushL(impArray); |
|
2122 REComSession::ListImplementationsL(TUid::Uid(KMmfUidPluginInterfaceHwDevice), impArray); |
|
2123 TBuf<KHwDeviceDefaultDataLength> datatype; |
|
2124 for(TInt i = 0; i < impArray.Count(); ++i) |
|
2125 { |
|
2126 CImplementationInformation& entry = *(impArray[i]); |
|
2127 // Validate lenght |
|
2128 if (entry.DataType().Length() == KHwDeviceDefaultDataLength) |
|
2129 { |
|
2130 INFO_PRINTF2(_L("Implementation UID=0x%08x"),entry.ImplementationUid()); |
|
2131 datatype.Copy(entry.DataType()); |
|
2132 INFO_PRINTF2(_L("Default data (fourCCs)=%S"), &datatype); |
|
2133 // Extract FourCC |
|
2134 if(aType == EDecoder) |
|
2135 { |
|
2136 fourCCPtr.Set(entry.DataType().Left(KFourCCLength)); |
|
2137 fourCCP16Ptr.Set(entry.DataType().Right(KFourCCLength)); |
|
2138 } |
|
2139 else if (aType == EEncoder) |
|
2140 { |
|
2141 fourCCPtr.Set(entry.DataType().Right(KFourCCLength)); |
|
2142 fourCCP16Ptr.Set(entry.DataType().Left(KFourCCLength)); |
|
2143 } |
|
2144 // Compare FourCC |
|
2145 TBuf16<4> foundFourCC; |
|
2146 foundFourCC.Copy(fourCCPtr); |
|
2147 if(aFourCC.CompareF(foundFourCC) == 0) |
|
2148 { |
|
2149 aHwDeviceUid = entry.ImplementationUid(); |
|
2150 break; |
|
2151 } |
|
2152 } |
|
2153 } |
|
2154 CleanupStack::PopAndDestroy(&impArray); |
|
2155 REComSession::FinalClose(); |
|
2156 } |