Use NDIlib_find_wait_for_sources() instead of thread::sleep()

This commit is contained in:
Sebastian Dröge 2019-07-09 19:16:53 +03:00
parent def42b5514
commit bd1f8cb7d1
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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,