Skip to content

Commit 10f3ad7

Browse files
committed
Block index was being increased more than it should for trimmed captures
CaptureFileOutputStream::Write should not handle the block index increment as it leads to miscalculations during trimmed captures.
1 parent c99f3ad commit 10f3ad7

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

framework/encode/capture_manager.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,13 @@ void CommonCaptureManager::WriteCreateHeapAllocationCmd(format::ApiFamilyId api_
15051505
void CommonCaptureManager::WriteToFile(const void* data, size_t size, util::FileOutputStream* file_stream)
15061506
{
15071507
file_stream ? file_stream->Write(data, size) : file_stream_->Write(data, size);
1508+
1509+
// Increment block index
1510+
auto thread_data = GetThreadData();
1511+
assert(thread_data != nullptr);
1512+
1513+
++block_index_;
1514+
thread_data->block_index_ = block_index_.load();
15081515
}
15091516

15101517
void CommonCaptureManager::AtExit()
@@ -1667,8 +1674,6 @@ bool CaptureFileOutputStream::Write(const void* data, size_t len)
16671674
}
16681675
}
16691676

1670-
capture_manager_->IncrementBlockIndex(1);
1671-
16721677
return ret;
16731678
}
16741679

framework/encode/capture_manager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,13 @@ class CommonCaptureManager
294294
{
295295
file_stream ? file_stream->CombineAndWrite<N>(buffers, GetThreadData()->GetScratchBuffer())
296296
: file_stream_->CombineAndWrite<N>(buffers, GetThreadData()->GetScratchBuffer());
297+
298+
// Increment block index
299+
auto thread_data = GetThreadData();
300+
assert(thread_data != nullptr);
301+
302+
++block_index_;
303+
thread_data->block_index_ = block_index_.load();
297304
}
298305

299306
void IncrementBlockIndex(uint64_t blocks)

0 commit comments

Comments
 (0)