Bug 1102703: (8/10) Porting bluetooth interface of bluez 5.26 (a2dp) r=btian, f=tzimmermann
authorBruce Sun <brsun@mozilla.com>
Fri, 09 Jan 2015 13:38:53 +0800
changeset 222992 24505b76d6ad652d7822cb49bf846cd631bcc7b2
parent 222991 d75205e308d8862995cbfabd31c8ba0e8e5e0cd4
child 222993 fc0b50dc40fe0e54ed26a515c7c4cec9e9eef0bd
push id28079
push userryanvm@gmail.com
push dateFri, 09 Jan 2015 19:45:59 +0000
treeherdermozilla-central@086396560012 [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: (8/10) 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