Commit 59dcd03b by taojishou Committed by GitHub

修改hls拉流后closestream崩溃的bug (#1678)

* 修改hls拉流后closestream崩溃的bug

Co-authored-by: 夏楚 <771730766@qq.com>
parent b0beea77
...@@ -378,7 +378,8 @@ void HlsPlayerImp::onPlayResult(const SockException &ex) { ...@@ -378,7 +378,8 @@ void HlsPlayerImp::onPlayResult(const SockException &ex) {
} }
void HlsPlayerImp::onShutdown(const SockException &ex) { void HlsPlayerImp::onShutdown(const SockException &ex) {
if (_demuxer) { while (_demuxer) {
try {
std::weak_ptr<HlsPlayerImp> weak_self = static_pointer_cast<HlsPlayerImp>(shared_from_this()); std::weak_ptr<HlsPlayerImp> weak_self = static_pointer_cast<HlsPlayerImp>(shared_from_this());
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() { static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
...@@ -387,9 +388,12 @@ void HlsPlayerImp::onShutdown(const SockException &ex) { ...@@ -387,9 +388,12 @@ void HlsPlayerImp::onShutdown(const SockException &ex) {
strong_self->onShutdown(ex); strong_self->onShutdown(ex);
} }
}); });
} else { return;
PlayerImp<HlsPlayer, PlayerBase>::onShutdown(ex); } catch (...) {
break;
}
} }
PlayerImp<HlsPlayer, PlayerBase>::onShutdown(ex);
} }
vector<Track::Ptr> HlsPlayerImp::getTracks(bool ready) const { vector<Track::Ptr> HlsPlayerImp::getTracks(bool ready) const {
......
...@@ -45,7 +45,8 @@ void TsPlayerImp::onPlayResult(const SockException &ex) { ...@@ -45,7 +45,8 @@ void TsPlayerImp::onPlayResult(const SockException &ex) {
} }
void TsPlayerImp::onShutdown(const SockException &ex) { void TsPlayerImp::onShutdown(const SockException &ex) {
if (_demuxer) { while (_demuxer) {
try {
std::weak_ptr<TsPlayerImp> weak_self = static_pointer_cast<TsPlayerImp>(shared_from_this()); std::weak_ptr<TsPlayerImp> weak_self = static_pointer_cast<TsPlayerImp>(shared_from_this());
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() { static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();
...@@ -54,9 +55,12 @@ void TsPlayerImp::onShutdown(const SockException &ex) { ...@@ -54,9 +55,12 @@ void TsPlayerImp::onShutdown(const SockException &ex) {
strong_self->onShutdown(ex); strong_self->onShutdown(ex);
} }
}); });
} else { return;
PlayerImp<TsPlayer, PlayerBase>::onShutdown(ex); } catch (...) {
break;
} }
}
PlayerImp<TsPlayer, PlayerBase>::onShutdown(ex);
} }
vector<Track::Ptr> TsPlayerImp::getTracks(bool ready) const { vector<Track::Ptr> TsPlayerImp::getTracks(bool ready) const {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论