17 |
17 |
18 |
18 |
19 // USER |
19 // USER |
20 #include "musengtelephoneutils.h" |
20 #include "musengtelephoneutils.h" |
21 #include "musengaudioroutingobserver.h" |
21 #include "musengaudioroutingobserver.h" |
22 #include "musengmcesession.h" |
|
23 #include "musengvolumechangeobserver.h" |
|
24 #include "muslogger.h" |
22 #include "muslogger.h" |
25 |
23 |
26 // SYSTEM |
24 // SYSTEM |
27 #include <centralrepository.h> |
25 #include <centralrepository.h> |
28 #include <telephonydomaincrkeys.h> |
26 #include <telincallvolcntrlcrkeys.h> |
29 #include <e32property.h> |
27 #include <e32property.h> |
30 #include <telephonydomainpskeys.h> |
28 #include <telephonydomainpskeys.h> |
31 #include <CPhCltCommandHandler.h> // for CPhCltCommandHandler |
29 #include <CPhCltCommandHandler.h> // for CPhCltCommandHandler |
32 |
30 |
33 |
31 // Constants |
34 // ----------------------------------------------------------------------------- |
32 const TInt KMusEngMaxVolume = 10; |
35 // |
33 const TInt KMusEngMinVolume = 0; |
36 // ----------------------------------------------------------------------------- |
34 |
37 // |
35 |
38 CMusEngTelephoneUtils* CMusEngTelephoneUtils::NewL() |
36 |
39 { |
37 |
40 CMusEngTelephoneUtils* self = new( ELeave ) CMusEngTelephoneUtils(); |
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CMusEngTelephoneUtils* CMusEngTelephoneUtils::NewL( |
|
43 MMusEngAudioRoutingObserver& aAudioRoutingObserver ) |
|
44 { |
|
45 CMusEngTelephoneUtils* self = |
|
46 new( ELeave )CMusEngTelephoneUtils( aAudioRoutingObserver ); |
41 CleanupStack::PushL( self ); |
47 CleanupStack::PushL( self ); |
42 self->ConstructL(); |
48 self->ConstructL(); |
43 CleanupStack::Pop( self ); |
49 CleanupStack::Pop( self ); |
44 return self; |
50 return self; |
45 } |
51 } |
46 |
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CMusEngTelephoneUtils::CMusEngTelephoneUtils( |
|
58 MMusEngAudioRoutingObserver& aAudioRoutingObserver ) |
|
59 : CActive( CActive::EPriorityStandard ), |
|
60 iAudioRoutingObserver( aAudioRoutingObserver ) |
|
61 { |
|
62 iAudioOutputAtStartup = CTelephonyAudioRouting::ENotActive; |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 void CMusEngTelephoneUtils::ConstructL() |
|
71 { |
|
72 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::ConstructL()" ) |
|
73 |
|
74 // Volume control |
|
75 iRepository = CRepository::NewL( KCRUidInCallVolume ); |
|
76 |
|
77 // Audio routing control |
|
78 iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this ); |
|
79 |
|
80 iAudioOutputAtStartup = iTelephonyAudioRouting->Output(); |
|
81 |
|
82 // Phone |
|
83 MUS_LOG( "mus: [ENGINE] Use static DLL" ) |
|
84 iPhoneCommandHandler = CPhCltCommandHandler::NewL(); |
|
85 |
|
86 CActiveScheduler::Add( this ); |
|
87 |
|
88 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::ConstructL()" ) |
|
89 } |
47 |
90 |
48 // ----------------------------------------------------------------------------- |
91 // ----------------------------------------------------------------------------- |
49 // |
92 // |
50 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
51 // |
94 // |
59 |
102 |
60 if( iTelephonyAudioRouting ) // If 2nd phase construction has succeeded |
103 if( iTelephonyAudioRouting ) // If 2nd phase construction has succeeded |
61 { |
104 { |
62 CTelephonyAudioRouting::TAudioOutput currentMode = |
105 CTelephonyAudioRouting::TAudioOutput currentMode = |
63 iTelephonyAudioRouting->Output(); |
106 iTelephonyAudioRouting->Output(); |
64 MUS_LOG1( "mus: [ENGINE] iAudioOutputAtStartup: %d", iAudioOutputAtStartup ); |
107 if( currentMode != iAudioOutputAtStartup ) |
65 MUS_LOG1( "mus: [ENGINE] currentMode: %d", currentMode ); |
|
66 // When active call is dropped, audio output is set to ENotActive, |
|
67 // but in some cases Mush engine get deleted before OutputChanged() |
|
68 // notification comes. In that case we shouldn't touch output. |
|
69 if( currentMode != iAudioOutputAtStartup && |
|
70 currentMode != CTelephonyAudioRouting::ENotActive ) |
|
71 { |
108 { |
72 // As going down, let audiorouting api to show notification |
109 // As going down, let audiorouting api to show notification |
73 iTelephonyAudioRouting->SetShowNote( ETrue ); |
110 iTelephonyAudioRouting->SetShowNote( ETrue ); |
74 TRAPD( err, DoSetOutputL( iAudioOutputAtStartup ) ); |
111 TRAPD( err, |
|
112 iTelephonyAudioRouting->SetOutputL( iAudioOutputAtStartup ) ) |
75 MUS_LOG1( "mus: [ENGINE] final route change completed: %d", err ) |
113 MUS_LOG1( "mus: [ENGINE] final route change completed: %d", err ) |
76 err++; |
114 err++; |
77 } |
115 } |
78 } |
116 } |
79 |
|
80 if ( iNotifier ) |
|
81 { |
|
82 iNotifier->StopListening(); |
|
83 delete iNotifier; |
|
84 } |
|
85 |
117 |
86 delete iRepository; |
118 delete iRepository; |
87 delete iTelephonyAudioRouting; |
119 delete iTelephonyAudioRouting; |
88 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::~CMusEngTelephoneUtils()" ) |
120 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::~CMusEngTelephoneUtils()" ) |
89 } |
121 } |
90 |
122 |
91 |
123 // ----------------------------------------------------------------------------- |
92 // ----------------------------------------------------------------------------- |
124 // |
93 // |
125 // ----------------------------------------------------------------------------- |
94 // ----------------------------------------------------------------------------- |
126 // |
95 // |
127 TBool CMusEngTelephoneUtils::AudioRoutingCanBeChanged() |
96 TBool CMusEngTelephoneUtils::AudioRoutingCanBeChanged() const |
|
97 { |
128 { |
98 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::AudioRoutingCanBeChanged" ) |
129 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::AudioRoutingCanBeChanged" ) |
99 |
130 |
100 TBool retValue = ( |
131 TBool retValue = ( iTelephonyAudioRouting->Output() != |
|
132 CTelephonyAudioRouting::EWiredAudioAccessory && |
|
133 iTelephonyAudioRouting->Output() != |
|
134 CTelephonyAudioRouting::EBTAudioAccessory && |
101 iTelephonyAudioRouting->Output() != |
135 iTelephonyAudioRouting->Output() != |
102 CTelephonyAudioRouting::ETTY ); |
136 CTelephonyAudioRouting::ETTY ); |
103 |
137 |
104 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::AudioRoutingCanBeChanged: %d", |
138 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::AudioRoutingCanBeChanged: %d", |
105 retValue ) |
139 retValue ) |
106 |
140 |
107 return retValue; |
141 return retValue; |
108 } |
142 } |
109 |
143 |
110 |
144 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
145 // |
112 // |
146 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
147 // |
114 // |
148 void CMusEngTelephoneUtils::LoudspeakerL( TBool aEnable ) |
115 TBool CMusEngTelephoneUtils::IsAudioRoutingHeadset() const |
|
116 { |
|
117 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::IsAudioRoutingHeadset" ) |
|
118 |
|
119 TBool retValue = ( iTelephonyAudioRouting->Output() == |
|
120 CTelephonyAudioRouting::EBTAudioAccessory || |
|
121 iTelephonyAudioRouting->Output() == |
|
122 CTelephonyAudioRouting::EWiredAudioAccessory ); |
|
123 |
|
124 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::IsAudioRoutingHeadset: %d", |
|
125 retValue ) |
|
126 |
|
127 return retValue; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TBool CMusEngTelephoneUtils::IsAudioRoutingLoudSpeaker() const |
|
135 { |
|
136 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::IsAudioRoutingLoudSpeaker" ) |
|
137 TBool retValue = EFalse; |
|
138 |
|
139 CTelephonyAudioRouting::TAudioOutput currentMode = |
|
140 iTelephonyAudioRouting->Output(); |
|
141 MUS_LOG1( "mus: [ENGINE] iAudioOutputAtStartup: %d", iAudioOutputAtStartup ); |
|
142 MUS_LOG1( "mus: [ENGINE] currentMode: %d", currentMode ); |
|
143 |
|
144 if( currentMode != iAudioOutputAtStartup && |
|
145 currentMode == CTelephonyAudioRouting::ELoudspeaker ) |
|
146 { |
|
147 |
|
148 retValue = ETrue; |
|
149 |
|
150 } |
|
151 |
|
152 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::IsAudioRoutingLoudSpeaker: %d", |
|
153 retValue ) |
|
154 |
|
155 return retValue; |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void CMusEngTelephoneUtils::LoudspeakerL( TBool aEnable, TBool aShowDialog ) |
|
163 { |
149 { |
164 MUS_LOG1( "mus: [ENGINE] -> CMusEngTelephoneUtils::LoudspeakerL(%d)", |
150 MUS_LOG1( "mus: [ENGINE] -> CMusEngTelephoneUtils::LoudspeakerL(%d)", |
165 aEnable ) |
151 aEnable ) |
166 |
152 |
|
153 // Disable note shown by audiorouting api as it causes |
|
154 // application going to background for a while. Instead, display |
|
155 // note by ourselves once setting output completes. This mechanism |
|
156 // is needed only for loudspeaker enabling as going to background |
|
157 // causes problems only at beginning of sharing session. |
|
158 iTelephonyAudioRouting->SetShowNote( EFalse ); |
167 if ( aEnable ) |
159 if ( aEnable ) |
168 { |
160 { |
169 if ( iTelephonyAudioRouting->Output() == |
161 if ( iTelephonyAudioRouting->Output() == |
170 CTelephonyAudioRouting::EHandset || |
162 CTelephonyAudioRouting::EHandset ) |
171 iTelephonyAudioRouting->Output() == |
163 { |
172 CTelephonyAudioRouting::EBTAudioAccessory|| |
164 iTelephonyAudioRouting->SetOutputL( |
173 iTelephonyAudioRouting->Output() == |
165 CTelephonyAudioRouting::ELoudspeaker ); |
174 CTelephonyAudioRouting::EWiredAudioAccessory ) |
|
175 { |
|
176 // Disable note shown by audiorouting api as it causes |
|
177 // application going to background for a while. Instead, display |
|
178 // note by ourselves once setting output completes. This mechanism |
|
179 // is needed only for loudspeaker enabling as going to background |
|
180 // causes problems only at beginning of sharing session. |
|
181 if ( aShowDialog ) |
|
182 { |
|
183 iTelephonyAudioRouting->SetShowNote( EFalse ); |
|
184 |
|
185 iShowDialog = aShowDialog; |
|
186 } |
|
187 |
|
188 DoSetOutputL( CTelephonyAudioRouting::ELoudspeaker ); |
|
189 } |
166 } |
190 } |
167 } |
191 else |
168 else |
192 { |
169 { |
193 iTelephonyAudioRouting->SetShowNote( aShowDialog ); |
|
194 |
|
195 if ( iAudioOutputAtStartup == CTelephonyAudioRouting::ELoudspeaker ) |
170 if ( iAudioOutputAtStartup == CTelephonyAudioRouting::ELoudspeaker ) |
196 { |
171 { |
197 DoSetOutputL( CTelephonyAudioRouting::EHandset ); |
172 iTelephonyAudioRouting->SetOutputL( |
|
173 CTelephonyAudioRouting::EHandset ); |
198 } |
174 } |
199 else |
175 else |
200 { |
176 { |
201 DoSetOutputL( iAudioOutputAtStartup ); |
177 iTelephonyAudioRouting->SetOutputL( iAudioOutputAtStartup ); |
202 } |
178 } |
203 } |
179 } |
204 |
|
205 |
|
206 |
180 |
207 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::LoudspeakerL(...)" ) |
181 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::LoudspeakerL(...)" ) |
208 } |
182 } |
209 |
183 |
210 |
|
211 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
212 // |
185 // |
213 // ----------------------------------------------------------------------------- |
186 // ----------------------------------------------------------------------------- |
214 // |
187 // |
215 TBool CMusEngTelephoneUtils::IsLoudSpeakerEnabled() const |
188 TBool CMusEngTelephoneUtils::IsLoudSpeakerEnabled() const |
243 else |
207 else |
244 { |
208 { |
245 User::LeaveIfError( iRepository->Get( KTelIncallEarVolume, |
209 User::LeaveIfError( iRepository->Get( KTelIncallEarVolume, |
246 currentVolume ) ); |
210 currentVolume ) ); |
247 } |
211 } |
248 |
|
249 return ValidateVolume( currentVolume ); |
212 return ValidateVolume( currentVolume ); |
250 } |
213 } |
251 |
|
252 |
214 |
253 // ----------------------------------------------------------------------------- |
215 // ----------------------------------------------------------------------------- |
254 // Sets the CS call volume level. |
216 // Sets the CS call volume level. |
255 // Leaves if error occurs when accessing central repository. |
217 // Leaves if error occurs when accessing central repository. |
256 // ----------------------------------------------------------------------------- |
218 // ----------------------------------------------------------------------------- |
257 // |
219 // |
258 void CMusEngTelephoneUtils::SetVolumeL( TInt aVolume ) |
220 void CMusEngTelephoneUtils::SetVolumeL( TInt aVolume ) |
259 { |
221 { |
260 TInt newVolume = ValidateVolume( aVolume ); |
222 TInt newVolume = ValidateVolume( aVolume ); |
261 MUS_LOG1( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetVolumeL(), %d", newVolume ) |
223 |
262 if ( iCurrentVolume != newVolume ) |
224 if ( GetVolumeL() != newVolume ) |
263 { |
225 { |
264 if ( IsLoudSpeakerEnabled() ) |
226 if ( IsLoudSpeakerEnabled() ) |
265 { |
227 { |
266 User::LeaveIfError( iRepository->Set( KTelIncallLoudspeakerVolume, |
228 User::LeaveIfError( iRepository->Set( KTelIncallLoudspeakerVolume, |
267 newVolume ) ); |
229 newVolume ) ); |
381 { |
302 { |
382 iPhoneCommandHandler->CancelAsyncRequest( EPhCltCommandMuteMic ); |
303 iPhoneCommandHandler->CancelAsyncRequest( EPhCltCommandMuteMic ); |
383 } |
304 } |
384 |
305 |
385 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::DoCancel()" ) |
306 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::DoCancel()" ) |
386 } |
307 } |
387 |
|
388 |
308 |
389 // ----------------------------------------------------------------------------- |
309 // ----------------------------------------------------------------------------- |
390 // |
310 // |
391 // ----------------------------------------------------------------------------- |
311 // ----------------------------------------------------------------------------- |
392 // |
312 // |
393 void CMusEngTelephoneUtils::AvailableOutputsChanged( |
313 void CMusEngTelephoneUtils::AvailableOutputsChanged( |
394 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/ ) |
314 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/ ) |
395 { |
315 { |
396 // NOP |
316 // NOP |
397 } |
317 } |
398 |
318 |
399 |
|
400 // ----------------------------------------------------------------------------- |
319 // ----------------------------------------------------------------------------- |
401 // |
320 // |
402 // ----------------------------------------------------------------------------- |
321 // ----------------------------------------------------------------------------- |
403 // |
322 // |
404 void CMusEngTelephoneUtils::OutputChanged( |
323 void CMusEngTelephoneUtils::OutputChanged( |
405 CTelephonyAudioRouting& aTelephonyAudioRouting ) |
324 CTelephonyAudioRouting& aTelephonyAudioRouting ) |
406 { |
325 { |
407 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::OutputChanged()" ) |
326 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::OutputChanged()" ) |
408 |
327 |
409 // Some other application has changed audio output routing. We consider |
328 // Some other application has changed audio output routing. We consider |
410 // this as a last will of a user and return to this state after sharing |
329 // this as a last will of a user and return to this state after sharing |
411 |
330 |
412 iAudioOutputAtStartup = aTelephonyAudioRouting.Output(); |
331 iAudioOutputAtStartup = aTelephonyAudioRouting.Output(); |
413 |
332 |
414 MUS_LOG1( "mus: [ENGINE] New audio routing is %d", iAudioOutputAtStartup ) |
333 MUS_LOG1( "mus: [ENGINE] New audio routing is %d", iAudioOutputAtStartup ) |
415 |
334 |
416 if ( iAudioRoutingObserver ) |
335 iAudioRoutingObserver.AudioRoutingChanged(); |
417 { |
336 |
418 iAudioRoutingObserver->AudioRoutingChanged( EFalse ); |
|
419 } |
|
420 |
|
421 UpdateCurrentVolume(ETrue); |
|
422 |
|
423 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::OutputChanged()" ) |
337 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::OutputChanged()" ) |
424 } |
338 } |
425 |
339 |
426 |
340 |
427 // ----------------------------------------------------------------------------- |
341 // ----------------------------------------------------------------------------- |
428 // |
342 // |
429 // ----------------------------------------------------------------------------- |
343 // ----------------------------------------------------------------------------- |
430 // |
344 // |
431 void CMusEngTelephoneUtils::SetOutputComplete( |
345 void CMusEngTelephoneUtils::SetOutputComplete( |
432 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/, |
346 CTelephonyAudioRouting& /*aTelephonyAudioRouting*/, |
433 TInt aError ) |
347 TInt aError ) |
434 { |
348 { |
435 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetOutputComplete()" ) |
349 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::SetOutputComplete()" ) |
436 |
350 |
437 if ( aError == KErrNone ) |
351 if ( aError == KErrNone ) |
438 { |
352 { |
439 if ( iAudioRoutingObserver ) |
353 iAudioRoutingObserver.AudioRoutingChanged(); |
440 { |
|
441 // If audio routing api didn't shown note and show dialog mode is on, |
|
442 // we know that this completion is for such setoutput call for which |
|
443 // we need to show the note. Show note mode is turned off only in that |
|
444 // case. |
|
445 TBool dialogShownByUs( EFalse ); |
|
446 TBool dialogShownByAudioRouting( EFalse ); |
|
447 aError = iTelephonyAudioRouting->GetShowNote( dialogShownByAudioRouting ); |
|
448 if ( aError == KErrNone && !dialogShownByAudioRouting && iShowDialog ) |
|
449 { |
|
450 dialogShownByUs = iShowDialog; |
|
451 iShowDialog = EFalse; |
|
452 } |
|
453 |
|
454 iAudioRoutingObserver->AudioRoutingChanged( dialogShownByUs ); |
|
455 } |
|
456 |
|
457 UpdateCurrentVolume(ETrue); |
|
458 } |
354 } |
459 |
355 |
460 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::SetOutputComplete()" ) |
356 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::SetOutputComplete()" ) |
461 } |
357 } |
462 |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 void CMusEngTelephoneUtils::UpdateCurrentVolume( TBool aAudioRouteChanged ) |
|
469 { |
|
470 TInt volume(0); |
|
471 TRAPD(error, volume = GetVolumeL() ); |
|
472 if( (KErrNone == error) && (iCurrentVolume != volume) ) |
|
473 { |
|
474 iCurrentVolume = volume; |
|
475 if ( iVolumeObserver ) |
|
476 { |
|
477 iVolumeObserver->VolumeChanged( volume, aAudioRouteChanged ); |
|
478 } |
|
479 } |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // |
|
484 // ----------------------------------------------------------------------------- |
|
485 // |
|
486 CMusEngTelephoneUtils::CMusEngTelephoneUtils() |
|
487 : CActive( CActive::EPriorityStandard ) |
|
488 { |
|
489 iAudioOutputAtStartup = CTelephonyAudioRouting::ENotActive; |
|
490 } |
|
491 |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 void CMusEngTelephoneUtils::ConstructL() |
|
498 { |
|
499 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::ConstructL()" ) |
|
500 |
|
501 // Volume control |
|
502 iRepository = CRepository::NewL( KCRUidInCallVolume ); |
|
503 |
|
504 iNotifier = CCenRepNotifyHandler::NewL( *this, *iRepository ); |
|
505 iNotifier->StartListeningL(); |
|
506 |
|
507 // Audio routing control |
|
508 iTelephonyAudioRouting = CTelephonyAudioRouting::NewL( *this ); |
|
509 |
|
510 iAudioOutputAtStartup = iTelephonyAudioRouting->Output(); |
|
511 MUS_LOG1( "mus: [ENGINE] iAudioOutputAtStartup: %d", iAudioOutputAtStartup ); |
|
512 // Phone |
|
513 MUS_LOG( "mus: [ENGINE] Use static DLL" ) |
|
514 iPhoneCommandHandler = CPhCltCommandHandler::NewL(); |
|
515 |
|
516 iCurrentVolume = GetVolumeL(); |
|
517 |
|
518 CActiveScheduler::Add( this ); |
|
519 |
|
520 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::ConstructL()" ) |
|
521 } |
|
522 |
|
523 |
358 |
524 // ----------------------------------------------------------------------------- |
359 // ----------------------------------------------------------------------------- |
525 // Validates that requested volume level is valid (between 1-10) and if it is |
360 // Validates that requested volume level is valid (between 1-10) and if it is |
526 // not, modifies requested volume level to be valid. Returns validated volume. |
361 // not, modifies requested volume level to be valid. Returns validated volume. |
527 // ----------------------------------------------------------------------------- |
362 // ----------------------------------------------------------------------------- |
541 // NOP, to keep PC-Lint happy |
376 // NOP, to keep PC-Lint happy |
542 } |
377 } |
543 |
378 |
544 return aVolume; |
379 return aVolume; |
545 } |
380 } |
546 |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // Set output if setting is currently allowed. |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CMusEngTelephoneUtils::DoSetOutputL( |
|
553 CTelephonyAudioRouting::TAudioOutput aAudioOutput ) |
|
554 { |
|
555 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::DoSetOutputL()" ) |
|
556 if ( iAudioRoutingObserver && !iAudioRoutingObserver->AudioRouteChangeAllowed() ) |
|
557 { |
|
558 MUS_LOG( "mus: [ENGINE] change not allowed!" ) |
|
559 User::Leave( KErrAccessDenied ); |
|
560 } |
|
561 iTelephonyAudioRouting->SetOutputL( aAudioOutput ); |
|
562 MUS_LOG( "mus: [ENGINE] <- CMusEngTelephoneUtils::DoSetOutputL()" ) |
|
563 } |
|
564 |
|
565 |
|
566 // --------------------------------------------------------------------------- |
|
567 // CMusEngTelephoneUtils::HandleNotifyGeneric |
|
568 // --------------------------------------------------------------------------- |
|
569 // |
|
570 void CMusEngTelephoneUtils::HandleNotifyGeneric( TUint32 aId ) |
|
571 { |
|
572 MUS_LOG( "mus: [ENGINE] -> CMusEngTelephoneUtils::HandleNotifyGeneric()" ) |
|
573 TInt error = KErrArgument; |
|
574 TInt volume = 0; |
|
575 if ( KTelIncallEarVolume == aId ) |
|
576 { |
|
577 error = iRepository->Get( KTelIncallEarVolume, volume ); |
|
578 MUS_LOG1( "mus: [ENGINE] EAR volume: %d", volume ); |
|
579 } |
|
580 else if ( KTelIncallLoudspeakerVolume == aId ) |
|
581 { |
|
582 error = iRepository->Get( KTelIncallLoudspeakerVolume, volume ); |
|
583 MUS_LOG1( "mus: [ENGINE] Loudspeakers volume: %d", volume ); |
|
584 } |
|
585 |
|
586 volume = ValidateVolume(volume); |
|
587 if ( (KErrNone == error) && (iCurrentVolume != volume) ) |
|
588 { |
|
589 MUS_LOG1( "mus: [ENGINE] volume changed: %d!, notifying UI...", volume ) |
|
590 iCurrentVolume = volume; |
|
591 if( iVolumeObserver ) |
|
592 { |
|
593 iVolumeObserver->VolumeChanged( volume, EFalse ); |
|
594 } |
|
595 } |
|
596 else |
|
597 { |
|
598 MUS_LOG( "mus: [ENGINE] volume hasn't changed!, do nothing..." ) |
|
599 } |
|
600 |
|
601 MUS_LOG1( "mus: [ENGINE] <- CMusEngTelephoneUtils::HandleNotifyGeneric(), error:%d", |
|
602 error ); |
|
603 } |
|