Merge "Camera VTS: Keep buffer ids and frame numbers consistent" into android13-tests-dev

This commit is contained in:
Treehugger Robot 2023-01-25 22:25:06 +00:00 committed by Gerrit Code Review
commit ceeef2d2bf
2 changed files with 12 additions and 9 deletions

View file

@ -1846,7 +1846,6 @@ TEST_P(CameraAidlTest, processUltraHighResolutionRequest) {
// Generate and verify 10-bit dynamic range request // Generate and verify 10-bit dynamic range request
TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) { TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
std::vector<std::string> cameraDeviceNames = getCameraDeviceNames(mProvider); std::vector<std::string> cameraDeviceNames = getCameraDeviceNames(mProvider);
int64_t bufferId = 1;
CameraMetadata settings; CameraMetadata settings;
for (const auto& name : cameraDeviceNames) { for (const auto& name : cameraDeviceNames) {
@ -1927,12 +1926,12 @@ TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
// Stream as long as needed to fill the Hal inflight queue // Stream as long as needed to fill the Hal inflight queue
std::vector<CaptureRequest> requests(halStreams[0].maxBuffers); std::vector<CaptureRequest> requests(halStreams[0].maxBuffers);
for (int32_t frameNumber = 0; frameNumber < requests.size(); frameNumber++) { for (int32_t requestId = 0; requestId < requests.size(); requestId++) {
std::shared_ptr<InFlightRequest> inflightReq = std::make_shared<InFlightRequest>( std::shared_ptr<InFlightRequest> inflightReq = std::make_shared<InFlightRequest>(
static_cast<ssize_t>(halStreams.size()), false, supportsPartialResults, static_cast<ssize_t>(halStreams.size()), false, supportsPartialResults,
partialResultCount, std::unordered_set<std::string>(), resultQueue); partialResultCount, std::unordered_set<std::string>(), resultQueue);
CaptureRequest& request = requests[frameNumber]; CaptureRequest& request = requests[requestId];
std::vector<StreamBuffer>& outputBuffers = request.outputBuffers; std::vector<StreamBuffer>& outputBuffers = request.outputBuffers;
outputBuffers.resize(halStreams.size()); outputBuffers.resize(halStreams.size());
@ -1941,6 +1940,7 @@ TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
std::vector<buffer_handle_t> graphicBuffers; std::vector<buffer_handle_t> graphicBuffers;
graphicBuffers.reserve(halStreams.size()); graphicBuffers.reserve(halStreams.size());
auto bufferId = requestId + 1; // Buffer id value 0 is not valid
for (const auto& halStream : halStreams) { for (const auto& halStream : halStreams) {
buffer_handle_t buffer_handle; buffer_handle_t buffer_handle;
if (useHalBufManager) { if (useHalBufManager) {
@ -1959,14 +1959,13 @@ TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
outputBuffers[k] = {halStream.id, bufferId, outputBuffers[k] = {halStream.id, bufferId,
android::makeToAidl(buffer_handle), BufferStatus::OK, NativeHandle(), android::makeToAidl(buffer_handle), BufferStatus::OK, NativeHandle(),
NativeHandle()}; NativeHandle()};
bufferId++;
} }
k++; k++;
} }
request.inputBuffer = { request.inputBuffer = {
-1, 0, NativeHandle(), BufferStatus::ERROR, NativeHandle(), NativeHandle()}; -1, 0, NativeHandle(), BufferStatus::ERROR, NativeHandle(), NativeHandle()};
request.frameNumber = frameNumber; request.frameNumber = bufferId;
request.fmqSettingsSize = 0; request.fmqSettingsSize = 0;
request.settings = settings; request.settings = settings;
request.inputWidth = 0; request.inputWidth = 0;
@ -1974,7 +1973,7 @@ TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
{ {
std::unique_lock<std::mutex> l(mLock); std::unique_lock<std::mutex> l(mLock);
mInflightMap[frameNumber] = inflightReq; mInflightMap[bufferId] = inflightReq;
} }
} }
@ -1990,7 +1989,10 @@ TEST_P(CameraAidlTest, process10BitDynamicRangeRequest) {
std::vector<int32_t> {halStreams[0].id}); std::vector<int32_t> {halStreams[0].id});
ASSERT_TRUE(returnStatus.isOk()); ASSERT_TRUE(returnStatus.isOk());
for (int32_t frameNumber = 0; frameNumber < requests.size(); frameNumber++) { // We are keeping frame numbers and buffer ids consistent. Buffer id value of 0
// is used to indicate a buffer that is not present/available so buffer ids as well
// as frame numbers begin with 1.
for (int32_t frameNumber = 1; frameNumber <= requests.size(); frameNumber++) {
const auto& inflightReq = mInflightMap[frameNumber]; const auto& inflightReq = mInflightMap[frameNumber];
std::unique_lock<std::mutex> l(mLock); std::unique_lock<std::mutex> l(mLock);
while (!inflightReq->errorCodeValid && while (!inflightReq->errorCodeValid &&

View file

@ -429,10 +429,11 @@ bool DeviceCb::processCaptureResultLocked(
CameraAidlTest::InFlightRequest::StreamBufferAndTimestamp streamBufferAndTimestamp; CameraAidlTest::InFlightRequest::StreamBufferAndTimestamp streamBufferAndTimestamp;
auto outstandingBuffers = mUseHalBufManager ? mOutstandingBufferIds : auto outstandingBuffers = mUseHalBufManager ? mOutstandingBufferIds :
request->mOutstandingBufferIds; request->mOutstandingBufferIds;
auto bufferId = mUseHalBufManager ? buffer.bufferId : results.frameNumber;
auto outputBuffer = outstandingBuffers.empty() ? ::android::makeFromAidl(buffer.buffer) : auto outputBuffer = outstandingBuffers.empty() ? ::android::makeFromAidl(buffer.buffer) :
outstandingBuffers[buffer.streamId][buffer.bufferId]; outstandingBuffers[buffer.streamId][bufferId];
streamBufferAndTimestamp.buffer = {buffer.streamId, streamBufferAndTimestamp.buffer = {buffer.streamId,
buffer.bufferId, bufferId,
outputBuffer, outputBuffer,
buffer.status, buffer.status,
::android::makeFromAidl(buffer.acquireFence), ::android::makeFromAidl(buffer.acquireFence),