diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp index 336cab4832..6790ebfcd4 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioDecTest.cpp @@ -588,12 +588,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, AudioDecHidlTest::standardComp comp) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { EXPECT_EQ(msg.type, Message::Type::EVENT); packedArgs audioArgs = {eEncoding, comp}; @@ -613,8 +613,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -654,11 +654,12 @@ void decodeNFrames(sp omxNode, sp observer, frameID++; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); // Port Reconfiguration if (status == android::hardware::media::omx::V1_0::Status::OK && @@ -688,18 +689,16 @@ void decodeNFrames(sp omxNode, sp observer, (*Info)[frameID].bytesCount, flags, (*Info)[frameID].timestamp); frameID++; - stall = false; - } else - stall = true; + iQueued = true; + } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; @@ -1149,9 +1148,8 @@ TEST_F(AudioDecHidlTest, FlushTest) { decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, eEncoding, kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, nFrames, compName, false); - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // Seek to next key frame and start decoding till the end @@ -1172,9 +1170,8 @@ TEST_F(AudioDecHidlTest, FlushTest) { kPortIndexInput, kPortIndexOutput, eleStream, &Info, index, Info.size() - index, compName, false); } - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // set state to idle diff --git a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp index ae79e82621..038830dc2e 100644 --- a/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp +++ b/media/omx/1.0/vts/functional/audio/VtsHalMediaOmxV1_0TargetAudioEncTest.cpp @@ -342,12 +342,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, android::Vector* oBuffer) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); EXPECT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); // status == TIMED_OUT, it could be due to process time being large @@ -362,8 +362,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -400,11 +400,12 @@ void encodeNFrames(sp omxNode, sp observer, nFrames--; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) ASSERT_TRUE(false); @@ -425,19 +426,17 @@ void encodeNFrames(sp omxNode, sp observer, timestamp); timestamp += timestampIncr; nFrames--; - stall = false; - } else - stall = true; + iQueued = true; + } // Dispatch output buffer if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp index 1863972e14..a890c4f487 100755 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.cpp @@ -532,7 +532,7 @@ void testEOS(sp omxNode, sp observer, } } - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_PE; while (timeOut--) { // Dispatch all client owned output buffers to recover remaining frames while (1) { @@ -541,15 +541,15 @@ void testEOS(sp omxNode, sp observer, // if dispatch is successful, perhaps there is a latency // in the component. Dont be in a haste to leave. reset timeout // counter - timeOut = TIMEOUT_COUNTER; + timeOut = TIMEOUT_COUNTER_PE; } else { break; } } Message msg; - status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + status = observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_PE, iBuffer, + oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { if (msg.data.eventData.event == OMX_EventPortSettingsChanged) { if (fptr) { diff --git a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h index 95e32fa18f..802f4d6075 100644 --- a/media/omx/1.0/vts/functional/common/media_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/common/media_hidl_test_common.h @@ -33,8 +33,21 @@ #include #include +/* TIME OUTS (Wait time in dequeueMessage()) */ + +/* As component is switching states (loaded<->idle<->execute), dequeueMessage() + * expects the events to be received within this duration */ #define DEFAULT_TIMEOUT 100000 -#define TIMEOUT_COUNTER (10000000 / DEFAULT_TIMEOUT) +/* Time interval between successive Input/Output enqueues */ +#define DEFAULT_TIMEOUT_Q 2000 +/* While the component is amidst a process call, asynchronous commands like + * flush, change states can get delayed (at max by process call time). Instead + * of waiting on DEFAULT_TIMEOUT, we give an additional leeway. */ +#define DEFAULT_TIMEOUT_PE 500000 + +/* Breakout Timeout :: 5 sec*/ +#define TIMEOUT_COUNTER_Q (5000000 / DEFAULT_TIMEOUT_Q) +#define TIMEOUT_COUNTER_PE (5000000 / DEFAULT_TIMEOUT_PE) /* * Random Index used for monkey testing while get/set parameters @@ -310,7 +323,8 @@ void dispatchInputBuffer(sp omxNode, void flushPorts(sp omxNode, sp observer, android::Vector* iBuffer, android::Vector* oBuffer, OMX_U32 kPortIndexInput, - OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT); + OMX_U32 kPortIndexOutput, + int64_t timeoutUs = DEFAULT_TIMEOUT_PE); typedef void (*portreconfig)(sp omxNode, sp observer, android::Vector* iBuffer, diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp index 12b1355f4e..a9c29c736a 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoDecTest.cpp @@ -604,12 +604,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, PortMode oPortMode) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { EXPECT_EQ(msg.type, Message::Type::EVENT); portReconfiguration(omxNode, observer, iBuffer, oBuffer, @@ -628,8 +628,8 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); + timeOut = TIMEOUT_COUNTER_Q; } - timeOut--; } } @@ -669,11 +669,12 @@ void decodeNFrames(sp omxNode, sp observer, frameID++; } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); // Port Reconfiguration if (status == android::hardware::media::omx::V1_0::Status::OK && @@ -702,18 +703,16 @@ void decodeNFrames(sp omxNode, sp observer, (*Info)[frameID].bytesCount, flags, (*Info)[frameID].timestamp); frameID++; - stall = false; - } else - stall = true; + iQueued = true; + } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index, oPortMode); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; @@ -1165,9 +1164,8 @@ TEST_F(VideoDecHidlTest, FlushTest) { decodeNFrames(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, kPortIndexOutput, eleStream, &Info, 0, nFrames, portMode[1], false); - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // Seek to next key frame and start decoding till the end @@ -1188,9 +1186,8 @@ TEST_F(VideoDecHidlTest, FlushTest) { kPortIndexOutput, eleStream, &Info, index, Info.size() - index, portMode[1], false); } - // Note: Assumes 200 ms is enough to end any decode call that started flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput, - kPortIndexOutput, 200000); + kPortIndexOutput); framesReceived = 0; // set state to idle diff --git a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp index a1ed21ae83..f4a4e9bf81 100644 --- a/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp +++ b/media/omx/1.0/vts/functional/video/VtsHalMediaOmxV1_0TargetVideoEncTest.cpp @@ -612,12 +612,12 @@ void waitOnInputConsumption(sp omxNode, sp observer, sp listener = nullptr) { android::hardware::media::omx::V1_0::Status status; Message msg; - int timeOut = TIMEOUT_COUNTER; + int timeOut = TIMEOUT_COUNTER_Q; while (timeOut--) { size_t i = 0; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); EXPECT_EQ(status, android::hardware::media::omx::V1_0::Status::TIMED_OUT); // status == TIMED_OUT, it could be due to process time being large @@ -636,6 +636,7 @@ void waitOnInputConsumption(sp omxNode, sp observer, size_t index; if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); + timeOut = TIMEOUT_COUNTER_Q; } } } @@ -1027,11 +1028,12 @@ void encodeNFrames(sp omxNode, sp observer, } } - int timeOut = TIMEOUT_COUNTER; - bool stall = false; + int timeOut = TIMEOUT_COUNTER_Q; + bool iQueued, oQueued; while (1) { + iQueued = oQueued = false; status = - observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer); + observer->dequeueMessage(&msg, DEFAULT_TIMEOUT_Q, iBuffer, oBuffer); if (status == android::hardware::media::omx::V1_0::Status::OK) { ASSERT_EQ(msg.type, Message::Type::EVENT); @@ -1062,9 +1064,7 @@ void encodeNFrames(sp omxNode, sp observer, timestamp += timestampIncr; nFrames--; ipCount++; - stall = false; - } else { - stall = true; + iQueued = true; } } else { if ((index = getEmptyBufferID(iBuffer)) < iBuffer->size()) { @@ -1083,20 +1083,17 @@ void encodeNFrames(sp omxNode, sp observer, timestamp += timestampIncr; nFrames--; ipCount++; - stall = false; - } else { - stall = true; + iQueued = true; } } if ((index = getEmptyBufferID(oBuffer)) < oBuffer->size()) { dispatchOutputBuffer(omxNode, oBuffer, index); - stall = false; - } else - stall = true; - if (stall) - timeOut--; + oQueued = true; + } + if (iQueued || oQueued) + timeOut = TIMEOUT_COUNTER_Q; else - timeOut = TIMEOUT_COUNTER; + timeOut--; if (timeOut == 0) { EXPECT_TRUE(false) << "Wait on Input/Output is found indefinite"; break; diff --git a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h index e6a61d4a8f..55de125877 100644 --- a/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h +++ b/media/omx/1.0/vts/functional/video/media_video_hidl_test_common.h @@ -17,7 +17,6 @@ #ifndef MEDIA_VIDEO_HIDL_TEST_COMMON_H #define MEDIA_VIDEO_HIDL_TEST_COMMON_H - /* * Common video utils */