From 8fb24547e4d068cdcd491e59ddc451b3a252ea4b Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 30 七月 2019 15:42:53 +0800 Subject: [PATCH] update rec frame id --- csrc/buz/recorder.cpp | 28 +++++++++++++--------------- 1 files changed, 13 insertions(+), 15 deletions(-) diff --git a/csrc/buz/recorder.cpp b/csrc/buz/recorder.cpp index 2267bf3..d80cea9 100644 --- a/csrc/buz/recorder.cpp +++ b/csrc/buz/recorder.cpp @@ -24,7 +24,6 @@ ,minduration(10 * 25) ,end_frame(minduration) ,cur_frame(-1) - ,thread_(nullptr) ,stop_recorder_(false) ,id_(id) ,id_frame_(0) @@ -34,13 +33,8 @@ {} Recorder::~Recorder(){ - if(thread_){ - stop_recorder_.store(true); - cv_.notify_one(); - thread_->join(); - } - if(out_) - delete out_; + stop_recorder_.store(true); + cv_.notify_one(); } int Recorder::init_writer(){ @@ -88,6 +82,9 @@ void Recorder::end_writer(){ if(cur_frame == -1) return; out_->endWriter(); + logIt("INDEX %d, FILE %s, CURFrame %d, ENDFrame %d\n", + file_frame_index_, file_path_.c_str(), cur_frame, end_frame); + //reinit cur_frame clear list pkt { std::lock_guard<std::mutex> locker(mutex_pkt_); @@ -98,7 +95,6 @@ //callback to frame index and path if(func_rec_info_){ func_rec_info_(id_,file_frame_index_, file_path_); - // logIt("recoder index %d, file name %s\n", file_frame_index_, file_path_.c_str()); }else{ // logIt("recorder has no func_rec_info"); } @@ -149,13 +145,13 @@ } } } + if (out_){ + delete out_; + out_ = NULL; + } } int Recorder::Run(const char* output, const int mind, const int maxd){ - if(thread_){ - logIt("recorder already run"); - return 0; - } dir_ = output; int ret = init_writer(); @@ -173,9 +169,9 @@ logIt("min %d max %d endcount %d", minduration, maxduration, end_frame); - thread_.reset(new std::thread([&]{ + std::thread([&]{ run_thread(); - })); + }).detach(); return 0; } @@ -193,6 +189,7 @@ end_frame = maxduration; } } + logIt("FIRE REC FRAME ID: %lld", id); return 0; } @@ -222,6 +219,7 @@ cv_.notify_one(); } + logIt("CACHE PACKET FRAME ID %lld", pkt.id); return 0; } -- Gitblit v1.8.0