@@ -1131,6 +1131,13 @@ void ACodec::sendFormatChange() {
11311131 mSentFormat = true ;
11321132}
11331133
1134+ void ACodec::signalError (OMX_ERRORTYPE error) {
1135+ sp<AMessage> notify = mNotify ->dup ();
1136+ notify->setInt32 (" what" , ACodec::kWhatError );
1137+ notify->setInt32 (" omx-error" , error);
1138+ notify->post ();
1139+ }
1140+
11341141// //////////////////////////////////////////////////////////////////////////////
11351142
11361143ACodec::BaseState::BaseState (ACodec *codec, const sp<AState> &parentState)
@@ -1252,10 +1259,7 @@ bool ACodec::BaseState::onOMXEvent(
12521259
12531260 LOGE (" [%s] ERROR(0x%08lx)" , mCodec ->mComponentName .c_str (), data1);
12541261
1255- sp<AMessage> notify = mCodec ->mNotify ->dup ();
1256- notify->setInt32 (" what" , ACodec::kWhatError );
1257- notify->setInt32 (" omx-error" , data1);
1258- notify->post ();
1262+ mCodec ->signalError ((OMX_ERRORTYPE)data1);
12591263
12601264 return true ;
12611265}
@@ -1548,12 +1552,14 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) {
15481552 && msg->findInt32 (" render" , &render) && render != 0 ) {
15491553 // The client wants this buffer to be rendered.
15501554
1551- CHECK_EQ (mCodec ->mNativeWindow ->queueBuffer (
1555+ if (mCodec ->mNativeWindow ->queueBuffer (
15521556 mCodec ->mNativeWindow .get (),
1553- info->mGraphicBuffer .get ()),
1554- 0 );
1555-
1556- info->mStatus = BufferInfo::OWNED_BY_NATIVE_WINDOW;
1557+ info->mGraphicBuffer .get ()) == OK) {
1558+ info->mStatus = BufferInfo::OWNED_BY_NATIVE_WINDOW;
1559+ } else {
1560+ mCodec ->signalError ();
1561+ info->mStatus = BufferInfo::OWNED_BY_US;
1562+ }
15571563 } else {
15581564 info->mStatus = BufferInfo::OWNED_BY_US;
15591565 }
@@ -1692,11 +1698,7 @@ void ACodec::UninitializedState::onSetup(
16921698 if (node == NULL ) {
16931699 LOGE (" Unable to instantiate a decoder for type '%s'." , mime.c_str ());
16941700
1695- sp<AMessage> notify = mCodec ->mNotify ->dup ();
1696- notify->setInt32 (" what" , ACodec::kWhatError );
1697- notify->setInt32 (" omx-error" , OMX_ErrorComponentNotFound);
1698- notify->post ();
1699-
1701+ mCodec ->signalError (OMX_ErrorComponentNotFound);
17001702 return ;
17011703 }
17021704
@@ -1744,10 +1746,7 @@ void ACodec::LoadedToIdleState::stateEntered() {
17441746 " (error 0x%08x)" ,
17451747 err);
17461748
1747- sp<AMessage> notify = mCodec ->mNotify ->dup ();
1748- notify->setInt32 (" what" , ACodec::kWhatError );
1749- notify->setInt32 (" omx-error" , OMX_ErrorUndefined);
1750- notify->post ();
1749+ mCodec ->signalError ();
17511750 }
17521751}
17531752
@@ -2063,10 +2062,7 @@ bool ACodec::OutputPortSettingsChangedState::onOMXEvent(
20632062 " port reconfiguration (error 0x%08x)" ,
20642063 err);
20652064
2066- sp<AMessage> notify = mCodec ->mNotify ->dup ();
2067- notify->setInt32 (" what" , ACodec::kWhatError );
2068- notify->setInt32 (" omx-error" , OMX_ErrorUndefined);
2069- notify->post ();
2065+ mCodec ->signalError ();
20702066 }
20712067
20722068 return true ;
0 commit comments