Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CombineAndWriteToFile() now takes a file output as an argument #1838

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions framework/encode/capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ void CommonCaptureManager::DeactivateTrimming(std::shared_lock<ApiCallMutexT>& c
}
}

void CommonCaptureManager::WriteFileHeader()
void CommonCaptureManager::WriteFileHeader(util::FileOutputStream* file_stream)
{
std::vector<format::FileOptionPair> option_list;

Expand All @@ -1291,7 +1291,8 @@ void CommonCaptureManager::WriteFileHeader()
file_header.num_options = static_cast<uint32_t>(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);
Expand All @@ -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<format::FileOptionPair> 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<uint32_t>(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<format::FileOptionPair>* option_list)
{
Expand Down
9 changes: 4 additions & 5 deletions framework/encode/capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,7 @@ class CommonCaptureManager
void ActivateTrimming(std::shared_lock<ApiCallMutexT>& current_lock);
void DeactivateTrimming(std::shared_lock<ApiCallMutexT>& 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<format::FileOptionPair>* option_list);
Expand All @@ -307,7 +305,8 @@ class CommonCaptureManager
void WriteToFile(const void* data, size_t size, util::FileOutputStream* file_stream = nullptr);

template <size_t N>
void CombineAndWriteToFile(const std::pair<const void*, size_t> (&buffers)[N])
void CombineAndWriteToFile(const std::pair<const void*, size_t> (&buffers)[N],
util::FileOutputStream* file_stream = nullptr)
{
static_assert(N != 1, "Use WriteToFile(void*, size) when writing a single buffer.");

Expand All @@ -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)
Expand Down
Loading