PacketBuffer: remove lock recursions.
This change removes lock recursions and adds thread annotations. Bug: webrtc:11567 Change-Id: Ibc429571926693f4b3de78f97a5dc5501d93a4a3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176240 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Markus Handell <handellm@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31369}
This commit is contained in:

committed by
Commit Bot

parent
bdb5830d69
commit
3eac111115
@ -112,7 +112,7 @@ PacketBuffer::InsertResult PacketBuffer::InsertPacket(
|
|||||||
// Clear the buffer, delete payload, and return false to signal that a
|
// Clear the buffer, delete payload, and return false to signal that a
|
||||||
// new keyframe is needed.
|
// new keyframe is needed.
|
||||||
RTC_LOG(LS_WARNING) << "Clear PacketBuffer and request key frame.";
|
RTC_LOG(LS_WARNING) << "Clear PacketBuffer and request key frame.";
|
||||||
Clear();
|
ClearInternal();
|
||||||
result.buffer_cleared = true;
|
result.buffer_cleared = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -174,16 +174,7 @@ void PacketBuffer::ClearTo(uint16_t seq_num) {
|
|||||||
|
|
||||||
void PacketBuffer::Clear() {
|
void PacketBuffer::Clear() {
|
||||||
rtc::CritScope lock(&crit_);
|
rtc::CritScope lock(&crit_);
|
||||||
for (auto& entry : buffer_) {
|
ClearInternal();
|
||||||
entry = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
first_packet_received_ = false;
|
|
||||||
is_cleared_to_first_seq_num_ = false;
|
|
||||||
last_received_packet_ms_.reset();
|
|
||||||
last_received_keyframe_packet_ms_.reset();
|
|
||||||
newest_inserted_seq_num_.reset();
|
|
||||||
missing_packets_.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketBuffer::InsertResult PacketBuffer::InsertPadding(uint16_t seq_num) {
|
PacketBuffer::InsertResult PacketBuffer::InsertPadding(uint16_t seq_num) {
|
||||||
@ -204,6 +195,19 @@ absl::optional<int64_t> PacketBuffer::LastReceivedKeyframePacketMs() const {
|
|||||||
return last_received_keyframe_packet_ms_;
|
return last_received_keyframe_packet_ms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PacketBuffer::ClearInternal() {
|
||||||
|
for (auto& entry : buffer_) {
|
||||||
|
entry = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
first_packet_received_ = false;
|
||||||
|
is_cleared_to_first_seq_num_ = false;
|
||||||
|
last_received_packet_ms_.reset();
|
||||||
|
last_received_keyframe_packet_ms_.reset();
|
||||||
|
newest_inserted_seq_num_.reset();
|
||||||
|
missing_packets_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
bool PacketBuffer::ExpandBufferSize() {
|
bool PacketBuffer::ExpandBufferSize() {
|
||||||
if (buffer_.size() == max_size_) {
|
if (buffer_.size() == max_size_) {
|
||||||
RTC_LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_
|
RTC_LOG(LS_WARNING) << "PacketBuffer is already at max size (" << max_size_
|
||||||
|
@ -82,19 +82,25 @@ class PacketBuffer {
|
|||||||
PacketBuffer(Clock* clock, size_t start_buffer_size, size_t max_buffer_size);
|
PacketBuffer(Clock* clock, size_t start_buffer_size, size_t max_buffer_size);
|
||||||
~PacketBuffer();
|
~PacketBuffer();
|
||||||
|
|
||||||
InsertResult InsertPacket(std::unique_ptr<Packet> packet)
|
InsertResult InsertPacket(std::unique_ptr<Packet> packet) ABSL_MUST_USE_RESULT
|
||||||
ABSL_MUST_USE_RESULT;
|
RTC_LOCKS_EXCLUDED(crit_);
|
||||||
InsertResult InsertPadding(uint16_t seq_num) ABSL_MUST_USE_RESULT;
|
InsertResult InsertPadding(uint16_t seq_num) ABSL_MUST_USE_RESULT
|
||||||
void ClearTo(uint16_t seq_num);
|
RTC_LOCKS_EXCLUDED(crit_);
|
||||||
void Clear();
|
void ClearTo(uint16_t seq_num) RTC_LOCKS_EXCLUDED(crit_);
|
||||||
|
void Clear() RTC_LOCKS_EXCLUDED(crit_);
|
||||||
|
|
||||||
// Timestamp (not RTP timestamp) of the last received packet/keyframe packet.
|
// Timestamp (not RTP timestamp) of the last received packet/keyframe packet.
|
||||||
absl::optional<int64_t> LastReceivedPacketMs() const;
|
absl::optional<int64_t> LastReceivedPacketMs() const
|
||||||
absl::optional<int64_t> LastReceivedKeyframePacketMs() const;
|
RTC_LOCKS_EXCLUDED(crit_);
|
||||||
|
absl::optional<int64_t> LastReceivedKeyframePacketMs() const
|
||||||
|
RTC_LOCKS_EXCLUDED(crit_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Clock* const clock_;
|
Clock* const clock_;
|
||||||
|
|
||||||
|
// Clears with |crit_| taken.
|
||||||
|
void ClearInternal() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||||
|
|
||||||
// Tries to expand the buffer.
|
// Tries to expand the buffer.
|
||||||
bool ExpandBufferSize() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
bool ExpandBufferSize() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user