From 00c9420350cf2229ce1d09e0438161c2c79e681e Mon Sep 17 00:00:00 2001 From: Paul-Louis Ageneau Date: Tue, 13 Jun 2023 14:23:41 +0200 Subject: [PATCH] Move resetting media handler outgoing callback outside of track lock --- src/impl/track.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/impl/track.cpp b/src/impl/track.cpp index dc31be002..0a3746fde 100644 --- a/src/impl/track.cpp +++ b/src/impl/track.cpp @@ -24,7 +24,7 @@ Track::Track(weak_ptr pc, Description::Media description) mRecvQueue(RECV_QUEUE_LIMIT, [](const message_ptr &m) { return m->size(); }) { // Discard messages by default if track is send only - if(mMediaDescription.direction() == Description::Direction::SendOnly) + if (mMediaDescription.direction() == Description::Direction::SendOnly) messageCallback = [](message_variant) {}; } @@ -201,11 +201,12 @@ bool Track::transportSend([[maybe_unused]] message_ptr message) { } void Track::setMediaHandler(shared_ptr handler) { + auto currentHandler = getMediaHandler(); + if (currentHandler) + currentHandler->onOutgoing(nullptr); + { std::unique_lock lock(mMutex); - if (mMediaHandler) - mMediaHandler->onOutgoing(nullptr); - mMediaHandler = handler; }