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