bug fix: handle OMX_EventBufferFlag events

OMX_EventBufferFlag event is sent when the component has processed a buffer
with its EOS flag set. This event is not sent by soft omx components.
Vendor components can send this. From IOMX point of view, this event is
not sent for processing

bug:64102197
Merged-In: I3a978a885b1e4446f82f2356ae677f70ea6f8150
Change-Id: I3a978a885b1e4446f82f2356ae677f70ea6f8150
This commit is contained in:
Ram Mohan M 2017-06-22 13:53:12 +05:30 committed by Pawin Vongmasa
parent 029633dcd0
commit c8df8940e1
4 changed files with 76 additions and 34 deletions

View file

@ -474,15 +474,20 @@ void GetURLForComponent(AudioDecHidlTest::standardComp comp, char* mURL,
// port settings reconfiguration during runtime. reconfigures sample rate and
// number
typedef struct {
OMX_AUDIO_CODINGTYPE eEncoding;
AudioDecHidlTest::standardComp comp;
} packedArgs;
void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
OMX_AUDIO_CODINGTYPE eEncoding,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
Message msg,
AudioDecHidlTest::standardComp comp =
AudioDecHidlTest::standardComp::unknown_comp) {
Message msg, PortMode oPortMode, void* args) {
android::hardware::media::omx::V1_0::Status status;
packedArgs* audioArgs = static_cast<packedArgs*>(args);
OMX_AUDIO_CODINGTYPE eEncoding = audioArgs->eEncoding;
AudioDecHidlTest::standardComp comp = audioArgs->comp;
(void)oPortMode;
if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput);
@ -568,7 +573,8 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
OMX_AUDIO_CODINGTYPE eEncoding,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput) {
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
AudioDecHidlTest::standardComp comp) {
android::hardware::media::omx::V1_0::Status status;
Message msg;
int timeOut = TIMEOUT_COUNTER;
@ -579,8 +585,10 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
if (status == android::hardware::media::omx::V1_0::Status::OK) {
EXPECT_EQ(msg.type, Message::Type::EVENT);
portReconfiguration(omxNode, observer, iBuffer, oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput, msg);
packedArgs audioArgs = {eEncoding, comp};
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
kPortIndexInput, kPortIndexOutput, msg,
PortMode::PRESET_BYTE_BUFFER, &audioArgs);
}
// status == TIMED_OUT, it could be due to process time being large
// than DEFAULT_TIMEOUT or component needs output buffers to start
@ -644,8 +652,10 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
// Port Reconfiguration
if (status == android::hardware::media::omx::V1_0::Status::OK &&
msg.type == Message::Type::EVENT) {
portReconfiguration(omxNode, observer, iBuffer, oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput, msg, comp);
packedArgs audioArgs = {eEncoding, comp};
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
kPortIndexInput, kPortIndexOutput, msg,
PortMode::PRESET_BYTE_BUFFER, &audioArgs);
}
if (frameID == (int)Info->size() || frameID == (offset + range)) break;
@ -789,8 +799,10 @@ TEST_F(AudioDecHidlTest, DecodeTest) {
(int)Info.size(), compName);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
kPortIndexInput, kPortIndexOutput, compName);
packedArgs audioArgs = {eEncoding, compName};
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr,
portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs);
EXPECT_EQ(timestampUslist.empty(), true);
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@ -846,7 +858,9 @@ TEST_F(AudioDecHidlTest, DISABLED_EOSTest_M) {
changeStateIdletoExecute(omxNode, observer);
// request EOS at the start
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag);
packedArgs audioArgs = {eEncoding, compName};
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr,
portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 0U);
@ -933,8 +947,10 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) {
compName);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag);
kPortIndexInput, kPortIndexOutput, compName);
packedArgs audioArgs = {eEncoding, compName};
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, nullptr,
portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@ -949,8 +965,9 @@ TEST_F(AudioDecHidlTest, ThumbnailTest) {
compName, false);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag);
kPortIndexInput, kPortIndexOutput, compName);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr,
portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@ -1034,8 +1051,10 @@ TEST_F(AudioDecHidlTest, SimpleEOSTest) {
(int)Info.size(), compName, false);
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer, eEncoding,
kPortIndexInput, kPortIndexOutput);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag);
kPortIndexInput, kPortIndexOutput, compName);
packedArgs audioArgs = {eEncoding, compName};
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, nullptr,
portReconfiguration, kPortIndexInput, kPortIndexOutput, &audioArgs);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
framesReceived = 0;

View file

@ -406,7 +406,8 @@ void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer, bool signalEOS,
bool& eosFlag, PortMode* portMode) {
bool& eosFlag, PortMode* portMode, portreconfig fptr,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput, void* args) {
android::hardware::media::omx::V1_0::Status status;
PortMode defaultPortMode[2], *pm;
@ -443,9 +444,15 @@ void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
status =
observer->dequeueMessage(&msg, DEFAULT_TIMEOUT, iBuffer, oBuffer);
if (status == android::hardware::media::omx::V1_0::Status::OK) {
if (msg.data.eventData.event == OMX_EventBufferFlag) {
// soft omx components donot send this, we will just ignore it
// for now
if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
if (fptr) {
(*fptr)(omxNode, observer, iBuffer, oBuffer,
kPortIndexInput, kPortIndexOutput, msg, pm[1],
args);
} else {
// something unexpected happened
EXPECT_TRUE(false);
}
} else {
// something unexpected happened
EXPECT_TRUE(false);

View file

@ -113,6 +113,12 @@ struct CodecObserver : public IOmxObserver {
android::hardware::media::omx::V1_0::Message::Type::EVENT) {
*msg = *it;
msgQueue.erase(it);
// OMX_EventBufferFlag event is sent when the component has
// processed a buffer with its EOS flag set. This event is
// not sent by soft omx components. Vendor components can
// send this. From IOMX point of view, we will ignore this
// event.
if (msg->data.eventData.event == OMX_EventBufferFlag) break;
return ::android::hardware::media::omx::V1_0::Status::OK;
} else if (it->type == android::hardware::media::omx::V1_0::
Message::Type::FILL_BUFFER_DONE) {
@ -299,9 +305,16 @@ void flushPorts(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* oBuffer, OMX_U32 kPortIndexInput,
OMX_U32 kPortIndexOutput, int64_t timeoutUs = DEFAULT_TIMEOUT);
typedef void (*portreconfig)(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
Message msg, PortMode oPortMode, void* args);
void testEOS(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer, bool signalEOS,
bool& eosFlag, PortMode* portMode = nullptr);
bool& eosFlag, PortMode* portMode = nullptr,
portreconfig fptr = nullptr, OMX_U32 kPortIndexInput = 0,
OMX_U32 kPortIndexOutput = 1, void* args = nullptr);
#endif // MEDIA_HIDL_TEST_COMMON_H

View file

@ -474,8 +474,9 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
android::Vector<BufferInfo>* iBuffer,
android::Vector<BufferInfo>* oBuffer,
OMX_U32 kPortIndexInput, OMX_U32 kPortIndexOutput,
Message msg, PortMode oPortMode) {
Message msg, PortMode oPortMode, void* args) {
android::hardware::media::omx::V1_0::Status status;
(void)args;
if (msg.data.eventData.event == OMX_EventPortSettingsChanged) {
ASSERT_EQ(msg.data.eventData.data1, kPortIndexOutput);
@ -575,9 +576,6 @@ void portReconfiguration(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
std::cout << "[ ] Warning ! OMX_EventError/ "
"Decode Frame Call might be failed \n";
return;
} else if (msg.data.eventData.event == OMX_EventBufferFlag) {
// soft omx components donot send this, we will just ignore it
// for now
} else {
// something unexpected happened
ASSERT_TRUE(false);
@ -602,7 +600,7 @@ void waitOnInputConsumption(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
EXPECT_EQ(msg.type, Message::Type::EVENT);
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
kPortIndexInput, kPortIndexOutput, msg,
oPortMode);
oPortMode, nullptr);
}
// status == TIMED_OUT, it could be due to process time being large
// than DEFAULT_TIMEOUT or component needs output buffers to start
@ -668,7 +666,7 @@ void decodeNFrames(sp<IOmxNode> omxNode, sp<CodecObserver> observer,
msg.type == Message::Type::EVENT) {
portReconfiguration(omxNode, observer, iBuffer, oBuffer,
kPortIndexInput, kPortIndexOutput, msg,
oPortMode);
oPortMode, nullptr);
}
if (frameID == (int)Info->size() || frameID == (offset + range)) break;
@ -834,7 +832,8 @@ TEST_F(VideoDecHidlTest, DecodeTest) {
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput, portMode[1]);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode,
portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
EXPECT_EQ(timestampUslist.empty(), true);
// set state to idle
changeStateExecutetoIdle(omxNode, observer, &iBuffer, &oBuffer);
@ -884,7 +883,8 @@ TEST_F(VideoDecHidlTest, EOSTest_M) {
changeStateIdletoExecute(omxNode, observer);
// request EOS at the start
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode,
portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 0U);
@ -968,7 +968,8 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput, portMode[1]);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode);
testEOS(omxNode, observer, &iBuffer, &oBuffer, false, eosFlag, portMode,
portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@ -983,7 +984,8 @@ TEST_F(VideoDecHidlTest, ThumbnailTest) {
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput, portMode[1]);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode,
portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
EXPECT_GE(framesReceived, 1U);
@ -1066,7 +1068,8 @@ TEST_F(VideoDecHidlTest, SimpleEOSTest) {
eleStream.close();
waitOnInputConsumption(omxNode, observer, &iBuffer, &oBuffer,
kPortIndexInput, kPortIndexOutput, portMode[1]);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode);
testEOS(omxNode, observer, &iBuffer, &oBuffer, true, eosFlag, portMode,
portReconfiguration, kPortIndexInput, kPortIndexOutput, nullptr);
flushPorts(omxNode, observer, &iBuffer, &oBuffer, kPortIndexInput,
kPortIndexOutput);
framesReceived = 0;