Bug 1098994 - Update video output buffer when gets INFO_OUTPUT_BUFFERS_CHANGED from OMX. r=edwin

This commit is contained in:
Alfredo Yang 2014-11-16 19:07:00 +01:00
parent d104b16262
commit c1f066c22d
3 changed files with 24 additions and 4 deletions

View File

@ -329,16 +329,21 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
return NS_OK; return NS_OK;
} }
case android::INFO_FORMAT_CHANGED: case android::INFO_FORMAT_CHANGED:
case android::INFO_OUTPUT_BUFFERS_CHANGED:
{ {
// If the format changed, update our cached info. // If the format changed, update our cached info.
ALOG("Decoder format changed"); ALOG("Decoder format changed");
if (!SetVideoFormat()) { if (!SetVideoFormat()) {
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
else
return Output(aStreamOffset, aOutData); return Output(aStreamOffset, aOutData);
} }
case android::INFO_OUTPUT_BUFFERS_CHANGED:
{
if (mDecoder->UpdateOutputBuffers()) {
return Output(aStreamOffset, aOutData);
}
return NS_ERROR_FAILURE;
}
case -EAGAIN: case -EAGAIN:
{ {
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
@ -420,7 +425,6 @@ GonkVideoDecoderManager::codecReserved()
} }
status_t err = mDecoder->configure(format, surface, nullptr, 0); status_t err = mDecoder->configure(format, surface, nullptr, 0);
mDecoder->Prepare(); mDecoder->Prepare();
SetVideoFormat();
if (mHandler != nullptr) { if (mHandler != nullptr) {
// post kNotifyCodecReserved to Looper thread. // post kNotifyCodecReserved to Looper thread.

View File

@ -504,6 +504,21 @@ bool MediaCodecProxy::Prepare()
return true; return true;
} }
bool MediaCodecProxy::UpdateOutputBuffers()
{
if (mCodec == nullptr) {
ALOG("MediaCodec has not been inited from input!");
return false;
}
status_t err = getOutputBuffers(&mOutputBuffers);
if (err != OK){
ALOG("Couldn't update output buffers from MediaCodec");
return false;
}
return true;
}
status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize, status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize,
int64_t aTimestampUsecs, uint64_t aflags) int64_t aTimestampUsecs, uint64_t aflags)
{ {
@ -540,7 +555,6 @@ status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize,
status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs) status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs)
{ {
if (mCodec == nullptr) { if (mCodec == nullptr) {
ALOG("MediaCodec has not been inited from output!"); ALOG("MediaCodec has not been inited from output!");
return NO_INIT; return NO_INIT;

View File

@ -132,6 +132,8 @@ public:
bool IsWaitingResources(); bool IsWaitingResources();
bool IsDormantNeeded(); bool IsDormantNeeded();
void ReleaseMediaResources(); void ReleaseMediaResources();
// This updates mOutputBuffer when receiving INFO_OUTPUT_BUFFERS_CHANGED event.
bool UpdateOutputBuffers();
void ReleaseMediaBuffer(MediaBuffer* abuffer); void ReleaseMediaBuffer(MediaBuffer* abuffer);