shithub: openh264

Download patch

ref: 955fce60a1cfcbd66a778350fc4b6d8e54ea946f
parent: f13f502203140574eb0e5c7bf15c0571ce7a57be
author: Hank Peng <[email protected]>
date: Wed Nov 4 06:29:02 EST 2015

Never call GMPVideoDecoderCallback after DecodingComplete, to fix bug #1204588 in Bugzilla

--- a/module/gmp-openh264.cpp
+++ b/module/gmp-openh264.cpp
@@ -361,6 +361,8 @@
   }
 
   virtual void EncodingComplete() {
+    // Release the reference to the callback, because it is no longer safe to call it
+    callback_ = nullptr;
     Release();
   }
 
@@ -532,7 +534,9 @@
     info.mBufferType = GMP_BufferLength32;
     info.mCodecSpecific.mH264.mSimulcastIdx = 0;
 
-    callback_->Encoded (f, reinterpret_cast<uint8_t*> (&info), sizeof (info));
+    if (callback_) {
+      callback_->Encoded (f, reinterpret_cast<uint8_t*> (&info), sizeof (info));
+    }
 
     stats_.FrameOut();
   }
@@ -716,6 +720,8 @@
   }
 
   virtual void DecodingComplete() {
+    // Release the reference to the callback, because it is no longer safe to call it
+    callback_ = nullptr;
     Release();
   }
 
@@ -780,7 +786,9 @@
 
     if (decoded->iBufferStatus != 1) {
       GMPLOG (GL_ERROR, "iBufferStatus=" << decoded->iBufferStatus);
-      callback_->InputDataExhausted();
+      if (callback_) {
+        callback_->InputDataExhausted();
+      }
       return;
     }
 
@@ -822,7 +830,9 @@
             << frame->AllocatedSize (kGMPYPlane));
     frame->SetTimestamp (inputFrame->TimeStamp());
     frame->SetDuration (inputFrame->Duration());
-    callback_->Decoded (frame);
+    if (callback_) {
+      callback_->Decoded (frame);
+    }
 
     stats_.FrameOut();
   }