Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0135d6ab authored by En-Shuo Hsu's avatar En-Shuo Hsu
Browse files

Clean noisy SCO debug log

Meaningful log is flooded by the SCO log. Remove most of them to
mitigate the issue.

Replace them with a summary debug log printed when SCO gets
disconnected.

Bug: 301673369, 308457537
Test: atest --host net_test_stack_btm --no-bazel-mode
Change-Id: I05fa8af5ecab1439530822fed4844c92d7818641
parent 6f4d2b66
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -328,10 +328,7 @@ void btm_route_sco_data(bluetooth::hci::ScoView valid_packet) {
                        ? &bluetooth::audio::sco::swb::decode
                        : &bluetooth::audio::sco::wbs::decode;
      rc = decode(&decoded);
      if (rc == 0) {
        LOG_DEBUG("Failed to decode %s frames", codec.c_str());
        break;
      }
      if (rc == 0) break;

      written += bluetooth::audio::sco::write(decoded, rc);
    }
@@ -1258,8 +1255,13 @@ void btm_sco_on_disconnected(uint16_t hci_handle, tHCI_REASON reason) {
      double packet_loss_ratio;
      if (fill_plc_stats(&num_decoded_frames, &packet_loss_ratio)) {
        const int16_t codec_id = sco_codec_type_to_id(codec_type);
        const std::string codec = sco_codec_type_text(codec_type);
        log_hfp_audio_packet_loss_stats(bd_addr, num_decoded_frames,
                                        packet_loss_ratio, codec_id);
        LOG_DEBUG(
            "Stopped SCO codec:%s, num_decoded_frames:%d, "
            "packet_loss_ratio:%lf",
            codec.c_str(), num_decoded_frames, packet_loss_ratio);
      } else {
        LOG_WARN("Failed to get the packet loss stats");
      }
+0 −25
Original line number Diff line number Diff line
@@ -509,7 +509,6 @@ struct tBTM_MSBC_INFO {

  const uint8_t* find_msbc_pkt_head() {
    if (read_corrupted) {
      LOG_DEBUG("Skip corrupted mSBC packets");
      read_corrupted = false;
      return nullptr;
    }
@@ -556,11 +555,6 @@ struct tBTM_MSBC_INFO {
  }

  size_t mark_pkt_dequeued() {
    LOG_DEBUG(
        "Try to mark an encoded packet dequeued: ro:%lu wo:%lu pkt_size:%lu",
        (unsigned long)encode_buf_ro, (unsigned long)encode_buf_wo,
        (unsigned long)packet_size);

    if (encode_buf_wo - encode_buf_ro < packet_size) return 0;

    encode_buf_ro += packet_size;
@@ -574,7 +568,6 @@ struct tBTM_MSBC_INFO {

  const uint8_t* sco_pkt_read_ptr() {
    if (encode_buf_wo - encode_buf_ro < packet_size) {
      LOG_DEBUG("Insufficient data as a SCO packet to read.");
      return nullptr;
    }

@@ -637,8 +630,6 @@ bool enqueue_packet(const std::vector<uint8_t>& data, bool corrupted) {

  msbc_info->read_corrupted |= corrupted;
  if (msbc_info->write(data) != data.size()) {
    LOG_DEBUG("Fail to write packet with size %lu to buffer",
              (unsigned long)data.size());
    return false;
  }

@@ -659,15 +650,11 @@ size_t decode(const uint8_t** out_data) {
  }

  if (msbc_info->decodable() < BTM_MSBC_PKT_LEN) {
    LOG_DEBUG("No complete mSBC packet to decode");
    return 0;
  }

  frame_head = msbc_info->find_msbc_pkt_head();
  if (frame_head == nullptr) {
    LOG_DEBUG("No valid mSBC packet to decode %lu, %lu",
              (unsigned long)msbc_info->decode_buf_ro,
              (unsigned long)msbc_info->decode_buf_wo);
    /* Done with parsing the raw bytes just read. If we couldn't find a valid
     * mSBC frame head, we shall treat the existing BTM_MSBC_PKT_LEN length
     * of mSBC data as a corrupted packet and conduct the PLC. */
@@ -677,7 +664,6 @@ size_t decode(const uint8_t** out_data) {
  if (!GetInterfaceToProfiles()->msbcCodec->decodePacket(
          frame_head, msbc_info->decoded_pcm_buf,
          sizeof(msbc_info->decoded_pcm_buf))) {
    LOG_DEBUG("Decoding mSBC packet failed");
    goto packet_loss;
  }

@@ -708,16 +694,11 @@ size_t encode(int16_t* data, size_t len) {
  }

  if (len < BTM_MSBC_CODE_SIZE) {
    LOG_DEBUG(
        "PCM frames with size %lu is insufficient to be encoded into a mSBC "
        "packet",
        (unsigned long)len);
    return 0;
  }

  pkt_body = msbc_info->fill_msbc_pkt_template();
  if (pkt_body == nullptr) {
    LOG_DEBUG("Failed to fill the template to fill the mSBC packet");
    return 0;
  }

@@ -925,11 +906,6 @@ struct tBTM_LC3_INFO {
  }

  size_t mark_pkt_dequeued() {
    LOG_DEBUG(
        "Try to mark an encoded packet dequeued: ro:%lu wo:%lu pkt_size:%lu",
        (unsigned long)encode_buf_ro, (unsigned long)encode_buf_wo,
        (unsigned long)packet_size);

    if (encode_buf_wo - encode_buf_ro < packet_size) return 0;

    encode_buf_ro += packet_size;
@@ -943,7 +919,6 @@ struct tBTM_LC3_INFO {

  const uint8_t* sco_pkt_read_ptr() {
    if (encode_buf_wo - encode_buf_ro < packet_size) {
      LOG_DEBUG("Insufficient data as a SCO packet to read.");
      return nullptr;
    }