Bug 1029390: Asynchronous AVRCP response interfaces, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 23 Jul 2014 07:56:23 +0200
changeset 195576 1a8d196dfcc1d08b13ed3d723e5653235093ba15
parent 195575 2ca67af54fa1ac5e59dbb524f99662d17cf159a1
child 195577 99870e191644c8d06700b81a8e7c9d347ad4a8ed
push id27187
push usercbook@mozilla.com
push dateWed, 23 Jul 2014 10:59:56 +0000
treeherdermozilla-central@d0f6259e8446 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1029390
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1029390: Asynchronous AVRCP response interfaces, r=shuang
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothInterface.cpp
dom/bluetooth/bluedroid/BluetoothInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -164,17 +164,17 @@ public:
     for (int i = 0; i < mNumAttr; i++) {
       nsAutoString attrText;
       attrs[i].attr_id = mPlayerAttrs[i];
       ConvertAttributeString(mPlayerAttrs[i], attrText);
       strcpy((char *)attrs[i].text, NS_ConvertUTF16toUTF8(attrText).get());
     }
 
     NS_ENSURE_TRUE(sBtAvrcpInterface, NS_OK);
-    sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, attrs);
+    sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, attrs, nullptr);
 
     return NS_OK;
   }
 private:
   uint8_t mNumAttr;
   btrc_media_attr_t* mPlayerAttrs;
 };
 
@@ -1109,25 +1109,25 @@ BluetoothA2dpManager::UpdateMetaData(con
     // since track stores as uint8[8]
     // 56 = 8 * (BTRC_UID_SIZE -1)
     for (int i = 0; i < BTRC_UID_SIZE; ++i) {
       param.track[i] = (aMediaNumber >> (56 - 8 * i));
     }
     mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
     sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_TRACK_CHANGE,
                                                BTRC_NOTIFICATION_TYPE_CHANGED,
-                                               &param);
+                                               &param, nullptr);
     if (mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
       param.song_pos = mPosition;
       // EVENT_PLAYBACK_POS_CHANGED shall be notified if changed current track
       mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
       sBtAvrcpInterface->RegisterNotificationRsp(
         BTRC_EVT_PLAY_POS_CHANGED,
         BTRC_NOTIFICATION_TYPE_CHANGED,
-        &param);
+        &param, nullptr);
     }
   }
 
   mTitle.Assign(aTitle);
   mArtist.Assign(aArtist);
   mAlbum.Assign(aAlbum);
   mMediaNumber = aMediaNumber;
   mTotalMediaCount = aTotalMediaCount;
@@ -1145,36 +1145,36 @@ BluetoothA2dpManager::UpdatePlayStatus(u
                                        ControlPlayStatus aPlayStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
 #if ANDROID_VERSION > 17
   NS_ENSURE_TRUE_VOID(sBtAvrcpInterface);
   // always update playstatus first
   sBtAvrcpInterface->GetPlayStatusRsp((btrc_play_status_t)aPlayStatus,
-                                      aDuration, aPosition);
+                                      aDuration, aPosition, nullptr);
   // 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->RegisterNotificationRsp(BTRC_EVT_PLAY_STATUS_CHANGED,
                                                BTRC_NOTIFICATION_TYPE_CHANGED,
-                                               &param);
+                                               &param, nullptr);
   }
 
   if (mPosition != aPosition &&
       mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) {
     btrc_register_notification_t param;
     param.song_pos = aPosition;
     mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED;
     sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_POS_CHANGED,
                                                BTRC_NOTIFICATION_TYPE_CHANGED,
-                                               &param);
+                                               &param, nullptr);
   }
 
   mDuration = aDuration;
   mPosition = aPosition;
   mPlayStatus = aPlayStatus;
 #endif
 }
 
@@ -1232,17 +1232,17 @@ BluetoothA2dpManager::UpdateRegisterNoti
       mPlaybackInterval = aParam;
       break;
     default:
       break;
   }
 
   sBtAvrcpInterface->RegisterNotificationRsp((btrc_event_id_t)aEventId,
                                               BTRC_NOTIFICATION_TYPE_INTERIM,
-                                              &param);
+                                              &param, nullptr);
 #endif
 }
 
 void
 BluetoothA2dpManager::GetAlbum(nsAString& aAlbum)
 {
   aAlbum.Assign(mAlbum);
 }
--- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp
@@ -1010,74 +1010,128 @@ BluetoothAvrcpInterface::Cleanup(Bluetoo
   mInterface->cleanup();
 
   if (aRes) {
     DispatchBluetoothAvrcpResult(aRes, &BluetoothAvrcpResultHandler::Cleanup,
                                  BT_STATUS_SUCCESS);
   }
 }
 
-bt_status_t
+void
 BluetoothAvrcpInterface::GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
-                                          uint32_t aSongLen, uint32_t aSongPos)
+                                          uint32_t aSongLen, uint32_t aSongPos,
+                                          BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->get_play_status_rsp(aPlayStatus, aSongLen, aSongPos);
+  bt_status_t status = mInterface->get_play_status_rsp(aPlayStatus, aSongLen,
+                                                       aSongPos);
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::ListPlayerAppAttrRsp(int aNumAttr,
-                                              btrc_player_attr_t* aPAttrs)
+void
+BluetoothAvrcpInterface::ListPlayerAppAttrRsp(
+  int aNumAttr, btrc_player_attr_t* aPAttrs,
+  BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->list_player_app_attr_rsp(aNumAttr, aPAttrs);
+  bt_status_t status = mInterface->list_player_app_attr_rsp(aNumAttr, aPAttrs);
+
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals)
+void
+BluetoothAvrcpInterface::ListPlayerAppValueRsp(
+  int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->list_player_app_value_rsp(aNumVal, aPVals);
+  bt_status_t status = mInterface->list_player_app_value_rsp(aNumVal, aPVals);
+
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::GetPlayerAppValueRsp(btrc_player_settings_t* aPVals)
+void
+BluetoothAvrcpInterface::GetPlayerAppValueRsp(
+  btrc_player_settings_t* aPVals, BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->get_player_app_value_rsp(aPVals);
+  bt_status_t status = mInterface->get_player_app_value_rsp(aPVals);
+
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp(int aNumAttr,
-  btrc_player_setting_text_t* aPAttrs)
+void
+BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp(
+  int aNumAttr, btrc_player_setting_text_t* aPAttrs,
+  BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->get_player_app_attr_text_rsp(aNumAttr, aPAttrs);
+  bt_status_t status = mInterface->get_player_app_attr_text_rsp(aNumAttr,
+                                                                aPAttrs);
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::GetPlayerAppValueTextRsp(int aNumVal,
-  btrc_player_setting_text_t* aPVals)
+void
+BluetoothAvrcpInterface::GetPlayerAppValueTextRsp(
+  int aNumVal, btrc_player_setting_text_t* aPVals,
+  BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->get_player_app_value_text_rsp(aNumVal, aPVals);
+  bt_status_t status = mInterface->get_player_app_value_text_rsp(aNumVal,
+                                                                 aPVals);
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::GetElementAttrRsp(uint8_t aNumAttr,
-                                           btrc_element_attr_val_t* aPAttrs)
+void
+BluetoothAvrcpInterface::GetElementAttrRsp(
+  uint8_t aNumAttr, btrc_element_attr_val_t* aPAttrs,
+  BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->get_element_attr_rsp(aNumAttr, aPAttrs);
+  bt_status_t status = mInterface->get_element_attr_rsp(aNumAttr, aPAttrs);
+
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::SetPlayerAppValueRsp(btrc_status_t aRspStatus)
+void
+BluetoothAvrcpInterface::SetPlayerAppValueRsp(
+  btrc_status_t aRspStatus, BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->set_player_app_value_rsp(aRspStatus);
+  bt_status_t status = mInterface->set_player_app_value_rsp(aRspStatus);
+
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp, status);
+  }
 }
 
-bt_status_t
-BluetoothAvrcpInterface::RegisterNotificationRsp(btrc_event_id_t aEventId,
-  btrc_notification_type_t aType, btrc_register_notification_t* aPParam)
+void
+BluetoothAvrcpInterface::RegisterNotificationRsp(
+  btrc_event_id_t aEventId, btrc_notification_type_t aType,
+  btrc_register_notification_t* aPParam, BluetoothAvrcpResultHandler* aRes)
 {
-  return mInterface->register_notification_rsp(aEventId, aType, aPParam);
+  bt_status_t status = mInterface->register_notification_rsp(aEventId, aType,
+                                                             aPParam);
+  if (aRes) {
+    DispatchBluetoothAvrcpResult(
+      aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp, status);
+  }
 }
 
 bt_status_t
 BluetoothAvrcpInterface::SetVolume(uint8_t aVolume)
 {
 #if ANDROID_VERSION >= 19
   return mInterface->set_volume(aVolume);
 #else
--- a/dom/bluetooth/bluedroid/BluetoothInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothInterface.h
@@ -263,36 +263,44 @@ class BluetoothAvrcpInterface
 #if ANDROID_VERSION >= 18
 public:
   friend class BluetoothInterface;
 
   void Init(btrc_callbacks_t* aCallbacks,
             BluetoothAvrcpResultHandler* aRes);
   void Cleanup(BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
-                               uint32_t aSongLen, uint32_t aSongPos);
+  void GetPlayStatusRsp(btrc_play_status_t aPlayStatus,
+                        uint32_t aSongLen, uint32_t aSongPos,
+                        BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t ListPlayerAppAttrRsp(int aNumAttr, btrc_player_attr_t* aPAttrs);
-  bt_status_t ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals);
+  void ListPlayerAppAttrRsp(int aNumAttr, btrc_player_attr_t* aPAttrs,
+                            BluetoothAvrcpResultHandler* aRes);
+  void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals,
+                             BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t GetPlayerAppValueRsp(btrc_player_settings_t* aPVals);
-  bt_status_t GetPlayerAppAttrTextRsp(int aNumAttr,
-                                      btrc_player_setting_text_t* aPAttrs);
-  bt_status_t GetPlayerAppValueTextRsp(int aNumVal,
-                                       btrc_player_setting_text_t* aPVals);
+  void GetPlayerAppValueRsp(btrc_player_settings_t* aPVals,
+                            BluetoothAvrcpResultHandler* aRes);
+  void GetPlayerAppAttrTextRsp(int aNumAttr,
+                               btrc_player_setting_text_t* aPAttrs,
+                               BluetoothAvrcpResultHandler* aRes);
+  void GetPlayerAppValueTextRsp(int aNumVal,
+                                btrc_player_setting_text_t* aPVals,
+                                BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t GetElementAttrRsp(uint8_t aNumAttr,
-                                btrc_element_attr_val_t* aPAttrs);
+  void GetElementAttrRsp(uint8_t aNumAttr, btrc_element_attr_val_t* aPAttrs,
+                         BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t SetPlayerAppValueRsp(btrc_status_t aRspStatus);
+  void SetPlayerAppValueRsp(btrc_status_t aRspStatus,
+                            BluetoothAvrcpResultHandler* aRes);
 
-  bt_status_t RegisterNotificationRsp(btrc_event_id_t aEventId,
-                                      btrc_notification_type_t aType,
-                                      btrc_register_notification_t* aPParam);
+  void RegisterNotificationRsp(btrc_event_id_t aEventId,
+                               btrc_notification_type_t aType,
+                               btrc_register_notification_t* aPParam,
+                               BluetoothAvrcpResultHandler* aRes);
 
   bt_status_t SetVolume(uint8_t aVolume);
 
 protected:
   BluetoothAvrcpInterface(const btrc_interface_t* aInterface);
   ~BluetoothAvrcpInterface();
 
 private: