1 /* |
1 /* |
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Implements the class CSPAudioHandler |
14 * Description: Implements the class CSPAudioHandler |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 |
17 |
19 #include "cspaudiohandler.h" |
18 #include "cspaudiohandler.h" |
20 |
19 #include "tmshandler.h" |
21 #include <telmicmutestatuspskeys.h> |
|
22 #include <telincallvolcntrlcrkeys.h> |
|
23 #include <PSVariables.h> |
|
24 #include <AudioPreference.h> |
|
25 |
|
26 #include "cspaudiostreams.h" |
|
27 #include "csppubsublistener.h" |
|
28 #include "cspcenreplistener.h" |
|
29 #include "csplogger.h" |
20 #include "csplogger.h" |
30 |
|
31 |
21 |
32 // --------------------------------------------------------------------------- |
22 // --------------------------------------------------------------------------- |
33 // CSPAudioHandler::NewL. |
23 // CSPAudioHandler::NewL. |
34 // --------------------------------------------------------------------------- |
24 // --------------------------------------------------------------------------- |
35 // |
25 // |
36 CSPAudioHandler* CSPAudioHandler::NewL( ) |
26 CSPAudioHandler* CSPAudioHandler::NewL() |
37 { |
27 { |
38 CSPLOGSTRING(CSPOBJECT, |
28 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::NewL()" ); |
39 "CSPAudioHandler::NewL()" ); |
29 CSPAudioHandler* self = new (ELeave) CSPAudioHandler(); |
40 CSPAudioHandler* self = new ( ELeave ) CSPAudioHandler( ); |
30 CleanupStack::PushL(self); |
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
31 self->ConstructL(); |
43 CleanupStack::Pop( self ); |
32 CleanupStack::Pop(self); |
44 return self; |
33 return self; |
45 } |
34 } |
46 |
35 |
47 // --------------------------------------------------------------------------- |
36 // --------------------------------------------------------------------------- |
48 // Destructs the object by canceling first ongoing monitoring. |
37 // Destructs the object by canceling first ongoing monitoring. |
49 // --------------------------------------------------------------------------- |
38 // --------------------------------------------------------------------------- |
50 // |
39 // |
51 CSPAudioHandler::~CSPAudioHandler( ) |
40 CSPAudioHandler::~CSPAudioHandler() |
52 { |
41 { |
53 CSPLOGSTRING(CSPOBJECT, |
42 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::~CSPAudioHandler()" ); |
54 "CSPAudioHandler::~CSPAudioHandler()" ); |
43 delete iTmsHandler; |
55 delete iMuteListener; |
|
56 delete iIncallLoudspeakerVolumeListener; |
|
57 delete iIncallEarVolumeListener; |
|
58 delete iAudioStreams; |
|
59 } |
44 } |
60 |
45 |
61 // --------------------------------------------------------------------------- |
46 // --------------------------------------------------------------------------- |
62 // CSPAudioHandler::Start |
47 // CSPAudioHandler::Start |
63 // --------------------------------------------------------------------------- |
48 // --------------------------------------------------------------------------- |
64 // |
49 // |
65 void CSPAudioHandler::Start() |
50 void CSPAudioHandler::Start() |
66 { |
51 { |
67 iCallCount++; |
52 iCallCount++; |
68 CSPLOGSTRING2( CSPINT, "CSPAudioHandler::Start callcount: %d", iCallCount ); |
53 CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Start callcount: %d", iCallCount); |
69 |
54 |
70 if ( iCallCount == 1 ) |
55 if (iTmsHandler && iCallCount == 1) |
71 { |
56 { |
72 iAudioStreams->StartStreams(); |
57 iTmsHandler->StartStreams(); |
73 } |
58 } |
74 } |
59 } |
75 |
60 |
76 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
77 // CSPAudioHandler::Stop |
62 // CSPAudioHandler::Stop |
78 // --------------------------------------------------------------------------- |
63 // --------------------------------------------------------------------------- |
79 // |
64 // |
80 void CSPAudioHandler::Stop() |
65 void CSPAudioHandler::Stop() |
81 { |
66 { |
82 CSPLOGSTRING2( CSPINT, "CSPAudioHandler::Stop callcount: %d", iCallCount ); |
67 CSPLOGSTRING2(CSPINT, "CSPAudioHandler::Stop callcount: %d", iCallCount); |
83 if ( iCallCount == 1 ) |
68 if (iTmsHandler && iCallCount == 1) |
84 { |
69 { |
85 iAudioStreams->StopStreams(); |
70 iTmsHandler->StopStreams(); |
86 iCallCount--; |
71 iCallCount--; |
87 } |
72 } |
88 else if ( iCallCount > 1 ) |
73 else if (iCallCount > 1) |
89 { |
74 { |
90 iCallCount--; |
75 iCallCount--; |
91 } |
76 } |
92 } |
77 } |
93 |
78 |
94 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
95 // From MCSPPubSubObserver |
|
96 // CSPAudioHandler::HandleNotifyPSL |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CSPAudioHandler::HandleNotifyPSL( const TUid /*aUid*/, const TInt& /*aKey*/, |
|
100 const TRequestStatus& /*aStatus*/ ) |
|
101 { |
|
102 TInt muteVal; |
|
103 TInt err = iMuteListener->Get( muteVal ); |
|
104 if ( err == KErrNone && muteVal == EPSTelMicMuteOn ) |
|
105 { |
|
106 CSPLOGSTRING2( CSPINT, |
|
107 "CSPAudioHandler::HandleNotifyPSL_MUTE %d", muteVal); |
|
108 #if !defined(__WINSCW__) |
|
109 iAudioStreams->SetMuted(); |
|
110 #endif //__WINSCW__ |
|
111 } |
|
112 else if ( err == KErrNone ) |
|
113 { |
|
114 CSPLOGSTRING2( CSPINT, |
|
115 "CSPAudioHandler::HandleNotifyPSL_UNMUTE %d", muteVal); |
|
116 #if !defined(__WINSCW__) |
|
117 // Change when gain is really changed |
|
118 iAudioStreams->SetUnmuted(); |
|
119 #endif //__WINSCW__ |
|
120 } |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // From MCSPCenRepObserver |
|
125 // CSPAudioHandler::HandleNotifyCenRepL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CSPAudioHandler::HandleNotifyCenRepL( const TUid /*aUid*/, |
|
129 const TUint32 aKey, |
|
130 TInt aVal ) |
|
131 { |
|
132 if ( aKey == KTelIncallLoudspeakerVolume ) |
|
133 { |
|
134 CSPLOGSTRING( CSPINT, "CSPAudioHandler::HandleNotifyCenRepL IncallLoudspeaker" ); |
|
135 iAudioStreams->VolumeChangedLoudspeaker( aVal ); |
|
136 } |
|
137 else if ( aKey == KTelIncallEarVolume ) |
|
138 { |
|
139 CSPLOGSTRING( CSPINT, "CSPAudioHandler::HandleNotifyCenRepL IncallEar" ); |
|
140 iAudioStreams->VolumeChangedEar( aVal ); |
|
141 } |
|
142 else |
|
143 { |
|
144 CSPLOGSTRING( CSPINT, "CSPAudioHandler::HandleNotifyCenRepL UNKNOWN" ); |
|
145 } |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CSPAudioHandler::InitializeComplete |
|
150 // |
|
151 // Handles DevSound initialisation callback |
|
152 // --------------------------------------------------------- |
|
153 // |
|
154 void CSPAudioHandler::InitializeComplete( TInt aError ) |
|
155 { |
|
156 if ( KErrNone != aError ) |
|
157 { |
|
158 // If initialisation failed, volume can not be adjusted |
|
159 CSPLOGSTRING2( CSPERROR, |
|
160 "CSPAudioHandler::InitializeComplete Error:%d", aError ); |
|
161 } |
|
162 else |
|
163 { |
|
164 CSPLOGSTRING( CSPINT, |
|
165 "CSPAudioHandler::InitializeComplete"); |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CSPAudioHandler::BufferToBeFilled |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 void CSPAudioHandler::BufferToBeFilled( CMMFBuffer* /*aBuffer*/ ) |
|
174 { |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------- |
|
178 // CSPAudioHandler::BufferToBeEmptied() |
|
179 // Not supported |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 void CSPAudioHandler::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ ) |
|
183 { |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------- |
|
187 // CSPAudioHandler::PlayError |
|
188 // Not supported |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 void CSPAudioHandler::PlayError( TInt /*aError*/ ) |
|
192 { |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------- |
|
196 // CSPAudioHandler::RecordError |
|
197 // Not supported |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void CSPAudioHandler::RecordError( TInt /*aError*/ ) |
|
201 { |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // CSPAudioHandler::ConvertError |
|
206 // Not supported |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 void CSPAudioHandler::ConvertError( TInt /*aError*/ ) |
|
210 { |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------- |
|
214 // CSPAudioHandler::DeviceMessage |
|
215 // Not supported |
|
216 // --------------------------------------------------------- |
|
217 // |
|
218 void CSPAudioHandler::DeviceMessage( TUid /*aMessageType*/, const TDesC8& /*aMsg*/ ) |
|
219 { |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CSPAudioHandler::ToneFinished |
|
224 // Not supported |
|
225 // --------------------------------------------------------- |
|
226 // |
|
227 void CSPAudioHandler::ToneFinished( TInt /*aError*/ ) |
|
228 { |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // Constructs the monitor. |
80 // Constructs the monitor. |
233 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
234 // |
82 // |
235 CSPAudioHandler::CSPAudioHandler( ) |
83 CSPAudioHandler::CSPAudioHandler() |
236 { |
84 { |
237 CSPLOGSTRING(CSPOBJECT, |
85 CSPLOGSTRING(CSPOBJECT, "CSPAudioHandler::CSPAudioHandler()"); |
238 "CSPAudioHandler::CSPAudioHandler()" ); |
|
239 iCallCount = 0; // Active calls count |
86 iCallCount = 0; // Active calls count |
240 } |
87 } |
241 |
88 |
242 // --------------------------------------------------------------------------- |
89 // --------------------------------------------------------------------------- |
243 // Second phase construction. |
90 // Second phase construction. |
244 // --------------------------------------------------------------------------- |
91 // --------------------------------------------------------------------------- |
245 // |
92 // |
246 void CSPAudioHandler::ConstructL() |
93 void CSPAudioHandler::ConstructL() |
247 { |
94 { |
248 RProperty::TType type( RProperty::EInt ); |
95 if (!iTmsHandler) |
249 TSecurityPolicy readPolicy( ECapability_None ); |
96 { |
250 TSecurityPolicy writePolicy( ECapabilityWriteDeviceData ); |
97 iTmsHandler = TmsHandler::NewL(); |
251 |
98 } |
252 RProperty::Define( KPSUidTelMicrophoneMuteStatus, |
|
253 KTelMicrophoneMuteState, |
|
254 type, |
|
255 readPolicy, |
|
256 writePolicy ); |
|
257 |
|
258 iMuteListener = CSPPubSubListener::NewL( |
|
259 KPSUidTelMicrophoneMuteStatus, |
|
260 KTelMicrophoneMuteState, |
|
261 this ); |
|
262 |
|
263 iIncallLoudspeakerVolumeListener = CSPCenRepListener::NewL( KCRUidInCallVolume, |
|
264 KTelIncallLoudspeakerVolume, this ); |
|
265 |
|
266 iIncallEarVolumeListener = CSPCenRepListener::NewL( KCRUidInCallVolume, |
|
267 KTelIncallEarVolume, this ); |
|
268 |
|
269 iAudioStreams = CSPAudioStreams::NewL(); |
|
270 |
|
271 // Initialize audio volumes |
|
272 TInt volEar; |
|
273 TInt volLoud; |
|
274 |
|
275 TInt volGetRes = iIncallEarVolumeListener->Get( volEar ); |
|
276 CSPLOGSTRING3(CSPINT, "CSPAudioHandler::ConstructL() ear %d %d", volGetRes, volEar ); |
|
277 volGetRes = iIncallLoudspeakerVolumeListener->Get( volLoud ); |
|
278 CSPLOGSTRING3(CSPINT, "CSPAudioHandler::ConstructL() loudspkr %d %d", volGetRes, volLoud ); |
|
279 |
|
280 iAudioStreams->StoreVolumes( volEar, volLoud ); |
|
281 } |
99 } |
282 |
100 |
283 // End of file |
101 // End of file |