From d84bd4f38dd07c23dccbc8671a9101d032a6e053 Mon Sep 17 00:00:00 2001 From: Panagiotis Apostolou Date: Sun, 27 Oct 2024 12:47:40 +0200 Subject: [PATCH] CombineAndWriteToFile() now takes a file output as an argument --- framework/encode/capture_manager.cpp | 23 +++-------------------- framework/encode/capture_manager.h | 9 ++++----- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/framework/encode/capture_manager.cpp b/framework/encode/capture_manager.cpp index fe06750cc..3296c49a5 100644 --- a/framework/encode/capture_manager.cpp +++ b/framework/encode/capture_manager.cpp @@ -1278,7 +1278,7 @@ void CommonCaptureManager::DeactivateTrimming(std::shared_lock& c } } -void CommonCaptureManager::WriteFileHeader() +void CommonCaptureManager::WriteFileHeader(util::FileOutputStream* file_stream) { std::vector option_list; @@ -1291,7 +1291,8 @@ void CommonCaptureManager::WriteFileHeader() file_header.num_options = static_cast(option_list.size()); CombineAndWriteToFile({ { &file_header, sizeof(file_header) }, - { option_list.data(), option_list.size() * sizeof(format::FileOptionPair) } }); + { option_list.data(), option_list.size() * sizeof(format::FileOptionPair) } }, + file_stream); // File header does not count as a block assert(block_index_ > 0); @@ -1301,24 +1302,6 @@ void CommonCaptureManager::WriteFileHeader() thread_data->block_index_ = block_index_.load(); } -void CommonCaptureManager::WriteFileHeader(util::FileOutputStream* file_stream) -{ - assert(file_stream != nullptr); - - std::vector option_list; - - BuildOptionList(file_options_, &option_list); - - format::FileHeader file_header; - file_header.fourcc = GFXRECON_FOURCC; - file_header.major_version = 0; - file_header.minor_version = 0; - file_header.num_options = static_cast(option_list.size()); - - WriteToFile(&file_header, sizeof(file_header), file_stream); - WriteToFile(option_list.data(), option_list.size() * sizeof(format::FileOptionPair), file_stream); -} - void CommonCaptureManager::BuildOptionList(const format::EnabledOptions& enabled_options, std::vector* option_list) { diff --git a/framework/encode/capture_manager.h b/framework/encode/capture_manager.h index b54f4e59e..01e1d158a 100644 --- a/framework/encode/capture_manager.h +++ b/framework/encode/capture_manager.h @@ -285,9 +285,7 @@ class CommonCaptureManager void ActivateTrimming(std::shared_lock& current_lock); void DeactivateTrimming(std::shared_lock& current_lock); - void WriteFileHeader(); - - void WriteFileHeader(util::FileOutputStream* file_stream); + void WriteFileHeader(util::FileOutputStream* file_stream = nullptr); void BuildOptionList(const format::EnabledOptions& enabled_options, std::vector* option_list); @@ -307,7 +305,8 @@ class CommonCaptureManager void WriteToFile(const void* data, size_t size, util::FileOutputStream* file_stream = nullptr); template - void CombineAndWriteToFile(const std::pair (&buffers)[N]) + void CombineAndWriteToFile(const std::pair (&buffers)[N], + util::FileOutputStream* file_stream = nullptr) { static_assert(N != 1, "Use WriteToFile(void*, size) when writing a single buffer."); @@ -321,7 +320,7 @@ class CommonCaptureManager scratch_buffer.insert(scratch_buffer.end(), data, data + size); } - WriteToFile(scratch_buffer.data(), scratch_buffer.size()); + WriteToFile(scratch_buffer.data(), scratch_buffer.size(), file_stream); } void IncrementBlockIndex(uint64_t blocks)