Wait for closeEvent thread to finish. Fixes unfinished event when zmc told to restart

This commit is contained in:
Isaac Connor 2021-12-09 12:33:59 -05:00
parent 35bca1d89b
commit 090c803b98
1 changed files with 4 additions and 3 deletions

View File

@ -3047,9 +3047,6 @@ int Monitor::PrimeCapture() {
int Monitor::PreCapture() const { return camera->PreCapture(); }
int Monitor::PostCapture() const { return camera->PostCapture(); }
int Monitor::Close() {
if (close_event_thread.joinable()) {
close_event_thread.join();
}
// Because the stream indexes may change we have to clear out the packetqueue
if (decoder) {
decoder->Stop();
@ -3067,10 +3064,14 @@ int Monitor::Close() {
video_fifo = nullptr;
}
if (close_event_thread.joinable()) {
close_event_thread.join();
}
std::lock_guard<std::mutex> lck(event_mutex);
if (event) {
Info("%s: image_count:%d - Closing event %" PRIu64 ", shutting down", name.c_str(), image_count, event->Id());
closeEvent();
close_event_thread.join();
}
if (camera) camera->Close();
return 1;