From bd1f8cb7d1d793ec2fceb3f6e3dab589082ebbcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 9 Jul 2019 19:16:53 +0300 Subject: [PATCH] Use NDIlib_find_wait_for_sources() instead of thread::sleep() --- src/lib.rs | 3 +-- src/ndisys.rs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 7037fe2d..989a5a23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,6 @@ mod ndivideosrc; // use gst_plugin::base_src::*; use ndisys::*; use std::ffi::{CStr, CString}; -use std::{thread, time}; use std::collections::HashMap; use std::sync::Mutex; @@ -121,7 +120,7 @@ fn connect_ndi( let p_sources; // TODO Sleep 1s to wait for all sources - thread::sleep(time::Duration::from_millis(2000)); + NDIlib_find_wait_for_sources(pNDI_find, 2000); p_sources = NDIlib_find_get_current_sources(pNDI_find, &mut total_sources as *mut u32); // We need at least one source diff --git a/src/ndisys.rs b/src/ndisys.rs index 30e5ebf4..858ed758 100644 --- a/src/ndisys.rs +++ b/src/ndisys.rs @@ -8,6 +8,10 @@ extern "C" { pub fn NDIlib_find_create_v2( p_create_settings: *const NDIlib_find_create_t, ) -> NDIlib_find_instance_t; + pub fn NDIlib_find_wait_for_sources( + p_instance: NDIlib_find_instance_t, + timeout_in_ms: u32, + ) -> bool; pub fn NDIlib_find_get_current_sources( p_instance: NDIlib_find_instance_t, p_no_sources: *mut u32,