58 } |
58 } |
59 |
59 |
60 void CBtmcVolume::SetSpeakerVolumeL(TInt aHfVol) |
60 void CBtmcVolume::SetSpeakerVolumeL(TInt aHfVol) |
61 { |
61 { |
62 TRACE_FUNC |
62 TRACE_FUNC |
63 TRACE_INFO((_L("phone vol %d, acc vol %d"), iPhnSpkrVol, iAccSpkrVol)) |
63 TRACE_INFO((_L("current vols phone %d, acc %d"), iPhnSpkrVol, iAccSpkrVol)) |
|
64 // Store the new volume setting of headset regardless of |
|
65 // whether volume control is active or not currently |
64 iAccSpkrVol = HfToPhoneVolScale(aHfVol); |
66 iAccSpkrVol = HfToPhoneVolScale(aHfVol); |
65 if (iVolCtrlActivated) |
67 TRACE_INFO((_L("new acc vol %d"), iAccSpkrVol)) |
66 { |
68 if ( IsActiveRemoteVolumeControl() ) |
67 TRACE_INFO((_L("to new vol %d"), iAccSpkrVol)) |
69 { |
68 TInt vol = GetNewPhoneVol(); |
70 TInt vol = GetNewPhoneVol(); |
69 if (vol != KNoAudioStreaming) |
71 if (vol != KNoAudioStreaming) |
70 { |
72 { |
71 TInt prevPhVol = iPhnSpkrVol; |
73 TInt prevPhVol = iPhnSpkrVol; |
72 iPhnSpkrVol = vol; |
74 iPhnSpkrVol = vol; |
73 DoSetSpeakerVolL( prevPhVol ); |
75 DoSetSpeakerVolL( prevPhVol ); |
74 } |
76 } |
75 } |
77 } |
76 else |
|
77 { |
|
78 TRACE_INFO((_L("volume control inactive!"))) |
|
79 } |
|
80 } |
78 } |
81 |
79 |
82 void CBtmcVolume::SetMicrophoneVolumeL(TInt /*aHfVol*/) |
80 void CBtmcVolume::SetMicrophoneVolumeL(TInt /*aHfVol*/) |
83 { |
81 { |
84 return; |
82 return; |
85 } |
83 } |
86 |
84 |
87 void CBtmcVolume::ActivateRemoteVolumeControl() |
85 void CBtmcVolume::ActivateRemoteVolumeControl() |
88 { |
86 { |
89 if (!iVolCtrlActivated) |
87 TRACE_FUNC |
90 { |
88 if (!IsActiveRemoteVolumeControl() ) |
91 TRACE_FUNC |
89 { |
92 iVolLevelProperty.Subscribe(iActive->iStatus); |
90 iVolLevelProperty.Subscribe(iActive->iStatus); |
93 iActive->GoActive(); |
91 iActive->GoActive(); |
94 |
|
95 iVolCtrlActivated = ETrue; |
|
96 TInt vol = GetNewPhoneVol(); |
92 TInt vol = GetNewPhoneVol(); |
97 TRACE_INFO((_L("current phone vol %d, acc vol %d"), vol, iAccSpkrVol)) |
93 TRACE_INFO((_L("current phone vol %d, acc vol %d"), vol, iAccSpkrVol)) |
98 if (vol != KNoAudioStreaming) |
94 if (vol != KNoAudioStreaming) |
99 { |
95 { |
100 iPhnSpkrVol = vol; |
96 iPhnSpkrVol = vol; |
240 if( diff2 <= diff1 ) |
232 if( diff2 <= diff1 ) |
241 { |
233 { |
242 volClick = (iAccSpkrVol > iPhnSpkrVol) ? KPSVolumeUpClicked : KPSVolumeDownClicked; |
234 volClick = (iAccSpkrVol > iPhnSpkrVol) ? KPSVolumeUpClicked : KPSVolumeDownClicked; |
243 } |
235 } |
244 } |
236 } |
245 |
237 TInt err( KErrNotFound ); |
246 if( volClick ) |
238 if( volClick ) |
247 { |
239 { |
248 iAction = ESpeakerVolSet; |
240 err = iVolKeyEventProperty.Set( volClick ); |
249 TInt err = iVolKeyEventProperty.Set( volClick ); |
241 TRACE_INFO((_L("Set KMediaKeysVolumeKeyEvent click %d err %d"), volClick, err)); |
250 if( err ) |
242 } |
251 { |
243 |
252 iAction = ESpeakerVolSubscribe; |
244 iAction = err ? ESpeakerVolSubscribe : ESpeakerVolSet; |
253 TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err)); |
245 |
254 } |
|
255 } |
|
256 else |
|
257 { |
|
258 iAction = ESpeakerVolSubscribe; |
|
259 } |
|
260 TRACE_FUNC_EXIT |
246 TRACE_FUNC_EXIT |
261 } |
247 } |
262 |
248 |
263 // ------------------------------------------------------------------------------- |
249 // ------------------------------------------------------------------------------- |
264 // CBtmcVolume::HfToPhoneVolScale |
250 // CBtmcVolume::HfToPhoneVolScale |