|
1 /* |
|
2 * Copyright (c) 2007 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: Implements the class CSPAudioHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cspaudiohandler.h" |
|
20 |
|
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" |
|
30 |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CSPAudioHandler::NewL. |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CSPAudioHandler* CSPAudioHandler::NewL( ) |
|
37 { |
|
38 CSPLOGSTRING(CSPOBJECT, |
|
39 "CSPAudioHandler::NewL()" ); |
|
40 CSPAudioHandler* self = new ( ELeave ) CSPAudioHandler( ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop( self ); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // Destructs the object by canceling first ongoing monitoring. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CSPAudioHandler::~CSPAudioHandler( ) |
|
52 { |
|
53 CSPLOGSTRING(CSPOBJECT, |
|
54 "CSPAudioHandler::~CSPAudioHandler()" ); |
|
55 delete iMuteListener; |
|
56 delete iIncallLoudspeakerVolumeListener; |
|
57 delete iIncallEarVolumeListener; |
|
58 delete iAudioStreams; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CSPAudioHandler::Start |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CSPAudioHandler::Start() |
|
66 { |
|
67 iCallCount++; |
|
68 CSPLOGSTRING2( CSPINT, "CSPAudioHandler::Start callcount: %d", iCallCount ); |
|
69 |
|
70 if ( iCallCount == 1 ) |
|
71 { |
|
72 iAudioStreams->StartStreams(); |
|
73 } |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CSPAudioHandler::Stop |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CSPAudioHandler::Stop() |
|
81 { |
|
82 CSPLOGSTRING2( CSPINT, "CSPAudioHandler::Stop callcount: %d", iCallCount ); |
|
83 if ( iCallCount == 1 ) |
|
84 { |
|
85 iAudioStreams->StopStreams(); |
|
86 iCallCount--; |
|
87 } |
|
88 else if ( iCallCount > 1 ) |
|
89 { |
|
90 iCallCount--; |
|
91 } |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
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. |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 CSPAudioHandler::CSPAudioHandler( ) |
|
236 { |
|
237 CSPLOGSTRING(CSPOBJECT, |
|
238 "CSPAudioHandler::CSPAudioHandler()" ); |
|
239 iCallCount = 0; // Active calls count |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // Second phase construction. |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CSPAudioHandler::ConstructL() |
|
247 { |
|
248 RProperty::TType type( RProperty::EInt ); |
|
249 TSecurityPolicy readPolicy( ECapability_None ); |
|
250 TSecurityPolicy writePolicy( ECapabilityWriteDeviceData ); |
|
251 |
|
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 } |
|
282 |
|
283 // End of file |