From d26b751273dc1af8ba0de11a0347f47a55f8b27f Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 12 Sep 2020 20:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhls=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8=E6=B5=81=E9=87=8F=E7=BB=9F=E8=AE=A1=E4=B8=8D=E5=87=86?= =?UTF-8?q?=E7=A1=AE=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Record/HlsMediaSource.cpp | 5 +++-- src/Record/HlsMediaSource.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Record/HlsMediaSource.cpp b/src/Record/HlsMediaSource.cpp index 4133a206..7888eddf 100644 --- a/src/Record/HlsMediaSource.cpp +++ b/src/Record/HlsMediaSource.cpp @@ -48,8 +48,9 @@ HlsCookieData::~HlsCookieData() { << ")断开,耗时(s):" << duration; GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); - if (_bytes > iFlowThreshold * 1024) { - NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, _bytes, duration, true, static_cast(*_sock_info)); + uint64_t bytes = _bytes.load(); + if (bytes > iFlowThreshold * 1024) { + NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, bytes, duration, true, static_cast(*_sock_info)); } } } diff --git a/src/Record/HlsMediaSource.h b/src/Record/HlsMediaSource.h index 1cd99c9b..ddf26721 100644 --- a/src/Record/HlsMediaSource.h +++ b/src/Record/HlsMediaSource.h @@ -103,10 +103,12 @@ public: HlsCookieData(const MediaInfo &info, const std::shared_ptr &sock_info); ~HlsCookieData(); void addByteUsage(uint64_t bytes); + private: void addReaderCount(); + private: - uint64_t _bytes = 0; + atomic _bytes {0}; MediaInfo _info; std::shared_ptr _added; weak_ptr _src;