mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-05 10:58:11 +08:00
HLS: 修复hls直播ts/m3u8文件更新导致mmap失效,触发bus error的bug
This commit is contained in:
@@ -132,8 +132,10 @@ void HlsMaker::flushLastSegment(bool eof){
|
||||
_seg_dur_list.push_back(std::make_tuple(seg_dur, std::move(_last_file_name)));
|
||||
_last_file_name.clear();
|
||||
delOldSegment();
|
||||
makeIndexFile(eof);
|
||||
//先flush ts切片,否则可能存在ts文件未写入完毕就被访问的情况
|
||||
onFlushLastSegment(seg_dur);
|
||||
//然后写m3u8文件
|
||||
makeIndexFile(eof);
|
||||
}
|
||||
|
||||
bool HlsMaker::isLive() {
|
||||
|
||||
@@ -125,10 +125,11 @@ void HlsMakerImp::onWriteHls(const char *data, size_t len) {
|
||||
}
|
||||
|
||||
void HlsMakerImp::onFlushLastSegment(uint32_t duration_ms) {
|
||||
//关闭并flush文件到磁盘
|
||||
_file = nullptr;
|
||||
|
||||
GET_CONFIG(bool, broadcastRecordTs, Hls::kBroadcastRecordTs);
|
||||
if (broadcastRecordTs) {
|
||||
//关闭ts文件以便获取正确的文件大小
|
||||
_file = nullptr;
|
||||
_info.time_len = duration_ms / 1000.0f;
|
||||
struct stat fileData;
|
||||
stat(_info.file_path.data(), &fileData);
|
||||
|
||||
Reference in New Issue
Block a user