Merge "Turn an another assertion into a runtime error in ACodec's implementation"

This commit is contained in:
Andreas Huber
2011-09-12 14:21:42 -07:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 22 deletions

View File

@@ -164,6 +164,8 @@ private:
void sendFormatChange(); void sendFormatChange();
void signalError(OMX_ERRORTYPE error = OMX_ErrorUndefined);
DISALLOW_EVIL_CONSTRUCTORS(ACodec); DISALLOW_EVIL_CONSTRUCTORS(ACodec);
}; };

View File

@@ -1131,6 +1131,13 @@ void ACodec::sendFormatChange() {
mSentFormat = true; mSentFormat = true;
} }
void ACodec::signalError(OMX_ERRORTYPE error) {
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", ACodec::kWhatError);
notify->setInt32("omx-error", error);
notify->post();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
@@ -1252,10 +1259,7 @@ bool ACodec::BaseState::onOMXEvent(
LOGE("[%s] ERROR(0x%08lx)", mCodec->mComponentName.c_str(), data1); LOGE("[%s] ERROR(0x%08lx)", mCodec->mComponentName.c_str(), data1);
sp<AMessage> notify = mCodec->mNotify->dup(); mCodec->signalError((OMX_ERRORTYPE)data1);
notify->setInt32("what", ACodec::kWhatError);
notify->setInt32("omx-error", data1);
notify->post();
return true; return true;
} }
@@ -1548,12 +1552,14 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) {
&& msg->findInt32("render", &render) && render != 0) { && msg->findInt32("render", &render) && render != 0) {
// The client wants this buffer to be rendered. // The client wants this buffer to be rendered.
CHECK_EQ(mCodec->mNativeWindow->queueBuffer( if (mCodec->mNativeWindow->queueBuffer(
mCodec->mNativeWindow.get(), mCodec->mNativeWindow.get(),
info->mGraphicBuffer.get()), info->mGraphicBuffer.get()) == OK) {
0); info->mStatus = BufferInfo::OWNED_BY_NATIVE_WINDOW;
} else {
info->mStatus = BufferInfo::OWNED_BY_NATIVE_WINDOW; mCodec->signalError();
info->mStatus = BufferInfo::OWNED_BY_US;
}
} else { } else {
info->mStatus = BufferInfo::OWNED_BY_US; info->mStatus = BufferInfo::OWNED_BY_US;
} }
@@ -1692,11 +1698,7 @@ void ACodec::UninitializedState::onSetup(
if (node == NULL) { if (node == NULL) {
LOGE("Unable to instantiate a decoder for type '%s'.", mime.c_str()); LOGE("Unable to instantiate a decoder for type '%s'.", mime.c_str());
sp<AMessage> notify = mCodec->mNotify->dup(); mCodec->signalError(OMX_ErrorComponentNotFound);
notify->setInt32("what", ACodec::kWhatError);
notify->setInt32("omx-error", OMX_ErrorComponentNotFound);
notify->post();
return; return;
} }
@@ -1744,10 +1746,7 @@ void ACodec::LoadedToIdleState::stateEntered() {
"(error 0x%08x)", "(error 0x%08x)",
err); err);
sp<AMessage> notify = mCodec->mNotify->dup(); mCodec->signalError();
notify->setInt32("what", ACodec::kWhatError);
notify->setInt32("omx-error", OMX_ErrorUndefined);
notify->post();
} }
} }
@@ -2063,10 +2062,7 @@ bool ACodec::OutputPortSettingsChangedState::onOMXEvent(
"port reconfiguration (error 0x%08x)", "port reconfiguration (error 0x%08x)",
err); err);
sp<AMessage> notify = mCodec->mNotify->dup(); mCodec->signalError();
notify->setInt32("what", ACodec::kWhatError);
notify->setInt32("omx-error", OMX_ErrorUndefined);
notify->post();
} }
return true; return true;