Skip to content

Commit

Permalink
Merge pull request #909 from paullouisageneau/fix-mediahandler-deadlock
Browse files Browse the repository at this point in the history
Fix possible track deadlock on media handler reset
  • Loading branch information
paullouisageneau authored Jun 13, 2023
2 parents a4bb0e2 + 00c9420 commit 378e109
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/impl/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Track::Track(weak_ptr<PeerConnection> 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) {};
}

Expand Down Expand Up @@ -201,11 +201,12 @@ bool Track::transportSend([[maybe_unused]] message_ptr message) {
}

void Track::setMediaHandler(shared_ptr<MediaHandler> handler) {
auto currentHandler = getMediaHandler();
if (currentHandler)
currentHandler->onOutgoing(nullptr);

{
std::unique_lock lock(mMutex);
if (mMediaHandler)
mMediaHandler->onOutgoing(nullptr);

mMediaHandler = handler;
}

Expand Down

0 comments on commit 378e109

Please sign in to comment.