From a8fc623f5a8070b7021d1e524a43c53f19007449 Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Wed, 28 Jun 2023 08:02:09 +0300 Subject: [PATCH] multiplex: Improve thread safety in reception_flow pull_frame --- src/reception_flow.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/reception_flow.cc b/src/reception_flow.cc index b80d7e1..73dacde 100644 --- a/src/reception_flow.cc +++ b/src/reception_flow.cc @@ -243,18 +243,16 @@ uvgrtp::frame::rtp_frame* uvgrtp::reception_flow::pull_frame(std::shared_ptrheader.ssrc == remote_ssrc.get()->load()) { - frames_.erase(frames_.begin()); - found_frame = true; + if (!frames_.empty()) { + frame = frames_.front(); + if (frame->header.ssrc == remote_ssrc.get()->load()) { + frames_.erase(frames_.begin()); + } } frames_mtx_.unlock(); - if (found_frame) { - return frame; - } - return nullptr; + return frame; } uvgrtp::frame::rtp_frame* uvgrtp::reception_flow::pull_frame(ssize_t timeout_ms, std::shared_ptr> remote_ssrc)