8000 fix "D:\a_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp(164): unl… · liliBestCoder/flutter-webrtc@9d0e266 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d0e266

Browse files
author
quxiaojun
committed
fix "D:\a_work\1\s\src\vctools\crt\github\stl\src\mutex.cpp(164): unlock of unowned mutex" error when call "captureFrame()" func on windows
1 parent a7589dd commit 9d0e266

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

common/cpp/include/flutter_frame_capturer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class FlutterFrameCapturer
2727
std::string path_;
2828
std::mutex mutex_;
2929
scoped_refptr<RTCVideoFrame> frame_;
30+
volatile bool catch_frame_;
3031

3132
bool SaveFrame();
3233
};

common/cpp/src/flutter_frame_capturer.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ void FlutterFrameCapturer::OnFrame(scoped_refptr<RTCVideoFrame> frame) {
2121
}
2222

2323
frame_ = frame.get()->Copy();
24-
mutex_.unlock();
24+
catch_frame_ = true;
2525
}
2626

2727
void FlutterFrameCapturer::CaptureFrame(
2828
std::unique_ptr<MethodResultProxy> result) {
2929
mutex_.lock();
30+
// Here init catch_frame_ flag
31+
catch_frame_ = false;
32+
3033
track_->AddRenderer(this);
34+
// Here waiting for catch_frame_ is set to true
35+
while(!catch_frame_){}
3136
// Here the OnFrame method has to unlock the mutex
37+
mutex_.unlock();
38+
3239
mutex_.lock();
3340
track_->RemoveRenderer(this);
3441

0 commit comments

Comments
 (0)
0