防止对象析构时抛异常导致的崩溃

This commit is contained in:
xia-chu
2024-07-05 21:05:59 +08:00
parent 8815776b81
commit b4fecdc929
7 changed files with 56 additions and 8 deletions

View File

@@ -48,7 +48,13 @@ public:
*/
RtmpMediaSource(const MediaTuple& tuple, int ring_size = RTMP_GOP_SIZE): MediaSource(RTMP_SCHEMA, tuple), _ring_size(ring_size) {}
~RtmpMediaSource() override { flush(); }
~RtmpMediaSource() override {
try {
flush();
} catch (std::exception &ex) {
WarnL << ex.what();
}
}
/**
* 获取媒体源的环形缓冲