Merge "media: keep JMediaCodec::mCodec reference until destruction" into qt-dev
am: 8a1174bc94
Change-Id: Ie53f380c5712f331d0345f33b621de26fb2975ce
This commit is contained in:
@@ -211,21 +211,22 @@ void JMediaCodec::registerSelf() {
|
||||
}
|
||||
|
||||
void JMediaCodec::release() {
|
||||
if (mCodec != NULL) {
|
||||
mCodec->release();
|
||||
mCodec.clear();
|
||||
mInitStatus = NO_INIT;
|
||||
}
|
||||
std::call_once(mReleaseFlag, [this] {
|
||||
if (mCodec != NULL) {
|
||||
mCodec->release();
|
||||
mInitStatus = NO_INIT;
|
||||
}
|
||||
|
||||
if (mLooper != NULL) {
|
||||
mLooper->unregisterHandler(id());
|
||||
mLooper->stop();
|
||||
mLooper.clear();
|
||||
}
|
||||
if (mLooper != NULL) {
|
||||
mLooper->unregisterHandler(id());
|
||||
mLooper->stop();
|
||||
mLooper.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
JMediaCodec::~JMediaCodec() {
|
||||
if (mCodec != NULL || mLooper != NULL) {
|
||||
if (mLooper != NULL) {
|
||||
/* MediaCodec and looper should have been released explicitly already
|
||||
* in setMediaCodec() (see comments in setMediaCodec()).
|
||||
*
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#ifndef _ANDROID_MEDIA_MEDIACODEC_H_
|
||||
#define _ANDROID_MEDIA_MEDIACODEC_H_
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#include <media/MediaAnalyticsItem.h>
|
||||
@@ -156,6 +158,7 @@ private:
|
||||
sp<ALooper> mLooper;
|
||||
sp<MediaCodec> mCodec;
|
||||
AString mNameAtCreation;
|
||||
std::once_flag mReleaseFlag;
|
||||
|
||||
sp<AMessage> mCallbackNotification;
|
||||
sp<AMessage> mOnFrameRenderedNotification;
|
||||
|
||||
Reference in New Issue
Block a user