Bug 976485 - [bluedroid] Fix sometimes Avrcp 1.3 play status is out of sync. r=gyeh
authorShawn Huang <shuang@mozilla.com>
Thu, 13 Mar 2014 09:12:41 -0400
changeset 173383 f351db5f11896ea30eaa2d30634fadfd5d75dee7
parent 173382 e574778a856384fea69bfd29b7d4ddcc7458960a
child 173384 ebba55b7f0d8d56fc9ecf68596e369bf8e4d8ea4
push id5434
push userryanvm@gmail.com
push dateThu, 13 Mar 2014 13:12:08 +0000
treeherderb2g-inbound@f351db5f1189 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgyeh
bugs976485
milestone30.0a1
Bug 976485 - [bluedroid] Fix sometimes Avrcp 1.3 play status is out of sync. r=gyeh
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -905,16 +905,19 @@ void
 BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
                                        uint32_t aPosition,
                                        ControlPlayStatus aPlayStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
 #if ANDROID_VERSION > 17
   NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
+  // always update playstatus first
+  sBtAvrcpInterface->get_play_status_rsp((btrc_play_status_t)aPlayStatus,
+                                         aDuration, aPosition);
   // when play status changed, send both play status and position
   if (mPlayStatus != aPlayStatus &&
       mPlayStatusChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
     btrc_register_notification_t param;
     param.play_status = (btrc_play_status_t)aPlayStatus;
     mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
     sBtAvrcpInterface->register_notification_rsp(BTRC_EVT_PLAY_STATUS_CHANGED,
                                                  BTRC_NOTIFICATION_TYPE_CHANGED,
@@ -926,18 +929,16 @@ BluetoothA2dpManager::UpdatePlayStatus(u
     btrc_register_notification_t param;
     param.song_pos = aPosition;
     mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
     sBtAvrcpInterface->register_notification_rsp(BTRC_EVT_PLAY_POS_CHANGED,
                                                  BTRC_NOTIFICATION_TYPE_CHANGED,
                                                  &param);
   }
 
-  sBtAvrcpInterface->get_play_status_rsp((btrc_play_status_t)aPlayStatus,
-                                         aDuration, aPosition);
   mDuration = aDuration;
   mPosition = aPosition;
   mPlayStatus = aPlayStatus;
 #endif
 }
 
 /*
  * This function handles RegisterNotification request from
@@ -953,17 +954,17 @@ BluetoothA2dpManager::UpdateRegisterNoti
 
 #if ANDROID_VERSION > 17
   NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
 
   btrc_register_notification_t param;
 
   switch (aEventId) {
     case BTRC_EVT_PLAY_STATUS_CHANGED:
-      mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM;
+      mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM;
       param.play_status = (btrc_play_status_t)mPlayStatus;
       break;
     case BTRC_EVT_TRACK_CHANGE:
       // In AVRCP 1.3 and 1.4, the identifier parameter of EVENT_TRACK_CHANGED
       // is different.
       // AVRCP 1.4: If no track is selected, we shall return 0xFFFFFFFFFFFFFFFF,
       // otherwise return 0x0 in the INTERRIM response. The expanded text in
       // version 1.4 is to allow for new UID feature. As for AVRCP 1.3, we shall