sl@0
|
1 |
// Copyright (c) 2001-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/plugin/mmfhwdeviceimplementationuids.hrh>
|
sl@0
|
17 |
#include "SoundDeviceBody.h"
|
sl@0
|
18 |
#include <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh> // KUidRefDevSoundTaskConfig
|
sl@0
|
19 |
|
sl@0
|
20 |
const TInt KMaxMessageQueueItems = 8;
|
sl@0
|
21 |
|
sl@0
|
22 |
/*
|
sl@0
|
23 |
*
|
sl@0
|
24 |
* Default Constructor.
|
sl@0
|
25 |
*
|
sl@0
|
26 |
* No default implementation. CMMFDevSound implements 2-phase construction.
|
sl@0
|
27 |
*
|
sl@0
|
28 |
*/
|
sl@0
|
29 |
CMMFDevSoundClientImp::CMMFDevSoundClientImp()
|
sl@0
|
30 |
{
|
sl@0
|
31 |
}
|
sl@0
|
32 |
|
sl@0
|
33 |
/*
|
sl@0
|
34 |
*
|
sl@0
|
35 |
* Destructor.
|
sl@0
|
36 |
*
|
sl@0
|
37 |
* Deletes all objects and releases all resource owned by this
|
sl@0
|
38 |
* instance.
|
sl@0
|
39 |
*
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
CMMFDevSoundClientImp::~CMMFDevSoundClientImp()
|
sl@0
|
42 |
{
|
sl@0
|
43 |
// clear the array of custom interfaces
|
sl@0
|
44 |
for (TInt i = 0; i < iCustomInterfaceArray.Count(); i++)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
iCustomInterfaceArray[i].iInterface->Release();
|
sl@0
|
47 |
}
|
sl@0
|
48 |
iCustomInterfaceArray.Reset();
|
sl@0
|
49 |
iCustomInterfaceArray.Close();
|
sl@0
|
50 |
|
sl@0
|
51 |
// delete the MUX utility
|
sl@0
|
52 |
delete iMuxUtility;
|
sl@0
|
53 |
|
sl@0
|
54 |
if (iMsgQueueHandler && iMsgQueueHandler->IsActive())
|
sl@0
|
55 |
{
|
sl@0
|
56 |
iMsgQueueHandler->Cancel();
|
sl@0
|
57 |
}
|
sl@0
|
58 |
delete iMsgQueueHandler;
|
sl@0
|
59 |
|
sl@0
|
60 |
iMsgQueue.Close();
|
sl@0
|
61 |
|
sl@0
|
62 |
if( iDevSoundProxy != NULL)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
iDevSoundProxy->Close();
|
sl@0
|
65 |
delete iDevSoundProxy;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
/*
|
sl@0
|
70 |
*
|
sl@0
|
71 |
* Constructs, and returns a pointer to, a new CMMFDevSound object.
|
sl@0
|
72 |
*
|
sl@0
|
73 |
* Leaves on failure.
|
sl@0
|
74 |
*
|
sl@0
|
75 |
*/
|
sl@0
|
76 |
CMMFDevSoundClientImp* CMMFDevSoundClientImp::NewL()
|
sl@0
|
77 |
{
|
sl@0
|
78 |
CMMFDevSoundClientImp* self = new (ELeave) CMMFDevSoundClientImp();
|
sl@0
|
79 |
CleanupStack::PushL(self);
|
sl@0
|
80 |
self->ConstructL();
|
sl@0
|
81 |
CleanupStack::Pop(self);
|
sl@0
|
82 |
return self;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
/*
|
sl@0
|
86 |
*
|
sl@0
|
87 |
* 2nd phase constructor - assumes that iParent has already been set up properly.
|
sl@0
|
88 |
*
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
void CMMFDevSoundClientImp::ConstructL()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
// all these data properties should be NULL, but add ASSERTs to verify
|
sl@0
|
93 |
|
sl@0
|
94 |
ASSERT(iDevSoundProxy==NULL);
|
sl@0
|
95 |
iDevSoundProxy = new (ELeave) RMMFDevSoundProxy();
|
sl@0
|
96 |
|
sl@0
|
97 |
TInt err = iMsgQueue.CreateGlobal(KNullDesC, KMaxMessageQueueItems); // global, accessible to all that have its handle
|
sl@0
|
98 |
User::LeaveIfError(err);
|
sl@0
|
99 |
err = iDevSoundProxy->Open(iMsgQueue);
|
sl@0
|
100 |
if(err)
|
sl@0
|
101 |
{
|
sl@0
|
102 |
delete iDevSoundProxy;
|
sl@0
|
103 |
iDevSoundProxy = NULL;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
|
sl@0
|
106 |
User::LeaveIfError(err);
|
sl@0
|
107 |
|
sl@0
|
108 |
// create MUX utility
|
sl@0
|
109 |
iMuxUtility = CMMFDevSoundCIMuxUtility::NewL(this);
|
sl@0
|
110 |
}
|
sl@0
|
111 |
|
sl@0
|
112 |
|
sl@0
|
113 |
/*
|
sl@0
|
114 |
*
|
sl@0
|
115 |
* Initializes CMMFDevSound object to play and record PCM16 raw audio data
|
sl@0
|
116 |
* with sampling rate of 8 KHz.
|
sl@0
|
117 |
*
|
sl@0
|
118 |
* On completion of Initialization, calls InitializeComplete() on
|
sl@0
|
119 |
* aDevSoundObserver.
|
sl@0
|
120 |
*
|
sl@0
|
121 |
* Leaves on failure.
|
sl@0
|
122 |
*
|
sl@0
|
123 |
* @param "MDevSoundObserver& aDevSoundObserver"
|
sl@0
|
124 |
* A reference to DevSound Observer instance.
|
sl@0
|
125 |
*
|
sl@0
|
126 |
* @param "TMMFState aMode"
|
sl@0
|
127 |
* Mode for which this object will be used.
|
sl@0
|
128 |
*
|
sl@0
|
129 |
*/
|
sl@0
|
130 |
void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, TMMFState aMode)
|
sl@0
|
131 |
|
sl@0
|
132 |
{
|
sl@0
|
133 |
TInt initError = KErrNone;
|
sl@0
|
134 |
iDevSoundObserver = &aDevSoundObserver;
|
sl@0
|
135 |
initError = iDevSoundProxy->InitializeL(aMode);
|
sl@0
|
136 |
|
sl@0
|
137 |
if (initError)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
User::Leave(initError);
|
sl@0
|
140 |
}
|
sl@0
|
141 |
|
sl@0
|
142 |
if (iMsgQueueHandler)
|
sl@0
|
143 |
{
|
sl@0
|
144 |
iMsgQueueHandler->Cancel();
|
sl@0
|
145 |
iMsgQueueHandler->SetObserver(*iDevSoundObserver);
|
sl@0
|
146 |
}
|
sl@0
|
147 |
else
|
sl@0
|
148 |
{
|
sl@0
|
149 |
iMsgQueueHandler = CMsgQueueHandler::NewL(iDevSoundProxy, *iDevSoundObserver, &iMsgQueue, *this);
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
iMsgQueueHandler->ReceiveEvents();
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
/*
|
sl@0
|
156 |
*
|
sl@0
|
157 |
* Configure CMMFDevSound object for the settings in aConfig.
|
sl@0
|
158 |
*
|
sl@0
|
159 |
* Use this to set sampling rate, Encoding and Mono/Stereo.
|
sl@0
|
160 |
*
|
sl@0
|
161 |
* @param "TMMFCapabilities& aConfig"
|
sl@0
|
162 |
* Attribute values to which CMMFDevSound object will be configured to.
|
sl@0
|
163 |
*
|
sl@0
|
164 |
* As part of defect 20796, the iRecordFormat has been set under the iPlayFormat,
|
sl@0
|
165 |
* before it was not set at all.
|
sl@0
|
166 |
*
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
void CMMFDevSoundClientImp::SetConfigL(const TMMFCapabilities& aConfig)
|
sl@0
|
169 |
{
|
sl@0
|
170 |
iDevSoundProxy->SetConfigL(aConfig);
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
/*
|
sl@0
|
174 |
*
|
sl@0
|
175 |
* Changes the current playback volume to a specified value.
|
sl@0
|
176 |
*
|
sl@0
|
177 |
* The volume can be changed before or during playback and is effective
|
sl@0
|
178 |
* immediately.
|
sl@0
|
179 |
*
|
sl@0
|
180 |
* @param "TInt aVolume"
|
sl@0
|
181 |
* The volume setting. This can be any value from zero to the value
|
sl@0
|
182 |
* returned by a call to CMdaAudioPlayerUtility::MaxVolume(). If the
|
sl@0
|
183 |
* volume is not within this range, the volume is automatically set to
|
sl@0
|
184 |
* minimum or maximum value based on the value that is being passed.
|
sl@0
|
185 |
* Setting a zero value mutes the sound. Setting the maximum value
|
sl@0
|
186 |
* results in the loudest possible sound.
|
sl@0
|
187 |
*
|
sl@0
|
188 |
*/
|
sl@0
|
189 |
void CMMFDevSoundClientImp::SetVolume(TInt aVolume)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
iDevSoundProxy->SetVolume(aVolume);
|
sl@0
|
192 |
}
|
sl@0
|
193 |
|
sl@0
|
194 |
/*
|
sl@0
|
195 |
*
|
sl@0
|
196 |
* Changes the current recording gain to a specified value.
|
sl@0
|
197 |
*
|
sl@0
|
198 |
* The gain can be changed before or during recording and is effective
|
sl@0
|
199 |
* immediately.
|
sl@0
|
200 |
*
|
sl@0
|
201 |
* @param "TInt aGain"
|
sl@0
|
202 |
* The volume setting. This can be any value from zero to the value
|
sl@0
|
203 |
* returned by a call to CMdaAudioPlayerUtility::MaxVolume(). If the
|
sl@0
|
204 |
* volume is not within this range, the gain is automatically set to
|
sl@0
|
205 |
* minimum or maximum value based on the value that is being passed.
|
sl@0
|
206 |
* Setting a zero value mutes the sound. Setting the maximum value
|
sl@0
|
207 |
* results in the loudest possible sound.
|
sl@0
|
208 |
*
|
sl@0
|
209 |
*/
|
sl@0
|
210 |
void CMMFDevSoundClientImp::SetGain(TInt aGain)
|
sl@0
|
211 |
{
|
sl@0
|
212 |
iDevSoundProxy->SetGain(aGain);
|
sl@0
|
213 |
}
|
sl@0
|
214 |
|
sl@0
|
215 |
/*
|
sl@0
|
216 |
*
|
sl@0
|
217 |
* Sets the speaker balance for playing.
|
sl@0
|
218 |
*
|
sl@0
|
219 |
* The speaker balance can be changed before or during playback and is
|
sl@0
|
220 |
* effective immediately.
|
sl@0
|
221 |
*
|
sl@0
|
222 |
* @param "TInt& aLeftPercentage"
|
sl@0
|
223 |
* On return contains left speaker volume perecentage. This can be any
|
sl@0
|
224 |
* value from zero to 100. Setting a zero value mutes the sound on left
|
sl@0
|
225 |
* speaker.
|
sl@0
|
226 |
*
|
sl@0
|
227 |
* @param "TInt& aRightPercentage"
|
sl@0
|
228 |
* On return contains right speaker volume perecentage. This can be any
|
sl@0
|
229 |
* value from zero to 100. Setting a zero value mutes the sound on
|
sl@0
|
230 |
* right speaker.
|
sl@0
|
231 |
*
|
sl@0
|
232 |
*/
|
sl@0
|
233 |
void CMMFDevSoundClientImp::SetPlayBalanceL(TInt aLeftPercentage, TInt aRightPercentage)
|
sl@0
|
234 |
{
|
sl@0
|
235 |
iDevSoundProxy->SetPlayBalanceL(aLeftPercentage, aRightPercentage);
|
sl@0
|
236 |
}
|
sl@0
|
237 |
|
sl@0
|
238 |
/*
|
sl@0
|
239 |
*
|
sl@0
|
240 |
* Sets the microphone gain balance for recording.
|
sl@0
|
241 |
*
|
sl@0
|
242 |
* The microphone gain balance can be changed before or during recording and
|
sl@0
|
243 |
* is effective immediately.
|
sl@0
|
244 |
*
|
sl@0
|
245 |
* @param "TInt aLeftPercentage"
|
sl@0
|
246 |
* Left microphone gain precentage. This can be any value from zero to
|
sl@0
|
247 |
* 100. Setting a zero value mutes the gain on left microphone.
|
sl@0
|
248 |
*
|
sl@0
|
249 |
* @param "TInt aRightPercentage"
|
sl@0
|
250 |
* Right microphone gain precentage. This can be any value from zero to
|
sl@0
|
251 |
* 100. Setting a zero value mutes the gain on right microphone.
|
sl@0
|
252 |
*
|
sl@0
|
253 |
*/
|
sl@0
|
254 |
void CMMFDevSoundClientImp::SetRecordBalanceL(TInt aLeftPercentage, TInt aRightPercentage)
|
sl@0
|
255 |
{
|
sl@0
|
256 |
iDevSoundProxy->SetRecordBalanceL(aLeftPercentage, aRightPercentage);
|
sl@0
|
257 |
}
|
sl@0
|
258 |
|
sl@0
|
259 |
/*
|
sl@0
|
260 |
*
|
sl@0
|
261 |
* Initializes audio device and start play process. This method queries and
|
sl@0
|
262 |
* acquires the audio policy before initializing audio device. If there was an
|
sl@0
|
263 |
* error during policy initialization, PlayError() method will be called on
|
sl@0
|
264 |
* the observer with error code KErrAccessDenied, otherwise BufferToBeFilled()
|
sl@0
|
265 |
* method will be called with a buffer reference. After reading data into the
|
sl@0
|
266 |
* buffer reference passed, the client should call PlayData() to play data.
|
sl@0
|
267 |
*
|
sl@0
|
268 |
* The amount of data that can be played is specified in
|
sl@0
|
269 |
* CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
|
sl@0
|
270 |
* size will be ignored.
|
sl@0
|
271 |
*
|
sl@0
|
272 |
* Leaves on failure.
|
sl@0
|
273 |
*
|
sl@0
|
274 |
*/
|
sl@0
|
275 |
void CMMFDevSoundClientImp::PlayInitL()
|
sl@0
|
276 |
{
|
sl@0
|
277 |
if (!iDevSoundObserver)
|
sl@0
|
278 |
User::Leave(KErrNotReady);
|
sl@0
|
279 |
iDevSoundProxy->PlayInitL();
|
sl@0
|
280 |
}
|
sl@0
|
281 |
|
sl@0
|
282 |
/*
|
sl@0
|
283 |
*
|
sl@0
|
284 |
* Initializes audio device and start record process. This method queries and
|
sl@0
|
285 |
* acquires the audio policy before initializing audio device. If there was an
|
sl@0
|
286 |
* error during policy initialization, RecordError() method will be called on
|
sl@0
|
287 |
* the observer with error code KErrAccessDenied, otherwise BufferToBeEmptied()
|
sl@0
|
288 |
* method will be called with a buffer reference. This buffer contains recorded
|
sl@0
|
289 |
* or encoded data. After processing data in the buffer reference passed, the
|
sl@0
|
290 |
* client should call RecordData() to continue recording process.
|
sl@0
|
291 |
*
|
sl@0
|
292 |
* The amount of data that is available is specified in
|
sl@0
|
293 |
* CMMFBuffer::RequestSize().
|
sl@0
|
294 |
*
|
sl@0
|
295 |
* Leaves on failure.
|
sl@0
|
296 |
*
|
sl@0
|
297 |
*/
|
sl@0
|
298 |
void CMMFDevSoundClientImp::RecordInitL()
|
sl@0
|
299 |
{
|
sl@0
|
300 |
|
sl@0
|
301 |
if (!iDevSoundObserver)
|
sl@0
|
302 |
User::Leave(KErrNotReady);
|
sl@0
|
303 |
iDevSoundProxy->RecordInitL();
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
/*
|
sl@0
|
307 |
*
|
sl@0
|
308 |
* Plays data in the buffer at the current volume. The client should fill
|
sl@0
|
309 |
* the buffer with audio data before calling this method. The Observer gets
|
sl@0
|
310 |
* reference to buffer along with callback BufferToBeFilled(). When playing of
|
sl@0
|
311 |
* the audio sample is complete, successfully or otherwise, the method
|
sl@0
|
312 |
* PlayError() on observer is called.
|
sl@0
|
313 |
*
|
sl@0
|
314 |
*/
|
sl@0
|
315 |
void CMMFDevSoundClientImp::PlayData()
|
sl@0
|
316 |
{
|
sl@0
|
317 |
ASSERT(iDevSoundObserver);
|
sl@0
|
318 |
iDevSoundProxy->PlayData();
|
sl@0
|
319 |
}
|
sl@0
|
320 |
|
sl@0
|
321 |
/*
|
sl@0
|
322 |
*
|
sl@0
|
323 |
* Stops the ongoing operation (Play, Record, TonePlay, Convert)
|
sl@0
|
324 |
*
|
sl@0
|
325 |
*/
|
sl@0
|
326 |
void CMMFDevSoundClientImp::Stop()
|
sl@0
|
327 |
{
|
sl@0
|
328 |
iDevSoundProxy->Stop();
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
/*
|
sl@0
|
332 |
*
|
sl@0
|
333 |
* Temporarily Stops the ongoing operation (Play, Record, TonePlay, Convert)
|
sl@0
|
334 |
*
|
sl@0
|
335 |
*/
|
sl@0
|
336 |
void CMMFDevSoundClientImp::Pause()
|
sl@0
|
337 |
{
|
sl@0
|
338 |
iDevSoundProxy->Pause();
|
sl@0
|
339 |
}
|
sl@0
|
340 |
|
sl@0
|
341 |
/*
|
sl@0
|
342 |
*
|
sl@0
|
343 |
* Returns the sample recorded so far.
|
sl@0
|
344 |
*
|
sl@0
|
345 |
* @return "TInt"
|
sl@0
|
346 |
* Returns the samples recorded.
|
sl@0
|
347 |
*
|
sl@0
|
348 |
*/
|
sl@0
|
349 |
TInt CMMFDevSoundClientImp::SamplesRecorded()
|
sl@0
|
350 |
{
|
sl@0
|
351 |
return iDevSoundProxy->SamplesRecorded();
|
sl@0
|
352 |
}
|
sl@0
|
353 |
|
sl@0
|
354 |
/*
|
sl@0
|
355 |
*
|
sl@0
|
356 |
* Returns the sample played so far.
|
sl@0
|
357 |
*
|
sl@0
|
358 |
* @return "TInt"
|
sl@0
|
359 |
* Returns the samples recorded.
|
sl@0
|
360 |
*
|
sl@0
|
361 |
*/
|
sl@0
|
362 |
TInt CMMFDevSoundClientImp::SamplesPlayed()
|
sl@0
|
363 |
{
|
sl@0
|
364 |
return iDevSoundProxy->SamplesPlayed();
|
sl@0
|
365 |
}
|
sl@0
|
366 |
|
sl@0
|
367 |
|
sl@0
|
368 |
/*
|
sl@0
|
369 |
*
|
sl@0
|
370 |
* Initializes audio device and start playing tone. Tone is played with
|
sl@0
|
371 |
* frequency and for duration specified.
|
sl@0
|
372 |
*
|
sl@0
|
373 |
* Leaves on failure.
|
sl@0
|
374 |
*
|
sl@0
|
375 |
* @param "TInt aFrequency"
|
sl@0
|
376 |
* Frequency at with the tone will be played.
|
sl@0
|
377 |
*
|
sl@0
|
378 |
* @param "TTimeIntervalMicroSeconds& aDuration"
|
sl@0
|
379 |
* The period over which the tone will be played. A zero value causes
|
sl@0
|
380 |
* the no tone to be played (Verify this with test app).
|
sl@0
|
381 |
*
|
sl@0
|
382 |
*/
|
sl@0
|
383 |
void CMMFDevSoundClientImp::PlayToneL(TInt aFrequency, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
iDevSoundProxy->PlayToneL(aFrequency, aDuration);
|
sl@0
|
386 |
}
|
sl@0
|
387 |
|
sl@0
|
388 |
/*
|
sl@0
|
389 |
* Initializes audio device and start playing a dual tone.
|
sl@0
|
390 |
* The tone consists of two sine waves of different frequencies summed together
|
sl@0
|
391 |
* Dual Tone is played with specified frequencies and for specified duration.
|
sl@0
|
392 |
*
|
sl@0
|
393 |
* @param "aFrequencyOne"
|
sl@0
|
394 |
* First frequency of dual tone
|
sl@0
|
395 |
*
|
sl@0
|
396 |
* @param "aFrequencyTwo"
|
sl@0
|
397 |
* Second frequency of dual tone
|
sl@0
|
398 |
*
|
sl@0
|
399 |
* @param "aDuration"
|
sl@0
|
400 |
* The period over which the tone will be played. A zero value causes
|
sl@0
|
401 |
* the no tone to be played (Verify this with test app).
|
sl@0
|
402 |
*/
|
sl@0
|
403 |
void CMMFDevSoundClientImp::PlayDualToneL(TInt aFrequencyOne, TInt aFrequencyTwo, const TTimeIntervalMicroSeconds& aDuration)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
iDevSoundProxy->PlayDualToneL(aFrequencyOne, aFrequencyTwo, aDuration);
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
/*
|
sl@0
|
409 |
*
|
sl@0
|
410 |
* Initializes audio device and start playing DTMF string aDTMFString.
|
sl@0
|
411 |
*
|
sl@0
|
412 |
* Leaves on failure.
|
sl@0
|
413 |
*
|
sl@0
|
414 |
* @param "TDesC& aDTMFString"
|
sl@0
|
415 |
* DTMF sequence in a descriptor.
|
sl@0
|
416 |
*
|
sl@0
|
417 |
*/
|
sl@0
|
418 |
void CMMFDevSoundClientImp::PlayDTMFStringL(const TDesC& aDTMFString)
|
sl@0
|
419 |
{
|
sl@0
|
420 |
if (!iDevSoundObserver)
|
sl@0
|
421 |
User::Leave(KErrNotReady);
|
sl@0
|
422 |
|
sl@0
|
423 |
iDevSoundProxy->PlayDTMFStringL(aDTMFString);
|
sl@0
|
424 |
}
|
sl@0
|
425 |
|
sl@0
|
426 |
/*
|
sl@0
|
427 |
*
|
sl@0
|
428 |
* Initializes audio device and start playing tone sequence.
|
sl@0
|
429 |
*
|
sl@0
|
430 |
* Leaves on failure.
|
sl@0
|
431 |
*
|
sl@0
|
432 |
* @param "TDesC8& aData"
|
sl@0
|
433 |
* Tone sequence in a descriptor.
|
sl@0
|
434 |
*
|
sl@0
|
435 |
*/
|
sl@0
|
436 |
void CMMFDevSoundClientImp::PlayToneSequenceL(const TDesC8& aData)
|
sl@0
|
437 |
{
|
sl@0
|
438 |
if (!iDevSoundObserver)
|
sl@0
|
439 |
User::Leave(KErrNotReady);
|
sl@0
|
440 |
|
sl@0
|
441 |
iDevSoundProxy->PlayToneSequenceL(aData);
|
sl@0
|
442 |
}
|
sl@0
|
443 |
|
sl@0
|
444 |
/*
|
sl@0
|
445 |
*
|
sl@0
|
446 |
* Initializes audio device and start playing the specified pre-defined tone
|
sl@0
|
447 |
* sequence.
|
sl@0
|
448 |
*
|
sl@0
|
449 |
* Leaves on failure.
|
sl@0
|
450 |
*
|
sl@0
|
451 |
* @param "TInt aSequenceNumber"
|
sl@0
|
452 |
* The index identifying the specific pre-defined tone sequence. Index
|
sl@0
|
453 |
* values are relative to zero.
|
sl@0
|
454 |
* This can be any value from zero to the value returned by a call to
|
sl@0
|
455 |
* CMdaAudioPlayerUtility::FixedSequenceCount() - 1.
|
sl@0
|
456 |
* The function raises a panic if sequence number is not within this
|
sl@0
|
457 |
* range.
|
sl@0
|
458 |
*
|
sl@0
|
459 |
*/
|
sl@0
|
460 |
void CMMFDevSoundClientImp::PlayFixedSequenceL(TInt aSequenceNumber)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
if (!iDevSoundObserver)
|
sl@0
|
463 |
User::Leave(KErrNotReady);
|
sl@0
|
464 |
|
sl@0
|
465 |
iDevSoundProxy->PlayFixedSequenceL(aSequenceNumber);
|
sl@0
|
466 |
}
|
sl@0
|
467 |
|
sl@0
|
468 |
/*
|
sl@0
|
469 |
*
|
sl@0
|
470 |
* Defines the duration of tone on, tone off and tone pause to be used during the
|
sl@0
|
471 |
* DTMF tone playback operation.
|
sl@0
|
472 |
*
|
sl@0
|
473 |
* Supported only during tone playing.
|
sl@0
|
474 |
*
|
sl@0
|
475 |
* @param "TTimeIntervalMicroSeconds32& aToneOnLength"
|
sl@0
|
476 |
* The period over which the tone will be played. If this is set to
|
sl@0
|
477 |
* zero, then the tone is not played.
|
sl@0
|
478 |
*
|
sl@0
|
479 |
* @param "TTimeIntervalMicroSeconds32& aToneOffLength"
|
sl@0
|
480 |
* The period over which the no tone will be played.
|
sl@0
|
481 |
*
|
sl@0
|
482 |
* @param "TTimeIntervalMicroSeconds32& aPauseLength"
|
sl@0
|
483 |
* The period over which the tone playing will be paused.
|
sl@0
|
484 |
*
|
sl@0
|
485 |
*/
|
sl@0
|
486 |
void CMMFDevSoundClientImp::SetDTMFLengths(TTimeIntervalMicroSeconds32& aToneOnLength,
|
sl@0
|
487 |
TTimeIntervalMicroSeconds32& aToneOffLength,
|
sl@0
|
488 |
TTimeIntervalMicroSeconds32& aPauseLength)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
iDevSoundProxy->SetDTMFLengths(aToneOnLength, aToneOffLength, aPauseLength);
|
sl@0
|
491 |
}
|
sl@0
|
492 |
|
sl@0
|
493 |
/*
|
sl@0
|
494 |
*
|
sl@0
|
495 |
* Defines the period over which the volume level is to rise smoothly from
|
sl@0
|
496 |
* nothing to the normal volume level.
|
sl@0
|
497 |
*
|
sl@0
|
498 |
* @param "TTimeIntervalMicroSeconds& aRampDuration"
|
sl@0
|
499 |
* The period over which the volume is to rise. A zero value causes
|
sl@0
|
500 |
* the tone sample to be played at the normal level for the full
|
sl@0
|
501 |
* duration of the playback. A value, which is longer than the duration
|
sl@0
|
502 |
* of the tone sample, that the sample never reaches its normal
|
sl@0
|
503 |
* volume level.
|
sl@0
|
504 |
*
|
sl@0
|
505 |
*
|
sl@0
|
506 |
*/
|
sl@0
|
507 |
void CMMFDevSoundClientImp::SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration)
|
sl@0
|
508 |
{
|
sl@0
|
509 |
iDevSoundProxy->SetVolumeRamp(aRampDuration);
|
sl@0
|
510 |
}
|
sl@0
|
511 |
|
sl@0
|
512 |
|
sl@0
|
513 |
/**
|
sl@0
|
514 |
* @see sounddevice.h
|
sl@0
|
515 |
*/
|
sl@0
|
516 |
void CMMFDevSoundClientImp::GetSupportedInputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const
|
sl@0
|
517 |
{
|
sl@0
|
518 |
iDevSoundProxy->GetSupportedInputDataTypesL(aSupportedDataTypes, aPrioritySettings);
|
sl@0
|
519 |
}
|
sl@0
|
520 |
|
sl@0
|
521 |
/**
|
sl@0
|
522 |
* @see sounddevice.h
|
sl@0
|
523 |
*/
|
sl@0
|
524 |
void CMMFDevSoundClientImp::GetSupportedOutputDataTypesL(RArray<TFourCC>& aSupportedDataTypes, const TMMFPrioritySettings& aPrioritySettings) const
|
sl@0
|
525 |
{
|
sl@0
|
526 |
iDevSoundProxy->GetSupportedOutputDataTypesL(aSupportedDataTypes, aPrioritySettings);
|
sl@0
|
527 |
}
|
sl@0
|
528 |
|
sl@0
|
529 |
/**
|
sl@0
|
530 |
* @see sounddevice.h
|
sl@0
|
531 |
*/
|
sl@0
|
532 |
TInt CMMFDevSoundClientImp::SetClientThreadInfo(TThreadId aTid)
|
sl@0
|
533 |
{
|
sl@0
|
534 |
return iDevSoundProxy->SetClientThreadInfo(aTid);
|
sl@0
|
535 |
}
|
sl@0
|
536 |
|
sl@0
|
537 |
|
sl@0
|
538 |
TInt CMMFDevSoundClientImp::RegisterAsClient(TUid aEventType, const TDesC8& aNotificationRegistrationData)
|
sl@0
|
539 |
{
|
sl@0
|
540 |
return iDevSoundProxy->RegisterAsClient(aEventType,aNotificationRegistrationData);
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
TInt CMMFDevSoundClientImp::CancelRegisterAsClient(TUid aEventType)
|
sl@0
|
544 |
{
|
sl@0
|
545 |
return iDevSoundProxy->CancelRegisterAsClient(aEventType);
|
sl@0
|
546 |
}
|
sl@0
|
547 |
|
sl@0
|
548 |
TInt CMMFDevSoundClientImp::GetResourceNotificationData(TUid aEventType,TDes8& aNotificationData)
|
sl@0
|
549 |
{
|
sl@0
|
550 |
return iDevSoundProxy->GetResourceNotificationData(aEventType,aNotificationData);
|
sl@0
|
551 |
}
|
sl@0
|
552 |
|
sl@0
|
553 |
TInt CMMFDevSoundClientImp::WillResumePlay()
|
sl@0
|
554 |
{
|
sl@0
|
555 |
return iDevSoundProxy->WillResumePlay();
|
sl@0
|
556 |
}
|
sl@0
|
557 |
|
sl@0
|
558 |
TInt CMMFDevSoundClientImp::EmptyBuffers()
|
sl@0
|
559 |
{
|
sl@0
|
560 |
return iDevSoundProxy->EmptyBuffers();
|
sl@0
|
561 |
}
|
sl@0
|
562 |
|
sl@0
|
563 |
TInt CMMFDevSoundClientImp::GetTimePlayed(TTimeIntervalMicroSeconds& aTime)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
return iDevSoundProxy->GetTimePlayed(aTime);
|
sl@0
|
566 |
}
|
sl@0
|
567 |
/*
|
sl@0
|
568 |
*
|
sl@0
|
569 |
* Returns a given Custom Interface on the DevSound based on the UID
|
sl@0
|
570 |
* If this is not recognised then the custominterface is created by
|
sl@0
|
571 |
* a pair of ECOM plugins.
|
sl@0
|
572 |
*
|
sl@0
|
573 |
* @released
|
sl@0
|
574 |
* @param "TUid aInterfaceId"
|
sl@0
|
575 |
* The UID of the required Custom Interface
|
sl@0
|
576 |
* @return a pointer to the custom interface
|
sl@0
|
577 |
*
|
sl@0
|
578 |
*/
|
sl@0
|
579 |
TAny* CMMFDevSoundClientImp::CustomInterface(TUid aInterfaceId)
|
sl@0
|
580 |
{
|
sl@0
|
581 |
// check if this UID refers to auto/pause/resume
|
sl@0
|
582 |
if (aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
|
sl@0
|
583 |
{
|
sl@0
|
584 |
MAutoPauseResumeSupport* result = this;
|
sl@0
|
585 |
return result;
|
sl@0
|
586 |
}
|
sl@0
|
587 |
if (aInterfaceId == KMmfUidDevSoundEmptyBuffersCustomInterface)
|
sl@0
|
588 |
{
|
sl@0
|
589 |
MMMFDevSoundEmptyBuffers* result = this;
|
sl@0
|
590 |
return result;
|
sl@0
|
591 |
}
|
sl@0
|
592 |
if (aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
|
sl@0
|
593 |
{
|
sl@0
|
594 |
MAudioClientThreadInfo* result = this;
|
sl@0
|
595 |
return result;
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
if (aInterfaceId == KMmfUidDevSoundTimePlayedCustomInterface)
|
sl@0
|
599 |
{
|
sl@0
|
600 |
MMMFDevSoundTimePlayed* result = this;
|
sl@0
|
601 |
return result;
|
sl@0
|
602 |
}
|
sl@0
|
603 |
|
sl@0
|
604 |
// we are being asked for a Custom Interface not natively supported
|
sl@0
|
605 |
// by the DevSound plugin.
|
sl@0
|
606 |
|
sl@0
|
607 |
// first check if we already have resolved a custom interface of this type
|
sl@0
|
608 |
TInt index = FindCustomInterface(aInterfaceId);
|
sl@0
|
609 |
|
sl@0
|
610 |
MMMFDevSoundCustomInterfaceMuxPlugin* ptr = NULL;
|
sl@0
|
611 |
|
sl@0
|
612 |
// if we found the interface, take a copy of this instead
|
sl@0
|
613 |
if (index != KNullHandle)
|
sl@0
|
614 |
{
|
sl@0
|
615 |
// check our index is valid
|
sl@0
|
616 |
ptr = iCustomInterfaceArray[index-1].iInterface;
|
sl@0
|
617 |
if (ptr)
|
sl@0
|
618 |
{
|
sl@0
|
619 |
return ptr->CustomInterface(aInterfaceId);
|
sl@0
|
620 |
}
|
sl@0
|
621 |
else
|
sl@0
|
622 |
{
|
sl@0
|
623 |
// we may not need this code because this
|
sl@0
|
624 |
// *should* be impossible to reach
|
sl@0
|
625 |
return NULL;
|
sl@0
|
626 |
}
|
sl@0
|
627 |
}
|
sl@0
|
628 |
else
|
sl@0
|
629 |
{
|
sl@0
|
630 |
// else try and instantiate a plugin tunnelling
|
sl@0
|
631 |
// pair to support this Custom Interface
|
sl@0
|
632 |
TRAPD(err, ptr = iMuxUtility->CreateCustomInterfaceMuxL(aInterfaceId));
|
sl@0
|
633 |
|
sl@0
|
634 |
if (ptr && (err == KErrNone))
|
sl@0
|
635 |
{
|
sl@0
|
636 |
TMMFDevSoundCustomInterfaceData data;
|
sl@0
|
637 |
data.iInterface = ptr;
|
sl@0
|
638 |
data.iId = aInterfaceId;
|
sl@0
|
639 |
|
sl@0
|
640 |
// attempt to open remote demux
|
sl@0
|
641 |
// this will store a handle in the mux plugin if successful
|
sl@0
|
642 |
// and also return it here - invalid handle = -1
|
sl@0
|
643 |
data.iHandle = ptr->OpenInterface(aInterfaceId);
|
sl@0
|
644 |
|
sl@0
|
645 |
// if the handle is greater than zero then we know we have
|
sl@0
|
646 |
// successfully opened the interface
|
sl@0
|
647 |
if (data.iHandle > KNullHandle)
|
sl@0
|
648 |
{
|
sl@0
|
649 |
// append this to the current interface list
|
sl@0
|
650 |
TInt err = KErrNone;
|
sl@0
|
651 |
err = iCustomInterfaceArray.Append(data);
|
sl@0
|
652 |
if (err == KErrNone)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
// return the custom interface on the ptr
|
sl@0
|
655 |
return ptr->CustomInterface(aInterfaceId);
|
sl@0
|
656 |
}
|
sl@0
|
657 |
}
|
sl@0
|
658 |
|
sl@0
|
659 |
// no memory or other problem so shut down interface
|
sl@0
|
660 |
ptr->Release();
|
sl@0
|
661 |
ptr = NULL;
|
sl@0
|
662 |
}
|
sl@0
|
663 |
}
|
sl@0
|
664 |
|
sl@0
|
665 |
// if code gets here then we don't support the interface
|
sl@0
|
666 |
// so we can pass it onto the DevSound proxy so that we
|
sl@0
|
667 |
// can attempt to resolve the interface externally
|
sl@0
|
668 |
return iDevSoundProxy->CustomInterface(aInterfaceId);
|
sl@0
|
669 |
}
|
sl@0
|
670 |
|
sl@0
|
671 |
TInt CMMFDevSoundClientImp::FindCustomInterface(TUid aInterfaceId)
|
sl@0
|
672 |
{
|
sl@0
|
673 |
TInt index = KNullHandle;
|
sl@0
|
674 |
|
sl@0
|
675 |
for (TInt i = 0; i < iCustomInterfaceArray.Count(); i++)
|
sl@0
|
676 |
{
|
sl@0
|
677 |
if (iCustomInterfaceArray[i].iId == aInterfaceId)
|
sl@0
|
678 |
{
|
sl@0
|
679 |
index = i+1; // use index+1 as the handle, so 0 is undefined/not-found
|
sl@0
|
680 |
break;
|
sl@0
|
681 |
}
|
sl@0
|
682 |
}
|
sl@0
|
683 |
|
sl@0
|
684 |
return index;
|
sl@0
|
685 |
}
|
sl@0
|
686 |
|
sl@0
|
687 |
void CMMFDevSoundClientImp::CloseCustomInterface(TInt aIndex)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
for (TInt i = 0; i < iCustomInterfaceArray.Count(); i++)
|
sl@0
|
690 |
{
|
sl@0
|
691 |
if(iCustomInterfaceArray[i].iHandle == aIndex)
|
sl@0
|
692 |
{
|
sl@0
|
693 |
iCustomInterfaceArray[i].iInterface->Release();
|
sl@0
|
694 |
iCustomInterfaceArray.Remove(i);
|
sl@0
|
695 |
break;
|
sl@0
|
696 |
}
|
sl@0
|
697 |
}
|
sl@0
|
698 |
}
|