mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-24 14:55:37 +00:00
Merge pull request #100 from PALConverteo/fix/wgc-capture-thread-safety
Fix corrupted MP4 recordings on Windows
This commit is contained in:
@@ -124,6 +124,7 @@ bool MFEncoder::initialize(const std::wstring& outputPath, int width, int height
|
||||
}
|
||||
|
||||
bool MFEncoder::writeFrame(ID3D11Texture2D* texture, int64_t timestampHns) {
|
||||
std::lock_guard<std::mutex> lock(writeMutex_);
|
||||
if (!initialized_ || !sinkWriter_) return false;
|
||||
|
||||
context_->CopyResource(stagingTexture_.Get(), texture);
|
||||
@@ -190,6 +191,7 @@ bool MFEncoder::writeFrame(ID3D11Texture2D* texture, int64_t timestampHns) {
|
||||
}
|
||||
|
||||
bool MFEncoder::finalize() {
|
||||
std::lock_guard<std::mutex> lock(writeMutex_);
|
||||
if (!initialized_) return false;
|
||||
initialized_ = false;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <wrl/client.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
@@ -32,4 +33,5 @@ private:
|
||||
int height_ = 0;
|
||||
int fps_ = 60;
|
||||
bool initialized_ = false;
|
||||
std::mutex writeMutex_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user