Merge "OMX VTS: free graphics buffers at the end of test"
This commit is contained in:
commit
7e734892c9
4 changed files with 57 additions and 35 deletions
|
@ -215,6 +215,7 @@ void allocateGraphicBuffers(sp<IOmxNode> omxNode, OMX_U32 portIndex,
|
|||
ASSERT_NE(handle, nullptr);
|
||||
|
||||
*nStride = static_cast<int32_t>(stride);
|
||||
buffer->handle = handle;
|
||||
buffer->omxBuffer.nativeHandle = handle;
|
||||
buffer->omxBuffer.attr.anwBuffer.width = nFrameWidth;
|
||||
buffer->omxBuffer.attr.anwBuffer.height = nFrameHeight;
|
||||
|
@ -335,6 +336,18 @@ void allocatePortBuffers(sp<IOmxNode> omxNode,
|
|||
}
|
||||
}
|
||||
|
||||
// free buffers needed on a component port
|
||||
void freePortBuffers(android::Vector<BufferInfo>* buffArray, PortMode portMode, bool allocGrap) {
|
||||
for (size_t i = 0; i < buffArray->size(); i++) {
|
||||
if (portMode == PortMode::PRESET_ANW_BUFFER ||
|
||||
(allocGrap && portMode == PortMode::DYNAMIC_ANW_BUFFER)) {
|
||||
android::GraphicBufferAllocator& allocator = android::GraphicBufferAllocator::get();
|
||||
android::status_t error = allocator.free((*buffArray)[i].handle);
|
||||
ASSERT_EQ(error, android::NO_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// State Transition : Loaded -> Idle
|
||||
// Note: This function does not make any background checks for this transition.
|
||||
// The callee holds the reponsibility to ensure the legality of the transition.
|
||||
|
@ -399,11 +412,15 @@ void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
|||
// The callee holds the reponsibility to ensure the legality of the transition.
|
||||
void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
||||
android::Vector<BufferInfo>* iBuffer,
|
||||
android::Vector<BufferInfo>* oBuffer,
|
||||
OMX_U32 kPortIndexInput,
|
||||
OMX_U32 kPortIndexOutput) {
|
||||
android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
|
||||
OMX_U32 kPortIndexOutput, PortMode* portMode, bool allocGrap) {
|
||||
android::hardware::media::omx::V1_0::Status status;
|
||||
Message msg;
|
||||
PortMode defaultPortMode[2], *pm;
|
||||
|
||||
defaultPortMode[0] = PortMode::PRESET_BYTE_BUFFER;
|
||||
defaultPortMode[1] = PortMode::PRESET_BYTE_BUFFER;
|
||||
pm = portMode ? portMode : defaultPortMode;
|
||||
|
||||
// set state to Loaded
|
||||
status = omxNode->sendCommand(toRawCommandType(OMX_CommandStateSet),
|
||||
|
@ -446,6 +463,8 @@ void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
|||
ASSERT_EQ(msg.data.eventData.data1, OMX_CommandStateSet);
|
||||
ASSERT_EQ(msg.data.eventData.data2, OMX_StateLoaded);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(freePortBuffers(iBuffer, pm[0], allocGrap));
|
||||
ASSERT_NO_FATAL_FAILURE(freePortBuffers(oBuffer, pm[1], allocGrap));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ inline uint32_t toRawCommandType(OMX_COMMANDTYPE l) {
|
|||
struct BufferInfo {
|
||||
uint32_t id;
|
||||
bufferOwner owner;
|
||||
buffer_handle_t handle;
|
||||
android::hardware::media::omx::V1_0::CodecBuffer omxBuffer;
|
||||
::android::sp<IMemory> mMemory;
|
||||
int32_t slot;
|
||||
|
@ -329,6 +330,9 @@ void allocatePortBuffers(sp<IOmxNode> omxNode,
|
|||
PortMode portMode = PortMode::PRESET_BYTE_BUFFER,
|
||||
bool allocGrap = false);
|
||||
|
||||
void freePortBuffers(android::Vector<BufferInfo>* buffArray, PortMode portMode,
|
||||
bool allocGrap = false);
|
||||
|
||||
void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
||||
android::Vector<BufferInfo>* iBuffer,
|
||||
android::Vector<BufferInfo>* oBuffer,
|
||||
|
@ -338,8 +342,9 @@ void changeStateLoadedtoIdle(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
|||
|
||||
void changeStateIdletoLoaded(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
||||
android::Vector<BufferInfo>* iBuffer,
|
||||
android::Vector<BufferInfo>* oBuffer,
|
||||
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput);
|
||||
android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
|
||||
OMX_U32 kPortIndexOutput, PortMode* portMode = nullptr,
|
||||
bool allocGrap = false);
|
||||
|
||||
void changeStateIdletoExecute(sp<IOmxNode> omxNode, sp<CodecObserver> observer);
|
||||
|
||||
|
|
|
@ -451,6 +451,7 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
|
|||
status,
|
||||
android::hardware::media::omx::V1_0::Status::TIMED_OUT);
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(freePortBuffers(oBuffer, oPortMode, true));
|
||||
ASSERT_NO_FATAL_FAILURE(allocatePortBuffers(
|
||||
omxNode, oBuffer, kPortIndexOutput, oPortMode, true));
|
||||
status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT,
|
||||
|
@ -853,9 +854,9 @@ TEST_P(VideoDecHidlTest, DecodeTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
// Test for adaptive playback support
|
||||
|
@ -1001,9 +1002,9 @@ TEST_P(VideoDecHidlTest, AdaptivePlaybackTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
// end of sequence test
|
||||
|
@ -1067,9 +1068,9 @@ TEST_P(VideoDecHidlTest, EOSTest_M) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
// end of sequence test
|
||||
|
@ -1188,9 +1189,9 @@ TEST_P(VideoDecHidlTest, ThumbnailTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
// end of sequence test
|
||||
|
@ -1295,9 +1296,9 @@ TEST_P(VideoDecHidlTest, SimpleEOSTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
// test input/output port flush
|
||||
|
@ -1414,9 +1415,9 @@ TEST_P(VideoDecHidlTest, FlushTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode,
|
||||
true));
|
||||
}
|
||||
|
||||
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(VideoDecHidlTest);
|
||||
|
|
|
@ -1057,9 +1057,9 @@ TEST_P(VideoEncHidlTest, BufferSourceCallBacks) {
|
|||
ASSERT_NO_FATAL_FAILURE(changeStateExecutetoIdle(
|
||||
omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(
|
||||
omxNode, observer, &buffersource->iBuffer, &buffersource->oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &buffersource->iBuffer,
|
||||
&buffersource->oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput, portMode));
|
||||
// test for callbacks
|
||||
EXPECT_EQ(buffersource->callback, 31);
|
||||
}
|
||||
|
@ -1174,9 +1174,8 @@ TEST_P(VideoEncHidlTest, EncodeTest) {
|
|||
ASSERT_NO_FATAL_FAILURE(
|
||||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode));
|
||||
}
|
||||
|
||||
// test raw stream encode (input is ANW buffers)
|
||||
|
@ -1337,9 +1336,8 @@ TEST_P(VideoEncHidlTest, EncodeTestBufferMetaModes) {
|
|||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers);
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode));
|
||||
|
||||
returnval = producer->disconnect(
|
||||
NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API);
|
||||
|
@ -1452,9 +1450,8 @@ TEST_P(VideoEncHidlTest, EncodeTestEOS) {
|
|||
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer));
|
||||
EXPECT_EQ(portDef.nBufferCountActual, listener->freeBuffers);
|
||||
// set state to executing
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer,
|
||||
&oBuffer, kPortIndexInput,
|
||||
kPortIndexOutput));
|
||||
ASSERT_NO_FATAL_FAILURE(changeStateIdletoLoaded(omxNode, observer, &iBuffer, &oBuffer,
|
||||
kPortIndexInput, kPortIndexOutput, portMode));
|
||||
|
||||
returnval = producer->disconnect(
|
||||
NATIVE_WINDOW_API_CPU, IGraphicBufferProducer::DisconnectMode::API);
|
||||
|
|
Loading…
Reference in a new issue