From feb26e474180b175ae4e0f8a594ef865055c2a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Mon, 6 Dec 2021 19:06:10 -0500 Subject: [PATCH] sink: avoid deadock during frame size change Lock was: frame #3: 0x00000074f22d0b74 libc++_shared.so`std::__ndk1::mutex::lock() frame #5: 0x00000074f2f91b10 libring.so`std::__ndk1::lock_guard::lock_guard() frame #6: 0x00000074f3156d3c libring.so`jami::video::SinkClient::registerTarget() at sinkclient.h:80:37 frame #7: 0x00000074f3154f74 libring.so`DRing::registerSinkTarget(sinkId="2920319278288091") at videomanager.cpp:527:15 frame #8: 0x00000074f2f1dccc libring.so`Java_net_jami_daemon_JamiServiceJNI_unregisterVideoCallback() frame #45: 0x00000074f2f3491c libring.so`SwigDirector_VideoCallback::decodingStopped() frame #48: 0x00000074f319a480 libring.so`void jami::emitSignal() at ring_signal.h:66:13 frame #49: 0x00000074f31993ec libring.so`jami::video::SinkClient::setFrameSize(this=0x00000074c298caa0, width=0, height=0) at sinkclient.cpp:482:9 frame #50: 0x00000074f3199f74 libring.so`jami::video::SinkClient::update() at sinkclient.cpp:427:13 frame #51: 0x00000074f316c69c libring.so`jami::Observable >::notify() at observer.h:138:23 frame #52: 0x00000074f31a7094 libring.so`jami::video::VideoGenerator::publishFrame() at video_base.cpp:56:5 Change-Id: I1824bad767543a3e789e13af1489613a044a7473 --- src/media/video/sinkclient.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/media/video/sinkclient.cpp b/src/media/video/sinkclient.cpp index 16b0ec343c0..1126eabe291 100644 --- a/src/media/video/sinkclient.cpp +++ b/src/media/video/sinkclient.cpp @@ -353,7 +353,7 @@ SinkClient::update(Observable>* /*obs*/, } #endif - std::lock_guard lock(mtx_); + std::unique_lock lock(mtx_); if (avTarget_.push) { auto outFrame = std::make_unique(); outFrame->copyFrom(*std::static_pointer_cast(frame_p)); @@ -424,6 +424,7 @@ SinkClient::update(Observable>* /*obs*/, } if (frame->height() != height_ || frame->width() != width_) { + lock.unlock(); setFrameSize(0, 0); setFrameSize(frame->width(), frame->height()); return;