bluetoothengine/btsac/btrcc/src/btrccVolumeLevelControllerBase.cpp
branchRCL_3
changeset 21 53b7818cd282
parent 0 f63038272f30
child 45 b0aebde9b1fb
equal deleted inserted replaced
20:2f88a7d66f50 21:53b7818cd282
    80 
    80 
    81 	iVolLevelProperty.Subscribe(iBtrccActive->iStatus);
    81 	iVolLevelProperty.Subscribe(iBtrccActive->iStatus);
    82     iBtrccActive->GoActive(); 
    82     iBtrccActive->GoActive(); 
    83 
    83 
    84     (void) GetPhoneVolume(iPhoneVolume);
    84     (void) GetPhoneVolume(iPhoneVolume);
       
    85     ScalePhoneVolume(iPhoneVolume);
    85     if( iPhoneVolume > -1)
    86     if( iPhoneVolume > -1)
    86         {
    87         {
    87         DoStart( iPhoneVolume );
    88         DoStart( iPhoneVolume );
    88         }
    89         }
    89     }
    90     }
   150     {
   151     {
   151     TRACE_FUNC
   152     TRACE_FUNC
   152     iRemoteVolume = aVolumeInPhoneScale;
   153     iRemoteVolume = aVolumeInPhoneScale;
   153     TInt vol;
   154     TInt vol;
   154     TInt err = GetPhoneVolume(vol);
   155     TInt err = GetPhoneVolume(vol);
       
   156     ScalePhoneVolume(iPhoneVolume);
   155     if(!err)
   157     if(!err)
   156         {
   158         {
       
   159         TInt prevPhVol = iPhoneVolume;
   157         iPhoneVolume = vol;
   160         iPhoneVolume = vol;
   158         SetPhoneVolume();
   161         TInt remoteVol = RoundRemoteVolume(prevPhVol);
       
   162         SetPhoneVolume(remoteVol);
   159         }
   163         }
   160     }
   164     }
   161 
   165 
   162 // -----------------------------------------------------------------------------
   166 // -----------------------------------------------------------------------------
   163 // CBTRCCVolumeLevelControllerBase::SetPhoneVolume
   167 // CBTRCCVolumeLevelControllerBase::SetPhoneVolume
   164 // -----------------------------------------------------------------------------
   168 // -----------------------------------------------------------------------------
   165 //
   169 //
   166 void CBTRCCVolumeLevelControllerBase::SetPhoneVolume()
   170 void CBTRCCVolumeLevelControllerBase::SetPhoneVolume(TInt aRemoteVol)
   167     {
   171     {
   168     TRACE_FUNC
   172     TRACE_FUNC
   169     TRACE_INFO((_L("iRemoteVolume = %d, iPhoneVolume = %d"), iRemoteVolume, iPhoneVolume))
   173     TRACE_INFO((_L("Remote Volume = %d, iPhoneVolume = %d"), aRemoteVol, iPhoneVolume))
   170     if (iRemoteVolume != iPhoneVolume)
   174     TInt err( KErrNotFound );
   171         {
   175     if (aRemoteVol != iPhoneVolume)
   172         TInt event = (iRemoteVolume > iPhoneVolume) ? KPSVolumeUpClicked : KPSVolumeDownClicked;
   176         {
   173         TInt err = iVolKeyEventProperty.Set(event);
   177         TInt event = (aRemoteVol > iPhoneVolume) ? KPSVolumeUpClicked : KPSVolumeDownClicked;
   174         if (err)
   178         err = iVolKeyEventProperty.Set(event);
   175             {
   179         TRACE_INFO((_L("Set KMediaKeysVolumeKeyEvent click %d err %d"), event, err));
   176             TRACE_ERROR((_L("Set KMediaKeysVolumeKeyEvent err %d"), err));
       
   177             }
       
   178         iState = ESetPhoneVolume;
       
   179         }    
   180         }    
   180     else
   181     iState = err ? ESubscribePhoneVolume : ESetPhoneVolume;
   181         {
       
   182         iState = ESubscribePhoneVolume;
       
   183         } 
       
   184     }
   182     }
   185 
   183 
   186 // -----------------------------------------------------------------------------
   184 // -----------------------------------------------------------------------------
   187 // CBTRCCVolumeLevelControllerBase::GetPhoneVolume
   185 // CBTRCCVolumeLevelControllerBase::GetPhoneVolume
   188 // -----------------------------------------------------------------------------
   186 // -----------------------------------------------------------------------------
   203     {
   201     {
   204     return iPhoneVolume;
   202     return iPhoneVolume;
   205     }
   203     }
   206 
   204 
   207 // -----------------------------------------------------------------------------
   205 // -----------------------------------------------------------------------------
       
   206 // CBTRCCVolumeLevelControllerBase::GetCurrentRemoteVolume
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 TInt CBTRCCVolumeLevelControllerBase::GetCurrentRemoteVolume()
       
   210     {
       
   211     return iRemoteVolume;
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CBTRCCVolumeLevelControllerBase::RoundRemoteVolume
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 TInt CBTRCCVolumeLevelControllerBase::RoundRemoteVolume(TInt /*aPrevPhVol*/)
       
   219     {
       
   220     TRACE_FUNC
       
   221     // default implementation
       
   222     return iRemoteVolume;
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CBTRCCVolumeLevelControllerBase::ScalePhoneVolume
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CBTRCCVolumeLevelControllerBase::ScalePhoneVolume(TInt& /*aVolume*/)
       
   230     {
       
   231     TRACE_FUNC
       
   232     // default implementation
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
   208 // CBTRCCVolumeLevelControllerBase::RequestCompletedL
   236 // CBTRCCVolumeLevelControllerBase::RequestCompletedL
   209 // -----------------------------------------------------------------------------
   237 // -----------------------------------------------------------------------------
   210 //
   238 //
   211 void CBTRCCVolumeLevelControllerBase::RequestCompletedL(CBTRCCActive& aActive, TInt aErr)
   239 void CBTRCCVolumeLevelControllerBase::RequestCompletedL(CBTRCCActive& aActive, TInt aErr)
   212     {
   240     {
   213     TRACE_FUNC
   241     TRACE_FUNC
   214     if(aActive.ServiceId() == KVolumeChangeListenerServiceId)
   242     if(aActive.ServiceId() == KVolumeChangeListenerServiceId)
   215         {
   243         {
       
   244         TInt prevPhVol = iPhoneVolume;
   216         TInt err = GetPhoneVolume(iPhoneVolume);
   245         TInt err = GetPhoneVolume(iPhoneVolume);
       
   246         ScalePhoneVolume(iPhoneVolume);
   217                 
   247                 
   218         if(!err && !aErr && iPhoneVolume > -1)
   248         if(!err && !aErr && iPhoneVolume > -1)
   219             {
   249             {
   220             switch(iState)
   250             switch(iState)
   221                 {
   251                 {
   222                 case ESubscribePhoneVolume:
   252                 case ESubscribePhoneVolume:
   223                     // Tell the specialization of the new volume level. 
   253                     // Tell the specialization of the new volume level. 
   224                     AdjustRemoteVolume(iPhoneVolume); 
   254                     AdjustRemoteVolume(iPhoneVolume); 
   225                     break;
   255                     break;
   226                 case ESetPhoneVolume:
   256                 case ESetPhoneVolume:
   227                     SetPhoneVolume();
   257                     TInt remoteVol = RoundRemoteVolume(prevPhVol);
       
   258                     SetPhoneVolume(remoteVol);
   228                     break;
   259                     break;
   229                 }
   260                 }
   230             }
   261             }
   231         
   262         
   232         iVolLevelProperty.Subscribe(iBtrccActive->iStatus);
   263         iVolLevelProperty.Subscribe(iBtrccActive->iStatus);