Merge pull request #2215 from pengyanhai/master
Tear down the OpenH264 encoder and decoder properly to avoid potential crash and memory leak
This commit is contained in:
commit
24916a652e
@ -368,7 +368,22 @@ class OpenH264VideoEncoder : public GMPVideoEncoder, public RefCounted {
|
||||
|
||||
private:
|
||||
virtual ~OpenH264VideoEncoder() {
|
||||
// Tear down the internal encoder
|
||||
TearDownEncoder();
|
||||
}
|
||||
|
||||
void TearDownEncoder() {
|
||||
// Stop the worker thread first
|
||||
if (worker_thread_) {
|
||||
worker_thread_->Join();
|
||||
worker_thread_ = nullptr;
|
||||
}
|
||||
|
||||
// Destroy OpenH264 encoder
|
||||
if (encoder_) {
|
||||
WelsDestroySVCEncoder(encoder_);
|
||||
encoder_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Error (GMPErr error) {
|
||||
@ -727,8 +742,23 @@ class OpenH264VideoDecoder : public GMPVideoDecoder, public RefCounted {
|
||||
|
||||
private:
|
||||
virtual ~OpenH264VideoDecoder() {
|
||||
// Tear down the internal decoder
|
||||
TearDownDecoder();
|
||||
}
|
||||
|
||||
void TearDownDecoder() {
|
||||
// Stop the worker thread first
|
||||
if (worker_thread_) {
|
||||
worker_thread_->Join();
|
||||
worker_thread_ = nullptr;
|
||||
}
|
||||
|
||||
// Destroy OpenH264 decoder
|
||||
if (decoder_) {
|
||||
WelsDestroyDecoder(decoder_);
|
||||
decoder_ = nullptr;
|
||||
}
|
||||
}
|
||||
void Error (GMPErr error) {
|
||||
if (callback_) {
|
||||
callback_->Error (error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user