bugfix: 修复所有Player的删除器使用同一个线程进行析构导致崩溃的问题 (#3672)

Player的删除器release_func是static类型,weak_poller不会更新了。后面析构使用的就不是正确的poller线程了。
This commit is contained in:
sgzed 2024-06-28 12:43:56 +08:00 committed by xia-chu
parent 5a717186dd
commit cf6066b36e

View File

@ -24,7 +24,7 @@ namespace mediakit {
PlayerBase::Ptr PlayerBase::createPlayer(const EventPoller::Ptr &in_poller, const string &url_in) {
auto poller = in_poller ? in_poller : EventPollerPool::Instance().getPoller();
std::weak_ptr<EventPoller> weak_poller = poller;
static auto release_func = [weak_poller](PlayerBase *ptr) {
auto release_func = [weak_poller](PlayerBase *ptr) {
if (auto poller = weak_poller.lock()) {
poller->async([ptr]() {
onceToken token(nullptr, [&]() { delete ptr; });