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

Commit 41f78db5 authored by Chris Manton's avatar Chris Manton
Browse files

stack::l2cap [5/19] L2CA_FlushChannel

Bug: 339732512
Test: m .
Flag: EXEMPT, Logging Change

Change-Id: I667ec494d34fb84e61ce337c2016560c733b2004
parent 80a428e7
Loading
Loading
Loading
Loading
+39 −9
Original line number Diff line number Diff line
@@ -1365,7 +1365,13 @@ void bta_av_do_close(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* /* p_data */) {
  p_scb->use_rtp_header_marker_bit = false;

  /* drop the buffers queued in L2CAP */
  const uint16_t buffers_left =
      L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);
  if (buffers_left) {
    log::warn(
        "Unable to flush L2CAP ALL channel peer:{} cid:{} buffers_left:{}",
        p_scb->PeerAddress(), p_scb->l2c_cid, buffers_left);
  }

  AVDT_CloseReq(p_scb->avdt_handle);
  /* just in case that the link is congested, link is flow controled by peer or
@@ -1974,8 +1980,17 @@ void bta_av_str_stopped(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
    }

    /* drop the audio buffers queued in L2CAP */
    if (p_data && p_data->api_stop.flush)
    if (p_data && p_data->api_stop.flush) {
      const uint16_t buffers_left =
          L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);

      if (buffers_left) {
        log::warn(
            "Unable to flush all L2CAP ALL channel peer:{} cid:{} "
            "buffers_left:{}",
            p_scb->PeerAddress(), p_scb->l2c_cid, buffers_left);
      }
    }
  }

  tBTA_AV_SUSPEND suspend_rsp = {};
@@ -2102,7 +2117,14 @@ void bta_av_reconfig(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
      bta_av_str_stopped(p_scb, NULL);
    }
    // Drop the buffers queued in L2CAP
    const uint16_t buffers_left =
        L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);
    if (buffers_left) {
      log::warn(
          "Unable to flush all L2CAP ALL channel peer:{} cid:{} "
          "buffers_left:{}",
          p_scb->PeerAddress(), p_scb->l2c_cid, buffers_left);
    }
    AVDT_CloseReq(p_scb->avdt_handle);
  }
}
@@ -2780,10 +2802,13 @@ void bta_av_suspend_cont(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
                 p_scb->PeerAddress());
      bta_av_ssm_execute(p_scb, BTA_AV_STR_DISC_FAIL_EVT, NULL);
    } else {
      log::error("suspend rejected, try close");
      /* drop the buffers queued in L2CAP */
      const uint16_t buffers_left =
          L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);

      if (buffers_left) {
        log::error("suspend rejected, closing peer:{} cid:{} buffers_left:{}",
                   p_scb->PeerAddress(), p_scb->l2c_cid, buffers_left);
      }
      AVDT_CloseReq(p_scb->avdt_handle);
    }
  } else {
@@ -2829,7 +2854,6 @@ void bta_av_rcfg_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  }

  if ((err_code != 0) || disable_avdtp_reconfigure) {
    log::error("reconfig rejected, try close");
    /* Disable reconfiguration feature only with explicit rejection(not with
     * timeout) */
    if ((err_code != AVDT_ERR_TIMEOUT) || disable_avdtp_reconfigure) {
@@ -2837,7 +2861,13 @@ void bta_av_rcfg_cfm(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
    }
    /* started flag is false when reconfigure command is sent */
    /* drop the buffers queued in L2CAP */
    const uint16_t buffers_left =
        L2CA_FlushChannel(p_scb->l2c_cid, L2CAP_FLUSH_CHANS_ALL);
    if (buffers_left) {
      log::error(
          "reconfig rejected, closing queued  peer:{} cid:{} buffers_left:{}",
          p_scb->PeerAddress(), p_scb->l2c_cid, buffers_left);
    }
    AVDT_CloseReq(p_scb->avdt_handle);
  } else {
    /* update the codec info after rcfg cfm */
+16 −2
Original line number Diff line number Diff line
@@ -1486,7 +1486,14 @@ class HearingAidImpl : public HearingAid {
          log::info("{} skipping {} packets", left->address, packets_in_chans);
          left->audio_stats.packet_flush_count += packets_in_chans;
          left->audio_stats.frame_flush_count++;
          L2CA_FlushChannel(cid, 0xffff);
          const uint16_t buffers_left =
              L2CA_FlushChannel(cid, L2CAP_FLUSH_CHANS_ALL);
          if (buffers_left) {
            log::warn(
                "Unable to flush L2CAP ALL (left HA) channel peer:{} cid:{} "
                "buffers_left:{}",
                left->address, cid, buffers_left);
          }
        }
        hearingDevices.StartRssiLog();
      }
@@ -1517,7 +1524,14 @@ class HearingAidImpl : public HearingAid {
          log::info("{} skipping {} packets", right->address, packets_in_chans);
          right->audio_stats.packet_flush_count += packets_in_chans;
          right->audio_stats.frame_flush_count++;
          L2CA_FlushChannel(cid, 0xffff);
          const uint16_t buffers_left =
              L2CA_FlushChannel(cid, L2CAP_FLUSH_CHANS_ALL);
          if (buffers_left) {
            log::warn(
                "Unable to flush L2CAP ALL (right HA) channel peer:{} cid:{} "
                "buffers_left:{}",
                right->address, cid, buffers_left);
          }
        }
        hearingDevices.StartRssiLog();
      }
+7 −1
Original line number Diff line number Diff line
@@ -1517,7 +1517,13 @@ void avdt_scb_clr_pkt(AvdtpScb* p_scb, tAVDT_SCB_EVT* /* p_data */) {
    tcid = avdt_ad_type_to_tcid(AVDT_CHAN_MEDIA, p_scb);

    lcid = avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid;
    const uint16_t buffers_left =
        L2CA_FlushChannel(lcid, L2CAP_FLUSH_CHANS_ALL);
    if (buffers_left) {
      log::warn(
          "Unable to flush L2CAP ALL channel peer:{} cid:{} buffers_left:{}",
          p_ccb->peer_addr, lcid, buffers_left);
    }
  }

  if (p_scb->p_pkt != NULL) {