@@ -182,27 +182,6 @@ namespace platf::dxgi {
182182 release_frame ();
183183 }
184184
185- void
186- display_base_t::high_precision_sleep (std::chrono::nanoseconds duration) {
187- if (!timer) {
188- BOOST_LOG (error) << " Attempting high_precision_sleep() with uninitialized timer" ;
189- return ;
190- }
191- if (duration < 0s) {
192- BOOST_LOG (error) << " Attempting high_precision_sleep() with negative duration" ;
193- return ;
194- }
195- if (duration > 5s) {
196- BOOST_LOG (error) << " Attempting high_precision_sleep() with unexpectedly large duration (>5s)" ;
197- return ;
198- }
199-
200- LARGE_INTEGER due_time;
201- due_time.QuadPart = duration.count () / -100 ;
202- SetWaitableTimer (timer.get (), &due_time, 0 , nullptr , nullptr , false );
203- WaitForSingleObject (timer.get (), INFINITE);
204- }
205-
206185 capture_e
207186 display_base_t::capture (const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) {
208187 auto adjust_client_frame_rate = [&]() -> DXGI_RATIONAL {
@@ -268,7 +247,7 @@ namespace platf::dxgi {
268247 status = capture_e::timeout;
269248 }
270249 else {
271- high_precision_sleep (sleep_period);
250+ timer-> sleep_for (sleep_period);
272251 std::chrono::nanoseconds overshoot_ns = std::chrono::steady_clock::now () - sleep_target;
273252 log_sleep_overshoot (overshoot_ns);
274253
@@ -799,15 +778,9 @@ namespace platf::dxgi {
799778 << " Max Full Luminance : " sv << desc1.MaxFullFrameLuminance << " nits" sv;
800779 }
801780
802- // Use CREATE_WAITABLE_TIMER_HIGH_RESOLUTION if supported (Windows 10 1809+)
803- timer.reset (CreateWaitableTimerEx (nullptr , nullptr , CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS));
804- if (!timer) {
805- timer.reset (CreateWaitableTimerEx (nullptr , nullptr , 0 , TIMER_ALL_ACCESS));
806- if (!timer) {
807- auto winerr = GetLastError ();
808- BOOST_LOG (error) << " Failed to create timer: " sv << winerr;
809- return -1 ;
810- }
781+ if (!timer || !*timer) {
782+ BOOST_LOG (error) << " Uninitialized high precision timer" ;
783+ return -1 ;
811784 }
812785
813786 return 0 ;
0 commit comments