sl@0
|
1 |
|
sl@0
|
2 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
// All rights reserved.
|
sl@0
|
4 |
// This component and the accompanying materials are made available
|
sl@0
|
5 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
// which accompanies this distribution, and is available
|
sl@0
|
7 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
//
|
sl@0
|
9 |
// Initial Contributors:
|
sl@0
|
10 |
// Nokia Corporation - initial contribution.
|
sl@0
|
11 |
//
|
sl@0
|
12 |
// Contributors:
|
sl@0
|
13 |
//
|
sl@0
|
14 |
// Description:
|
sl@0
|
15 |
// This program is designed to test the MMF_ACLNT.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file TSI_MMFACLNT.cpp
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
#include <mda/common/audio.h>
|
sl@0
|
23 |
#include <mda/common/gsmaudio.h>
|
sl@0
|
24 |
#include "TSI_MMFACLNT.h"
|
sl@0
|
25 |
#include "TSI_MMFACLNT.inl"
|
sl@0
|
26 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
sl@0
|
27 |
#include <mda/common/mdagsmwavcodec.h>
|
sl@0
|
28 |
#endif
|
sl@0
|
29 |
|
sl@0
|
30 |
void CPlayerCallbackHandler::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
|
sl@0
|
31 |
{
|
sl@0
|
32 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
33 |
}
|
sl@0
|
34 |
|
sl@0
|
35 |
void CPlayerCallbackHandler::MapcPlayComplete(TInt aError)
|
sl@0
|
36 |
{
|
sl@0
|
37 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
38 |
}
|
sl@0
|
39 |
|
sl@0
|
40 |
void CStateCallbackHandler::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
|
sl@0
|
41 |
{
|
sl@0
|
42 |
iMchObserver->MchoComplete(ID(),aErrorCode);
|
sl@0
|
43 |
}
|
sl@0
|
44 |
|
sl@0
|
45 |
void CToneCallbackHandler::MatoPrepareComplete(TInt aError)
|
sl@0
|
46 |
{
|
sl@0
|
47 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
|
sl@0
|
50 |
void CToneCallbackHandler::MatoPlayComplete(TInt aError)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
iMchObserver->MchoComplete(ID(),aError);
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
/**
|
sl@0
|
56 |
* Timeout function
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
void CTestMmfAclntStep::WaitWithTimeout(TRequestStatus& aStatus, TInt aNumberOfMicroSeconds)
|
sl@0
|
59 |
{
|
sl@0
|
60 |
TRequestStatus timerStatus;
|
sl@0
|
61 |
RTimer timer ;
|
sl@0
|
62 |
timer.CreateLocal() ;
|
sl@0
|
63 |
timer.After(timerStatus,aNumberOfMicroSeconds);
|
sl@0
|
64 |
|
sl@0
|
65 |
User::WaitForRequest(aStatus, timerStatus);
|
sl@0
|
66 |
if (timerStatus == KRequestPending)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
timer.Cancel();
|
sl@0
|
69 |
User::WaitForRequest(timerStatus);
|
sl@0
|
70 |
}
|
sl@0
|
71 |
else
|
sl@0
|
72 |
{
|
sl@0
|
73 |
INFO_PRINTF1(_L("Time is over!!!")) ;
|
sl@0
|
74 |
}
|
sl@0
|
75 |
timer.Close() ;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
* Time comparison utility function
|
sl@0
|
80 |
*
|
sl@0
|
81 |
* @param "const TUint aActual"
|
sl@0
|
82 |
* The actual timer value produced
|
sl@0
|
83 |
* @param "const TUint aExpected"
|
sl@0
|
84 |
* Expected timer value
|
sl@0
|
85 |
* @param "const TUint aDeviation"
|
sl@0
|
86 |
* Allowed deviation of the expected value
|
sl@0
|
87 |
* from the actual value.
|
sl@0
|
88 |
* @return "TBool"
|
sl@0
|
89 |
* Did actual timed value fall within deviation limits
|
sl@0
|
90 |
*/
|
sl@0
|
91 |
TBool CTestMmfAclntStep::TimeComparison(const TUint aActual, const TUint aExpected, const TUint aDeviation)
|
sl@0
|
92 |
{
|
sl@0
|
93 |
// save unnessary conditions
|
sl@0
|
94 |
if(aActual == aExpected)
|
sl@0
|
95 |
return ETrue;
|
sl@0
|
96 |
|
sl@0
|
97 |
// Prevent unsigned wrapping errors
|
sl@0
|
98 |
TUint difference;
|
sl@0
|
99 |
if(aActual > aExpected)
|
sl@0
|
100 |
difference = aActual - aExpected;
|
sl@0
|
101 |
else
|
sl@0
|
102 |
difference = aExpected - aActual;
|
sl@0
|
103 |
|
sl@0
|
104 |
// comapare
|
sl@0
|
105 |
if(difference < aDeviation)
|
sl@0
|
106 |
return ETrue;
|
sl@0
|
107 |
return EFalse;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
/**
|
sl@0
|
111 |
* Test Preample routines.
|
sl@0
|
112 |
*
|
sl@0
|
113 |
* Creates our own Active Scheduler.
|
sl@0
|
114 |
*
|
sl@0
|
115 |
* @return "TVerdict"
|
sl@0
|
116 |
* Did Preamble complete.
|
sl@0
|
117 |
*/
|
sl@0
|
118 |
TVerdict CTestMmfAclntStep::DoTestStepPreambleL()
|
sl@0
|
119 |
{
|
sl@0
|
120 |
|
sl@0
|
121 |
iActiveScheduler = new(ELeave) CActiveScheduler;
|
sl@0
|
122 |
CActiveScheduler::Install(iActiveScheduler);
|
sl@0
|
123 |
|
sl@0
|
124 |
|
sl@0
|
125 |
return EPass;
|
sl@0
|
126 |
}
|
sl@0
|
127 |
|
sl@0
|
128 |
/**
|
sl@0
|
129 |
* Test Postamble routines.
|
sl@0
|
130 |
*
|
sl@0
|
131 |
* Destroys our Active Scheduler.
|
sl@0
|
132 |
*
|
sl@0
|
133 |
* @return "TVerdict"
|
sl@0
|
134 |
* Did Postamble complete.
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
TVerdict CTestMmfAclntStep::DoTestStepPostambleL()
|
sl@0
|
137 |
{
|
sl@0
|
138 |
delete iActiveScheduler;
|
sl@0
|
139 |
iActiveScheduler = NULL;
|
sl@0
|
140 |
|
sl@0
|
141 |
return EPass;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
/**
|
sl@0
|
145 |
* CTestMMFACLNTStep Implementation
|
sl@0
|
146 |
*
|
sl@0
|
147 |
* @parameter "const CTestSuite* aTestSuite"
|
sl@0
|
148 |
* Sets test suite pointer
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
void CTestMmfAclntStep::SetTestSuite(const CTestSuite* aTestSuite )
|
sl@0
|
151 |
{
|
sl@0
|
152 |
iTestSuite = aTestSuite;
|
sl@0
|
153 |
}
|
sl@0
|
154 |
|
sl@0
|
155 |
/**
|
sl@0
|
156 |
* CTestMMFACLNTStep Implementation
|
sl@0
|
157 |
*/
|
sl@0
|
158 |
CTestMmfAclntStep::CTestMmfAclntStep()
|
sl@0
|
159 |
:iActiveScheduler( NULL )
|
sl@0
|
160 |
{}
|
sl@0
|
161 |
|
sl@0
|
162 |
//------------------------------------------------------
|
sl@0
|
163 |
|
sl@0
|
164 |
/**
|
sl@0
|
165 |
* Deconstructors destroys iFormat and iCodec
|
sl@0
|
166 |
*
|
sl@0
|
167 |
*/
|
sl@0
|
168 |
TVerdict CTestMmfAclntCodecTest::DoTestStepPostambleL()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
if(iFormat != NULL)
|
sl@0
|
171 |
{
|
sl@0
|
172 |
delete iFormat;
|
sl@0
|
173 |
iFormat = NULL;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
if(iCodec != NULL)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
delete iCodec;
|
sl@0
|
178 |
iCodec = NULL;
|
sl@0
|
179 |
}
|
sl@0
|
180 |
return CTestMmfAclntStep::DoTestStepPostambleL();
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
/**
|
sl@0
|
184 |
* Setup codec and format to test
|
sl@0
|
185 |
*
|
sl@0
|
186 |
* @parameter "const TTestFormat aFormat"
|
sl@0
|
187 |
* enum of format to use
|
sl@0
|
188 |
*/
|
sl@0
|
189 |
void CTestMmfAclntCodecTest::SetupFormatL(const TTestFormat aFormat)
|
sl@0
|
190 |
{
|
sl@0
|
191 |
if(iFormat)
|
sl@0
|
192 |
delete iFormat;
|
sl@0
|
193 |
if(iCodec)
|
sl@0
|
194 |
delete iCodec;
|
sl@0
|
195 |
iFormat = NULL;
|
sl@0
|
196 |
iCodec = NULL;
|
sl@0
|
197 |
|
sl@0
|
198 |
switch(aFormat)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
case EPcm16Wav:
|
sl@0
|
201 |
iFormat = new (ELeave) TMdaWavClipFormat;
|
sl@0
|
202 |
CleanupStack::PushL(iFormat);
|
sl@0
|
203 |
iCodec = new (ELeave) TMdaPcmWavCodec;
|
sl@0
|
204 |
CleanupStack::PushL(iCodec);
|
sl@0
|
205 |
break;
|
sl@0
|
206 |
case EMulawRaw:
|
sl@0
|
207 |
iFormat = new (ELeave) TMdaRawAudioClipFormat;
|
sl@0
|
208 |
CleanupStack::PushL(iFormat);
|
sl@0
|
209 |
iCodec = new (ELeave) TMdaAlawRawAudioCodec;
|
sl@0
|
210 |
CleanupStack::PushL(iCodec);
|
sl@0
|
211 |
break;
|
sl@0
|
212 |
case E16BitAu:
|
sl@0
|
213 |
iFormat = new (ELeave) TMdaAuClipFormat;
|
sl@0
|
214 |
CleanupStack::PushL(iFormat);
|
sl@0
|
215 |
iCodec = new (ELeave) TMdaAuCodec;
|
sl@0
|
216 |
CleanupStack::PushL(iCodec);
|
sl@0
|
217 |
break;
|
sl@0
|
218 |
case EAlawAu:
|
sl@0
|
219 |
iFormat = new (ELeave) TMdaAuClipFormat;
|
sl@0
|
220 |
CleanupStack::PushL(iFormat);
|
sl@0
|
221 |
iCodec = new (ELeave) TMdaAlawAuCodec;
|
sl@0
|
222 |
CleanupStack::PushL(iCodec);
|
sl@0
|
223 |
break;
|
sl@0
|
224 |
case EPcm16Au:
|
sl@0
|
225 |
iFormat = new (ELeave) TMdaAuClipFormat;
|
sl@0
|
226 |
CleanupStack::PushL(iFormat);
|
sl@0
|
227 |
iCodec = new (ELeave) TMdaPcm16BitAuCodec;
|
sl@0
|
228 |
CleanupStack::PushL(iCodec);
|
sl@0
|
229 |
break;
|
sl@0
|
230 |
case EImaAdpcmWav:
|
sl@0
|
231 |
iFormat = new (ELeave) TMdaWavClipFormat;
|
sl@0
|
232 |
CleanupStack::PushL(iFormat);
|
sl@0
|
233 |
iCodec = new (ELeave) TMdaImaAdpcmWavCodec;
|
sl@0
|
234 |
CleanupStack::PushL(iCodec);
|
sl@0
|
235 |
break;
|
sl@0
|
236 |
case EAlawWav:
|
sl@0
|
237 |
iFormat = new (ELeave) TMdaWavClipFormat;
|
sl@0
|
238 |
CleanupStack::PushL(iFormat);
|
sl@0
|
239 |
iCodec = new (ELeave) TMdaAlawWavCodec;
|
sl@0
|
240 |
CleanupStack::PushL(iCodec);
|
sl@0
|
241 |
break;
|
sl@0
|
242 |
case EPcmU16:
|
sl@0
|
243 |
iFormat = new (ELeave) TMdaRawAudioClipFormat();
|
sl@0
|
244 |
CleanupStack::PushL(iFormat);
|
sl@0
|
245 |
iCodec = new (ELeave) TMdaUB16RawAudioCodec();
|
sl@0
|
246 |
CleanupStack::PushL(iCodec);
|
sl@0
|
247 |
break;
|
sl@0
|
248 |
case EPcmU8:
|
sl@0
|
249 |
iFormat = new (ELeave) TMdaRawAudioClipFormat();
|
sl@0
|
250 |
CleanupStack::PushL(iFormat);
|
sl@0
|
251 |
iCodec = new (ELeave) TMdaU8PcmRawAudioCodec();
|
sl@0
|
252 |
CleanupStack::PushL(iCodec);
|
sl@0
|
253 |
break;
|
sl@0
|
254 |
case EImasPcmWav:
|
sl@0
|
255 |
iFormat = new (ELeave) TMdaWavClipFormat();
|
sl@0
|
256 |
CleanupStack::PushL(iFormat);
|
sl@0
|
257 |
iCodec = new (ELeave) TMdaImaAdpcmWavCodec();
|
sl@0
|
258 |
CleanupStack::PushL(iCodec);
|
sl@0
|
259 |
break;
|
sl@0
|
260 |
case EPcm8:
|
sl@0
|
261 |
iFormat = new (ELeave) TMdaWavClipFormat();
|
sl@0
|
262 |
CleanupStack::PushL(iFormat);
|
sl@0
|
263 |
iCodec = new (ELeave) TMdaPcmWavCodec(TMdaPcmWavCodec::E8BitPcm);
|
sl@0
|
264 |
CleanupStack::PushL(iCodec);
|
sl@0
|
265 |
break;
|
sl@0
|
266 |
case EGsmWav:
|
sl@0
|
267 |
iFormat = new (ELeave) TMdaWavClipFormat;
|
sl@0
|
268 |
CleanupStack::PushL(iFormat);
|
sl@0
|
269 |
iCodec = new (ELeave) TMdaGsmWavCodec;
|
sl@0
|
270 |
CleanupStack::PushL(iCodec);
|
sl@0
|
271 |
break;
|
sl@0
|
272 |
case EEpocWve:
|
sl@0
|
273 |
case ENone:
|
sl@0
|
274 |
default:
|
sl@0
|
275 |
// will create an inconlusive result as preamble leaves.
|
sl@0
|
276 |
iFormat = NULL;
|
sl@0
|
277 |
iCodec = NULL;
|
sl@0
|
278 |
break;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
if((iFormat != NULL) && (iCodec != NULL))
|
sl@0
|
282 |
{
|
sl@0
|
283 |
CleanupStack::Pop(); // iFormat
|
sl@0
|
284 |
CleanupStack::Pop(); // iCodec
|
sl@0
|
285 |
}
|
sl@0
|
286 |
}
|
sl@0
|
287 |
|