mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1155498 - Part 5 - Use new FenceHandle to handle Decoder fence. r=sotaro
--HG-- extra : rebase_source : 07572915abb33e362bbd3e3817fb57e6296ae871
This commit is contained in:
parent
7980550521
commit
683fb496b3
@ -787,16 +787,9 @@ MediaCodecReader::TextureClientRecycleCallback(TextureClient* aClient)
|
||||
return;
|
||||
}
|
||||
|
||||
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 17
|
||||
sp<Fence> fence = aClient->GetReleaseFenceHandle().mFence;
|
||||
if (fence.get() && fence->isValid()) {
|
||||
mPendingReleaseItems.AppendElement(ReleaseItem(index, fence));
|
||||
} else {
|
||||
mPendingReleaseItems.AppendElement(ReleaseItem(index, nullptr));
|
||||
}
|
||||
#else
|
||||
mPendingReleaseItems.AppendElement(ReleaseItem(index));
|
||||
#endif
|
||||
FenceHandle handle = aClient->GetAndResetReleaseFenceHandle();
|
||||
mPendingReleaseItems.AppendElement(ReleaseItem(index, handle));
|
||||
|
||||
mTextureClientIndexes.Remove(aClient);
|
||||
}
|
||||
|
||||
@ -819,13 +812,13 @@ MediaCodecReader::WaitFenceAndReleaseOutputBuffer()
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < releasingItems.Length(); i++) {
|
||||
if (releasingItems[i].mReleaseFence.IsValid()) {
|
||||
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 17
|
||||
sp<Fence> fence;
|
||||
fence = releasingItems[i].mReleaseFence;
|
||||
if (fence.get() && fence->isValid()) {
|
||||
nsRefPtr<FenceHandle::FdObj> fdObj = releasingItems[i].mReleaseFence.GetAndResetFdObj();
|
||||
sp<Fence> fence = new Fence(fdObj->GetAndResetFd());
|
||||
fence->waitForever("MediaCodecReader");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (mVideoTrack.mCodec != nullptr) {
|
||||
mVideoTrack.mCodec->releaseOutputBuffer(releasingItems[i].mReleaseIndex);
|
||||
}
|
||||
|
@ -439,25 +439,17 @@ private:
|
||||
int64_t mNextParserPosition;
|
||||
int64_t mParsedDataLength;
|
||||
nsAutoPtr<MP3FrameParser> mMP3FrameParser;
|
||||
#if MOZ_WIDGET_GONK && ANDROID_VERSION >= 17
|
||||
// mReleaseIndex corresponding to a graphic buffer, and the mReleaseFence is
|
||||
// the graohic buffer's fence. We must wait for the fence signaled by
|
||||
// compositor, otherwise we will see the flicker because the HW decoder and
|
||||
// compositor use the buffer concurrently.
|
||||
struct ReleaseItem {
|
||||
ReleaseItem(size_t aIndex, const android::sp<android::Fence>& aFence)
|
||||
ReleaseItem(size_t aIndex, const FenceHandle& aFence)
|
||||
: mReleaseIndex(aIndex)
|
||||
, mReleaseFence(aFence) {}
|
||||
size_t mReleaseIndex;
|
||||
android::sp<android::Fence> mReleaseFence;
|
||||
FenceHandle mReleaseFence;
|
||||
};
|
||||
#else
|
||||
struct ReleaseItem {
|
||||
ReleaseItem(size_t aIndex)
|
||||
: mReleaseIndex(aIndex) {}
|
||||
size_t mReleaseIndex;
|
||||
};
|
||||
#endif
|
||||
nsTArray<ReleaseItem> mPendingReleaseItems;
|
||||
};
|
||||
|
||||
|
@ -355,7 +355,7 @@ void OmxDecoder::ReleaseMediaResources() {
|
||||
GrallocTextureClientOGL* client = static_cast<GrallocTextureClientOGL*>(*it);
|
||||
client->ClearRecycleCallback();
|
||||
if (client->GetMediaBuffer()) {
|
||||
mPendingVideoBuffers.push(BufferItem(client->GetMediaBuffer(), client->GetReleaseFenceHandle()));
|
||||
mPendingVideoBuffers.push(BufferItem(client->GetMediaBuffer(), client->GetAndResetReleaseFenceHandle()));
|
||||
}
|
||||
}
|
||||
mPendingRecycleTexutreClients.clear();
|
||||
@ -873,12 +873,9 @@ void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
|
||||
MediaBuffer *buffer;
|
||||
buffer = releasingVideoBuffers[i].mMediaBuffer;
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17
|
||||
android::sp<Fence> fence;
|
||||
int fenceFd = -1;
|
||||
fence = releasingVideoBuffers[i].mReleaseFenceHandle.mFence;
|
||||
if (fence.get() && fence->isValid()) {
|
||||
fenceFd = fence->dup();
|
||||
}
|
||||
nsRefPtr<FenceHandle::FdObj> fdObj = releasingVideoBuffers.editItemAt(i).mReleaseFenceHandle.GetAndResetFdObj();
|
||||
int fenceFd = fdObj->GetAndResetFd();
|
||||
|
||||
MOZ_ASSERT(buffer->refcount() == 1);
|
||||
// This code expect MediaBuffer's ref count is 1.
|
||||
// Return gralloc buffer to ANativeWindow
|
||||
@ -910,7 +907,7 @@ void OmxDecoder::RecycleCallbackImp(TextureClient* aClient)
|
||||
mPendingRecycleTexutreClients.erase(aClient);
|
||||
GrallocTextureClientOGL* client = static_cast<GrallocTextureClientOGL*>(aClient);
|
||||
if (client->GetMediaBuffer()) {
|
||||
mPendingVideoBuffers.push(BufferItem(client->GetMediaBuffer(), client->GetReleaseFenceHandle()));
|
||||
mPendingVideoBuffers.push(BufferItem(client->GetMediaBuffer(), client->GetAndResetReleaseFenceHandle()));
|
||||
}
|
||||
}
|
||||
sp<AMessage> notify =
|
||||
|
Loading…
Reference in New Issue
Block a user