diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index 33e5f3c0..c88d3328 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -389,12 +389,11 @@ void MultiMediaSourceMuxer::createGopCacheIfNeed() { return; } weak_ptr weak_self = shared_from_this(); - _ring = std::make_shared(1024, [weak_self](int size) { - auto strong_self = weak_self.lock(); - if (strong_self) { + auto src = std::make_shared(weak_self.lock()); + _ring = std::make_shared(1024, [weak_self, src](int size) { + if (auto strong_self = weak_self.lock()) { // 切换到归属线程 strong_self->getOwnerPoller(MediaSource::NullMediaSource())->async([=]() { - auto src = std::make_shared(strong_self); strong_self->onReaderChanged(*src, strong_self->totalReaderCount()); }); }