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

Commit ff6008e7 authored by Jack He's avatar Jack He
Browse files

StopWatch: Declare a stop_watch variable while timing

* A variable is needed to hold the reference of stop watch
  in the current scope. The variable will be freed once the
  current scope exits
* Without such a variable, the constructed stopwatch will only
  exist as a temporary stack variable and freed immediately
  after the declaration line, making the stop watch only timing
  the time needed for construction and immediate destruction.
  As result, current stop watch all show very minimum durations.
* Commands used:
  * find ./ -type f -exec sed -i 's/StopWatchLegacy(__func__);/StopWatchLegacy stop_watch(__func__);/g' {} \;
  * find ./ -type f -exec sed -i 's/common::StopWatch(/common::StopWatch stop_watch(/g' {} \;

Bug: 207608879
Test: GD presubmit and make
Tag: #gd-refactor
Change-Id: Ia38cf3d1473f750c6a08ba4d6551d7fafba4345a
parent ea93c89d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ class BluetoothAudioPortImpl : public IBluetoothAudioPort {
      : transport_instance_(transport_instance), provider_(provider) {}

  Return<void> startStream() override {
    StopWatchLegacy(__func__);
    StopWatchLegacy stop_watch(__func__);
    BluetoothAudioCtrlAck ack = transport_instance_->StartRequest();
    if (ack != BluetoothAudioCtrlAck::PENDING) {
      auto hidl_retval =
@@ -88,7 +88,7 @@ class BluetoothAudioPortImpl : public IBluetoothAudioPort {
  }

  Return<void> suspendStream() override {
    StopWatchLegacy(__func__);
    StopWatchLegacy stop_watch(__func__);
    BluetoothAudioCtrlAck ack = transport_instance_->SuspendRequest();
    if (ack != BluetoothAudioCtrlAck::PENDING) {
      auto hidl_retval =
@@ -102,14 +102,14 @@ class BluetoothAudioPortImpl : public IBluetoothAudioPort {
  }

  Return<void> stopStream() override {
    StopWatchLegacy(__func__);
    StopWatchLegacy stop_watch(__func__);
    transport_instance_->StopRequest();
    return Void();
  }

  Return<void> getPresentationPosition(
      getPresentationPosition_cb _hidl_cb) override {
    StopWatchLegacy(__func__);
    StopWatchLegacy stop_watch(__func__);
    uint64_t remote_delay_report_ns;
    uint64_t total_bytes_read;
    timespec data_position;
@@ -136,7 +136,7 @@ class BluetoothAudioPortImpl : public IBluetoothAudioPort {
  }

  Return<void> updateMetadata(const SourceMetadata& sourceMetadata) override {
    StopWatchLegacy(__func__);
    StopWatchLegacy stop_watch(__func__);
    LOG(INFO) << __func__ << ": " << sourceMetadata.tracks.size()
              << " track(s)";
    // refer to StreamOut.impl.h within Audio HAL (AUDIO_HAL_VERSION_5_0)
+5 −5
Original line number Diff line number Diff line
@@ -83,14 +83,14 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {
  }

  Return<void> initializationComplete(HidlStatus status) {
    common::StopWatch(__func__);
    common::StopWatch stop_watch(__func__);
    ASSERT(status == HidlStatus::SUCCESS);
    init_promise_->set_value();
    return Void();
  }

  Return<void> hciEventReceived(const hidl_vec<uint8_t>& event) override {
    common::StopWatch(GetTimerText(__func__, event));
    common::StopWatch stop_watch(GetTimerText(__func__, event));
    std::vector<uint8_t> received_hci_packet(event.begin(), event.end());
    btsnoop_logger_->Capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::EVT);
    if (common::init_flags::btaa_hci_is_enabled()) {
@@ -103,7 +103,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {
  }

  Return<void> aclDataReceived(const hidl_vec<uint8_t>& data) override {
    common::StopWatch(GetTimerText(__func__, data));
    common::StopWatch stop_watch(GetTimerText(__func__, data));
    std::vector<uint8_t> received_hci_packet(data.begin(), data.end());
    btsnoop_logger_->Capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::ACL);
    if (common::init_flags::btaa_hci_is_enabled()) {
@@ -116,7 +116,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {
  }

  Return<void> scoDataReceived(const hidl_vec<uint8_t>& data) override {
    common::StopWatch(GetTimerText(__func__, data));
    common::StopWatch stop_watch(GetTimerText(__func__, data));
    std::vector<uint8_t> received_hci_packet(data.begin(), data.end());
    btsnoop_logger_->Capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::SCO);
    if (common::init_flags::btaa_hci_is_enabled()) {
@@ -129,7 +129,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks {
  }

  Return<void> isoDataReceived(const hidl_vec<uint8_t>& data) override {
    common::StopWatch(GetTimerText(__func__, data));
    common::StopWatch stop_watch(GetTimerText(__func__, data));
    std::vector<uint8_t> received_hci_packet(data.begin(), data.end());
    btsnoop_logger_->Capture(received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::ISO);
    if (callback_ != nullptr) {