mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-31 03:19:29 +00:00
Unlock the RtcpHandler lock before calling the handler
This commit is contained in:
@ -64,7 +64,9 @@ bool Track::send(message_variant data) {
|
|||||||
|
|
||||||
std::shared_lock lock(mRtcpHandlerMutex);
|
std::shared_lock lock(mRtcpHandlerMutex);
|
||||||
if (mRtcpHandler) {
|
if (mRtcpHandler) {
|
||||||
message = mRtcpHandler->outgoing(message);
|
auto copy = mRtcpHandler;
|
||||||
|
lock.unlock();
|
||||||
|
message = copy->outgoing(message);
|
||||||
if (!message)
|
if (!message)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -125,7 +127,9 @@ void Track::incoming(message_ptr message) {
|
|||||||
|
|
||||||
std::shared_lock lock(mRtcpHandlerMutex);
|
std::shared_lock lock(mRtcpHandlerMutex);
|
||||||
if (mRtcpHandler) {
|
if (mRtcpHandler) {
|
||||||
message = mRtcpHandler->incoming(message);
|
auto copy = mRtcpHandler;
|
||||||
|
lock.unlock();
|
||||||
|
message = copy->incoming(message);
|
||||||
if (!message)
|
if (!message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -163,14 +167,20 @@ bool Track::outgoing([[maybe_unused]] message_ptr message) {
|
|||||||
void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) {
|
void Track::setRtcpHandler(std::shared_ptr<RtcpHandler> handler) {
|
||||||
std::unique_lock lock(mRtcpHandlerMutex);
|
std::unique_lock lock(mRtcpHandlerMutex);
|
||||||
mRtcpHandler = std::move(handler);
|
mRtcpHandler = std::move(handler);
|
||||||
if (mRtcpHandler)
|
if (mRtcpHandler) {
|
||||||
mRtcpHandler->onOutgoing(std::bind(&Track::outgoing, this, std::placeholders::_1));
|
auto copy = mRtcpHandler;
|
||||||
|
lock.unlock();
|
||||||
|
copy->onOutgoing(std::bind(&Track::outgoing, this, std::placeholders::_1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Track::requestKeyframe() {
|
bool Track::requestKeyframe() {
|
||||||
std::shared_lock lock(mRtcpHandlerMutex);
|
std::shared_lock lock(mRtcpHandlerMutex);
|
||||||
if (mRtcpHandler)
|
if (mRtcpHandler) {
|
||||||
return mRtcpHandler->requestKeyframe();
|
auto copy = mRtcpHandler;
|
||||||
|
lock.unlock();
|
||||||
|
return copy->requestKeyframe();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user