summaryrefslogtreecommitdiffstats
path: root/dom/media/gmp/GMPVideoEncoderChild.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/gmp/GMPVideoEncoderChild.cpp')
-rw-r--r--dom/media/gmp/GMPVideoEncoderChild.cpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/dom/media/gmp/GMPVideoEncoderChild.cpp b/dom/media/gmp/GMPVideoEncoderChild.cpp
index 19a96b5efe..01a913f920 100644
--- a/dom/media/gmp/GMPVideoEncoderChild.cpp
+++ b/dom/media/gmp/GMPVideoEncoderChild.cpp
@@ -38,6 +38,11 @@ GMPVideoHostImpl& GMPVideoEncoderChild::Host() { return mVideoHost; }
void GMPVideoEncoderChild::Encoded(GMPVideoEncodedFrame* aEncodedFrame,
const uint8_t* aCodecSpecificInfo,
uint32_t aCodecSpecificInfoLength) {
+ if (NS_WARN_IF(!mPlugin)) {
+ aEncodedFrame->Destroy();
+ return;
+ }
+
MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
auto ef = static_cast<GMPVideoEncodedFrameImpl*>(aEncodedFrame);
@@ -53,6 +58,10 @@ void GMPVideoEncoderChild::Encoded(GMPVideoEncodedFrame* aEncodedFrame,
}
void GMPVideoEncoderChild::Error(GMPErr aError) {
+ if (NS_WARN_IF(!mPlugin)) {
+ return;
+ }
+
MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
SendError(aError);
@@ -95,9 +104,9 @@ mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvEncode(
mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvChildShmemForPool(
Shmem&& aEncodedBuffer) {
- if (aEncodedBuffer.IsWritable()) {
- mVideoHost.SharedMemMgr()->MgrDeallocShmem(GMPSharedMem::kGMPEncodedData,
- aEncodedBuffer);
+ GMPSharedMemManager* memMgr = mVideoHost.SharedMemMgr();
+ if (memMgr && aEncodedBuffer.IsWritable()) {
+ memMgr->MgrDeallocShmem(GMPSharedMem::kGMPEncodedData, aEncodedBuffer);
}
return IPC_OK();
}
@@ -142,6 +151,7 @@ mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvSetPeriodicKeyFrames(
}
mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvEncodingComplete() {
+ MOZ_ASSERT(mPlugin);
MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
if (mNeedShmemIntrCount) {
@@ -153,26 +163,29 @@ mozilla::ipc::IPCResult GMPVideoEncoderChild::RecvEncodingComplete() {
return IPC_OK();
}
- if (!mVideoEncoder) {
- // There is not much to clean up anymore.
- Unused << Send__delete__(this);
- return IPC_OK();
- }
+ // This will call ActorDestroy.
+ Unused << Send__delete__(this);
+ return IPC_OK();
+}
- // Ignore any return code. It is OK for this to fail without killing the
- // process.
- mVideoEncoder->EncodingComplete();
+void GMPVideoEncoderChild::ActorDestroy(ActorDestroyReason why) {
+ if (mVideoEncoder) {
+ // Ignore any return code. It is OK for this to fail without killing the
+ // process.
+ mVideoEncoder->EncodingComplete();
+ mVideoEncoder = nullptr;
+ }
mVideoHost.DoneWithAPI();
mPlugin = nullptr;
-
- Unused << Send__delete__(this);
-
- return IPC_OK();
}
bool GMPVideoEncoderChild::Alloc(size_t aSize, Shmem* aMem) {
+ if (NS_WARN_IF(!mPlugin)) {
+ return false;
+ }
+
MOZ_ASSERT(mPlugin->GMPMessageLoop() == MessageLoop::current());
bool rv;