sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <mmf/common/mmfpaniccodes.h>
|
sl@0
|
17 |
|
sl@0
|
18 |
#include "mmfclienttoneplayer.h"
|
sl@0
|
19 |
using namespace ContentAccess;
|
sl@0
|
20 |
enum TMmfMdaAudioToneUtility
|
sl@0
|
21 |
{
|
sl@0
|
22 |
EBadArgument,
|
sl@0
|
23 |
EPostConditionViolation,
|
sl@0
|
24 |
EPlayStartedCalledWithError
|
sl@0
|
25 |
};
|
sl@0
|
26 |
|
sl@0
|
27 |
// declared in the recorder module
|
sl@0
|
28 |
void Panic(TInt aPanicCode);
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
Creates a new instance of the tone player utility.
|
sl@0
|
32 |
The default volume is set to MaxVolume() / 2.
|
sl@0
|
33 |
|
sl@0
|
34 |
@param aObserver
|
sl@0
|
35 |
A class to receive notifications from the tone player.
|
sl@0
|
36 |
@param aServer
|
sl@0
|
37 |
This parameter is no longer used and should be NULL.
|
sl@0
|
38 |
|
sl@0
|
39 |
@return A pointer to the new audio tone player utility object.
|
sl@0
|
40 |
|
sl@0
|
41 |
@since 5.0
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
EXPORT_C CMdaAudioToneUtility* CMdaAudioToneUtility::NewL(MMdaAudioToneObserver& aObserver, CMdaServer* aServer /*= NULL*/)
|
sl@0
|
44 |
{
|
sl@0
|
45 |
return CMdaAudioToneUtility::NewL(aObserver, aServer, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
/**
|
sl@0
|
49 |
Creates a new instance of the tone player utility.
|
sl@0
|
50 |
The default volume is set to MaxVolume() / 2.
|
sl@0
|
51 |
|
sl@0
|
52 |
@param aObserver
|
sl@0
|
53 |
A class to receive notifications from the tone player
|
sl@0
|
54 |
@param aServer
|
sl@0
|
55 |
This parameter is no longer used and should be NULL
|
sl@0
|
56 |
@param aPriority
|
sl@0
|
57 |
The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and
|
sl@0
|
58 |
EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request.
|
sl@0
|
59 |
@param aPref
|
sl@0
|
60 |
The Priority Preference - an additional audio policy parameter. The suggested default is
|
sl@0
|
61 |
EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional
|
sl@0
|
62 |
values may be supported by given phones and/or platforms, but should not be depended upon by
|
sl@0
|
63 |
portable code.
|
sl@0
|
64 |
|
sl@0
|
65 |
@return A pointer to the new audio tone player utility object.
|
sl@0
|
66 |
|
sl@0
|
67 |
@since 5.0
|
sl@0
|
68 |
|
sl@0
|
69 |
Note: The Priority Value and Priority Preference are used primarily when deciding what to do when
|
sl@0
|
70 |
several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference,
|
sl@0
|
71 |
the adaptation may consider other parameters such as the SecureId and Capabilities of the client process.
|
sl@0
|
72 |
Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may
|
sl@0
|
73 |
vary between different phones. Portable applications are advised not to assume any specific behaviour.
|
sl@0
|
74 |
*/
|
sl@0
|
75 |
EXPORT_C CMdaAudioToneUtility* CMdaAudioToneUtility::NewL(MMdaAudioToneObserver& aObserver, CMdaServer* /*aServer = NULL*/,
|
sl@0
|
76 |
TInt aPriority /*= EMdaPriorityNormal*/,
|
sl@0
|
77 |
TInt aPref /*= EMdaPriorityPreferenceTimeAndQuality*/)
|
sl@0
|
78 |
{
|
sl@0
|
79 |
CMdaAudioToneUtility* self = new(ELeave) CMdaAudioToneUtility();
|
sl@0
|
80 |
CleanupStack::PushL(self);
|
sl@0
|
81 |
self->iProperties = CMMFMdaAudioToneUtility::NewL(aObserver, NULL, aPriority, aPref);
|
sl@0
|
82 |
CleanupStack::Pop(); //self
|
sl@0
|
83 |
return self;
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
Destructor. Frees any resources held by the tone player
|
sl@0
|
88 |
|
sl@0
|
89 |
@since 5.0
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
CMdaAudioToneUtility::~CMdaAudioToneUtility()
|
sl@0
|
92 |
{
|
sl@0
|
93 |
delete iProperties;
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
/**
|
sl@0
|
97 |
Returns the current state of the audio tone utility.
|
sl@0
|
98 |
|
sl@0
|
99 |
@return The state of the audio tone utility.
|
sl@0
|
100 |
|
sl@0
|
101 |
@since 5.0
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
TMdaAudioToneUtilityState CMdaAudioToneUtility::State()
|
sl@0
|
104 |
{
|
sl@0
|
105 |
ASSERT(iProperties);
|
sl@0
|
106 |
return iProperties->State();
|
sl@0
|
107 |
}
|
sl@0
|
108 |
|
sl@0
|
109 |
/**
|
sl@0
|
110 |
Returns the maximum volume supported by the device. This is the maximum value which can be
|
sl@0
|
111 |
passed to CMdaAudioToneUtility::SetVolume().
|
sl@0
|
112 |
|
sl@0
|
113 |
@return The maximum volume. This value is platform dependent but is always greater than or equal to one.
|
sl@0
|
114 |
|
sl@0
|
115 |
@since 5.0
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
TInt CMdaAudioToneUtility::MaxVolume()
|
sl@0
|
118 |
{
|
sl@0
|
119 |
ASSERT(iProperties);
|
sl@0
|
120 |
return iProperties->MaxVolume();
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
/**
|
sl@0
|
124 |
Returns an integer representing the current volume of the audio device.
|
sl@0
|
125 |
|
sl@0
|
126 |
@return The current volume.
|
sl@0
|
127 |
|
sl@0
|
128 |
@since 5.0
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
TInt CMdaAudioToneUtility::Volume()
|
sl@0
|
131 |
{
|
sl@0
|
132 |
ASSERT(iProperties);
|
sl@0
|
133 |
return iProperties->Volume();
|
sl@0
|
134 |
}
|
sl@0
|
135 |
|
sl@0
|
136 |
/**
|
sl@0
|
137 |
Changes the volume of the audio device.
|
sl@0
|
138 |
|
sl@0
|
139 |
The volume can be changed before or during play and is effective
|
sl@0
|
140 |
immediately.
|
sl@0
|
141 |
|
sl@0
|
142 |
@param aVolume
|
sl@0
|
143 |
The volume setting. This can be any value from zero to
|
sl@0
|
144 |
the value returned by a call to
|
sl@0
|
145 |
CMdaAudioToneUtility::MaxVolume().
|
sl@0
|
146 |
Setting a zero value mutes the sound. Setting the
|
sl@0
|
147 |
maximum value results in the loudest possible sound.
|
sl@0
|
148 |
|
sl@0
|
149 |
@since 5.0
|
sl@0
|
150 |
*/
|
sl@0
|
151 |
void CMdaAudioToneUtility::SetVolume(TInt aVolume)
|
sl@0
|
152 |
{
|
sl@0
|
153 |
ASSERT(iProperties);
|
sl@0
|
154 |
iProperties->SetVolume(aVolume);
|
sl@0
|
155 |
}
|
sl@0
|
156 |
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
Changes the clients priority.
|
sl@0
|
159 |
|
sl@0
|
160 |
@param aPriority
|
sl@0
|
161 |
The Priority Value.
|
sl@0
|
162 |
@param aPref
|
sl@0
|
163 |
The Priority Preference.
|
sl@0
|
164 |
|
sl@0
|
165 |
@see CMdaAudioToneUtility::NewL()
|
sl@0
|
166 |
|
sl@0
|
167 |
@since 5.0
|
sl@0
|
168 |
|
sl@0
|
169 |
*/
|
sl@0
|
170 |
void CMdaAudioToneUtility::SetPriority(TInt aPriority, TInt aPref)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
ASSERT(iProperties);
|
sl@0
|
173 |
iProperties->SetPriority(aPriority, aPref);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
/**
|
sl@0
|
177 |
Changes the duration of DTMF tones, the gaps between DTMF tones and the
|
sl@0
|
178 |
pauses.
|
sl@0
|
179 |
|
sl@0
|
180 |
@param aToneLength
|
sl@0
|
181 |
The duration of the DTMF tone in microseconds.
|
sl@0
|
182 |
@param aToneOffLength
|
sl@0
|
183 |
The gap between DTFM tones in microseconds.
|
sl@0
|
184 |
@param aPauseLength
|
sl@0
|
185 |
Pauses in microseconds
|
sl@0
|
186 |
*/
|
sl@0
|
187 |
void CMdaAudioToneUtility::SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength,
|
sl@0
|
188 |
TTimeIntervalMicroSeconds32 aToneOffLength,
|
sl@0
|
189 |
TTimeIntervalMicroSeconds32 aPauseLength)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
ASSERT(iProperties);
|
sl@0
|
192 |
iProperties->SetDTMFLengths(aToneLength, aToneOffLength, aPauseLength);
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
/**
|
sl@0
|
196 |
Sets the number of times the tone sequence is to be repeated during
|
sl@0
|
197 |
the play operation.
|
sl@0
|
198 |
|
sl@0
|
199 |
A period of silence can follow each playing of the tone sequence. The
|
sl@0
|
200 |
tone sequence can be repeated indefinitely.
|
sl@0
|
201 |
|
sl@0
|
202 |
@param aRepeatNumberOfTimes
|
sl@0
|
203 |
The number of times the tone sequence, together with
|
sl@0
|
204 |
the trailing silence, is to be repeated. If this is
|
sl@0
|
205 |
set to KMdaRepeatForever, then the tone
|
sl@0
|
206 |
sequence, together with the trailing silence, is
|
sl@0
|
207 |
repeated indefinitely. The behaviour is undefined for values other than
|
sl@0
|
208 |
KMdaRepeatForever, zero and positive.
|
sl@0
|
209 |
@param aTrailingSilence
|
sl@0
|
210 |
The time interval of the training silence. The behaviour is undefined
|
sl@0
|
211 |
for values other than zero and positive.
|
sl@0
|
212 |
|
sl@0
|
213 |
@since 5.0
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
void CMdaAudioToneUtility::SetRepeats(TInt aRepeatNumberOfTimes,
|
sl@0
|
216 |
const TTimeIntervalMicroSeconds& aTrailingSilence)
|
sl@0
|
217 |
{
|
sl@0
|
218 |
ASSERT(iProperties);
|
sl@0
|
219 |
iProperties->SetRepeats(aRepeatNumberOfTimes, aTrailingSilence);
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
/**
|
sl@0
|
223 |
Defines the period over which the volume level is to rise smoothly
|
sl@0
|
224 |
from nothing to the normal volume level.
|
sl@0
|
225 |
|
sl@0
|
226 |
@param aRampDuration
|
sl@0
|
227 |
The period over which the volume is to rise. A zero
|
sl@0
|
228 |
value causes the tone to be played at the normal level
|
sl@0
|
229 |
for the full duration of the playback. A value which
|
sl@0
|
230 |
is longer than the duration of the tone sequence means
|
sl@0
|
231 |
that the tone never reaches its normal volume level.
|
sl@0
|
232 |
|
sl@0
|
233 |
@since 5.0
|
sl@0
|
234 |
*/
|
sl@0
|
235 |
void CMdaAudioToneUtility::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
|
sl@0
|
236 |
{
|
sl@0
|
237 |
ASSERT(iProperties);
|
sl@0
|
238 |
iProperties->SetVolumeRamp(aRampDuration);
|
sl@0
|
239 |
}
|
sl@0
|
240 |
|
sl@0
|
241 |
/**
|
sl@0
|
242 |
Returns the number of available pre-defined tone sequences.
|
sl@0
|
243 |
|
sl@0
|
244 |
@return The number of tone sequences. This value is implementation
|
sl@0
|
245 |
dependent but is always greater than or equal to zero.
|
sl@0
|
246 |
|
sl@0
|
247 |
@since 5.0
|
sl@0
|
248 |
*/
|
sl@0
|
249 |
TInt CMdaAudioToneUtility::FixedSequenceCount()
|
sl@0
|
250 |
{
|
sl@0
|
251 |
ASSERT(iProperties);
|
sl@0
|
252 |
return iProperties->FixedSequenceCount();
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
/**
|
sl@0
|
256 |
Returns the name assigned to a specific pre-defined tone sequence.
|
sl@0
|
257 |
|
sl@0
|
258 |
@param aSequenceNumber
|
sl@0
|
259 |
The index identifying the specific pre-defined tone sequence.
|
sl@0
|
260 |
Index values are relative to zero. This can be any value from
|
sl@0
|
261 |
zero to the value returned by a call to FixedSequenceCount() - 1.
|
sl@0
|
262 |
The function raises a panic if sequence number is not within this
|
sl@0
|
263 |
range.
|
sl@0
|
264 |
|
sl@0
|
265 |
@see CMMFDevSound::FixedSequenceName(TInt aSequenceNumber)
|
sl@0
|
266 |
@see FixedSequenceCount()
|
sl@0
|
267 |
|
sl@0
|
268 |
@return The name assigned to the tone sequence.
|
sl@0
|
269 |
|
sl@0
|
270 |
@since 5.0
|
sl@0
|
271 |
*/
|
sl@0
|
272 |
const TDesC& CMdaAudioToneUtility::FixedSequenceName(TInt aSequenceNumber)
|
sl@0
|
273 |
{
|
sl@0
|
274 |
ASSERT(iProperties);
|
sl@0
|
275 |
return iProperties->FixedSequenceName(aSequenceNumber);
|
sl@0
|
276 |
}
|
sl@0
|
277 |
|
sl@0
|
278 |
/**
|
sl@0
|
279 |
Configures the audio tone player utility to play a single tone.
|
sl@0
|
280 |
|
sl@0
|
281 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
282 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
283 |
called, indicating the success or failure of the configuration
|
sl@0
|
284 |
operation.The configuration operation can be cancelled by calling
|
sl@0
|
285 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
286 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
287 |
|
sl@0
|
288 |
@param aFrequency
|
sl@0
|
289 |
The frequency (pitch) of the tone in Hz.
|
sl@0
|
290 |
@param aDuration
|
sl@0
|
291 |
The duration of the tone in microseconds.
|
sl@0
|
292 |
@since 5.0
|
sl@0
|
293 |
*/
|
sl@0
|
294 |
void CMdaAudioToneUtility::PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
ASSERT(iProperties);
|
sl@0
|
297 |
iProperties->PrepareToPlayTone(aFrequency, aDuration);
|
sl@0
|
298 |
}
|
sl@0
|
299 |
|
sl@0
|
300 |
/**
|
sl@0
|
301 |
Configures the audio tone player utility to play a dual tone.
|
sl@0
|
302 |
The generated tone consists of two sine waves of different
|
sl@0
|
303 |
frequencies summed together.
|
sl@0
|
304 |
|
sl@0
|
305 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
306 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
307 |
called, indicating the success or failure of the configuration
|
sl@0
|
308 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
309 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
310 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
311 |
|
sl@0
|
312 |
@param aFrequencyOne
|
sl@0
|
313 |
The first frequency (pitch) of the tone.
|
sl@0
|
314 |
@param aFrequencyTwo
|
sl@0
|
315 |
The second frequency (pitch) of the tone.
|
sl@0
|
316 |
@param aDuration
|
sl@0
|
317 |
The duration of the tone in microseconds.
|
sl@0
|
318 |
|
sl@0
|
319 |
@since 7.0sy
|
sl@0
|
320 |
*/
|
sl@0
|
321 |
EXPORT_C void CMdaAudioToneUtility::PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
ASSERT(iProperties);
|
sl@0
|
324 |
iProperties->PrepareToPlayDualTone(aFrequencyOne, aFrequencyTwo, aDuration);
|
sl@0
|
325 |
}
|
sl@0
|
326 |
|
sl@0
|
327 |
/**
|
sl@0
|
328 |
Configures the audio tone utility player to play a DTMF (Dual-Tone
|
sl@0
|
329 |
Multi-Frequency) string.
|
sl@0
|
330 |
|
sl@0
|
331 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
332 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
333 |
called, indicating the success or failure of the configuration
|
sl@0
|
334 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
335 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
336 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
337 |
|
sl@0
|
338 |
@param aDTMF
|
sl@0
|
339 |
A descriptor containing the DTMF string.
|
sl@0
|
340 |
|
sl@0
|
341 |
@since 5.0
|
sl@0
|
342 |
*/
|
sl@0
|
343 |
void CMdaAudioToneUtility::PrepareToPlayDTMFString(const TDesC& aDTMF)
|
sl@0
|
344 |
{
|
sl@0
|
345 |
ASSERT(iProperties);
|
sl@0
|
346 |
iProperties->PrepareToPlayDTMFString(aDTMF);
|
sl@0
|
347 |
}
|
sl@0
|
348 |
|
sl@0
|
349 |
/**
|
sl@0
|
350 |
Configures the audio tone player utility to play a tone sequence
|
sl@0
|
351 |
contained in a descriptor.
|
sl@0
|
352 |
|
sl@0
|
353 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
354 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
355 |
called, indicating the success or failure of the configuration
|
sl@0
|
356 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
357 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
358 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
359 |
|
sl@0
|
360 |
@param aSequence
|
sl@0
|
361 |
The descriptor containing the tone sequence. The
|
sl@0
|
362 |
format of the data is unspecified but is expected to
|
sl@0
|
363 |
be platform dependent. A device might support more
|
sl@0
|
364 |
than one form of sequence data.
|
sl@0
|
365 |
|
sl@0
|
366 |
@since 5.0
|
sl@0
|
367 |
*/
|
sl@0
|
368 |
void CMdaAudioToneUtility::PrepareToPlayDesSequence(const TDesC8& aSequence)
|
sl@0
|
369 |
{
|
sl@0
|
370 |
ASSERT(iProperties);
|
sl@0
|
371 |
iProperties->PrepareToPlayDesSequence(aSequence);
|
sl@0
|
372 |
}
|
sl@0
|
373 |
|
sl@0
|
374 |
/**
|
sl@0
|
375 |
Configures the audio tone player utility to play a tone sequence
|
sl@0
|
376 |
contained in a file.
|
sl@0
|
377 |
|
sl@0
|
378 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
379 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
380 |
called, indicating the success or failure of the configuration
|
sl@0
|
381 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
382 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
383 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
384 |
|
sl@0
|
385 |
@param aFileName
|
sl@0
|
386 |
The full path name of the file containing the tone
|
sl@0
|
387 |
sequence. The format of the data is unspecified but is
|
sl@0
|
388 |
expected to be platform dependent. A device might
|
sl@0
|
389 |
support more than one form of sequence data.
|
sl@0
|
390 |
|
sl@0
|
391 |
@since 5.0
|
sl@0
|
392 |
*/
|
sl@0
|
393 |
void CMdaAudioToneUtility::PrepareToPlayFileSequence(const TDesC& aFileName)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
ASSERT(iProperties);
|
sl@0
|
396 |
iProperties->PrepareToPlayFileSequence(aFileName);
|
sl@0
|
397 |
}
|
sl@0
|
398 |
|
sl@0
|
399 |
/**
|
sl@0
|
400 |
Configures the audio tone player utility to play a tone sequence
|
sl@0
|
401 |
contained in a file.
|
sl@0
|
402 |
|
sl@0
|
403 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
404 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
405 |
called, indicating the success or failure of the configuration
|
sl@0
|
406 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
407 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
408 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
409 |
|
sl@0
|
410 |
@param aFile
|
sl@0
|
411 |
A handle to an open file containing the tone
|
sl@0
|
412 |
sequence. The format of the data is unspecified but is
|
sl@0
|
413 |
expected to be platform dependent. A device might
|
sl@0
|
414 |
support more than one form of sequence data.
|
sl@0
|
415 |
|
sl@0
|
416 |
@since 5.0
|
sl@0
|
417 |
*/
|
sl@0
|
418 |
EXPORT_C void CMdaAudioToneUtility::PrepareToPlayFileSequence(RFile& aFile)
|
sl@0
|
419 |
{
|
sl@0
|
420 |
ASSERT(iProperties);
|
sl@0
|
421 |
iProperties->PrepareToPlayFileSequence(aFile);
|
sl@0
|
422 |
}
|
sl@0
|
423 |
|
sl@0
|
424 |
|
sl@0
|
425 |
/**
|
sl@0
|
426 |
Configures the audio tone player utility to play the specified
|
sl@0
|
427 |
pre-defined tone sequence.
|
sl@0
|
428 |
|
sl@0
|
429 |
This function is asynchronous. On completion, the observer callback
|
sl@0
|
430 |
function MMdaAudioToneObserver::MatoPrepareComplete() is
|
sl@0
|
431 |
called, indicating the success or failure of the configuration
|
sl@0
|
432 |
operation. The configuration operation can be cancelled by calling
|
sl@0
|
433 |
CMdaAudioToneUtility::CancelPrepare(). The configuration
|
sl@0
|
434 |
operation cannot be started if a play operation is in progress.
|
sl@0
|
435 |
|
sl@0
|
436 |
@param aSequenceNumber
|
sl@0
|
437 |
An index into the set of pre-defined tone sequences.
|
sl@0
|
438 |
This can be any value from zero to the value returned by a
|
sl@0
|
439 |
call to FixedSequenceCount() - 1.
|
sl@0
|
440 |
If the sequence number is not within this range, a panic will be
|
sl@0
|
441 |
raised when Play() is called later.
|
sl@0
|
442 |
|
sl@0
|
443 |
@see FixedSequenceCount()
|
sl@0
|
444 |
@see CMMFDevSound::PlayFixedSequenceL(TInt aSequenceNumber)
|
sl@0
|
445 |
|
sl@0
|
446 |
@since 5.0
|
sl@0
|
447 |
*/
|
sl@0
|
448 |
void CMdaAudioToneUtility::PrepareToPlayFixedSequence(TInt aSequenceNumber)
|
sl@0
|
449 |
{
|
sl@0
|
450 |
ASSERT(iProperties);
|
sl@0
|
451 |
iProperties->PrepareToPlayFixedSequence(aSequenceNumber);
|
sl@0
|
452 |
}
|
sl@0
|
453 |
|
sl@0
|
454 |
/**
|
sl@0
|
455 |
Cancels the configuration operation.
|
sl@0
|
456 |
|
sl@0
|
457 |
The observer callback function
|
sl@0
|
458 |
MMdaAudioToneObserver::MatoPrepareComplete() is not
|
sl@0
|
459 |
called.
|
sl@0
|
460 |
|
sl@0
|
461 |
@since 5.0
|
sl@0
|
462 |
*/
|
sl@0
|
463 |
void CMdaAudioToneUtility::CancelPrepare()
|
sl@0
|
464 |
{
|
sl@0
|
465 |
ASSERT(iProperties);
|
sl@0
|
466 |
iProperties->CancelPrepare();
|
sl@0
|
467 |
}
|
sl@0
|
468 |
|
sl@0
|
469 |
/**
|
sl@0
|
470 |
Plays the tone.
|
sl@0
|
471 |
|
sl@0
|
472 |
The tone played depends on the current configuration.This function is
|
sl@0
|
473 |
asynchronous. On completion, the observer callback function
|
sl@0
|
474 |
MMdaAudioToneObserver::MatoPlayComplete() is called,
|
sl@0
|
475 |
indicating the success or failure of the play operation.The play
|
sl@0
|
476 |
operation can be cancelled by
|
sl@0
|
477 |
calling CMdaAudioToneUtility::CancelPlay().
|
sl@0
|
478 |
|
sl@0
|
479 |
@since 5.0
|
sl@0
|
480 |
*/
|
sl@0
|
481 |
void CMdaAudioToneUtility::Play()
|
sl@0
|
482 |
{
|
sl@0
|
483 |
ASSERT(iProperties);
|
sl@0
|
484 |
iProperties->Play();
|
sl@0
|
485 |
}
|
sl@0
|
486 |
|
sl@0
|
487 |
EXPORT_C TInt CMdaAudioToneUtility::Pause()
|
sl@0
|
488 |
{
|
sl@0
|
489 |
ASSERT(iProperties);
|
sl@0
|
490 |
return iProperties->Pause();
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
EXPORT_C TInt CMdaAudioToneUtility::Resume()
|
sl@0
|
494 |
{
|
sl@0
|
495 |
ASSERT(iProperties);
|
sl@0
|
496 |
return iProperties->Resume();
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
/**
|
sl@0
|
500 |
Cancels the tone playing operation.
|
sl@0
|
501 |
|
sl@0
|
502 |
The observer callback
|
sl@0
|
503 |
function MMdaAudioToneObserver::MatoPlayComplete() is not
|
sl@0
|
504 |
called.
|
sl@0
|
505 |
|
sl@0
|
506 |
@since 5.0
|
sl@0
|
507 |
*/
|
sl@0
|
508 |
void CMdaAudioToneUtility::CancelPlay()
|
sl@0
|
509 |
{
|
sl@0
|
510 |
ASSERT(iProperties);
|
sl@0
|
511 |
iProperties->CancelPlay();
|
sl@0
|
512 |
}
|
sl@0
|
513 |
|
sl@0
|
514 |
/**
|
sl@0
|
515 |
Sets the stereo balance for playback.
|
sl@0
|
516 |
|
sl@0
|
517 |
@param aBalance
|
sl@0
|
518 |
The balance. Should be between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.
|
sl@0
|
519 |
|
sl@0
|
520 |
@return An error code indicating if the function call was successful. KErrNone on success, otherwise
|
sl@0
|
521 |
another of the system-wide error codes.
|
sl@0
|
522 |
|
sl@0
|
523 |
@since 7.0s
|
sl@0
|
524 |
*/
|
sl@0
|
525 |
EXPORT_C void CMdaAudioToneUtility::SetBalanceL(TInt aBalance /*=KMMFBalanceCenter*/)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
ASSERT(iProperties);
|
sl@0
|
528 |
iProperties->SetBalanceL(aBalance);
|
sl@0
|
529 |
}
|
sl@0
|
530 |
|
sl@0
|
531 |
/**
|
sl@0
|
532 |
* Returns The current playback balance.This function may not return the same value
|
sl@0
|
533 |
* as passed to SetBalanceL depending on the internal implementation in
|
sl@0
|
534 |
* the underlying components.
|
sl@0
|
535 |
*
|
sl@0
|
536 |
* @return The balance. Should be between KMMFBalanceMaxLeft and KMMFBalanceMaxRight.
|
sl@0
|
537 |
*
|
sl@0
|
538 |
* @since 7.0s
|
sl@0
|
539 |
*/
|
sl@0
|
540 |
EXPORT_C TInt CMdaAudioToneUtility::GetBalanceL()
|
sl@0
|
541 |
{
|
sl@0
|
542 |
ASSERT(iProperties);
|
sl@0
|
543 |
return iProperties->GetBalanceL();
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
/**
|
sl@0
|
547 |
Retrieves a custom interface to the underlying device.
|
sl@0
|
548 |
|
sl@0
|
549 |
@param aInterfaceId
|
sl@0
|
550 |
The interface UID, defined with the custom interface.
|
sl@0
|
551 |
|
sl@0
|
552 |
@return A pointer to the interface implementation, or NULL if the device does not
|
sl@0
|
553 |
implement the interface requested. The return value must be cast to the
|
sl@0
|
554 |
correct type by the user.
|
sl@0
|
555 |
*/
|
sl@0
|
556 |
EXPORT_C TAny* CMdaAudioToneUtility::CustomInterface(TUid aInterfaceId)
|
sl@0
|
557 |
{
|
sl@0
|
558 |
ASSERT(iProperties);
|
sl@0
|
559 |
return iProperties->CustomInterface(aInterfaceId);
|
sl@0
|
560 |
}
|
sl@0
|
561 |
|
sl@0
|
562 |
EXPORT_C void CMdaAudioToneUtility::RegisterPlayStartCallback(MMdaAudioTonePlayStartObserver& aObserver)
|
sl@0
|
563 |
{
|
sl@0
|
564 |
ASSERT(iProperties);
|
sl@0
|
565 |
iProperties->RegisterPlayStartCallback(aObserver);
|
sl@0
|
566 |
}
|
sl@0
|
567 |
|
sl@0
|
568 |
|
sl@0
|
569 |
|
sl@0
|
570 |
CMMFMdaAudioToneUtility* CMMFMdaAudioToneUtility::NewL(MMdaAudioToneObserver& aObserver, CMdaServer* /*aServer = NULL*/,
|
sl@0
|
571 |
TInt aPriority /*= EMdaPriorityNormal*/,
|
sl@0
|
572 |
TInt aPref /*= EMdaPriorityPreferenceTimeAndQuality*/)
|
sl@0
|
573 |
|
sl@0
|
574 |
{
|
sl@0
|
575 |
CMMFMdaAudioToneUtility* self = new(ELeave) CMMFMdaAudioToneUtility(aObserver, aPriority, aPref);
|
sl@0
|
576 |
CleanupStack::PushL(self);
|
sl@0
|
577 |
self->ConstructL();
|
sl@0
|
578 |
CleanupStack::Pop(self);
|
sl@0
|
579 |
return self;
|
sl@0
|
580 |
}
|
sl@0
|
581 |
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
CMMFMdaAudioToneUtility::CMMFMdaAudioToneUtility(MMdaAudioToneObserver& aCallback, TInt aPriority, TInt aPref) :
|
sl@0
|
585 |
iCallback(aCallback)
|
sl@0
|
586 |
{
|
sl@0
|
587 |
iPrioritySettings.iPref = aPref;
|
sl@0
|
588 |
iPrioritySettings.iPriority = aPriority;
|
sl@0
|
589 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
590 |
iInitialized = EFalse;
|
sl@0
|
591 |
iPlayCalled = EFalse;
|
sl@0
|
592 |
|
sl@0
|
593 |
#ifdef _DEBUG
|
sl@0
|
594 |
iPlayCalledBeforeInitialized = EFalse;
|
sl@0
|
595 |
#endif
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
void CMMFMdaAudioToneUtility::ConstructL()
|
sl@0
|
599 |
{
|
sl@0
|
600 |
iAsyncCallback = CMMFMdaAudioToneObserverCallback::NewL(*this, *this);
|
sl@0
|
601 |
|
sl@0
|
602 |
iDevSound = CMMFDevSound::NewL();
|
sl@0
|
603 |
iDevSound->InitializeL(*this,EMMFStateTonePlaying);
|
sl@0
|
604 |
|
sl@0
|
605 |
// In some implementations InitializeComplete() returns in the InitializeL() context,
|
sl@0
|
606 |
// check the error
|
sl@0
|
607 |
User::LeaveIfError(iInitializeState);
|
sl@0
|
608 |
|
sl@0
|
609 |
iDevSound->SetPrioritySettings(iPrioritySettings);
|
sl@0
|
610 |
SetVolume(MaxVolume()/2 ); // set the volume to an intermediate value
|
sl@0
|
611 |
}
|
sl@0
|
612 |
|
sl@0
|
613 |
CMMFMdaAudioToneUtility::~CMMFMdaAudioToneUtility()
|
sl@0
|
614 |
{
|
sl@0
|
615 |
delete iDevSound;
|
sl@0
|
616 |
delete iAsyncCallback;
|
sl@0
|
617 |
delete iToneConfig;
|
sl@0
|
618 |
}
|
sl@0
|
619 |
|
sl@0
|
620 |
|
sl@0
|
621 |
|
sl@0
|
622 |
void CMMFMdaAudioToneUtility::InitializeComplete(TInt aError)
|
sl@0
|
623 |
{
|
sl@0
|
624 |
#ifdef _DEBUG
|
sl@0
|
625 |
__ASSERT_ALWAYS(!iPlayCalledBeforeInitialized, User::Panic(_L("PlayInitialized called before InitializeComplete"), 0));
|
sl@0
|
626 |
#endif
|
sl@0
|
627 |
iInitialized = ETrue;
|
sl@0
|
628 |
|
sl@0
|
629 |
if (iPlayCalled)
|
sl@0
|
630 |
{
|
sl@0
|
631 |
// Play() is called before InitializeComplete()
|
sl@0
|
632 |
if (aError == KErrNone)
|
sl@0
|
633 |
{
|
sl@0
|
634 |
PlayAfterInitialized();
|
sl@0
|
635 |
}
|
sl@0
|
636 |
else
|
sl@0
|
637 |
{
|
sl@0
|
638 |
// InitializeComplete() with error other than KErrNone
|
sl@0
|
639 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
640 |
iAsyncCallback->MatoPlayComplete(aError);
|
sl@0
|
641 |
}
|
sl@0
|
642 |
iPlayCalled = EFalse;
|
sl@0
|
643 |
}
|
sl@0
|
644 |
iInitializeState = aError;
|
sl@0
|
645 |
}
|
sl@0
|
646 |
|
sl@0
|
647 |
void CMMFMdaAudioToneUtility::ToneFinished(TInt aError)
|
sl@0
|
648 |
{
|
sl@0
|
649 |
if (aError != KErrCancel)
|
sl@0
|
650 |
{
|
sl@0
|
651 |
if (aError == KErrUnderflow)
|
sl@0
|
652 |
{
|
sl@0
|
653 |
aError = KErrNone;
|
sl@0
|
654 |
}
|
sl@0
|
655 |
|
sl@0
|
656 |
iAsyncCallback->MatoPlayComplete(aError);
|
sl@0
|
657 |
}
|
sl@0
|
658 |
// else don't want to callback after a cancel
|
sl@0
|
659 |
}
|
sl@0
|
660 |
|
sl@0
|
661 |
|
sl@0
|
662 |
TMdaAudioToneUtilityState CMMFMdaAudioToneUtility::State()
|
sl@0
|
663 |
{
|
sl@0
|
664 |
return iState;
|
sl@0
|
665 |
}
|
sl@0
|
666 |
|
sl@0
|
667 |
TInt CMMFMdaAudioToneUtility::MaxVolume()
|
sl@0
|
668 |
{
|
sl@0
|
669 |
return iDevSound->MaxVolume();
|
sl@0
|
670 |
}
|
sl@0
|
671 |
|
sl@0
|
672 |
TInt CMMFMdaAudioToneUtility::Volume()
|
sl@0
|
673 |
{
|
sl@0
|
674 |
return iDevSound->Volume();
|
sl@0
|
675 |
}
|
sl@0
|
676 |
|
sl@0
|
677 |
void CMMFMdaAudioToneUtility::SetVolume(TInt aVolume)
|
sl@0
|
678 |
{
|
sl@0
|
679 |
iDevSound->SetVolume(aVolume);
|
sl@0
|
680 |
}
|
sl@0
|
681 |
|
sl@0
|
682 |
void CMMFMdaAudioToneUtility::SetPriority(TInt aPriority, TInt aPref)
|
sl@0
|
683 |
{
|
sl@0
|
684 |
iPrioritySettings.iPref = aPref;
|
sl@0
|
685 |
iPrioritySettings.iPriority = aPriority;
|
sl@0
|
686 |
iDevSound->SetPrioritySettings(iPrioritySettings);
|
sl@0
|
687 |
}
|
sl@0
|
688 |
|
sl@0
|
689 |
void CMMFMdaAudioToneUtility::SetDTMFLengths(TTimeIntervalMicroSeconds32 aToneLength,
|
sl@0
|
690 |
TTimeIntervalMicroSeconds32 aToneOffLength,
|
sl@0
|
691 |
TTimeIntervalMicroSeconds32 aPauseLength)
|
sl@0
|
692 |
{
|
sl@0
|
693 |
iDevSound->SetDTMFLengths(aToneLength, aToneOffLength, aPauseLength);
|
sl@0
|
694 |
}
|
sl@0
|
695 |
|
sl@0
|
696 |
void CMMFMdaAudioToneUtility::SetRepeats(TInt aRepeatNumberOfTimes, const TTimeIntervalMicroSeconds& aTrailingSilence)
|
sl@0
|
697 |
{
|
sl@0
|
698 |
iDevSound->SetToneRepeats(aRepeatNumberOfTimes, aTrailingSilence);
|
sl@0
|
699 |
}
|
sl@0
|
700 |
|
sl@0
|
701 |
void CMMFMdaAudioToneUtility::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
|
sl@0
|
702 |
{
|
sl@0
|
703 |
iDevSound->SetVolumeRamp(aRampDuration);
|
sl@0
|
704 |
}
|
sl@0
|
705 |
|
sl@0
|
706 |
TInt CMMFMdaAudioToneUtility::FixedSequenceCount()
|
sl@0
|
707 |
{
|
sl@0
|
708 |
return iDevSound->FixedSequenceCount();
|
sl@0
|
709 |
}
|
sl@0
|
710 |
|
sl@0
|
711 |
const TDesC& CMMFMdaAudioToneUtility::FixedSequenceName(TInt aSequenceNumber)
|
sl@0
|
712 |
{
|
sl@0
|
713 |
return iDevSound->FixedSequenceName(aSequenceNumber);
|
sl@0
|
714 |
}
|
sl@0
|
715 |
|
sl@0
|
716 |
/**
|
sl@0
|
717 |
* CalculateBalance
|
sl@0
|
718 |
* @param aBalance
|
sl@0
|
719 |
* @param aLeft
|
sl@0
|
720 |
* @param aRight
|
sl@0
|
721 |
*
|
sl@0
|
722 |
* follows a simple straight line transformation
|
sl@0
|
723 |
* y = m x + c
|
sl@0
|
724 |
* m = (KMMFBalanceMaxLeft-KMMFBalanceMaxRight)/ 100
|
sl@0
|
725 |
* c = KMMFBalanceMaxRight
|
sl@0
|
726 |
* by substitution
|
sl@0
|
727 |
* when aLeft = 0
|
sl@0
|
728 |
* KMMFBalanceMaxRight = m * 0 + c
|
sl@0
|
729 |
* c = KMMFBalanceMaxRight
|
sl@0
|
730 |
* when aLeft = 100
|
sl@0
|
731 |
* KMMFBalanceMaxLeft = m * 100 + KMMFBalanceMaxRight
|
sl@0
|
732 |
* m = ( KMMFBalanceMaxLeft - KMMFBalanceMaxRight ) /100
|
sl@0
|
733 |
*/
|
sl@0
|
734 |
void CMMFMdaAudioToneUtility::CalculateBalance( TInt& aBalance, TInt aLeft, TInt aRight ) const
|
sl@0
|
735 |
{
|
sl@0
|
736 |
//[ assert pre conditions ]
|
sl@0
|
737 |
__ASSERT_ALWAYS( (( aLeft + aRight ) == 100 ), Panic( EBadArgument ));
|
sl@0
|
738 |
__ASSERT_ALWAYS( (( 0 <= aLeft) && ( 100 >= aLeft)), Panic( EBadArgument) );
|
sl@0
|
739 |
__ASSERT_ALWAYS( (( 0 <= aRight) && ( 100 >= aRight)), Panic( EBadArgument) );
|
sl@0
|
740 |
|
sl@0
|
741 |
aBalance = (aLeft * (KMMFBalanceMaxLeft-KMMFBalanceMaxRight))/100 + KMMFBalanceMaxRight;
|
sl@0
|
742 |
|
sl@0
|
743 |
//[ assert post condition that aBalance is within limits ]
|
sl@0
|
744 |
__ASSERT_ALWAYS( !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight), Panic(EBadArgument));
|
sl@0
|
745 |
|
sl@0
|
746 |
}
|
sl@0
|
747 |
|
sl@0
|
748 |
|
sl@0
|
749 |
/**
|
sl@0
|
750 |
* CalculateLeftRightBalance
|
sl@0
|
751 |
* @param aLeft
|
sl@0
|
752 |
* @param aRight
|
sl@0
|
753 |
* @param aBalance
|
sl@0
|
754 |
* Preconditions:
|
sl@0
|
755 |
* !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight)
|
sl@0
|
756 |
* y = m x + c
|
sl@0
|
757 |
* aLeft = m ( aBalance ) + c
|
sl@0
|
758 |
* when aBalance = KMMFBalanceMaxLeft aLeft = 100
|
sl@0
|
759 |
* when aBalance = KMMFBalanceMaxRight aLeft = 0
|
sl@0
|
760 |
* 100 = m( KMMFBalanceMaxLeft ) + c
|
sl@0
|
761 |
* 0 = m( KMMFBalanceMaxRight ) + c
|
sl@0
|
762 |
* c = -(KMMFBalanceMaxRight) m
|
sl@0
|
763 |
* 100 = m(KMMFBalanceMaxLeft ) - m(KMMFBalanceMaxRight)
|
sl@0
|
764 |
* m = 100/(KMMFBalanceMaxLeft - KMMFBalanceMaxRight )
|
sl@0
|
765 |
* c = -(KMMFBalanceMaxRight) * 100 /(KMMFBalanceMaxLeft - KMMFBalanceMaxRight )
|
sl@0
|
766 |
* aLeft = ( aBalance - KMMFBalanceMaxRight ) * 100 /( KMMFBalanceMaxLeft - KMMFBalanceMaxRight )
|
sl@0
|
767 |
*/
|
sl@0
|
768 |
void CMMFMdaAudioToneUtility::CalculateLeftRightBalance( TInt& aLeft, TInt& aRight, TInt aBalance ) const
|
sl@0
|
769 |
{
|
sl@0
|
770 |
// [ assert precondition that aBalance is within limits ]
|
sl@0
|
771 |
__ASSERT_ALWAYS( !(aBalance < KMMFBalanceMaxLeft || aBalance > KMMFBalanceMaxRight), Panic(EBadArgument));
|
sl@0
|
772 |
|
sl@0
|
773 |
//[ Now separate percentage balances out from aBalance ]
|
sl@0
|
774 |
aLeft = (100 * (aBalance-KMMFBalanceMaxRight)) / (KMMFBalanceMaxLeft-KMMFBalanceMaxRight);
|
sl@0
|
775 |
aRight = 100 - aLeft;
|
sl@0
|
776 |
|
sl@0
|
777 |
//[ assert post condition that left and right are within range ]
|
sl@0
|
778 |
__ASSERT_ALWAYS( ( (aLeft <= 100) && (aLeft >= 0) ), Panic(EPostConditionViolation));
|
sl@0
|
779 |
__ASSERT_ALWAYS( ( (aRight <= 100) && (aRight >= 0) ), Panic(EPostConditionViolation));
|
sl@0
|
780 |
}
|
sl@0
|
781 |
|
sl@0
|
782 |
|
sl@0
|
783 |
void CMMFMdaAudioToneUtility::SetBalanceL(TInt aBalance)
|
sl@0
|
784 |
{
|
sl@0
|
785 |
TInt left;
|
sl@0
|
786 |
TInt right;
|
sl@0
|
787 |
CalculateLeftRightBalance(left,right,aBalance);
|
sl@0
|
788 |
iDevSound->SetPlayBalanceL(left,right);
|
sl@0
|
789 |
}
|
sl@0
|
790 |
|
sl@0
|
791 |
TInt CMMFMdaAudioToneUtility::GetBalanceL()
|
sl@0
|
792 |
{
|
sl@0
|
793 |
TInt left;
|
sl@0
|
794 |
TInt right;
|
sl@0
|
795 |
TInt balance;
|
sl@0
|
796 |
iDevSound->GetPlayBalanceL(left, right);
|
sl@0
|
797 |
CalculateBalance(balance,left,right);
|
sl@0
|
798 |
return balance;
|
sl@0
|
799 |
}
|
sl@0
|
800 |
|
sl@0
|
801 |
void CMMFMdaAudioToneUtility::PrepareToPlayTone(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
802 |
{
|
sl@0
|
803 |
delete iToneConfig;
|
sl@0
|
804 |
iToneConfig = NULL;
|
sl@0
|
805 |
TRAPD(error, iToneConfig = CMMFSimpleToneConfig::NewL(aFrequency, aDuration));
|
sl@0
|
806 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
807 |
}
|
sl@0
|
808 |
|
sl@0
|
809 |
void CMMFMdaAudioToneUtility::PrepareToPlayDualTone(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
810 |
{
|
sl@0
|
811 |
delete iToneConfig;
|
sl@0
|
812 |
iToneConfig = NULL;
|
sl@0
|
813 |
TRAPD(error, iToneConfig = CMMFDualToneConfig::NewL(aFrequencyOne, aFrequencyTwo, aDuration));
|
sl@0
|
814 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
815 |
}
|
sl@0
|
816 |
|
sl@0
|
817 |
void CMMFMdaAudioToneUtility::PrepareToPlayDTMFString(const TDesC& aDTMF)
|
sl@0
|
818 |
{
|
sl@0
|
819 |
delete iToneConfig;
|
sl@0
|
820 |
iToneConfig = NULL;
|
sl@0
|
821 |
TRAPD(error, iToneConfig = CMMFDTMFStringToneConfig::NewL(aDTMF));
|
sl@0
|
822 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
823 |
}
|
sl@0
|
824 |
|
sl@0
|
825 |
void CMMFMdaAudioToneUtility::PrepareToPlayDesSequence(const TDesC8& aSequence)
|
sl@0
|
826 |
{
|
sl@0
|
827 |
delete iToneConfig;
|
sl@0
|
828 |
iToneConfig = NULL;
|
sl@0
|
829 |
TRAPD(error, iToneConfig = CMMFDesSeqToneConfig::NewL(aSequence));
|
sl@0
|
830 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
831 |
}
|
sl@0
|
832 |
|
sl@0
|
833 |
void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(const TDesC& aFileName)
|
sl@0
|
834 |
{
|
sl@0
|
835 |
delete iToneConfig;
|
sl@0
|
836 |
iToneConfig = NULL;
|
sl@0
|
837 |
TRAPD(error, iToneConfig = CMMFFileSeqToneConfig::NewL(aFileName));
|
sl@0
|
838 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
839 |
}
|
sl@0
|
840 |
|
sl@0
|
841 |
void CMMFMdaAudioToneUtility::PrepareToPlayFileSequence(RFile& aFileName)
|
sl@0
|
842 |
{
|
sl@0
|
843 |
delete iToneConfig;
|
sl@0
|
844 |
iToneConfig = NULL;
|
sl@0
|
845 |
TRAPD(error, iToneConfig = CMMFFileSeqToneConfig::NewL(aFileName));
|
sl@0
|
846 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
847 |
}
|
sl@0
|
848 |
|
sl@0
|
849 |
|
sl@0
|
850 |
|
sl@0
|
851 |
|
sl@0
|
852 |
void CMMFMdaAudioToneUtility::PrepareToPlayFixedSequence(TInt aSequenceNumber)
|
sl@0
|
853 |
{
|
sl@0
|
854 |
delete iToneConfig;
|
sl@0
|
855 |
iToneConfig = NULL;
|
sl@0
|
856 |
TRAPD(error, iToneConfig = CMMFFixedSeqToneConfig::NewL(aSequenceNumber));
|
sl@0
|
857 |
iSequenceNumber = aSequenceNumber;
|
sl@0
|
858 |
iAsyncCallback->MatoPrepareComplete(error);
|
sl@0
|
859 |
}
|
sl@0
|
860 |
|
sl@0
|
861 |
void CMMFMdaAudioToneUtility::CancelPrepare()
|
sl@0
|
862 |
{
|
sl@0
|
863 |
// xxx - do we need to cancel the callback? What if the callback is actually calling back another error? Probably best not to cancel...
|
sl@0
|
864 |
delete iToneConfig;
|
sl@0
|
865 |
iToneConfig = NULL;
|
sl@0
|
866 |
|
sl@0
|
867 |
if (iState == EMdaAudioToneUtilityPrepared)
|
sl@0
|
868 |
{
|
sl@0
|
869 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
870 |
}
|
sl@0
|
871 |
// Cancel the AO
|
sl@0
|
872 |
iAsyncCallback->Cancel();
|
sl@0
|
873 |
}
|
sl@0
|
874 |
|
sl@0
|
875 |
TInt CMMFMdaAudioToneUtility::Pause()
|
sl@0
|
876 |
{
|
sl@0
|
877 |
// Handle scenario when Pause is called before playback has started
|
sl@0
|
878 |
if (iState != EMdaAudioToneUtilityPlaying || (iState == EMdaAudioToneUtilityPlaying && !iInitialized))
|
sl@0
|
879 |
{
|
sl@0
|
880 |
return KErrNotReady;
|
sl@0
|
881 |
}
|
sl@0
|
882 |
|
sl@0
|
883 |
else if(! iDevSound->IsResumeSupported() || iToneConfig->Type() != CMMFToneConfig::EMmfToneTypeFileSeq)
|
sl@0
|
884 |
{
|
sl@0
|
885 |
return KErrNotSupported;
|
sl@0
|
886 |
}
|
sl@0
|
887 |
|
sl@0
|
888 |
iDevSound->Pause();
|
sl@0
|
889 |
iState = EMdaAudioToneUtilityPaused;
|
sl@0
|
890 |
return KErrNone;
|
sl@0
|
891 |
}
|
sl@0
|
892 |
|
sl@0
|
893 |
TInt CMMFMdaAudioToneUtility::Resume()
|
sl@0
|
894 |
{
|
sl@0
|
895 |
TInt err = KErrNone;
|
sl@0
|
896 |
if (iState != EMdaAudioToneUtilityPaused)
|
sl@0
|
897 |
{
|
sl@0
|
898 |
err = KErrNotReady;
|
sl@0
|
899 |
}
|
sl@0
|
900 |
|
sl@0
|
901 |
else if( iDevSound->IsResumeSupported() == EFalse || iToneConfig->Type() != CMMFToneConfig::EMmfToneTypeFileSeq)
|
sl@0
|
902 |
{
|
sl@0
|
903 |
err = KErrNotSupported;
|
sl@0
|
904 |
}
|
sl@0
|
905 |
|
sl@0
|
906 |
if(err == KErrNone)
|
sl@0
|
907 |
{
|
sl@0
|
908 |
err = iDevSound->Resume();
|
sl@0
|
909 |
if(err == KErrNone)
|
sl@0
|
910 |
{
|
sl@0
|
911 |
iState = EMdaAudioToneUtilityPlaying;
|
sl@0
|
912 |
}
|
sl@0
|
913 |
}
|
sl@0
|
914 |
return err;
|
sl@0
|
915 |
}
|
sl@0
|
916 |
|
sl@0
|
917 |
void CMMFMdaAudioToneUtility::Play()
|
sl@0
|
918 |
{
|
sl@0
|
919 |
TInt error = KErrNone;
|
sl@0
|
920 |
|
sl@0
|
921 |
if ((iState == EMdaAudioToneUtilityPlaying) || (iState == EMdaAudioToneUtilityPaused) || iPlayCalled)
|
sl@0
|
922 |
{
|
sl@0
|
923 |
error = KErrInUse;
|
sl@0
|
924 |
}
|
sl@0
|
925 |
|
sl@0
|
926 |
if (!error)
|
sl@0
|
927 |
{
|
sl@0
|
928 |
if (!iToneConfig)
|
sl@0
|
929 |
{
|
sl@0
|
930 |
TRAP(error, iToneConfig = CMMFFixedSeqToneConfig::NewL(iSequenceNumber));
|
sl@0
|
931 |
}
|
sl@0
|
932 |
}
|
sl@0
|
933 |
// If there was an error, notify the client now. Otherwise, client will be notified when
|
sl@0
|
934 |
// play has finished.
|
sl@0
|
935 |
if (error)
|
sl@0
|
936 |
{
|
sl@0
|
937 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
938 |
iAsyncCallback->MatoPlayComplete(error);
|
sl@0
|
939 |
}
|
sl@0
|
940 |
|
sl@0
|
941 |
if (!error)
|
sl@0
|
942 |
{
|
sl@0
|
943 |
iState = EMdaAudioToneUtilityPlaying;
|
sl@0
|
944 |
|
sl@0
|
945 |
if (iInitialized)
|
sl@0
|
946 |
{
|
sl@0
|
947 |
// Play() is called after InitializeComplete()
|
sl@0
|
948 |
if (iInitializeState)
|
sl@0
|
949 |
{
|
sl@0
|
950 |
// InitializeComplete() with error other than KErrNone
|
sl@0
|
951 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
952 |
iAsyncCallback->MatoPlayComplete(iInitializeState);
|
sl@0
|
953 |
}
|
sl@0
|
954 |
else
|
sl@0
|
955 |
{
|
sl@0
|
956 |
PlayAfterInitialized();
|
sl@0
|
957 |
}
|
sl@0
|
958 |
}
|
sl@0
|
959 |
else
|
sl@0
|
960 |
{
|
sl@0
|
961 |
// Play() is called before InitializeComplete()
|
sl@0
|
962 |
iPlayCalled = ETrue;
|
sl@0
|
963 |
}
|
sl@0
|
964 |
}
|
sl@0
|
965 |
}
|
sl@0
|
966 |
|
sl@0
|
967 |
void CMMFMdaAudioToneUtility::PlayAfterInitialized()
|
sl@0
|
968 |
{
|
sl@0
|
969 |
#ifdef _DEBUG
|
sl@0
|
970 |
if (iInitialized == EFalse)
|
sl@0
|
971 |
{
|
sl@0
|
972 |
iPlayCalledBeforeInitialized = ETrue;
|
sl@0
|
973 |
}
|
sl@0
|
974 |
#endif
|
sl@0
|
975 |
|
sl@0
|
976 |
TInt error = KErrNone;
|
sl@0
|
977 |
switch (iToneConfig->Type())
|
sl@0
|
978 |
{
|
sl@0
|
979 |
case CMMFToneConfig::EMmfToneTypeSimple:
|
sl@0
|
980 |
{
|
sl@0
|
981 |
CMMFSimpleToneConfig* c = STATIC_CAST(CMMFSimpleToneConfig*, iToneConfig);
|
sl@0
|
982 |
TRAP(error, iDevSound->PlayToneL(c->Frequency(), c->Duration()));
|
sl@0
|
983 |
break;
|
sl@0
|
984 |
}
|
sl@0
|
985 |
case CMMFToneConfig::EMmfToneTypeDual:
|
sl@0
|
986 |
{
|
sl@0
|
987 |
CMMFDualToneConfig* c = STATIC_CAST(CMMFDualToneConfig*, iToneConfig);
|
sl@0
|
988 |
TRAP(error, iDevSound->PlayDualToneL(c->FrequencyOne(), c->FrequencyTwo(), c->Duration()));
|
sl@0
|
989 |
break;
|
sl@0
|
990 |
}
|
sl@0
|
991 |
case CMMFToneConfig::EMmfToneTypeDTMF:
|
sl@0
|
992 |
{
|
sl@0
|
993 |
CMMFDTMFStringToneConfig* c = STATIC_CAST(CMMFDTMFStringToneConfig*, iToneConfig);
|
sl@0
|
994 |
TRAP(error, iDevSound->PlayDTMFStringL(c->DTMF()));
|
sl@0
|
995 |
break;
|
sl@0
|
996 |
}
|
sl@0
|
997 |
case CMMFToneConfig::EMmfToneTypeDesSeq:
|
sl@0
|
998 |
{
|
sl@0
|
999 |
CMMFDesSeqToneConfig* c = STATIC_CAST(CMMFDesSeqToneConfig*, iToneConfig);
|
sl@0
|
1000 |
TRAP(error, iDevSound->PlayToneSequenceL(c->DesSeq()));
|
sl@0
|
1001 |
break;
|
sl@0
|
1002 |
}
|
sl@0
|
1003 |
case CMMFToneConfig::EMmfToneTypeFileSeq:
|
sl@0
|
1004 |
{
|
sl@0
|
1005 |
CMMFFileSeqToneConfig* c = STATIC_CAST(CMMFFileSeqToneConfig*, iToneConfig);
|
sl@0
|
1006 |
|
sl@0
|
1007 |
// check we have rights to play
|
sl@0
|
1008 |
TRAP(error, c->ExecuteIntentL());
|
sl@0
|
1009 |
|
sl@0
|
1010 |
// if we have rights then go ahead and play
|
sl@0
|
1011 |
if (error == KErrNone)
|
sl@0
|
1012 |
{
|
sl@0
|
1013 |
TRAP(error, iDevSound->PlayToneSequenceL(c->FileSeq()));
|
sl@0
|
1014 |
}
|
sl@0
|
1015 |
|
sl@0
|
1016 |
break;
|
sl@0
|
1017 |
}
|
sl@0
|
1018 |
case CMMFToneConfig::EMmfToneTypeFixedSeq:
|
sl@0
|
1019 |
{
|
sl@0
|
1020 |
CMMFFixedSeqToneConfig* c = STATIC_CAST(CMMFFixedSeqToneConfig*, iToneConfig);
|
sl@0
|
1021 |
TRAP(error, iDevSound->PlayFixedSequenceL(c->SequenceNumber()));
|
sl@0
|
1022 |
break;
|
sl@0
|
1023 |
}
|
sl@0
|
1024 |
default:
|
sl@0
|
1025 |
{
|
sl@0
|
1026 |
User::Panic(KMMFMdaAudioToneUtilityPanicCategory, EMMFMdaAudioToneUtilityBadToneConfig);
|
sl@0
|
1027 |
break;
|
sl@0
|
1028 |
}
|
sl@0
|
1029 |
}
|
sl@0
|
1030 |
|
sl@0
|
1031 |
// If there was an error, notify the client now. Otherwise, client will be notified when
|
sl@0
|
1032 |
// play has finished.
|
sl@0
|
1033 |
if (error)
|
sl@0
|
1034 |
{
|
sl@0
|
1035 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
1036 |
iAsyncCallback->MatoPlayComplete(error);
|
sl@0
|
1037 |
}
|
sl@0
|
1038 |
else
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
if(iPlayStartObserver)
|
sl@0
|
1041 |
{
|
sl@0
|
1042 |
iAsyncCallback->MatoPlayStarted(KErrNone);
|
sl@0
|
1043 |
}
|
sl@0
|
1044 |
}
|
sl@0
|
1045 |
}
|
sl@0
|
1046 |
|
sl@0
|
1047 |
void CMMFMdaAudioToneUtility::CancelPlay()
|
sl@0
|
1048 |
{
|
sl@0
|
1049 |
iDevSound->Stop();
|
sl@0
|
1050 |
|
sl@0
|
1051 |
if(iState == EMdaAudioToneUtilityPlaying || iState == EMdaAudioToneUtilityPaused)
|
sl@0
|
1052 |
{
|
sl@0
|
1053 |
iState = EMdaAudioToneUtilityPrepared;
|
sl@0
|
1054 |
}
|
sl@0
|
1055 |
// Cancel the AO
|
sl@0
|
1056 |
iAsyncCallback->Cancel();
|
sl@0
|
1057 |
iPlayCalled = EFalse;
|
sl@0
|
1058 |
}
|
sl@0
|
1059 |
|
sl@0
|
1060 |
|
sl@0
|
1061 |
void CMMFMdaAudioToneUtility::SendEventToClient(const TMMFEvent& /*aEvent*/)
|
sl@0
|
1062 |
{
|
sl@0
|
1063 |
if(iState == EMdaAudioToneUtilityPlaying)
|
sl@0
|
1064 |
{
|
sl@0
|
1065 |
iState = EMdaAudioToneUtilityPrepared;
|
sl@0
|
1066 |
}
|
sl@0
|
1067 |
|
sl@0
|
1068 |
iAsyncCallback->MatoPlayComplete(KErrInUse);
|
sl@0
|
1069 |
}
|
sl@0
|
1070 |
|
sl@0
|
1071 |
|
sl@0
|
1072 |
void CMMFMdaAudioToneUtility::RegisterPlayStartCallback(MMdaAudioTonePlayStartObserver& aObserver)
|
sl@0
|
1073 |
{
|
sl@0
|
1074 |
iPlayStartObserver = &aObserver;
|
sl@0
|
1075 |
}
|
sl@0
|
1076 |
|
sl@0
|
1077 |
void CMMFMdaAudioToneUtility::MatoPrepareComplete(TInt aError)
|
sl@0
|
1078 |
{
|
sl@0
|
1079 |
if (!aError)
|
sl@0
|
1080 |
{
|
sl@0
|
1081 |
iState = EMdaAudioToneUtilityPrepared;
|
sl@0
|
1082 |
}
|
sl@0
|
1083 |
else
|
sl@0
|
1084 |
{
|
sl@0
|
1085 |
iState = EMdaAudioToneUtilityNotReady;
|
sl@0
|
1086 |
}
|
sl@0
|
1087 |
|
sl@0
|
1088 |
iCallback.MatoPrepareComplete(aError);
|
sl@0
|
1089 |
}
|
sl@0
|
1090 |
|
sl@0
|
1091 |
void CMMFMdaAudioToneUtility::MatoPlayComplete(TInt aError)
|
sl@0
|
1092 |
{
|
sl@0
|
1093 |
iState = EMdaAudioToneUtilityPrepared;
|
sl@0
|
1094 |
iCallback.MatoPlayComplete(aError);
|
sl@0
|
1095 |
}
|
sl@0
|
1096 |
|
sl@0
|
1097 |
void CMMFMdaAudioToneUtility::MatoPlayStarted(TInt aError)
|
sl@0
|
1098 |
{
|
sl@0
|
1099 |
__ASSERT_DEBUG(aError==KErrNone, Panic(EPlayStartedCalledWithError));
|
sl@0
|
1100 |
|
sl@0
|
1101 |
// Not always there is an observer registered
|
sl@0
|
1102 |
if(iPlayStartObserver)
|
sl@0
|
1103 |
{
|
sl@0
|
1104 |
iPlayStartObserver->MatoPlayStarted(aError);
|
sl@0
|
1105 |
}
|
sl@0
|
1106 |
}
|
sl@0
|
1107 |
|
sl@0
|
1108 |
// CustomInferface - just pass on to DevSound.
|
sl@0
|
1109 |
TAny* CMMFMdaAudioToneUtility::CustomInterface(TUid aInterfaceId)
|
sl@0
|
1110 |
{
|
sl@0
|
1111 |
return iDevSound->CustomInterface(aInterfaceId);
|
sl@0
|
1112 |
}
|
sl@0
|
1113 |
|
sl@0
|
1114 |
|
sl@0
|
1115 |
CMMFMdaAudioToneObserverCallback* CMMFMdaAudioToneObserverCallback::NewL(MMdaAudioToneObserver& aCallback, MMdaAudioTonePlayStartObserver& aPlayStartCallback)
|
sl@0
|
1116 |
{
|
sl@0
|
1117 |
return new(ELeave) CMMFMdaAudioToneObserverCallback(aCallback, aPlayStartCallback);
|
sl@0
|
1118 |
}
|
sl@0
|
1119 |
|
sl@0
|
1120 |
CMMFMdaAudioToneObserverCallback::CMMFMdaAudioToneObserverCallback(MMdaAudioToneObserver& aCallback, MMdaAudioTonePlayStartObserver& aPlayStartCallback) :
|
sl@0
|
1121 |
CActive(CActive::EPriorityHigh),
|
sl@0
|
1122 |
iCallback(aCallback),
|
sl@0
|
1123 |
iPlayStartCallback(aPlayStartCallback)
|
sl@0
|
1124 |
{
|
sl@0
|
1125 |
CActiveScheduler::Add(this);
|
sl@0
|
1126 |
}
|
sl@0
|
1127 |
|
sl@0
|
1128 |
CMMFMdaAudioToneObserverCallback::~CMMFMdaAudioToneObserverCallback()
|
sl@0
|
1129 |
{
|
sl@0
|
1130 |
Cancel();
|
sl@0
|
1131 |
}
|
sl@0
|
1132 |
|
sl@0
|
1133 |
void CMMFMdaAudioToneObserverCallback::MatoPrepareComplete(TInt aError)
|
sl@0
|
1134 |
{
|
sl@0
|
1135 |
if(!IsActive())
|
sl@0
|
1136 |
{
|
sl@0
|
1137 |
iAction = EPrepareComplete;
|
sl@0
|
1138 |
iErrorCode = aError;
|
sl@0
|
1139 |
|
sl@0
|
1140 |
TRequestStatus* s = &iStatus;
|
sl@0
|
1141 |
SetActive();
|
sl@0
|
1142 |
User::RequestComplete(s, KErrNone);
|
sl@0
|
1143 |
}
|
sl@0
|
1144 |
else
|
sl@0
|
1145 |
{
|
sl@0
|
1146 |
// Since the default granularity is 8, failing of Append() is unusual, hence ignoring the return err.
|
sl@0
|
1147 |
iCallBackQueue.Append(EPrepareComplete);
|
sl@0
|
1148 |
iCallBackQueueError.Append(aError);
|
sl@0
|
1149 |
}
|
sl@0
|
1150 |
}
|
sl@0
|
1151 |
|
sl@0
|
1152 |
void CMMFMdaAudioToneObserverCallback::MatoPlayComplete(TInt aError)
|
sl@0
|
1153 |
{
|
sl@0
|
1154 |
if(!IsActive())
|
sl@0
|
1155 |
{
|
sl@0
|
1156 |
iAction = EPlayComplete;
|
sl@0
|
1157 |
iErrorCode = aError;
|
sl@0
|
1158 |
|
sl@0
|
1159 |
TRequestStatus* s = &iStatus;
|
sl@0
|
1160 |
SetActive();
|
sl@0
|
1161 |
User::RequestComplete(s, KErrNone);
|
sl@0
|
1162 |
}
|
sl@0
|
1163 |
else
|
sl@0
|
1164 |
{
|
sl@0
|
1165 |
iCallBackQueue.Append(EPlayComplete);
|
sl@0
|
1166 |
iCallBackQueueError.Append(aError);
|
sl@0
|
1167 |
}
|
sl@0
|
1168 |
}
|
sl@0
|
1169 |
|
sl@0
|
1170 |
void CMMFMdaAudioToneObserverCallback::MatoPlayStarted(TInt aError)
|
sl@0
|
1171 |
{
|
sl@0
|
1172 |
if(!IsActive())
|
sl@0
|
1173 |
{
|
sl@0
|
1174 |
iAction = EPlayStarted;
|
sl@0
|
1175 |
iErrorCode = aError;
|
sl@0
|
1176 |
|
sl@0
|
1177 |
TRequestStatus* s = &iStatus;
|
sl@0
|
1178 |
SetActive();
|
sl@0
|
1179 |
User::RequestComplete(s, KErrNone);
|
sl@0
|
1180 |
}
|
sl@0
|
1181 |
else
|
sl@0
|
1182 |
{
|
sl@0
|
1183 |
iCallBackQueue.Append(EPlayStarted);
|
sl@0
|
1184 |
iCallBackQueueError.Append(aError);
|
sl@0
|
1185 |
}
|
sl@0
|
1186 |
}
|
sl@0
|
1187 |
|
sl@0
|
1188 |
void CMMFMdaAudioToneObserverCallback::RunL()
|
sl@0
|
1189 |
{
|
sl@0
|
1190 |
switch (iAction)
|
sl@0
|
1191 |
{
|
sl@0
|
1192 |
case EPrepareComplete:
|
sl@0
|
1193 |
{
|
sl@0
|
1194 |
iCallback.MatoPrepareComplete(iErrorCode);
|
sl@0
|
1195 |
break;
|
sl@0
|
1196 |
}
|
sl@0
|
1197 |
case EPlayComplete:
|
sl@0
|
1198 |
{
|
sl@0
|
1199 |
iCallback.MatoPlayComplete(iErrorCode);
|
sl@0
|
1200 |
break;
|
sl@0
|
1201 |
}
|
sl@0
|
1202 |
case EPlayStarted:
|
sl@0
|
1203 |
iPlayStartCallback.MatoPlayStarted(iErrorCode);
|
sl@0
|
1204 |
break;
|
sl@0
|
1205 |
}
|
sl@0
|
1206 |
if(iCallBackQueue.Count() > 0 & !IsActive() )
|
sl@0
|
1207 |
{
|
sl@0
|
1208 |
iAction = TMMFAudioToneObserverCallbackAction(iCallBackQueue[0]);
|
sl@0
|
1209 |
iCallBackQueue.Remove(0);
|
sl@0
|
1210 |
iErrorCode = iCallBackQueueError[0];
|
sl@0
|
1211 |
iCallBackQueueError.Remove(0);
|
sl@0
|
1212 |
|
sl@0
|
1213 |
TRequestStatus* s = &iStatus;
|
sl@0
|
1214 |
User::RequestComplete(s, KErrNone);
|
sl@0
|
1215 |
SetActive();
|
sl@0
|
1216 |
}
|
sl@0
|
1217 |
}
|
sl@0
|
1218 |
|
sl@0
|
1219 |
void CMMFMdaAudioToneObserverCallback::DoCancel()
|
sl@0
|
1220 |
{
|
sl@0
|
1221 |
//nothing to cancel
|
sl@0
|
1222 |
}
|
sl@0
|
1223 |
|
sl@0
|
1224 |
|
sl@0
|
1225 |
|
sl@0
|
1226 |
|
sl@0
|
1227 |
|
sl@0
|
1228 |
|
sl@0
|
1229 |
// Tone config classes
|
sl@0
|
1230 |
|
sl@0
|
1231 |
// Simple Tone
|
sl@0
|
1232 |
CMMFToneConfig* CMMFSimpleToneConfig::NewL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
1233 |
{
|
sl@0
|
1234 |
return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFSimpleToneConfig(aFrequency, aDuration));
|
sl@0
|
1235 |
}
|
sl@0
|
1236 |
|
sl@0
|
1237 |
CMMFSimpleToneConfig::CMMFSimpleToneConfig(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration) :
|
sl@0
|
1238 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeSimple),
|
sl@0
|
1239 |
iFrequency(aFrequency),
|
sl@0
|
1240 |
iDuration(aDuration)
|
sl@0
|
1241 |
{
|
sl@0
|
1242 |
}
|
sl@0
|
1243 |
|
sl@0
|
1244 |
CMMFSimpleToneConfig::~CMMFSimpleToneConfig()
|
sl@0
|
1245 |
{
|
sl@0
|
1246 |
}
|
sl@0
|
1247 |
|
sl@0
|
1248 |
TInt CMMFSimpleToneConfig::Frequency()
|
sl@0
|
1249 |
{
|
sl@0
|
1250 |
return iFrequency;
|
sl@0
|
1251 |
}
|
sl@0
|
1252 |
|
sl@0
|
1253 |
const TTimeIntervalMicroSeconds& CMMFSimpleToneConfig::Duration()
|
sl@0
|
1254 |
{
|
sl@0
|
1255 |
return iDuration;
|
sl@0
|
1256 |
}
|
sl@0
|
1257 |
|
sl@0
|
1258 |
|
sl@0
|
1259 |
// Dual Tone
|
sl@0
|
1260 |
CMMFToneConfig* CMMFDualToneConfig::NewL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
1261 |
{
|
sl@0
|
1262 |
return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFDualToneConfig(aFrequencyOne, aFrequencyTwo, aDuration));
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
|
sl@0
|
1265 |
CMMFDualToneConfig::CMMFDualToneConfig(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration) :
|
sl@0
|
1266 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDual),
|
sl@0
|
1267 |
iFrequencyOne(aFrequencyOne),
|
sl@0
|
1268 |
iFrequencyTwo(aFrequencyTwo),
|
sl@0
|
1269 |
iDuration(aDuration)
|
sl@0
|
1270 |
{
|
sl@0
|
1271 |
}
|
sl@0
|
1272 |
|
sl@0
|
1273 |
CMMFDualToneConfig::~CMMFDualToneConfig()
|
sl@0
|
1274 |
{
|
sl@0
|
1275 |
}
|
sl@0
|
1276 |
|
sl@0
|
1277 |
TInt CMMFDualToneConfig::FrequencyOne()
|
sl@0
|
1278 |
{
|
sl@0
|
1279 |
return iFrequencyOne;
|
sl@0
|
1280 |
}
|
sl@0
|
1281 |
|
sl@0
|
1282 |
TInt CMMFDualToneConfig::FrequencyTwo()
|
sl@0
|
1283 |
{
|
sl@0
|
1284 |
return iFrequencyTwo;
|
sl@0
|
1285 |
}
|
sl@0
|
1286 |
|
sl@0
|
1287 |
const TTimeIntervalMicroSeconds& CMMFDualToneConfig::Duration()
|
sl@0
|
1288 |
{
|
sl@0
|
1289 |
return iDuration;
|
sl@0
|
1290 |
}
|
sl@0
|
1291 |
|
sl@0
|
1292 |
|
sl@0
|
1293 |
CMMFToneConfig* CMMFDTMFStringToneConfig::NewL(const TDesC& aDTMF)
|
sl@0
|
1294 |
{
|
sl@0
|
1295 |
CMMFDTMFStringToneConfig* s = new(ELeave) CMMFDTMFStringToneConfig;
|
sl@0
|
1296 |
CleanupStack::PushL(s);
|
sl@0
|
1297 |
s->ConstructL(aDTMF);
|
sl@0
|
1298 |
CleanupStack::Pop();
|
sl@0
|
1299 |
return STATIC_CAST(CMMFToneConfig*, s);
|
sl@0
|
1300 |
}
|
sl@0
|
1301 |
|
sl@0
|
1302 |
CMMFDTMFStringToneConfig::CMMFDTMFStringToneConfig() :
|
sl@0
|
1303 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDTMF)
|
sl@0
|
1304 |
{
|
sl@0
|
1305 |
}
|
sl@0
|
1306 |
|
sl@0
|
1307 |
LOCAL_C void validateDTMFL(const TDesC& aDTMF)
|
sl@0
|
1308 |
//
|
sl@0
|
1309 |
// Validate that the supplied DTMf string contains only playable characters
|
sl@0
|
1310 |
//
|
sl@0
|
1311 |
{
|
sl@0
|
1312 |
TInt stringLength = aDTMF.Length();
|
sl@0
|
1313 |
TChar ch;
|
sl@0
|
1314 |
for (TInt index = 0; index < stringLength ; index++)
|
sl@0
|
1315 |
{
|
sl@0
|
1316 |
ch = aDTMF[index];
|
sl@0
|
1317 |
if (!ch.IsDigit() && !ch.IsHexDigit() && !ch.IsSpace() &&
|
sl@0
|
1318 |
(ch != '*') && (ch != '#') && (ch != ','))
|
sl@0
|
1319 |
{
|
sl@0
|
1320 |
User::Leave(KErrArgument); // Bad DTMF string
|
sl@0
|
1321 |
}
|
sl@0
|
1322 |
}
|
sl@0
|
1323 |
}
|
sl@0
|
1324 |
|
sl@0
|
1325 |
void CMMFDTMFStringToneConfig::ConstructL(const TDesC& aDTMF)
|
sl@0
|
1326 |
{
|
sl@0
|
1327 |
validateDTMFL(aDTMF);
|
sl@0
|
1328 |
iDTMF = aDTMF.AllocL();
|
sl@0
|
1329 |
}
|
sl@0
|
1330 |
|
sl@0
|
1331 |
CMMFDTMFStringToneConfig::~CMMFDTMFStringToneConfig()
|
sl@0
|
1332 |
{
|
sl@0
|
1333 |
delete iDTMF;
|
sl@0
|
1334 |
}
|
sl@0
|
1335 |
|
sl@0
|
1336 |
const TDesC& CMMFDTMFStringToneConfig::DTMF()
|
sl@0
|
1337 |
{
|
sl@0
|
1338 |
return *iDTMF;
|
sl@0
|
1339 |
}
|
sl@0
|
1340 |
|
sl@0
|
1341 |
|
sl@0
|
1342 |
CMMFToneConfig* CMMFDesSeqToneConfig::NewL(const TDesC8& aDesSeq)
|
sl@0
|
1343 |
{
|
sl@0
|
1344 |
CMMFDesSeqToneConfig* s = new(ELeave) CMMFDesSeqToneConfig;
|
sl@0
|
1345 |
CleanupStack::PushL(s);
|
sl@0
|
1346 |
s->ConstructL(aDesSeq);
|
sl@0
|
1347 |
CleanupStack::Pop();
|
sl@0
|
1348 |
return STATIC_CAST(CMMFToneConfig*, s);
|
sl@0
|
1349 |
}
|
sl@0
|
1350 |
|
sl@0
|
1351 |
CMMFDesSeqToneConfig::CMMFDesSeqToneConfig() :
|
sl@0
|
1352 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeDesSeq)
|
sl@0
|
1353 |
{
|
sl@0
|
1354 |
}
|
sl@0
|
1355 |
|
sl@0
|
1356 |
void CMMFDesSeqToneConfig::ConstructL(const TDesC8& aDesSeq)
|
sl@0
|
1357 |
{
|
sl@0
|
1358 |
iDesSeq = aDesSeq.AllocL();
|
sl@0
|
1359 |
}
|
sl@0
|
1360 |
|
sl@0
|
1361 |
CMMFDesSeqToneConfig::~CMMFDesSeqToneConfig()
|
sl@0
|
1362 |
{
|
sl@0
|
1363 |
delete iDesSeq;
|
sl@0
|
1364 |
}
|
sl@0
|
1365 |
|
sl@0
|
1366 |
const TDesC8& CMMFDesSeqToneConfig::DesSeq()
|
sl@0
|
1367 |
{
|
sl@0
|
1368 |
return *iDesSeq;
|
sl@0
|
1369 |
}
|
sl@0
|
1370 |
|
sl@0
|
1371 |
|
sl@0
|
1372 |
CMMFToneConfig* CMMFFileSeqToneConfig::NewL(const TDesC& aFileSeq)
|
sl@0
|
1373 |
{
|
sl@0
|
1374 |
CMMFFileSeqToneConfig* s = new(ELeave) CMMFFileSeqToneConfig;
|
sl@0
|
1375 |
CleanupStack::PushL(s);
|
sl@0
|
1376 |
s->ConstructL(aFileSeq);
|
sl@0
|
1377 |
CleanupStack::Pop();
|
sl@0
|
1378 |
return STATIC_CAST(CMMFToneConfig*, s);
|
sl@0
|
1379 |
}
|
sl@0
|
1380 |
|
sl@0
|
1381 |
CMMFFileSeqToneConfig::CMMFFileSeqToneConfig() :
|
sl@0
|
1382 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeFileSeq)
|
sl@0
|
1383 |
{
|
sl@0
|
1384 |
}
|
sl@0
|
1385 |
|
sl@0
|
1386 |
void CMMFFileSeqToneConfig::ConstructL(const TDesC& aFileSeq)
|
sl@0
|
1387 |
{
|
sl@0
|
1388 |
// get access to DRM content through filename
|
sl@0
|
1389 |
iCAFContent = CContent::NewL(aFileSeq);
|
sl@0
|
1390 |
|
sl@0
|
1391 |
// open the CAF source with play intent
|
sl@0
|
1392 |
iCAFData = iCAFContent->OpenContentL(ContentAccess::EPlay, KDefaultContentObject);
|
sl@0
|
1393 |
|
sl@0
|
1394 |
// read into a descriptor
|
sl@0
|
1395 |
TInt dataSize = 0;
|
sl@0
|
1396 |
iCAFData->DataSizeL(dataSize);
|
sl@0
|
1397 |
|
sl@0
|
1398 |
iDesSeq = HBufC8::NewL(dataSize);
|
sl@0
|
1399 |
TPtr8 desSeqPtr = iDesSeq->Des();
|
sl@0
|
1400 |
iCAFData->Read(desSeqPtr);
|
sl@0
|
1401 |
}
|
sl@0
|
1402 |
|
sl@0
|
1403 |
|
sl@0
|
1404 |
|
sl@0
|
1405 |
CMMFToneConfig* CMMFFileSeqToneConfig::NewL(RFile& aFile)
|
sl@0
|
1406 |
{
|
sl@0
|
1407 |
CMMFFileSeqToneConfig* s = new(ELeave) CMMFFileSeqToneConfig;
|
sl@0
|
1408 |
CleanupStack::PushL(s);
|
sl@0
|
1409 |
s->ConstructL(aFile);
|
sl@0
|
1410 |
CleanupStack::Pop();
|
sl@0
|
1411 |
return STATIC_CAST(CMMFToneConfig*, s);
|
sl@0
|
1412 |
}
|
sl@0
|
1413 |
|
sl@0
|
1414 |
|
sl@0
|
1415 |
void CMMFFileSeqToneConfig::ConstructL(RFile& aFile)
|
sl@0
|
1416 |
{
|
sl@0
|
1417 |
// get DRM access to file handle
|
sl@0
|
1418 |
iCAFContent = CContent::NewL(aFile);
|
sl@0
|
1419 |
|
sl@0
|
1420 |
// open the CAF source with play intent
|
sl@0
|
1421 |
iCAFData = iCAFContent->OpenContentL(ContentAccess::EPlay, KDefaultContentObject);
|
sl@0
|
1422 |
|
sl@0
|
1423 |
// read into a descriptor
|
sl@0
|
1424 |
TInt dataSize = 0;
|
sl@0
|
1425 |
iCAFData->DataSizeL(dataSize);
|
sl@0
|
1426 |
|
sl@0
|
1427 |
iDesSeq = HBufC8::NewL(dataSize);
|
sl@0
|
1428 |
TPtr8 desSeqPtr = iDesSeq->Des();
|
sl@0
|
1429 |
iCAFData->Read(desSeqPtr);
|
sl@0
|
1430 |
}
|
sl@0
|
1431 |
|
sl@0
|
1432 |
|
sl@0
|
1433 |
CMMFFileSeqToneConfig::~CMMFFileSeqToneConfig()
|
sl@0
|
1434 |
{
|
sl@0
|
1435 |
delete iCAFData;
|
sl@0
|
1436 |
iCAFData = NULL;
|
sl@0
|
1437 |
|
sl@0
|
1438 |
delete iCAFContent;
|
sl@0
|
1439 |
iCAFContent = NULL;
|
sl@0
|
1440 |
|
sl@0
|
1441 |
delete iDesSeq;
|
sl@0
|
1442 |
}
|
sl@0
|
1443 |
|
sl@0
|
1444 |
const TDesC8& CMMFFileSeqToneConfig::FileSeq()
|
sl@0
|
1445 |
{
|
sl@0
|
1446 |
return *iDesSeq;
|
sl@0
|
1447 |
}
|
sl@0
|
1448 |
|
sl@0
|
1449 |
void CMMFFileSeqToneConfig::ExecuteIntentL()
|
sl@0
|
1450 |
{
|
sl@0
|
1451 |
if (iCAFData)
|
sl@0
|
1452 |
{
|
sl@0
|
1453 |
User::LeaveIfError(iCAFData->ExecuteIntent(ContentAccess::EPlay));
|
sl@0
|
1454 |
}
|
sl@0
|
1455 |
}
|
sl@0
|
1456 |
|
sl@0
|
1457 |
CMMFToneConfig* CMMFFixedSeqToneConfig::NewL(TInt aSeqNo)
|
sl@0
|
1458 |
{
|
sl@0
|
1459 |
return STATIC_CAST(CMMFToneConfig*, new(ELeave) CMMFFixedSeqToneConfig(aSeqNo));
|
sl@0
|
1460 |
}
|
sl@0
|
1461 |
|
sl@0
|
1462 |
CMMFFixedSeqToneConfig::CMMFFixedSeqToneConfig(TInt aSeqNo) :
|
sl@0
|
1463 |
CMMFToneConfig(CMMFToneConfig::EMmfToneTypeFixedSeq),
|
sl@0
|
1464 |
iSequenceNumber(aSeqNo)
|
sl@0
|
1465 |
{
|
sl@0
|
1466 |
}
|
sl@0
|
1467 |
|
sl@0
|
1468 |
CMMFFixedSeqToneConfig::~CMMFFixedSeqToneConfig()
|
sl@0
|
1469 |
{
|
sl@0
|
1470 |
}
|
sl@0
|
1471 |
|
sl@0
|
1472 |
TInt CMMFFixedSeqToneConfig::SequenceNumber()
|
sl@0
|
1473 |
{
|
sl@0
|
1474 |
return iSequenceNumber;
|
sl@0
|
1475 |
}
|