37
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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: This module contains the implementation of CPEAudioDtmfTonePlayer class
|
|
15 |
* member functions
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "cpeaudiodtmftoneplayer.h"
|
|
22 |
#include "pepanic.pan"
|
|
23 |
#include <utility.h>
|
|
24 |
#include <mdaaudiotoneplayer.h>
|
|
25 |
#include <talogger.h>
|
|
26 |
#include <AudioPreference.h>
|
|
27 |
|
|
28 |
// EXTERNAL DATA STRUCTURES
|
|
29 |
// None
|
|
30 |
|
|
31 |
// EXTERNAL FUNCTION PROTOTYPES
|
|
32 |
// None
|
|
33 |
|
|
34 |
// CONSTANTS
|
|
35 |
const TInt KDtmfPauseAfterTone = 100000;
|
|
36 |
const TInt KDtmfToneZero = 0;
|
|
37 |
const TInt KBufSize = 10;
|
|
38 |
_LIT( KPhoneTone_Asterisk, "*+w" );
|
|
39 |
|
|
40 |
const TInt KMaxVolumeLevel = 10;
|
|
41 |
|
|
42 |
// MACROS
|
|
43 |
// None
|
|
44 |
|
|
45 |
// LOCAL CONSTANTS AND MACROS
|
|
46 |
// None
|
|
47 |
|
|
48 |
// MODULE DATA STRUCTURES
|
|
49 |
// None
|
|
50 |
|
|
51 |
// LOCAL FUNCTION PROTOTYPES
|
|
52 |
// None
|
|
53 |
|
|
54 |
// FORWARD DECLARATIONS
|
|
55 |
// None.
|
|
56 |
|
|
57 |
// ==================== LOCAL FUNCTIONS =====================================
|
|
58 |
// None
|
|
59 |
|
|
60 |
// ================= MEMBER FUNCTIONS =======================================
|
|
61 |
|
|
62 |
// -----------------------------------------------------------------------------
|
|
63 |
// CPEAudioDtmfTonePlayer::NewL
|
|
64 |
// Two-phased constructor.
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CPEAudioDtmfTonePlayer* CPEAudioDtmfTonePlayer::NewL()
|
|
68 |
{
|
|
69 |
CPEAudioDtmfTonePlayer* self =
|
|
70 |
new ( ELeave ) CPEAudioDtmfTonePlayer;
|
|
71 |
|
|
72 |
CleanupStack::PushL( self );
|
|
73 |
self->ConstructL();
|
|
74 |
CleanupStack::Pop( self );
|
|
75 |
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
//Destructor
|
|
80 |
CPEAudioDtmfTonePlayer::~CPEAudioDtmfTonePlayer()
|
|
81 |
{
|
|
82 |
TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::~CPEAudioDtmfTonePlayer");
|
|
83 |
Cancel();
|
|
84 |
delete iDTMFPlayer;
|
|
85 |
}
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer
|
|
89 |
// C++ default constructor can NOT contain any code, that
|
|
90 |
// might leave.
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer()
|
|
94 |
{
|
|
95 |
TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer");
|
|
96 |
}
|
|
97 |
|
|
98 |
// -----------------------------------------------------------------------------
|
|
99 |
// CPEAudioDtmfTonePlayer::ConstructL
|
|
100 |
// Symbian 2nd phase constructor can leave.
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
void CPEAudioDtmfTonePlayer::ConstructL()
|
|
104 |
{
|
|
105 |
TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::ConstructL start");
|
|
106 |
TMMFPrioritySettings dtmfClickPlayerPrioritySettings;
|
|
107 |
iDTMFPlayer = CMMFDevSound::NewL();
|
|
108 |
|
|
109 |
iDTMFPlayer->InitializeL( *this, EMMFStateTonePlaying );
|
|
110 |
|
|
111 |
TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::ConstructL completed");
|
|
112 |
}
|
|
113 |
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
// CPEAudioDtmfTonePlayer::SetVolume
|
|
116 |
// Sets the volume level that is used when the dtmf tone is played.
|
|
117 |
// -----------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CPEAudioDtmfTonePlayer::SetVolume(
|
|
120 |
TInt aVolume //Volume to be set
|
|
121 |
)
|
|
122 |
{
|
|
123 |
TInt vol = ConvertVolume( aVolume );
|
|
124 |
|
|
125 |
if ( vol != iVolume )
|
|
126 |
{
|
|
127 |
iVolume = vol;
|
|
128 |
iDTMFPlayer->SetVolume( iVolume );
|
|
129 |
TEFLOGSTRING2( KTAINT, "AUD CPEAudioDtmfTonePlayer::SetVolume, iVolume = %d",
|
|
130 |
iVolume );
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
// -----------------------------------------------------------------------------
|
|
135 |
// CPEAudioDtmfTonePlayer::PlayDtmfTone
|
|
136 |
// Searches the given DTMF tone from iToneArray and calls PlayCurrentTone -member function.
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
//
|
|
139 |
void CPEAudioDtmfTonePlayer::PlayDtmfTone(
|
|
140 |
TChar aTone )
|
|
141 |
{
|
|
142 |
TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::PlayDtmfTone");
|
|
143 |
Cancel();
|
|
144 |
Normalize( aTone );
|
|
145 |
|
|
146 |
// DTMF signalling.
|
|
147 |
if ( iDTMFPlayer )
|
|
148 |
{
|
|
149 |
TBuf<KBufSize> key;
|
|
150 |
key.Append( aTone );
|
|
151 |
TEFLOGSTRING( KTAREQOUT, "AUD CPEAudioDtmfTonePlayer::PlayDtmfTone > CMMFDevSound::PlayDTMFStringL");
|
|
152 |
TRAP_IGNORE( iDTMFPlayer->PlayDTMFStringL( key ) );
|
|
153 |
}
|
|
154 |
}
|
|
155 |
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
// CPEAudioDtmfTonePlayer::Cancel
|
|
158 |
// Cancels the currently playing tone.
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CPEAudioDtmfTonePlayer::Cancel()
|
|
162 |
{
|
|
163 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::Cancel");
|
|
164 |
iDTMFPlayer->Stop();
|
|
165 |
}
|
|
166 |
|
|
167 |
// -----------------------------------------------------------------------------
|
|
168 |
// CPEAudioDtmfTonePlayer::Normalize
|
|
169 |
// Lowers case for chars and if its '*','+', or 'w' sets it to asterisk char ('*').
|
|
170 |
// -----------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
void CPEAudioDtmfTonePlayer::Normalize(
|
|
173 |
TChar& aTone )
|
|
174 |
{
|
|
175 |
TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::Normalize");
|
|
176 |
aTone.LowerCase();
|
|
177 |
|
|
178 |
TPtrC ast( KPhoneTone_Asterisk );
|
|
179 |
|
|
180 |
if ( ast.Locate( aTone ) != KErrNotFound )
|
|
181 |
{
|
|
182 |
aTone = ast[ 0 ];
|
|
183 |
TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::Normalize");
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------
|
|
188 |
// CPEAudioDtmfTonePlayer::InitializeComplete
|
|
189 |
// ---------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CPEAudioDtmfTonePlayer::InitializeComplete(
|
|
192 |
TInt aError )
|
|
193 |
{
|
|
194 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::InitializeComplete");
|
|
195 |
__ASSERT_DEBUG( aError == KErrNone , Panic( EPEPanicAudioInitializeError ) );
|
|
196 |
|
|
197 |
if( aError == KErrNone)
|
|
198 |
{
|
|
199 |
TMMFPrioritySettings dtmfClickPlayerSettings;
|
|
200 |
|
|
201 |
dtmfClickPlayerSettings.iPref =
|
|
202 |
( TMdaPriorityPreference ) KAudioPrefKeyDownDTMF;
|
|
203 |
dtmfClickPlayerSettings.iPriority = KAudioPriorityDtmfKeyPress;
|
|
204 |
dtmfClickPlayerSettings.iState = EMMFStateTonePlaying;
|
|
205 |
|
|
206 |
iDTMFPlayer->SetPrioritySettings( dtmfClickPlayerSettings );
|
|
207 |
|
|
208 |
TTimeIntervalMicroSeconds32 length( KMdaInfiniteDurationDTMFToneOnLength );
|
|
209 |
TTimeIntervalMicroSeconds32 pause( KDtmfPauseAfterTone );
|
|
210 |
TTimeIntervalMicroSeconds32 zero( KDtmfToneZero );
|
|
211 |
|
|
212 |
iDTMFPlayer->SetDTMFLengths( length, pause, zero );
|
|
213 |
|
|
214 |
iDTMFPlayer->SetToneRepeats(
|
|
215 |
KMdaAudioToneRepeatForever,
|
|
216 |
TTimeIntervalMicroSeconds( KDtmfToneZero ) );
|
|
217 |
// Must initialize volume to dtmf player. Otherwise it will be
|
|
218 |
// 5 by default in audio SW.
|
|
219 |
iDTMFPlayer->SetVolume( iVolume );
|
|
220 |
}
|
|
221 |
|
|
222 |
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------
|
|
226 |
// CPEAudioDtmfTonePlayer::ToneFinished
|
|
227 |
// ---------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CPEAudioDtmfTonePlayer::ToneFinished(
|
|
230 |
TInt /*aError*/ )
|
|
231 |
{
|
|
232 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ToneFinished");
|
|
233 |
}
|
|
234 |
|
|
235 |
// ---------------------------------------------------------
|
|
236 |
// CPEAudioDtmfTonePlayer::BufferToBeFilled
|
|
237 |
// ---------------------------------------------------------
|
|
238 |
//
|
|
239 |
void CPEAudioDtmfTonePlayer::BufferToBeFilled( CMMFBuffer* /*aBuffer*/ )
|
|
240 |
{
|
|
241 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::BufferToBeFilled");
|
|
242 |
}
|
|
243 |
|
|
244 |
// ---------------------------------------------------------
|
|
245 |
// CPEAudioDtmfTonePlayer::PlayError
|
|
246 |
// ---------------------------------------------------------
|
|
247 |
//
|
|
248 |
void CPEAudioDtmfTonePlayer::PlayError( TInt /*aError*/ )
|
|
249 |
{
|
|
250 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::PlayError");
|
|
251 |
}
|
|
252 |
|
|
253 |
// ---------------------------------------------------------
|
|
254 |
// CPEAudioDtmfTonePlayer::BufferToBeEmptied
|
|
255 |
// ---------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CPEAudioDtmfTonePlayer::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ )
|
|
258 |
{
|
|
259 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::BufferToBeEmptied");
|
|
260 |
}
|
|
261 |
|
|
262 |
// ---------------------------------------------------------
|
|
263 |
// CPEAudioDtmfTonePlayer::RecordError
|
|
264 |
// ---------------------------------------------------------
|
|
265 |
//
|
|
266 |
void CPEAudioDtmfTonePlayer::RecordError( TInt /*aError*/ )
|
|
267 |
{
|
|
268 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::RecordError");
|
|
269 |
}
|
|
270 |
|
|
271 |
// ---------------------------------------------------------
|
|
272 |
// CPEAudioDtmfTonePlayer::ConvertError
|
|
273 |
// ---------------------------------------------------------
|
|
274 |
//
|
|
275 |
void CPEAudioDtmfTonePlayer::ConvertError( TInt /*aError*/ )
|
|
276 |
{
|
|
277 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ConvertError");
|
|
278 |
}
|
|
279 |
|
|
280 |
// ---------------------------------------------------------
|
|
281 |
// CPEAudioDtmfTonePlayer::DeviceMessage
|
|
282 |
// ---------------------------------------------------------
|
|
283 |
//
|
|
284 |
void CPEAudioDtmfTonePlayer::DeviceMessage( TUid /*aMessageType*/,
|
|
285 |
const TDesC8& /*aMsg*/ )
|
|
286 |
{
|
|
287 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::DeviceMessage");
|
|
288 |
}
|
|
289 |
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
// CPEAudioDtmfTonePlayer::ConvertVolume
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
//
|
|
294 |
TInt CPEAudioDtmfTonePlayer::ConvertVolume( TInt aVolume )
|
|
295 |
{
|
|
296 |
TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ConvertVolume");
|
|
297 |
TInt result = iDTMFPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;
|
|
298 |
|
|
299 |
TEFLOGSTRING3( KTAREQEND,
|
|
300 |
"AUD CPEAudioDtmfTonePlayer::ConvertVolume, result = %d, maxVol=%d",
|
|
301 |
result, iDTMFPlayer->MaxVolume() );
|
|
302 |
return result;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ================= OTHER EXPORTED FUNCTIONS ==============
|
|
306 |
// None.
|
|
307 |
|
|
308 |
// End of File
|