|
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_caudioinputdata.h" |
|
20 |
|
21 |
|
22 /*@{*/ |
|
23 // Output options Id's |
|
24 const TUid INPUT_DEFAULTMIC = TUid::Uid(0x00); |
|
25 const TUid INPUT_OUTPUTTOSPEAKER = TUid::Uid(0x01); |
|
26 const TUid INPUT_FMRADIO = TUid::Uid(0x02); |
|
27 const TUid INPUT_VOICECALL = TUid::Uid(0x03); |
|
28 const TUid INPUT_LINEIN = TUid::Uid(0x04); |
|
29 /*@}*/ |
|
30 |
|
31 |
|
32 /*@{*/ |
|
33 //Section name literals |
|
34 _LIT(KDevSoundKey, "DevSoundInstanceName"); |
|
35 _LIT(KAudioInputPar, "AudioInput"); |
|
36 /*@}*/ |
|
37 |
|
38 /*@{*/ |
|
39 //Command literals |
|
40 _LIT(KCmdNewL, "NewL"); |
|
41 _LIT(KCmdDestructor, "~"); |
|
42 _LIT(KCmdAudioInput, "AudioInput"); |
|
43 _LIT(KCmdSetAudioInput, "SetAudioInput"); |
|
44 /*@}*/ |
|
45 |
|
46 |
|
47 |
|
48 /*@{*/ |
|
49 // Output options literal |
|
50 _LIT(KInput_DefaultMic, "Input_DefaultMic"); |
|
51 _LIT(KInput_OutputtoSpeaker, "Input_OutputtoSpeaker"); |
|
52 _LIT(KInput_FMRadio, "Input_FMRadio"); |
|
53 _LIT(KInput_VoiceCall, "Input_VoiceCall"); |
|
54 _LIT(KInput_LineIn, "Input_LineIn"); |
|
55 /*@}*/ |
|
56 |
|
57 |
|
58 const CDataWrapperBase::TEnumEntryTable CT_CAudioInputData::iEnumInputOptions[] = |
|
59 { |
|
60 { KInput_DefaultMic, INPUT_DEFAULTMIC.iUid }, |
|
61 { KInput_OutputtoSpeaker, INPUT_OUTPUTTOSPEAKER.iUid }, |
|
62 { KInput_FMRadio, INPUT_FMRADIO.iUid }, |
|
63 { KInput_VoiceCall, INPUT_VOICECALL.iUid }, |
|
64 { KInput_LineIn, INPUT_LINEIN.iUid } |
|
65 }; |
|
66 |
|
67 |
|
68 /** |
|
69 * Two phase constructor |
|
70 * |
|
71 * @leave system wide error |
|
72 */ |
|
73 CT_CAudioInputData* CT_CAudioInputData::NewL() |
|
74 { |
|
75 CT_CAudioInputData* ret = new (ELeave) CT_CAudioInputData(); |
|
76 return ret; |
|
77 } |
|
78 |
|
79 /** |
|
80 * Private constructor. First phase construction |
|
81 */ |
|
82 CT_CAudioInputData::CT_CAudioInputData() |
|
83 : |
|
84 iAudioInput(NULL) |
|
85 { |
|
86 } |
|
87 |
|
88 /** |
|
89 * Return a pointer to the object that the data wraps |
|
90 * |
|
91 * @return pointer to the object that the data wraps |
|
92 */ |
|
93 TAny* CT_CAudioInputData::GetObject() |
|
94 { |
|
95 return iAudioInput; |
|
96 } |
|
97 /** |
|
98 * Helper method for DoCmdDestructor |
|
99 */ |
|
100 void CT_CAudioInputData::DestroyData() |
|
101 { |
|
102 if (iAudioInput) |
|
103 { |
|
104 delete iAudioInput; |
|
105 iAudioInput = NULL; |
|
106 } |
|
107 } |
|
108 |
|
109 /** |
|
110 * Process a command read from the Ini file |
|
111 * @param aCommand - The command to process |
|
112 * @param aSection - The section get from the *.ini file of the project T_Wlan |
|
113 * @param aAsyncErrorIndex - Command index dor async calls to returns errors to |
|
114 * @return TBool - ETrue if the command is process |
|
115 * @leave - system wide error |
|
116 */ |
|
117 TBool CT_CAudioInputData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
118 { |
|
119 TBool ret = ETrue; |
|
120 if (aCommand == KCmdNewL) |
|
121 { |
|
122 DoCmdNewL(aSection); |
|
123 } |
|
124 else if (aCommand == KCmdDestructor) |
|
125 { |
|
126 DoCmdDestructor(); |
|
127 } |
|
128 else if (aCommand == KCmdAudioInput) |
|
129 { |
|
130 DoCmdAudioInput(); |
|
131 } |
|
132 else if (aCommand == KCmdSetAudioInput) |
|
133 { |
|
134 DoCmdSetAudioInputL(aSection); |
|
135 } |
|
136 else |
|
137 { |
|
138 ERR_PRINTF1(_L("Unknown command.")); |
|
139 ret=EFalse; |
|
140 } |
|
141 return ret; |
|
142 } |
|
143 |
|
144 /** |
|
145 * Create an instance of CAudioInput object |
|
146 * @param aSection - Section to read param from the ini file |
|
147 * @return none |
|
148 */ |
|
149 void CT_CAudioInputData::DoCmdNewL(const TTEFSectionName& aSection) |
|
150 { |
|
151 DestroyData(); |
|
152 INFO_PRINTF1(_L("*START*CT_CAudioInputData::DoCmdNewL()")); |
|
153 TPtrC devSoundObject; |
|
154 if( !GetStringFromConfig(aSection, KDevSoundKey, devSoundObject) ) |
|
155 { |
|
156 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDevSoundKey); |
|
157 SetBlockResult(EFail); |
|
158 } |
|
159 else |
|
160 { |
|
161 CMMFDevSound* DevSoundObject = static_cast<CMMFDevSound*>(GetDataObjectL(devSoundObject)); |
|
162 iAudioInput = (CAudioInput*)DevSoundObject->CustomInterface(KUidAudioInput); |
|
163 INFO_PRINTF1(_L("*END*CT_CAudioInputData::DoCmdNewL()")); |
|
164 } |
|
165 } |
|
166 |
|
167 /** |
|
168 * Destroy an instance of CAudioInput object |
|
169 * @param none |
|
170 * @param none |
|
171 */ |
|
172 void CT_CAudioInputData::DoCmdDestructor() |
|
173 { |
|
174 INFO_PRINTF1(_L("*START*CT_CAudioInputData::DoCmdDestructor()")); |
|
175 DestroyData(); |
|
176 INFO_PRINTF1(_L("*END*CT_CAudioInputData::DoCmdDestructor()")); |
|
177 } |
|
178 |
|
179 /** |
|
180 * Get an array of Audio Input |
|
181 * @param none |
|
182 * @return none |
|
183 */ |
|
184 void CT_CAudioInputData::DoCmdAudioInput() |
|
185 { |
|
186 INFO_PRINTF1(_L("*START*CT_CAudioInputData::DoCmdAudioInput()")); |
|
187 CAudioInput::TAudioInputArray inputArray = iAudioInput->AudioInput(); |
|
188 INFO_PRINTF1(_L("*END*CT_CAudioInputData::DoCmdAudioInput()")); |
|
189 } |
|
190 |
|
191 /** |
|
192 * Set the audio input |
|
193 * @param aSection - Section to read param from the ini file |
|
194 * @return none |
|
195 */ |
|
196 void CT_CAudioInputData::DoCmdSetAudioInputL(const TTEFSectionName& aSection) |
|
197 { |
|
198 |
|
199 INFO_PRINTF1(_L("*START*CT_CAudioInputData::DoCmdSetAudioInputL()")); |
|
200 TInt parAudioInput; |
|
201 if(!GetEnumFromConfig(aSection, KAudioInputPar, iEnumInputOptions, parAudioInput)) |
|
202 { |
|
203 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KAudioInputPar); |
|
204 SetBlockResult(EFail); |
|
205 } |
|
206 else |
|
207 { |
|
208 CArrayFixFlat<CAudioInput::TAudioInputPreference>* inputarray = new (ELeave) CArrayFixFlat<CAudioInput::TAudioInputPreference>(4); |
|
209 CleanupStack::PushL(inputarray); |
|
210 inputarray->AppendL((CAudioInput::TAudioInputPreference)parAudioInput); |
|
211 TRAPD( error, iAudioInput->SetAudioInputL( inputarray->Array() ) ); |
|
212 if( error != KErrNone ) |
|
213 { |
|
214 ERR_PRINTF2(_L("Setting audio input failed with error %d"), error); |
|
215 SetError(error); |
|
216 } |
|
217 else |
|
218 { |
|
219 CleanupStack::PopAndDestroy(&inputarray); |
|
220 INFO_PRINTF1(_L("*END*CT_CAudioInputData::DoCmdSetAudioInputL()")); |
|
221 } |
|
222 } |
|
223 } |
|
224 |