mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 03:10:04 +08:00
修复hls/ts拉流崩溃问题:#2057
This commit is contained in:
parent
9498b96b95
commit
918b1fce6c
@ -380,10 +380,14 @@ void HlsPlayerImp::onPlayResult(const SockException &ex) {
|
|||||||
void HlsPlayerImp::onShutdown(const SockException &ex) {
|
void HlsPlayerImp::onShutdown(const SockException &ex) {
|
||||||
while (_demuxer) {
|
while (_demuxer) {
|
||||||
try {
|
try {
|
||||||
|
//shared_from_this()可能抛异常
|
||||||
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());
|
||||||
|
if (_decoder) {
|
||||||
|
_decoder->flush();
|
||||||
|
}
|
||||||
|
//等待所有frame flush输出后,再触发onShutdown事件
|
||||||
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
|
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
|
||||||
auto strong_self = weak_self.lock();
|
if (auto strong_self = weak_self.lock()) {
|
||||||
if (strong_self) {
|
|
||||||
strong_self->_demuxer = nullptr;
|
strong_self->_demuxer = nullptr;
|
||||||
strong_self->onShutdown(ex);
|
strong_self->onShutdown(ex);
|
||||||
}
|
}
|
||||||
@ -393,9 +397,6 @@ void HlsPlayerImp::onShutdown(const SockException &ex) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_decoder) {
|
|
||||||
_decoder->flush();
|
|
||||||
}
|
|
||||||
PlayerImp<HlsPlayer, PlayerBase>::onShutdown(ex);
|
PlayerImp<HlsPlayer, PlayerBase>::onShutdown(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,10 +47,14 @@ void TsPlayerImp::onPlayResult(const SockException &ex) {
|
|||||||
void TsPlayerImp::onShutdown(const SockException &ex) {
|
void TsPlayerImp::onShutdown(const SockException &ex) {
|
||||||
while (_demuxer) {
|
while (_demuxer) {
|
||||||
try {
|
try {
|
||||||
|
//shared_from_this()可能抛异常
|
||||||
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());
|
||||||
|
if (_decoder) {
|
||||||
|
_decoder->flush();
|
||||||
|
}
|
||||||
|
//等待所有frame flush输出后,再触发onShutdown事件
|
||||||
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
|
static_pointer_cast<HlsDemuxer>(_demuxer)->pushTask([weak_self, ex]() {
|
||||||
auto strong_self = weak_self.lock();
|
if (auto strong_self = weak_self.lock()) {
|
||||||
if (strong_self) {
|
|
||||||
strong_self->_demuxer = nullptr;
|
strong_self->_demuxer = nullptr;
|
||||||
strong_self->onShutdown(ex);
|
strong_self->onShutdown(ex);
|
||||||
}
|
}
|
||||||
@ -60,9 +64,6 @@ void TsPlayerImp::onShutdown(const SockException &ex) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_decoder) {
|
|
||||||
_decoder->flush();
|
|
||||||
}
|
|
||||||
PlayerImp<TsPlayer, PlayerBase>::onShutdown(ex);
|
PlayerImp<TsPlayer, PlayerBase>::onShutdown(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user