bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp
branchRCL_3
changeset 10 0707dd69d236
parent 0 f63038272f30
child 13 b6f55cd40afd
--- a/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp	Fri Feb 19 22:59:18 2010 +0200
+++ b/bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp	Fri Mar 12 15:43:23 2010 +0200
@@ -60,11 +60,13 @@
 void CBtmcVolume::SetSpeakerVolumeL(TInt aHfVol)
     {
     TRACE_FUNC
-    TRACE_INFO((_L("phone vol %d, acc vol %d"), iPhnSpkrVol, iAccSpkrVol))
+    TRACE_INFO((_L("current vols phone %d, acc %d"), iPhnSpkrVol, iAccSpkrVol))
+    // Store the new volume setting of headset regardless of 
+    // whether volume control is active or not currently
     iAccSpkrVol = HfToPhoneVolScale(aHfVol);
-    if (iVolCtrlActivated)
+    TRACE_INFO((_L("new acc vol %d"), iAccSpkrVol))
+    if ( IsActiveRemoteVolumeControl() )
         {
-        TRACE_INFO((_L("to new vol %d"), iAccSpkrVol))
         TInt vol = GetNewPhoneVol();
         if (vol != KNoAudioStreaming)
             {
@@ -73,10 +75,6 @@
             DoSetSpeakerVolL( prevPhVol );
             }
         }
-    else
-        {
-        TRACE_INFO((_L("volume control inactive!")))
-        }
     }
 
 void CBtmcVolume::SetMicrophoneVolumeL(TInt /*aHfVol*/)
@@ -86,13 +84,11 @@
 
 void CBtmcVolume::ActivateRemoteVolumeControl()
     {
-    if (!iVolCtrlActivated)
+    TRACE_FUNC
+    if (!IsActiveRemoteVolumeControl() )
         {
-        TRACE_FUNC
 		iVolLevelProperty.Subscribe(iActive->iStatus);     
         iActive->GoActive();
-
-        iVolCtrlActivated = ETrue;
         TInt vol = GetNewPhoneVol();
         TRACE_INFO((_L("current phone vol %d, acc vol %d"), vol, iAccSpkrVol))
         if (vol != KNoAudioStreaming)
@@ -109,11 +105,7 @@
 
 void CBtmcVolume::DeActivateRemoteVolumeControl()
     {
-    if (iVolCtrlActivated)
-        {
-        iVolCtrlActivated = EFalse;
-        iActive->Cancel();
-        }
+    iActive->Cancel();
     TRACE_FUNC
     }
 
@@ -242,21 +234,15 @@
             volClick = (iAccSpkrVol > iPhnSpkrVol) ? KPSVolumeUpClicked : KPSVolumeDownClicked;
             }        
         }
-     
+    TInt err( KErrNotFound );
     if( volClick )
         {
-        iAction = ESpeakerVolSet;
-        TInt err = iVolKeyEventProperty.Set( volClick );
-        if( err )
-            {
-            iAction = ESpeakerVolSubscribe;
-            TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err));
-            }
+        err = iVolKeyEventProperty.Set( volClick );
+        TRACE_INFO((_L("Set KMediaKeysVolumeKeyEvent click %d err %d"), volClick, err));
         }
-    else
-        {        
-        iAction = ESpeakerVolSubscribe;
-        }
+    
+    iAction = err ? ESpeakerVolSubscribe : ESpeakerVolSet;
+
     TRACE_FUNC_EXIT 
     }
 
@@ -313,4 +299,9 @@
 	return iPhnSpkrVol;
 	}
 
+TBool CBtmcVolume::IsActiveRemoteVolumeControl()
+    {
+    return iActive->IsActive();
+    }
+
 // End of file