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