sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-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 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "t_cg711decoderintfcdata.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
/*@{*/
|
sl@0
|
24 |
//Enumeration Literals
|
sl@0
|
25 |
_LIT(KEDecALaw, "EDecALaw");
|
sl@0
|
26 |
_LIT(KEDecULaw, "EDecULaw" );
|
sl@0
|
27 |
/*@}*/
|
sl@0
|
28 |
|
sl@0
|
29 |
/*@{*/
|
sl@0
|
30 |
//Command literals
|
sl@0
|
31 |
_LIT(KCmdNewL, "NewL");
|
sl@0
|
32 |
_LIT(KCmdDestructor, "~");
|
sl@0
|
33 |
_LIT(KCmdSetDecoderMode, "SetDecoderMode");
|
sl@0
|
34 |
_LIT(KCmdSetCng, "KCmdSetCng");
|
sl@0
|
35 |
/*@}*/
|
sl@0
|
36 |
|
sl@0
|
37 |
/*@{*/
|
sl@0
|
38 |
//INI Section name literals
|
sl@0
|
39 |
_LIT(KDecoder, "Decoder");
|
sl@0
|
40 |
_LIT(KCng, "CNG");
|
sl@0
|
41 |
/*@}*/
|
sl@0
|
42 |
|
sl@0
|
43 |
const CDataWrapperBase::TEnumEntryTable iEnumDecoders[] =
|
sl@0
|
44 |
{
|
sl@0
|
45 |
{ KEDecALaw, 0/*EDecALaw */},
|
sl@0
|
46 |
{ KEDecULaw, 1/*EDecULaw*/ }
|
sl@0
|
47 |
};
|
sl@0
|
48 |
|
sl@0
|
49 |
|
sl@0
|
50 |
/**
|
sl@0
|
51 |
* Private constructor. First phase construction
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
CT_CG711DecoderIntfcData::CT_CG711DecoderIntfcData()
|
sl@0
|
54 |
:
|
sl@0
|
55 |
iG711Decoder(NULL),
|
sl@0
|
56 |
iCng(EFalse)
|
sl@0
|
57 |
{
|
sl@0
|
58 |
}
|
sl@0
|
59 |
|
sl@0
|
60 |
/**
|
sl@0
|
61 |
* Second phase construction
|
sl@0
|
62 |
*
|
sl@0
|
63 |
* @internalComponent
|
sl@0
|
64 |
* @return N/A
|
sl@0
|
65 |
* @pre None
|
sl@0
|
66 |
* @post None
|
sl@0
|
67 |
* @leave system wide error
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
//void CT_CG711DecoderIntfcData::ConstructL()
|
sl@0
|
70 |
// {
|
sl@0
|
71 |
//
|
sl@0
|
72 |
// }
|
sl@0
|
73 |
|
sl@0
|
74 |
/**
|
sl@0
|
75 |
* Two phase constructor
|
sl@0
|
76 |
*
|
sl@0
|
77 |
* @leave system wide error
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
CT_CG711DecoderIntfcData* CT_CG711DecoderIntfcData::NewL()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
CT_CG711DecoderIntfcData* self = new (ELeave)CT_CG711DecoderIntfcData();
|
sl@0
|
82 |
return self;
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
/**
|
sl@0
|
86 |
* Return a pointer to the object that the data wraps
|
sl@0
|
87 |
*
|
sl@0
|
88 |
* @return pointer to the object that the data wraps
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
TAny* CT_CG711DecoderIntfcData::GetObject()
|
sl@0
|
91 |
{
|
sl@0
|
92 |
return iG711Decoder;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
/**
|
sl@0
|
96 |
* Public destructor
|
sl@0
|
97 |
*/
|
sl@0
|
98 |
CT_CG711DecoderIntfcData::~CT_CG711DecoderIntfcData()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
DestroyData();
|
sl@0
|
101 |
}
|
sl@0
|
102 |
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
* Helper method for DoCmdDestructor
|
sl@0
|
105 |
*/
|
sl@0
|
106 |
void CT_CG711DecoderIntfcData::DestroyData()
|
sl@0
|
107 |
{
|
sl@0
|
108 |
if (iG711Decoder != NULL)
|
sl@0
|
109 |
{
|
sl@0
|
110 |
delete iG711Decoder;
|
sl@0
|
111 |
iG711Decoder = NULL;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
}
|
sl@0
|
114 |
|
sl@0
|
115 |
/**
|
sl@0
|
116 |
* Process a command read from the Ini file
|
sl@0
|
117 |
* @param aCommand - The command to process
|
sl@0
|
118 |
* @param aSection - The section get from the *.ini file of the project T_Wlan
|
sl@0
|
119 |
* @param aAsyncErrorIndex - Command index dor async calls to returns errors to
|
sl@0
|
120 |
* @return TBool - ETrue if the command is process
|
sl@0
|
121 |
* @leave - system wide error
|
sl@0
|
122 |
*/
|
sl@0
|
123 |
TBool CT_CG711DecoderIntfcData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
|
sl@0
|
124 |
{
|
sl@0
|
125 |
TBool ret = ETrue;
|
sl@0
|
126 |
|
sl@0
|
127 |
if (aCommand == KCmdNewL)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
DoCmdNewL();
|
sl@0
|
130 |
}
|
sl@0
|
131 |
else if (aCommand == KCmdDestructor)
|
sl@0
|
132 |
{
|
sl@0
|
133 |
DoCmdDestructor();
|
sl@0
|
134 |
}
|
sl@0
|
135 |
else if (aCommand == KCmdSetDecoderMode)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
DoCmdSetDecoderMode(aSection);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
else if (aCommand == KCmdSetCng)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
DoCmdSetCng(aSection);
|
sl@0
|
142 |
}
|
sl@0
|
143 |
else
|
sl@0
|
144 |
{
|
sl@0
|
145 |
ERR_PRINTF1(_L("Unknown command."));
|
sl@0
|
146 |
ret=EFalse;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
|
sl@0
|
149 |
return ret;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
|
sl@0
|
152 |
/**
|
sl@0
|
153 |
* Create an Instance of CG711DecoderIntfc
|
sl@0
|
154 |
* @param none
|
sl@0
|
155 |
* @return none
|
sl@0
|
156 |
*/
|
sl@0
|
157 |
void CT_CG711DecoderIntfcData::DoCmdNewL()
|
sl@0
|
158 |
{
|
sl@0
|
159 |
INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdNewL()"));
|
sl@0
|
160 |
|
sl@0
|
161 |
TRAPD(error, CT_CG711DecoderIntfcData::NewL());
|
sl@0
|
162 |
if(KErrNone!=error)
|
sl@0
|
163 |
{
|
sl@0
|
164 |
ERR_PRINTF2(_L("> Could not create CG711HwDevice: %d"), error);
|
sl@0
|
165 |
SetError(error);
|
sl@0
|
166 |
}
|
sl@0
|
167 |
else
|
sl@0
|
168 |
{
|
sl@0
|
169 |
INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdNewL()"));
|
sl@0
|
170 |
}
|
sl@0
|
171 |
}
|
sl@0
|
172 |
|
sl@0
|
173 |
/**
|
sl@0
|
174 |
* Destroy an instance of CG711DecoderIntfc
|
sl@0
|
175 |
* @param none
|
sl@0
|
176 |
* @return none
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
void CT_CG711DecoderIntfcData::DoCmdDestructor()
|
sl@0
|
179 |
{
|
sl@0
|
180 |
INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdDestructor()"));
|
sl@0
|
181 |
DestroyData();
|
sl@0
|
182 |
INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdDestructor()"));
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
/**
|
sl@0
|
186 |
* Set decoder mode
|
sl@0
|
187 |
* @param aSection - Section to read param from the ini file
|
sl@0
|
188 |
* @return none
|
sl@0
|
189 |
*/
|
sl@0
|
190 |
void CT_CG711DecoderIntfcData::DoCmdSetDecoderMode(const TTEFSectionName& aSection)
|
sl@0
|
191 |
{
|
sl@0
|
192 |
INFO_PRINTF1(_L("*START* CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()"));
|
sl@0
|
193 |
TInt expectedValue;
|
sl@0
|
194 |
if (!GetEnumFromConfig(aSection, KDecoder, iEnumDecoders, expectedValue))
|
sl@0
|
195 |
{
|
sl@0
|
196 |
INFO_PRINTF2(_L("Parameter %S was not found in INI file."), &KDecoder);
|
sl@0
|
197 |
SetBlockResult(EFail);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
else
|
sl@0
|
200 |
{
|
sl@0
|
201 |
TInt error = iG711Decoder->SetDecoderMode((CG711DecoderIntfc::TDecodeMode)expectedValue);
|
sl@0
|
202 |
if ( KErrNone != error )
|
sl@0
|
203 |
{
|
sl@0
|
204 |
ERR_PRINTF2(_L("[%d] SetDecoderMode()"), error);
|
sl@0
|
205 |
SetError(error);
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else
|
sl@0
|
208 |
{
|
sl@0
|
209 |
INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetDecoderMode()"));
|
sl@0
|
210 |
}
|
sl@0
|
211 |
}
|
sl@0
|
212 |
}
|
sl@0
|
213 |
|
sl@0
|
214 |
/**
|
sl@0
|
215 |
* @param aSection - Section to read param from the ini file
|
sl@0
|
216 |
* @return none
|
sl@0
|
217 |
*/
|
sl@0
|
218 |
void CT_CG711DecoderIntfcData::DoCmdSetCng(const TTEFSectionName& aSection)
|
sl@0
|
219 |
{
|
sl@0
|
220 |
INFO_PRINTF1(_L("*START*CT_CG711DecoderIntfcData::DoCmdSetCng()"));
|
sl@0
|
221 |
|
sl@0
|
222 |
if(!GetBoolFromConfig(aSection, KCng, iCng))
|
sl@0
|
223 |
{
|
sl@0
|
224 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KCng);
|
sl@0
|
225 |
SetBlockResult(EFail);
|
sl@0
|
226 |
return;
|
sl@0
|
227 |
}
|
sl@0
|
228 |
else
|
sl@0
|
229 |
{
|
sl@0
|
230 |
TInt error = iG711Decoder->SetCng(iCng);
|
sl@0
|
231 |
if ( KErrNone != error )
|
sl@0
|
232 |
{
|
sl@0
|
233 |
ERR_PRINTF2(_L("[%d] SetCng() error "), error);
|
sl@0
|
234 |
SetError(error);
|
sl@0
|
235 |
return;
|
sl@0
|
236 |
}
|
sl@0
|
237 |
else
|
sl@0
|
238 |
{
|
sl@0
|
239 |
INFO_PRINTF1(_L("*END*CT_CG711DecoderIntfcData::DoCmdSetCng()"));
|
sl@0
|
240 |
}
|
sl@0
|
241 |
}
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|