Commit 9f07f980 by xiongziliang

修复bug

parent 015a61c4
Subproject commit e54bd41dbf832ecf49358f4b877372808e8be587 Subproject commit 337e0ff2f9552b7fb0c1678598288194cc203bf9
...@@ -242,6 +242,10 @@ void RtmpSession::doPlayResponse(const string &err,bool tryDelay,const std::shar ...@@ -242,6 +242,10 @@ void RtmpSession::doPlayResponse(const string &err,bool tryDelay,const std::shar
return; return;
} }
//切换到自己的线程再回复 //切换到自己的线程再回复
//如果触发 kBroadcastMediaChanged 事件的线程与本RtmpSession绑定的线程相同,
//那么strongSelf->async操作可能是同步操作,
//通过指定参数may_sync为false确保 NoticeCenter::delListener操作延后执行,
//以便防止遍历事件监听对象map时做删除操作
strongSelf->async([task_id,weakSelf,pToken,media_info](){ strongSelf->async([task_id,weakSelf,pToken,media_info](){
auto strongSelf = weakSelf.lock(); auto strongSelf = weakSelf.lock();
if(!strongSelf) { if(!strongSelf) {
...@@ -252,9 +256,11 @@ void RtmpSession::doPlayResponse(const string &err,bool tryDelay,const std::shar ...@@ -252,9 +256,11 @@ void RtmpSession::doPlayResponse(const string &err,bool tryDelay,const std::shar
strongSelf->doPlayResponse("",false,pToken); strongSelf->doPlayResponse("",false,pToken);
//取消延时任务,防止多次回复 //取消延时任务,防止多次回复
strongSelf->cancelDelyaTask(); strongSelf->cancelDelyaTask();
//取消事件监听 //取消事件监听
//在事件触发时不能在当前线程移除事件监听,否则会导致遍历map时做删除操作导致程序崩溃
NoticeCenter::Instance().delListener(task_id,Broadcast::kBroadcastMediaChanged); NoticeCenter::Instance().delListener(task_id,Broadcast::kBroadcastMediaChanged);
}); }, false);
} }
}); });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论