transcoder: Move create callback into benchmark state loop
When the google benchmark iterator loop executes
more than once, using the same callback results
in abort. This is reproducible when the transcoding
operation is of the order of 100s of milliseconds
and so the benchmark attempts to run more
iterations. To fix the issue, moved creating
callback into benchmark state loop.
Bug: 175889103
Test: ./MediaTranscoderBenchmark
Change-Id: I20a435a93ed8ccb3c8fd3d27053b20b54d9d6e26
diff --git a/media/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp b/media/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
index 9ee55e5..602bde6 100644
--- a/media/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
+++ b/media/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
@@ -113,7 +113,6 @@
std::string srcPath = kAssetDirectory + srcFileName;
std::string dstPath = kAssetDirectory + dstFileName;
- auto callbacks = std::make_shared<TranscoderCallbacks>();
media_status_t status = AMEDIA_OK;
if ((srcFd = open(srcPath.c_str(), O_RDONLY)) < 0) {
@@ -126,6 +125,7 @@
}
for (auto _ : state) {
+ auto callbacks = std::make_shared<TranscoderCallbacks>();
auto transcoder = MediaTranscoder::create(callbacks);
status = transcoder->configureSource(srcFd);