Shut down the encoder/decoder thread when Encoding/DecodingComplete is invoked, to avoid potential crash on Android

This commit is contained in:
Hank Peng 2015-11-13 10:01:10 -08:00
parent e014b5ea43
commit baa69f3cd0

View File

@ -364,12 +364,14 @@ class OpenH264VideoEncoder : public GMPVideoEncoder, public RefCounted {
// Release the reference to the external objects, because it is no longer safe to call them // Release the reference to the external objects, because it is no longer safe to call them
host_ = nullptr; host_ = nullptr;
callback_ = nullptr; callback_ = nullptr;
TearDownEncoder();
Release(); Release();
} }
private: private:
virtual ~OpenH264VideoEncoder() { virtual ~OpenH264VideoEncoder() {
// Tear down the internal encoder // Tear down the internal encoder in case of EncodingComplete() not being called
TearDownEncoder(); TearDownEncoder();
} }
@ -741,12 +743,14 @@ class OpenH264VideoDecoder : public GMPVideoDecoder, public RefCounted {
// Release the reference to the external objects, because it is no longer safe to call them // Release the reference to the external objects, because it is no longer safe to call them
host_ = nullptr; host_ = nullptr;
callback_ = nullptr; callback_ = nullptr;
TearDownDecoder();
Release(); Release();
} }
private: private:
virtual ~OpenH264VideoDecoder() { virtual ~OpenH264VideoDecoder() {
// Tear down the internal decoder // Tear down the internal decoder in case of DecodingComplete() not being called
TearDownDecoder(); TearDownDecoder();
} }