replay: fix hanging on exit if stream thread has not been started yet (#22770)

old-commit-hash: 6f78cc77fc
commatwo_master
Dean Lee 4 years ago committed by GitHub
parent 950211e15f
commit 993aa64067
  1. 2
      selfdrive/ui/replay/filereader.cc
  2. 1
      selfdrive/ui/replay/framereader.cc
  3. 15
      selfdrive/ui/replay/replay.cc

@ -18,7 +18,7 @@ std::string cacheFilePath(const std::string &url) {
return comma_cache.back() == '/' ? comma_cache : comma_cache + "/"; return comma_cache.back() == '/' ? comma_cache : comma_cache + "/";
}(); }();
return cache_path + sha256(getUrlWithoutQuery(url));; return cache_path + sha256(getUrlWithoutQuery(url));
} }
std::string FileReader::read(const std::string &file, std::atomic<bool> *abort) { std::string FileReader::read(const std::string &file, std::atomic<bool> *abort) {

@ -44,7 +44,6 @@ FrameReader::FrameReader(bool local_cache, int chunk_size, int retries) : FileRe
av_frame_ = av_frame_alloc(); av_frame_ = av_frame_alloc();
rgb_frame_ = av_frame_alloc(); rgb_frame_ = av_frame_alloc();
yuv_frame_ = av_frame_alloc();; yuv_frame_ = av_frame_alloc();;
} }
FrameReader::~FrameReader() { FrameReader::~FrameReader() {

@ -41,15 +41,16 @@ Replay::~Replay() {
} }
void Replay::stop() { void Replay::stop() {
if (stream_thread_ == nullptr) return; if (!stream_thread_ && segments_.empty()) return;
qDebug() << "shutdown: in progress..."; qDebug() << "shutdown: in progress...";
exit_ = updating_events_ = true; if (stream_thread_ != nullptr) {
stream_cv_.notify_one(); exit_ = updating_events_ = true;
stream_thread_->quit(); stream_cv_.notify_one();
stream_thread_->wait(); stream_thread_->quit();
stream_thread_ = nullptr; stream_thread_->wait();
stream_thread_ = nullptr;
}
segments_.clear(); segments_.clear();
camera_server_.reset(nullptr); camera_server_.reset(nullptr);
qDebug() << "shutdown: done"; qDebug() << "shutdown: done";

Loading…
Cancel
Save