mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1094614 - Release codec resource properly. r=sotaro
This commit is contained in:
parent
5bd38bae7a
commit
f794e5dc08
@ -162,12 +162,13 @@ GonkMediaDataDecoder::IsWaitingMediaResources() {
|
||||
|
||||
bool
|
||||
GonkMediaDataDecoder::IsDormantNeeded() {
|
||||
return mDecoder->IsDormantNeeded();
|
||||
|
||||
return mDecoder.get() ? true : false;
|
||||
}
|
||||
|
||||
void
|
||||
GonkMediaDataDecoder::ReleaseMediaResources() {
|
||||
mDecoder->ReleaseMediaResources();
|
||||
mManager->ReleaseMediaResources();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
virtual nsresult Output(int64_t aStreamOffset,
|
||||
nsRefPtr<MediaData>& aOutput) = 0;
|
||||
|
||||
virtual void ReleaseMediaResources() {};
|
||||
};
|
||||
|
||||
// Samples are decoded using the GonkDecoder (MediaCodec)
|
||||
|
@ -455,6 +455,7 @@ GonkVideoDecoderManager::onMessageReceived(const sp<AMessage> &aMessage)
|
||||
{
|
||||
// Our decode may have acquired the hardware resource that it needs
|
||||
// to start. Notify the state machine to resume loading metadata.
|
||||
ALOG("CodecReserved!");
|
||||
mReaderCallback->NotifyResourcesStatusChanged();
|
||||
break;
|
||||
}
|
||||
@ -467,7 +468,7 @@ GonkVideoDecoderManager::onMessageReceived(const sp<AMessage> &aMessage)
|
||||
|
||||
case kNotifyPostReleaseBuffer:
|
||||
{
|
||||
ReleaseAllPendingVideoBuffersLocked();
|
||||
ReleaseAllPendingVideoBuffers();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -562,7 +563,7 @@ void GonkVideoDecoderManager::PostReleaseVideoBuffer(
|
||||
|
||||
}
|
||||
|
||||
void GonkVideoDecoderManager::ReleaseAllPendingVideoBuffersLocked()
|
||||
void GonkVideoDecoderManager::ReleaseAllPendingVideoBuffers()
|
||||
{
|
||||
Vector<android::MediaBuffer*> releasingVideoBuffers;
|
||||
{
|
||||
@ -584,4 +585,9 @@ void GonkVideoDecoderManager::ReleaseAllPendingVideoBuffersLocked()
|
||||
releasingVideoBuffers.clear();
|
||||
}
|
||||
|
||||
void GonkVideoDecoderManager::ReleaseMediaResources() {
|
||||
ALOG("ReleseMediaResources");
|
||||
ReleaseAllPendingVideoBuffers();
|
||||
mDecoder->ReleaseMediaResources();
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
@ -50,7 +50,10 @@ public:
|
||||
virtual nsresult Output(int64_t aStreamOffset,
|
||||
nsRefPtr<MediaData>& aOutput) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ReleaseMediaResources();
|
||||
|
||||
static void RecycleCallback(TextureClient* aClient, void* aClosure);
|
||||
|
||||
private:
|
||||
struct FrameInfo
|
||||
{
|
||||
@ -112,7 +115,7 @@ private:
|
||||
void codecCanceled();
|
||||
void onMessageReceived(const sp<AMessage> &aMessage);
|
||||
|
||||
void ReleaseAllPendingVideoBuffersLocked();
|
||||
void ReleaseAllPendingVideoBuffers();
|
||||
void PostReleaseVideoBuffer(android::MediaBuffer *aBuffer);
|
||||
|
||||
uint32_t mVideoWidth;
|
||||
|
@ -110,10 +110,6 @@ MediaCodecProxy::MediaCodecProxy(sp<ALooper> aLooper,
|
||||
MediaCodecProxy::~MediaCodecProxy()
|
||||
{
|
||||
releaseCodec();
|
||||
|
||||
// Complete all pending Binder ipc transactions
|
||||
IPCThreadState::self()->flushCommands();
|
||||
|
||||
cancelResource();
|
||||
}
|
||||
|
||||
@ -181,6 +177,7 @@ MediaCodecProxy::releaseCodec()
|
||||
|
||||
// Release MediaCodec
|
||||
if (mCodec != nullptr) {
|
||||
status_t err = mCodec->stop();
|
||||
mCodec->release();
|
||||
mCodec = nullptr;
|
||||
}
|
||||
@ -190,6 +187,10 @@ MediaCodecProxy::releaseCodec()
|
||||
// this value come from stagefright's AwesomePlayer.
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
// Complete all pending Binder ipc transactions
|
||||
IPCThreadState::self()->flushCommands();
|
||||
|
||||
}
|
||||
|
||||
bool
|
||||
@ -597,6 +598,8 @@ status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs)
|
||||
|
||||
bool MediaCodecProxy::IsWaitingResources()
|
||||
{
|
||||
// Write Lock for mCodec
|
||||
RWLock::AutoWLock awl(mCodecLock);
|
||||
return mCodec == nullptr;
|
||||
}
|
||||
|
||||
@ -607,11 +610,8 @@ bool MediaCodecProxy::IsDormantNeeded()
|
||||
|
||||
void MediaCodecProxy::ReleaseMediaResources()
|
||||
{
|
||||
if (mCodec.get()) {
|
||||
mCodec->stop();
|
||||
mCodec->release();
|
||||
mCodec.clear();
|
||||
}
|
||||
releaseCodec();
|
||||
cancelResource();
|
||||
}
|
||||
|
||||
void MediaCodecProxy::ReleaseMediaBuffer(MediaBuffer* aBuffer) {
|
||||
|
Loading…
Reference in New Issue
Block a user