From 7ab1554948eb842962d458252de7054e8e8a66ff Mon Sep 17 00:00:00 2001 From: Kingtous Date: Fri, 17 Feb 2023 14:34:38 +0800 Subject: [PATCH] fix: add copy on windows --- windows/texture_rgba.cpp | 8 ++++---- windows/texture_rgba.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/windows/texture_rgba.cpp b/windows/texture_rgba.cpp index a58111b..6ca6889 100644 --- a/windows/texture_rgba.cpp +++ b/windows/texture_rgba.cpp @@ -19,10 +19,10 @@ TextureRgba::~TextureRgba() void TextureRgba::MarkVideoFrameAvailable(const std::vector& buffer, size_t width, size_t height) { const std::lock_guard lock(mutex_); - // FIXME: maybe without copy, it's easily crash with corrupt memory access. - // buffer_tmp_.resize(buffer.size()); - // std::copy(buffer.begin(), buffer.end(), buffer_tmp_.begin()); - flutter_pixel_buffer_.buffer = &buffer[0]; + // FIXME: remove copy. + buffer_tmp_.resize(buffer.size()); + std::copy(buffer.begin(), buffer.end(), buffer_tmp_.begin()); + flutter_pixel_buffer_.buffer = &buffer_tmp_[0]; flutter_pixel_buffer_.width = width; flutter_pixel_buffer_.height = height; texture_registrar_->MarkTextureFrameAvailable(texture_id_); diff --git a/windows/texture_rgba.h b/windows/texture_rgba.h index 6b9fbdc..a235514 100644 --- a/windows/texture_rgba.h +++ b/windows/texture_rgba.h @@ -20,6 +20,6 @@ private: std::unique_ptr texture_ = nullptr; int64_t texture_id_; mutable std::mutex mutex_; - // std::vector buffer_tmp_; + std::vector buffer_tmp_; };