修复获取推流所有权导致引用计数紊乱的bug: #1397

This commit is contained in:
xiongziliang 2022-01-26 00:36:57 +08:00
parent 756ec1364b
commit 3bf6ec8939

View File

@ -91,7 +91,8 @@ std::shared_ptr<void> MediaSource::getOwnership() {
return nullptr; return nullptr;
} }
weak_ptr<MediaSource> weak_self = shared_from_this(); weak_ptr<MediaSource> weak_self = shared_from_this();
return std::shared_ptr<void>(this, [weak_self](void *ptr) { //确保返回的Ownership智能指针不为空0x01无实际意义
return std::shared_ptr<void>((void *) 0x01, [weak_self](void *ptr) {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
if (strong_self) { if (strong_self) {
strong_self->_owned.clear(); strong_self->_owned.clear();