OSDN Git Service

Merge "Revert "HAL: Add ISO packet callbacks""
authorMyles Watson <mylesgw@google.com>
Thu, 13 Aug 2020 17:19:22 +0000 (17:19 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Thu, 13 Aug 2020 17:19:22 +0000 (17:19 +0000)
1  2 
gd/hal/hci_hal_host_rootcanal.cc
gd/hal/snoop_logger.cc
gd/hal/snoop_logger.h

Simple merge
@@@ -195,36 -110,17 +195,32 @@@ void SnoopLogger::Capture(const HciPack
        flags.set(0, true);
        flags.set(1, true);
        break;
-     case PacketType::ISO:
-       flags.set(0, direction == Direction::INCOMING);
-       flags.set(1, true);
-       break;
    }
    uint32_t length = packet.size() + /* type byte */ 1;
 -  btsnoop_packet_header_t header = {.length_original = htonl(length),
 -                                    .length_captured = htonl(length),
 -                                    .flags = htonl(static_cast<uint32_t>(flags.to_ulong())),
 -                                    .dropped_packets = 0,
 -                                    .timestamp = htonll(timestamp_us + BTSNOOP_EPOCH_DELTA),
 -                                    .type = static_cast<uint8_t>(type)};
 -  btsnoop_ostream_.write(reinterpret_cast<const char*>(&header), sizeof(btsnoop_packet_header_t));
 -  btsnoop_ostream_.write(reinterpret_cast<const char*>(packet.data()), packet.size());
 -  if (AlwaysFlush) btsnoop_ostream_.flush();
 +  PacketHeaderType header = {.length_original = htonl(length),
 +                             .length_captured = htonl(length),
 +                             .flags = htonl(static_cast<uint32_t>(flags.to_ulong())),
 +                             .dropped_packets = 0,
 +                             .timestamp = htonll(timestamp_us + kBtSnoopEpochDelta),
 +                             .type = static_cast<uint8_t>(type)};
 +  {
 +    std::lock_guard<std::recursive_mutex> lock(file_mutex_);
 +    packet_counter_++;
 +    if (packet_counter_ > max_packets_per_file_) {
 +      OpenNextSnoopLogFile();
 +    }
 +    if (!btsnoop_ostream_.write(reinterpret_cast<const char*>(&header), sizeof(PacketHeaderType))) {
 +      LOG_ERROR("Failed to write packet header, error: \"%s\"", strerror(errno));
 +    }
 +    if (!btsnoop_ostream_.write(reinterpret_cast<const char*>(packet.data()), packet.size())) {
 +      LOG_ERROR("Failed to write packet payload, error: \"%s\"", strerror(errno));
 +    }
 +    if (os::ParameterProvider::SnoopLogAlwaysFlush()) {
 +      if (!btsnoop_ostream_.flush()) {
 +        LOG_ERROR("Failed to flush, error: \"%s\"", strerror(errno));
 +      }
 +    }
 +  }
  }
  
  void SnoopLogger::ListDependencies(ModuleList* list) {
@@@ -77,10 -43,9 +77,9 @@@ class SnoopLogger : public ::bluetooth:
      ACL = 2,
      SCO = 3,
      EVT = 4,
-     ISO = 5,
    };
  
 -  enum class Direction {
 +  enum Direction {
      INCOMING,
      OUTGOING,
    };