Loading media/java/android/media/tv/tuner/filter/MediaEvent.java +17 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.media.MediaCodec.LinearBlock; @SystemApi public class MediaEvent extends FilterEvent { private long mNativeContext; private boolean mReleased = false; private final Object mLock = new Object(); private native Long nativeGetAudioHandle(); Loading Loading @@ -181,7 +182,21 @@ public class MediaEvent extends FilterEvent { */ @Override protected void finalize() { release(); } /** * Releases the MediaEvent object. * @hide */ public void release() { synchronized (mLock) { if (mReleased) { return; } nativeFinalize(); mNativeContext = 0; mReleased = true; } } } media/jni/android_media_tv_Tuner.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -314,8 +314,9 @@ MediaEvent::~MediaEvent() { if (mIonHandle != NULL) { delete mIonHandle; } if (mC2Buffer != NULL) { mC2Buffer->unregisterOnDestroyNotify(&DestroyCallback, this); std::shared_ptr<C2Buffer> pC2Buffer = mC2Buffer.lock(); if (pC2Buffer != NULL) { pC2Buffer->unregisterOnDestroyNotify(&DestroyCallback, this); } } Loading @@ -340,15 +341,17 @@ jobject MediaEvent::getLinearBlock() { JNIEnv *env = AndroidRuntime::getJNIEnv(); std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock}; context->mBlock = block; mC2Buffer = context->toC2Buffer(0, mDataLength); std::shared_ptr<C2Buffer> pC2Buffer = context->toC2Buffer(0, mDataLength); context->mBuffer = pC2Buffer; mC2Buffer = pC2Buffer; if (mAvHandle->numInts > 0) { // use first int in the native_handle as the index int index = mAvHandle->data[mAvHandle->numFds]; std::shared_ptr<C2Param> c2param = std::make_shared<C2DataIdInfo>(index, mDataId); std::shared_ptr<C2Info> info(std::static_pointer_cast<C2Info>(c2param)); mC2Buffer->setInfo(info); pC2Buffer->setInfo(info); } mC2Buffer->registerOnDestroyNotify(&DestroyCallback, this); pC2Buffer->registerOnDestroyNotify(&DestroyCallback, this); jobject linearBlock = env->NewObject( env->FindClass("android/media/MediaCodec$LinearBlock"), Loading media/jni/android_media_tv_Tuner.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ struct MediaEvent : public RefBase { jweak mMediaEventObj; jweak mLinearBlockObj; C2HandleIon* mIonHandle; std::shared_ptr<C2Buffer> mC2Buffer; std::weak_ptr<C2Buffer> mC2Buffer; }; struct Filter : public RefBase { Loading Loading
media/java/android/media/tv/tuner/filter/MediaEvent.java +17 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.media.MediaCodec.LinearBlock; @SystemApi public class MediaEvent extends FilterEvent { private long mNativeContext; private boolean mReleased = false; private final Object mLock = new Object(); private native Long nativeGetAudioHandle(); Loading Loading @@ -181,7 +182,21 @@ public class MediaEvent extends FilterEvent { */ @Override protected void finalize() { release(); } /** * Releases the MediaEvent object. * @hide */ public void release() { synchronized (mLock) { if (mReleased) { return; } nativeFinalize(); mNativeContext = 0; mReleased = true; } } }
media/jni/android_media_tv_Tuner.cpp +8 −5 Original line number Diff line number Diff line Loading @@ -314,8 +314,9 @@ MediaEvent::~MediaEvent() { if (mIonHandle != NULL) { delete mIonHandle; } if (mC2Buffer != NULL) { mC2Buffer->unregisterOnDestroyNotify(&DestroyCallback, this); std::shared_ptr<C2Buffer> pC2Buffer = mC2Buffer.lock(); if (pC2Buffer != NULL) { pC2Buffer->unregisterOnDestroyNotify(&DestroyCallback, this); } } Loading @@ -340,15 +341,17 @@ jobject MediaEvent::getLinearBlock() { JNIEnv *env = AndroidRuntime::getJNIEnv(); std::unique_ptr<JMediaCodecLinearBlock> context{new JMediaCodecLinearBlock}; context->mBlock = block; mC2Buffer = context->toC2Buffer(0, mDataLength); std::shared_ptr<C2Buffer> pC2Buffer = context->toC2Buffer(0, mDataLength); context->mBuffer = pC2Buffer; mC2Buffer = pC2Buffer; if (mAvHandle->numInts > 0) { // use first int in the native_handle as the index int index = mAvHandle->data[mAvHandle->numFds]; std::shared_ptr<C2Param> c2param = std::make_shared<C2DataIdInfo>(index, mDataId); std::shared_ptr<C2Info> info(std::static_pointer_cast<C2Info>(c2param)); mC2Buffer->setInfo(info); pC2Buffer->setInfo(info); } mC2Buffer->registerOnDestroyNotify(&DestroyCallback, this); pC2Buffer->registerOnDestroyNotify(&DestroyCallback, this); jobject linearBlock = env->NewObject( env->FindClass("android/media/MediaCodec$LinearBlock"), Loading
media/jni/android_media_tv_Tuner.h +1 −1 Original line number Diff line number Diff line Loading @@ -130,7 +130,7 @@ struct MediaEvent : public RefBase { jweak mMediaEventObj; jweak mLinearBlockObj; C2HandleIon* mIonHandle; std::shared_ptr<C2Buffer> mC2Buffer; std::weak_ptr<C2Buffer> mC2Buffer; }; struct Filter : public RefBase { Loading