|
1 /* |
|
2 * Copyright (c) 2005-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "t_cerrorconcealmentintfcdata.h" |
|
20 |
|
21 /*@{*/ |
|
22 //Command literals |
|
23 _LIT(KCmdNewL, "NewL"); |
|
24 _LIT(KCmdDestructor, "~"); |
|
25 _LIT(KCmdConcealErrorForNextBuffer, "ConcealErrorForNextBuffer"); |
|
26 _LIT(KCmdSetFrameMode, "SetFrameMode"); |
|
27 _LIT(KCmdFrameModeRqrdForEC, "FrameModeRqrdForEC"); |
|
28 /*@}*/ |
|
29 |
|
30 /*@{*/ |
|
31 //INI Section name literals |
|
32 _LIT(KFrameMode, "FrameMode"); |
|
33 _LIT(KFrameModeRqrd, "FrameModeRqrd"); |
|
34 _LIT(KDevSoundInstanceName, "DevSoundInstanceName"); |
|
35 /*@}*/ |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 /** |
|
41 * Two phase constructor |
|
42 * @leave system wide error |
|
43 */ |
|
44 CT_CErrorConcealmentIntfcData* CT_CErrorConcealmentIntfcData::NewL() |
|
45 { |
|
46 CT_CErrorConcealmentIntfcData* self = new (ELeave)CT_CErrorConcealmentIntfcData(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 /** |
|
51 * Private constructor. First phase construction |
|
52 */ |
|
53 CT_CErrorConcealmentIntfcData::CT_CErrorConcealmentIntfcData() |
|
54 : |
|
55 iErrorConcealmentIntfc(NULL) |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 /** |
|
61 * Public destructor |
|
62 */ |
|
63 CT_CErrorConcealmentIntfcData::~CT_CErrorConcealmentIntfcData() |
|
64 { |
|
65 DestroyData(); |
|
66 } |
|
67 |
|
68 |
|
69 /** |
|
70 * Helper method for DoCmdDestructor |
|
71 */ |
|
72 void CT_CErrorConcealmentIntfcData::DestroyData() |
|
73 { |
|
74 if (iErrorConcealmentIntfc) |
|
75 { |
|
76 delete iErrorConcealmentIntfc; |
|
77 iErrorConcealmentIntfc = NULL; |
|
78 } |
|
79 } |
|
80 |
|
81 /** |
|
82 * Return a pointer to the object that the data wraps |
|
83 * |
|
84 * @return pointer to the object that the data wraps |
|
85 */ |
|
86 TAny* CT_CErrorConcealmentIntfcData::GetObject() |
|
87 { |
|
88 return iErrorConcealmentIntfc; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Process a command read from the Ini file |
|
93 * @param aCommand - The command to process |
|
94 * @param aSection - The section get from the *.ini file of the project T_Wlan |
|
95 * @param aAsyncErrorIndex - Command index dor async calls to returns errors to |
|
96 * @return TBool - ETrue if the command is process |
|
97 * @leave - System wide error |
|
98 */ |
|
99 TBool CT_CErrorConcealmentIntfcData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
100 { |
|
101 TBool ret = ETrue; |
|
102 if (aCommand == KCmdNewL) |
|
103 { |
|
104 DoCmdNewL(); |
|
105 } |
|
106 else if (aCommand == KCmdDestructor) |
|
107 { |
|
108 DoCmdDestructor(); |
|
109 } |
|
110 else if (aCommand == KCmdConcealErrorForNextBuffer) |
|
111 { |
|
112 DoCmdConcealErrorForNextBuffer(); |
|
113 } |
|
114 else if (aCommand == KCmdSetFrameMode) |
|
115 { |
|
116 DoCmdSetFrameMode(aSection); |
|
117 } |
|
118 else if (aCommand == KCmdFrameModeRqrdForEC) |
|
119 { |
|
120 DoCmdFrameModeRqrdForEC(aSection); |
|
121 } |
|
122 else |
|
123 { |
|
124 ERR_PRINTF1(_L("Unknown command")); |
|
125 ret=EFalse; |
|
126 } |
|
127 return ret; |
|
128 } |
|
129 |
|
130 /** |
|
131 * Create an instance of CErrorConcealmentIntfc |
|
132 * @param none |
|
133 * @return none |
|
134 */ |
|
135 void CT_CErrorConcealmentIntfcData::DoCmdNewL() |
|
136 { |
|
137 DestroyData(); |
|
138 INFO_PRINTF1(_L("*START*CT_CErrorConcealmentIntfcData::DoCmdNewL()")); |
|
139 if (!iErrorConcealmentIntfc) |
|
140 { |
|
141 TPtrC devSoundInstanceName; |
|
142 if (!GetStringFromConfig(aSection, KDevSoundInstanceName, devSoundInstanceName)) |
|
143 { |
|
144 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDevSoundInstanceName); |
|
145 SetBlockResult(EFail); |
|
146 } |
|
147 else |
|
148 { |
|
149 CMMFDevSound* devSoundInstance = static_cast<CMMFDevSound*>(GetDataObjectL(devSoundInstanceName)); |
|
150 if(devSoundInstance) |
|
151 { |
|
152 iErrorConcelmentIntfc == (CErrorConcealmentIntfc*)devSoundInstance->CustomInterface(KUidErrorConcealmentIntfc); |
|
153 if (iErrorConcealmentIntfc == NULL) |
|
154 { |
|
155 ERR_PRINTF1(_L("Could not get ErrConcealment CI")); |
|
156 SetError(KErrNotFound); |
|
157 } |
|
158 else |
|
159 { |
|
160 INFO_PRINTF1(_L("ErrConcealment created successfully")); |
|
161 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdNewL()")); |
|
162 } |
|
163 } |
|
164 else |
|
165 { |
|
166 ERR_PRINTF1(_L("DevSound not ready")); |
|
167 SetError(KErrNotReady); |
|
168 } |
|
169 } |
|
170 } |
|
171 else |
|
172 { |
|
173 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdNewL()")); |
|
174 } |
|
175 } |
|
176 |
|
177 /** |
|
178 * Destroy an instance of CErrorConcealmentIntfc |
|
179 * @param |
|
180 * @none |
|
181 */ |
|
182 void CT_CErrorConcealmentIntfcData::DoCmdDestructor() |
|
183 { |
|
184 INFO_PRINTF1(_L("*START*CT_CErrorConcealmentIntfcData::DoCmdDestroyData()")); |
|
185 DestroyData(); |
|
186 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdDestroyData()")); |
|
187 } |
|
188 |
|
189 /** |
|
190 * Command for Conceal and error for next buffer |
|
191 * @param none |
|
192 * @return none |
|
193 */ |
|
194 void CT_CErrorConcealmentIntfcData::DoCmdConcealErrorForNextBuffer() |
|
195 { |
|
196 INFO_PRINTF1(_L("*START*CT_CErrorConcealmentIntfcData::DoCmdConcealErrorForNextBuffer()")); |
|
197 TInt error = iErrorConcealmentIntfc->ConcealErrorForNextBuffer()); |
|
198 if(error != KErrNone) |
|
199 { |
|
200 ERR_PRINTF2(_L("> Could not execute DoCmdConcealErrorForNextBuffer: %d"), error); |
|
201 SetError(error); |
|
202 } |
|
203 else |
|
204 { |
|
205 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdConcealErrorForNextBuffer()")); |
|
206 } |
|
207 } |
|
208 |
|
209 /** |
|
210 * Puts the hwdevice into a frame-based interface. |
|
211 * The alternate mode of interface would be buffer-based. |
|
212 * @param aSection - The section to read param from the ini file |
|
213 * @return none |
|
214 */ |
|
215 void CT_CErrorConcealmentIntfcData::DoCmdSetFrameMode(const TTEFSectionName& aSection) |
|
216 { |
|
217 INFO_PRINTF1(_L("*START*CT_CErrorConcealmentIntfcData::DoCmdSetFrameMode()")); |
|
218 TBool aFrameMode = EFalse; |
|
219 if (!GetBoolFromConfig(aSection, KFrameMode, aFrameMode)) |
|
220 { |
|
221 INFO_PRINTF2(_L("Parameter %S was not found in INI file."), &KFrameMode); |
|
222 SetBlockResult(EFail); |
|
223 } |
|
224 else |
|
225 { |
|
226 TInt error = iErrorConcealmentIntfc->SetFrameMode(aFrameMode); |
|
227 if ( KErrNone != error ) |
|
228 { |
|
229 ERR_PRINTF2(_L("> Could not execute DoCmdSetFrameMode: %d"), error); |
|
230 SetError(error); |
|
231 } |
|
232 else |
|
233 { |
|
234 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdSetFrameMode()")); |
|
235 } |
|
236 } |
|
237 } |
|
238 |
|
239 /** |
|
240 * Query to find out if frame-based interface is required by hwdevice |
|
241 * for supporting error concealment. |
|
242 * @param aSection |
|
243 * @return none |
|
244 */ |
|
245 void CT_CErrorConcealmentIntfcData::DoCmdFrameModeRqrdForEC(const TTEFSectionName& aSection) |
|
246 { |
|
247 INFO_PRINTF1(_L("*START*CT_CErrorConcealmentIntfcData::DoCmdFrameModeRqrdForEC()")); |
|
248 TBool aFrameModeRqrd = EFalse; |
|
249 if (!GetBoolFromConfig(aSection, KFrameModeRqrd, aFrameModeRqrd)) |
|
250 { |
|
251 INFO_PRINTF2(_L("Parameter %S was not found in INI file."), &KFrameModeRqrd); |
|
252 SetBlockResult(EFail); |
|
253 } |
|
254 else |
|
255 { |
|
256 TInt error = iErrorConcealmentIntfc->FrameModeRqrdForEC(aFrameModeRqrd); |
|
257 |
|
258 if ( KErrNone != error ) |
|
259 { |
|
260 ERR_PRINTF2(_L("> Could not execute DoCmdSetFrameMode: %d"), error); |
|
261 SetError(error); |
|
262 } |
|
263 else |
|
264 { |
|
265 INFO_PRINTF1(_L("*END*CT_CErrorConcealmentIntfcData::DoCmdFrameModeRqrdForEC()")); |
|
266 } |
|
267 } |
|
268 } |