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

This commit is contained in:
xiongziliang 2023-11-04 22:24:55 +08:00
parent 9f28384cd9
commit 2206b031a9
2 changed files with 13 additions and 3 deletions

View File

@ -34,8 +34,12 @@ MP4Recorder::MP4Recorder(const string &path, const string &vhost, const string &
}
MP4Recorder::~MP4Recorder() {
flush();
closeFile();
try {
flush();
closeFile();
} catch (std::exception &ex) {
WarnL << ex.what();
}
}
void MP4Recorder::createFile() {

View File

@ -26,7 +26,13 @@ public:
_media_src = std::make_shared<TSMediaSource>(tuple);
}
~TSMediaSourceMuxer() override { MpegMuxer::flush(); };
~TSMediaSourceMuxer() override {
try {
MpegMuxer::flush();
} catch (std::exception &ex) {
WarnL << ex.what();
}
};
void setListener(const std::weak_ptr<MediaSourceEvent> &listener){
setDelegate(listener);