OSDN Git Service

Log RSSI when A2DP buffers are flushed
authorAndre Eisenbach <eisenbach@google.com>
Wed, 29 Jun 2016 19:46:13 +0000 (12:46 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 29 Jun 2016 20:25:21 +0000 (20:25 +0000)
To add another datapoint and potentially narrow down *why* we had to
flush the buffers, add RSSI logging to keep track of signal strength
during audio drop-out events.

Change-Id: Ie52f56290951130165a9f375a898a9bacf459d55

btif/src/btif_media_task.c

index 08af577..262bc53 100644 (file)
@@ -492,6 +492,25 @@ UNUSED_ATTR static const char *dump_media_event(UINT16 event)
     }
 }
 
+static void btm_read_rssi_cb(void *data)
+{
+    assert(data);
+
+    tBTM_RSSI_RESULTS *result = (tBTM_RSSI_RESULTS*)data;
+    if (result->status != BTM_SUCCESS)
+    {
+        LOG_ERROR(LOG_TAG, "%s unable to read remote RSSI (status %d)",
+            __func__, result->status);
+        return;
+    }
+
+    char temp_buffer[20] = {0};
+    LOG_WARN(LOG_TAG, "%s device: %s, rssi: %d", __func__,
+        bdaddr_to_string((bt_bdaddr_t *)result->rem_bda, temp_buffer,
+            sizeof(temp_buffer)),
+        result->rssi);
+}
+
 /*****************************************************************************
  **  A2DP CTRL PATH
  *****************************************************************************/
@@ -3096,13 +3115,19 @@ static void btif_media_aa_prep_2_send(UINT8 nb_frame, uint64_t timestamp_us)
         APPL_TRACE_WARNING("%s() - TX queue buffer count %d/%d", __func__,
                            fixed_queue_length(btif_media_cb.TxAaQ),
                            MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ - nb_frame);
+        // Keep track of drop-outs
         btif_media_cb.stats.tx_queue_dropouts++;
         btif_media_cb.stats.tx_queue_last_dropouts_us = timestamp_us;
 
+        // Flush all queued buffers...
         while (fixed_queue_length(btif_media_cb.TxAaQ)) {
             btif_media_cb.stats.tx_queue_total_dropped_messages++;
             osi_free(fixed_queue_try_dequeue(btif_media_cb.TxAaQ));
         }
+
+        // Request RSSI for log purposes if we had to flush buffers
+        bt_bdaddr_t peer_bda = btif_av_get_addr();
+        BTM_ReadRSSI(peer_bda.address, btm_read_rssi_cb);
     }
 
     // Transcode frame