Bug 1102703 - Porting bluetooth interface of bluez 5.26 (a2dp). r=btian, f=tzimmermann
☠☠ backed out by b4926227268f ☠ ☠
authorBruce Sun <brsun@mozilla.com>
Thu, 08 Jan 2015 11:49:49 +0800
changeset 222674 b61bf281e9910a32f2084e99aabf1f7f45438d74
parent 222673 f62155e4fb9c32f91e21395bab8b870b992f0388
child 222675 d9d1879fc90f22934dcd06f0841d98255ab9e71a
push id28071
push userkwierso@gmail.com
push dateFri, 09 Jan 2015 00:54:55 +0000
treeherdermozilla-central@ccfafae7330f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1102703
milestone37.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 1102703 - Porting bluetooth interface of bluez 5.26 (a2dp). r=btian, f=tzimmermann
dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.cpp
@@ -257,25 +257,74 @@ void
 BluetoothDaemonA2dpModule::AudioStateNtf(
   const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
 {
   AudioStateNotification::Dispatch(
     &BluetoothA2dpNotificationHandler::AudioStateNotification,
     AudioStateInitOp(aPDU));
 }
 
+// Init operator class for AudioConfigNotification
+class BluetoothDaemonA2dpModule::AudioConfigInitOp MOZ_FINAL
+  : private PDUInitOp
+{
+public:
+  AudioConfigInitOp(BluetoothDaemonPDU& aPDU)
+    : PDUInitOp(aPDU)
+  { }
+
+  nsresult
+  operator () (nsString& aArg1, uint32_t aArg2, uint8_t aArg3) const
+  {
+    BluetoothDaemonPDU& pdu = GetPDU();
+
+    /* Read address */
+    nsresult rv = UnpackPDU(
+      pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg1));
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+
+    /* Read sample rate */
+    rv = UnpackPDU(pdu, aArg2);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+
+    /* Read channel count */
+    rv = UnpackPDU(pdu, aArg3);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+};
+
+void
+BluetoothDaemonA2dpModule::AudioConfigNtf(
+  const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
+{
+  AudioConfigNotification::Dispatch(
+    &BluetoothA2dpNotificationHandler::AudioConfigNotification,
+    AudioConfigInitOp(aPDU));
+}
+
 void
 BluetoothDaemonA2dpModule::HandleNtf(
   const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
   void* aUserData)
 {
   static void (BluetoothDaemonA2dpModule::* const HandleNtf[])(
     const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = {
     INIT_ARRAY_AT(0, &BluetoothDaemonA2dpModule::ConnectionStateNtf),
     INIT_ARRAY_AT(1, &BluetoothDaemonA2dpModule::AudioStateNtf),
+#if ANDROID_VERSION >= 21
+    INIT_ARRAY_AT(2, &BluetoothDaemonA2dpModule::AudioConfigNtf),
+#endif
   };
 
   MOZ_ASSERT(!NS_IsMainThread());
 
   uint8_t index = aHeader.mOpcode - 0x81;
 
   if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) ||
       NS_WARN_IF(!HandleNtf[index])) {
--- a/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonA2dpInterface.h
@@ -100,25 +100,34 @@ protected:
 
   typedef BluetoothNotificationRunnable2<NotificationHandlerWrapper, void,
                                          BluetoothA2dpAudioState,
                                          nsString,
                                          BluetoothA2dpAudioState,
                                          const nsAString&>
     AudioStateNotification;
 
+  typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
+                                         nsString, uint32_t, uint8_t,
+                                         const nsAString&, uint32_t, uint8_t>
+    AudioConfigNotification;
+
+  class ConnectionStateInitOp;
   class AudioStateInitOp;
-  class ConnectionStateInitOp;
+  class AudioConfigInitOp;
 
   void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader,
                           BluetoothDaemonPDU& aPDU);
 
   void AudioStateNtf(const BluetoothDaemonPDUHeader& aHeader,
                      BluetoothDaemonPDU& aPDU);
 
+  void AudioConfigNtf(const BluetoothDaemonPDUHeader& aHeader,
+                      BluetoothDaemonPDU& aPDU);
+
   void HandleNtf(const BluetoothDaemonPDUHeader& aHeader,
                  BluetoothDaemonPDU& aPDU,
                  void* aUserData);
 
   static BluetoothA2dpNotificationHandler* sNotificationHandler;
 };
 
 class BluetoothDaemonA2dpInterface MOZ_FINAL