18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include "cmmaplayer.h" |
20 #include "cmmaplayer.h" |
21 #include "cmmavolumecontrol.h" |
21 #include "cmmavolumecontrol.h" |
22 #include <jdebug.h> |
22 #include <jdebug.h> |
23 #include <mprofile.h> |
23 #include <MProfile.h> |
24 #include <mprofileengine.h> |
24 #include <MProfileEngine.h> |
25 #include <cprofilechangenotifyhandler.h> |
25 #include <CProfileChangeNotifyHandler.h> |
26 |
26 |
27 _LIT(KMMAVolumeErrorMsg, "Can't set volume level"); |
27 _LIT(KMMAVolumeErrorMsg, "Can't set volume level"); |
28 |
28 |
29 const TInt KMMAJavaSoundIndex = 0; |
29 const TInt KMMAJavaSoundIndex = 0; |
30 const TInt KMMAProfileSoundIndex = 1; |
30 const TInt KMMAProfileSoundIndex = 1; |
44 // Java level is the first |
44 // Java level is the first |
45 aVolumeControl->GetVolumeLevelL(KMMAJavaSoundIndex, aLevel); |
45 aVolumeControl->GetVolumeLevelL(KMMAJavaSoundIndex, aLevel); |
46 } |
46 } |
47 |
47 |
48 |
48 |
49 CMMAVolumeControl::CMMAVolumeControl(CMMAPlayer* aPlayer) |
49 EXPORT_C CMMAVolumeControl::CMMAVolumeControl(CMMAPlayer* aPlayer) |
50 : iPlayer(aPlayer), iLevel(KMMAVolumeMaxLevel) |
50 : iPlayer(aPlayer), iLevel(KMMAVolumeMaxLevel) |
51 { |
51 { |
52 } |
52 } |
53 |
53 |
54 |
54 |
55 CMMAVolumeControl::~CMMAVolumeControl() |
55 EXPORT_C CMMAVolumeControl::~CMMAVolumeControl() |
56 { |
56 { |
57 delete iProfChangeNotifier; |
57 delete iProfChangeNotifier; |
58 iLevels.Close(); |
58 iLevels.Close(); |
59 } |
59 } |
60 |
60 |
61 |
61 |
62 void CMMAVolumeControl::ConstructBaseL() |
62 EXPORT_C void CMMAVolumeControl::ConstructBaseL() |
63 { |
63 { |
64 iPlayer->AddStateListenerL(this); |
64 iPlayer->AddStateListenerL(this); |
65 |
65 |
66 // Add level for javasound, will set in StaticSetLevelL method. |
66 // Add level for javasound, will set in StaticSetLevelL method. |
67 SetJavaSoundVolumeLevelL(); |
67 SetJavaSoundVolumeLevelL(); |
112 iProfChangeNotifier = CProfileChangeNotifyHandler::NewL( this ); |
112 iProfChangeNotifier = CProfileChangeNotifyHandler::NewL( this ); |
113 // Sets level to 0 if profile isn't on |
113 // Sets level to 0 if profile isn't on |
114 iLevel = CalculateLevel(); |
114 iLevel = CalculateLevel(); |
115 |
115 |
116 } |
116 } |
117 void CMMAVolumeControl::HandleActiveProfileEventL(TProfileEvent aProfileEvent, |
117 EXPORT_C void CMMAVolumeControl::HandleActiveProfileEventL( |
118 TInt aProfileId) |
118 TProfileEvent aProfileEvent, TInt aProfileId) |
119 { |
119 { |
120 switch (aProfileEvent) |
120 switch (aProfileEvent) |
121 { |
121 { |
122 case EProfileNewActiveProfile: |
122 case EProfileNewActiveProfile: |
123 { |
123 { |
202 // Error ID AKUR-7G69Q5 GLOBAL VOLUME EVENT CR |
202 // Error ID AKUR-7G69Q5 GLOBAL VOLUME EVENT CR |
203 if (aState == CMMAPlayer::ERealized) |
203 if (aState == CMMAPlayer::ERealized) |
204 { |
204 { |
205 if ((iLevels.Count() - 1) == KMMAGlobalVolumeSoundIndex) |
205 if ((iLevels.Count() - 1) == KMMAGlobalVolumeSoundIndex) |
206 { |
206 { |
207 DEBUG("MMA::CMMAVolumeControl::StateChanged : Post GLOBAL VOL EVENT "); |
207 if ((iLevels[ KMMAGlobalVolumeSoundIndex ] != KErrNotFound) && |
208 if (iLevels[ KMMAGlobalVolumeSoundIndex ] != KErrNotFound) |
208 (iLevels[ KMMAGlobalVolumeSoundIndex] != iInitialGlobalVolumeLevel)) |
209 { |
209 { |
210 DEBUG_INT("MMA::CMMAVolumeControl::StateChanged : Post complete Val = %d ",iLevels[ KMMAGlobalVolumeSoundIndex ]); |
210 DEBUG("MMA::CMMAVolumeControl::StateChanged : Post GLOBAL VOL EVENT "); |
|
211 DEBUG_INT("MMA::CMMAVolumeControl::StateChanged : Post complete Val = %d ", |
|
212 iLevels[ KMMAGlobalVolumeSoundIndex ]); |
211 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT, |
213 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT, |
212 iLevels[ KMMAGlobalVolumeSoundIndex ]); |
214 iLevels[ KMMAGlobalVolumeSoundIndex ]); |
213 } |
215 } |
214 } |
216 } |
215 } |
217 } |
216 } |
218 } |
217 |
219 |
218 void CMMAVolumeControl::RefreshVolume() |
220 EXPORT_C void CMMAVolumeControl::RefreshVolume() |
219 { |
221 { |
220 DEBUG("MMA::CMMAVolumeControl::RefreshVolume ++ "); |
222 DEBUG("MMA::CMMAVolumeControl::RefreshVolume ++ "); |
221 TRAPD(error, |
223 TRAPD(error, |
222 { |
224 { |
223 // Get the default value for the Java sound level |
225 // Get the default value for the Java sound level |
281 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT, |
283 iPlayer->PostLongEvent(CMMAPlayerEvent::ENOKIA_EXTERNAL_VOLUME_EVENT, |
282 iLevels[ aLevelIndex ]); |
284 iLevels[ aLevelIndex ]); |
283 } |
285 } |
284 } |
286 } |
285 |
287 |
|
288 void CMMAVolumeControl::InitializeGlobalVolumeLevel(TInt aGlobalVolumeLevel) |
|
289 { |
|
290 iInitialGlobalVolumeLevel = aGlobalVolumeLevel; |
|
291 } |
286 void CMMAVolumeControl::GetVolumeLevelL(TInt aLevelIndex, |
292 void CMMAVolumeControl::GetVolumeLevelL(TInt aLevelIndex, |
287 TInt* aVolumeLevel) |
293 TInt* aVolumeLevel) |
288 { |
294 { |
289 DEBUG_INT("CMMAVolumeControl::GetVolumeLevelL - level index %d", aLevelIndex); |
295 DEBUG_INT("CMMAVolumeControl::GetVolumeLevelL - level index %d", aLevelIndex); |
290 |
296 |
328 |
334 |
329 // All levels in the array are percentage of the max volume (0..100). |
335 // All levels in the array are percentage of the max volume (0..100). |
330 // Actual sound level will be multiplying all levels. |
336 // Actual sound level will be multiplying all levels. |
331 for (TInt i = 0; i < levelCount; i++) |
337 for (TInt i = 0; i < levelCount; i++) |
332 { |
338 { |
|
339 DEBUG_INT2("CMMAVolumeControl::CalculateLevel value at iLevels[ %d ] is %d",i,iLevels[i]); |
333 // If the level is not known it is expected to be max volume |
340 // If the level is not known it is expected to be max volume |
334 level = (iLevels[ i ] == KErrNotFound ? |
341 level = (iLevels[ i ] == KErrNotFound ? |
335 level * KMMAVolumeMaxLevel : |
342 level * KMMAVolumeMaxLevel : |
336 level * iLevels[ i ]); |
343 level * iLevels[ i ]); |
337 sum *= KMMAVolumeMaxLevel; |
344 sum *= KMMAVolumeMaxLevel; |