Extractor dtor on media.extractor side happens asynchronously with the
dtor of StagefrightMetadataRetriever. If the extractor calls back into
the DataSource after mediaserver side released the reference to it, the
binder transaction could get stuck.
Adding an explicity release() and call it before StagefrightMetadataRetriever
continues to destruct the DataSource. Only implement it for MPEG4Extractor
to avoid impacting other extractors at this stage.
Also adding some code to aggressively release the extractor and data
source in HeifDecoderImpl to free up memory.
bug:
65463215
Change-Id: I84c442a1e010dd37a976af5453a353e43f672e22
videoFrame->getFlattenedIccData());
}
mFrameDecoded = true;
+
+ // Aggressive clear to avoid holding on to resources
+ mRetriever.clear();
+ mDataSource.clear();
return true;
}
SETMEDIACAS,
SETUID,
NAME,
- GETMETRICS
+ GETMETRICS,
+ RELEASE,
};
class BpMediaExtractor : public BpInterface<IMediaExtractor> {
ALOGV("name NOT IMPLEMENTED");
return NULL;
}
+
+ virtual void release() {
+ ALOGV("release");
+ Parcel data, reply;
+ data.writeInterfaceToken(BpMediaExtractor::getInterfaceDescriptor());
+ remote()->transact(RELEASE, data, &reply);
+ }
};
IMPLEMENT_META_INTERFACE(MediaExtractor, "android.media.IMediaExtractor");
reply->writeInt32(setMediaCas(casToken));
return OK;
}
+ case RELEASE: {
+ ALOGV("release");
+ CHECK_INTERFACE(IMediaExtractor, data, reply);
+ release();
+ return OK;
+ }
default:
return BBinder::onTransact(code, data, reply, flags);
}
virtual void setUID(uid_t uid) = 0;
virtual const char * name() = 0;
+
+ virtual void release() = 0;
};
}
MPEG4Extractor::~MPEG4Extractor() {
+ release();
+}
+
+void MPEG4Extractor::release() {
Track *track = mFirstTrack;
while (track) {
Track *next = track->next;
for (size_t i = 0; i < mPssh.size(); i++) {
delete [] mPssh[i].data;
}
+ mPssh.clear();
+
+ if (mDataSource != NULL) {
+ mDataSource->close();
+ mDataSource.clear();
+ }
}
uint32_t MPEG4Extractor::flags() const {
StagefrightMetadataRetriever::~StagefrightMetadataRetriever() {
ALOGV("~StagefrightMetadataRetriever()");
clearMetadata();
+ // Explicitly release extractor before continuing with the destructor,
+ // some extractors might need to callback to close off the DataSource
+ // and we need to make sure it's still there.
+ if (mExtractor != NULL) {
+ mExtractor->release();
+ }
if (mSource != NULL) {
mSource->close();
}
virtual sp<MetaData> getMetaData();
virtual uint32_t flags() const;
virtual const char * name() { return "MPEG4Extractor"; }
+ virtual void release();
// for DRM
virtual char* getDrmTrackInfo(size_t trackID, int *len);
virtual const char * name() { return "<unspecified>"; }
+ virtual void release() {}
+
protected:
MediaExtractor();
virtual ~MediaExtractor();