bluetoothengine/btmac/src/BTMonoCmdHandler/btmcvolume.cpp
branchRCL_3
changeset 10 0707dd69d236
parent 0 f63038272f30
child 13 b6f55cd40afd
equal deleted inserted replaced
6:6a29d5ad0713 10:0707dd69d236
    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;
   107         }
   103         }
   108     }
   104     }
   109 
   105 
   110 void CBtmcVolume::DeActivateRemoteVolumeControl()
   106 void CBtmcVolume::DeActivateRemoteVolumeControl()
   111     {
   107     {
   112     if (iVolCtrlActivated)
   108     iActive->Cancel();
   113         {
       
   114         iVolCtrlActivated = EFalse;
       
   115         iActive->Cancel();
       
   116         }
       
   117     TRACE_FUNC
   109     TRACE_FUNC
   118     }
   110     }
   119 
   111 
   120 void CBtmcVolume::RequestCompletedL(CBtmcActive& aActive, TInt aErr)
   112 void CBtmcVolume::RequestCompletedL(CBtmcActive& aActive, TInt aErr)
   121     {
   113     {
   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
   311 	if (iPhnSpkrVol != KNoAudioStreaming)
   297 	if (iPhnSpkrVol != KNoAudioStreaming)
   312 	    return PhoneToHfVolScale(iPhnSpkrVol);
   298 	    return PhoneToHfVolScale(iPhnSpkrVol);
   313 	return iPhnSpkrVol;
   299 	return iPhnSpkrVol;
   314 	}
   300 	}
   315 
   301 
       
   302 TBool CBtmcVolume::IsActiveRemoteVolumeControl()
       
   303     {
       
   304     return iActive->IsActive();
       
   305     }
       
   306 
   316 // End of file
   307 // End of file