From dd384e9e6d7694e05e5b7dee61013d3ada4e90ec Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 8 Dec 2017 21:29:05 -0500 Subject: [PATCH] reduce wait time when waiting for first frame --- src/zm_monitor.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 1576eedeb..57c8cc880 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -3258,9 +3258,12 @@ void Monitor::get_ref_image() { && ! zm_terminate ) { Warning( "Waiting for capture daemon" ); - usleep( 100000 ); + usleep( 50000 ); } - image_buffer[shared_data->last_write_index].mutex.lock(); - ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[shared_data->last_write_index].image->Buffer(), camera->ImageSize()); - image_buffer[shared_data->last_write_index].mutex.unlock(); + int last_write_index = shared_data->last_write_index ; + + Warning( "Waiting for capture daemon unlock" ); + image_buffer[last_write_index].mutex.lock(); + ref_image.Assign( width, height, camera->Colours(), camera->SubpixelOrder(), image_buffer[last_write_index].image->Buffer(), camera->ImageSize()); + image_buffer[last_write_index].mutex.unlock(); }