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