Skip to content

Commit

Permalink
sink: avoid deadock during frame size change
Browse files Browse the repository at this point in the history
Lock was:
    frame #3: 0x00000074f22d0b74 libc++_shared.so`std::__ndk1::mutex::lock()
    frame #5: 0x00000074f2f91b10 libring.so`std::__ndk1::lock_guard<std::__ndk1::mutex>::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<DRing::VideoSignal::DecodingStopped>() 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<std::__ndk1::shared_ptr<DRing::MediaFrame> >::notify() at observer.h:138:23
    frame #52: 0x00000074f31a7094 libring.so`jami::video::VideoGenerator::publishFrame() at video_base.cpp:56:5


Change-Id: I1824bad767543a3e789e13af1489613a044a7473
  • Loading branch information
aberaud committed Dec 7, 2021
1 parent 9c74ea2 commit feb26e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/media/video/sinkclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
}
#endif

std::lock_guard<std::mutex> lock(mtx_);
std::unique_lock<std::mutex> lock(mtx_);
if (avTarget_.push) {
auto outFrame = std::make_unique<VideoFrame>();
outFrame->copyFrom(*std::static_pointer_cast<VideoFrame>(frame_p));
Expand Down Expand Up @@ -424,6 +424,7 @@ SinkClient::update(Observable<std::shared_ptr<MediaFrame>>* /*obs*/,
}

if (frame->height() != height_ || frame->width() != width_) {
lock.unlock();
setFrameSize(0, 0);
setFrameSize(frame->width(), frame->height());
return;
Expand Down

0 comments on commit feb26e4

Please sign in to comment.