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

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

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