Add NdiInstance struct that implement Send

https://doc.rust-lang.org/book/second-edition/ch19-03-advanced-traits.html#the-newtype-pattern-to-implement-external-traits-on-external-types

error[E0277]: the trait bound `*mut std::os::raw::c_void: std::marker::Send` is not satisfied in `ndisrc::State`
   --> src/ndisrc.rs:276:6
       |
       276 | impl ObjectImpl<BaseSrc> for NdiSrc {
           |      ^^^^^^^^^^^^^^^^^^^ `*mut std::os::raw::c_void` cannot be sent between threads safely
               |
                   = help: within `ndisrc::State`, the trait `std::marker::Send` is not implemented for `*mut std::os::raw::c_void`
                       = note: required because it appears within the type `std::option::Option<*mut std::os::raw::c_void>`
                           = note: required because it appears within the type `ndisrc::State`
                               = note: required because of the requirements on the impl of `std::marker::Sync` for `std::sync::Mutex<ndisrc::State>`
                                   = note: required because it appears within the type `ndisrc::NdiSrc`

error[E0277]: the trait bound `*mut std::os::raw::c_void: std::marker::Send` is not satisfied in `ndisrc::State`
   --> src/ndisrc.rs:405:6
       |
       405 | impl ElementImpl<BaseSrc> for NdiSrc {
           |      ^^^^^^^^^^^^^^^^^^^^ `*mut std::os::raw::c_void` cannot be sent between threads safely
               |
                   = help: within `ndisrc::State`, the trait `std::marker::Send` is not implemented for `*mut std::os::raw::c_void`
                       = note: required because it appears within the type `std::option::Option<*mut std::os::raw::c_void>`
                           = note: required because it appears within the type `ndisrc::State`
                               = note: required because of the requirements on the impl of `std::marker::Sync` for `std::sync::Mutex<ndisrc::State>`
                                   = note: required because it appears within the type `ndisrc::NdiSrc`

error[E0277]: the trait bound `*mut std::os::raw::c_void: std::marker::Send` is not satisfied in `ndisrc::State`
   --> src/ndisrc.rs:424:6
       |
       424 | impl BaseSrcImpl<BaseSrc> for NdiSrc {
           |      ^^^^^^^^^^^^^^^^^^^^ `*mut std::os::raw::c_void` cannot be sent between threads safely
               |
                   = help: within `ndisrc::State`, the trait `std::marker::Send` is not implemented for `*mut std::os::raw::c_void`
                       = note: required because it appears within the type `std::option::Option<*mut std::os::raw::c_void>`
                           = note: required because it appears within the type `ndisrc::State`
                               = note: required because of the requirements on the impl of `std::marker::Sync` for `std::sync::Mutex<ndisrc::State>`
                                   = note: required because it appears within the type `ndisrc::NdiSrc`

error: aborting due to 3 previous errors
This commit is contained in:
rubenrua 2018-04-16 16:44:00 +00:00
parent 892eb29c3b
commit 1377916b3b
2 changed files with 10 additions and 3 deletions

View file

@ -147,6 +147,12 @@ impl Default for NDIlib_recv_create_v3_t {
pub type NDIlib_recv_instance_t = *mut ::std::os::raw::c_void;
//Rust wrapper around *mut ::std::os::raw::c_void
pub struct NdiInstance (NDIlib_recv_instance_t);
unsafe impl ::std::marker::Send for NdiInstance {}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NDIlib_tally_t {

View file

@ -116,7 +116,7 @@ static PROPERTIES: [Property; 6] = [
// and sample offset
struct State {
info: Option<gst_video::VideoInfo>,
recv: Option<NDIlib_recv_instance_t>,
recv: Option<NdiInstance>,
// sample_offset: u64,
// sample_stop: Option<u64>,
// accumulator: f64,
@ -126,7 +126,7 @@ impl Default for State {
fn default() -> State {
State {
info: None,
//recv: None,
recv: None,
// sample_offset: 0,
// sample_stop: None,
// accumulator: 0.0,
@ -440,7 +440,8 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
let mut state = self.state.lock().unwrap();
*state = State {
info: Some(info),
info: Some(info),
recv: None
};
// element.set_blocksize(info.bpf() * (*self.settings.lock().unwrap()).samples_per_buffer);