Skip to content

Commit

Permalink
Update dependencies and switch to rust stable
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosland committed Sep 15, 2018
1 parent 37d6b9b commit d1bce8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ exclude = [ "ci/*" ]
build = "build.rs"

[dependencies]
mmal-sys = "0.1.0-1"
mmal-sys = { version = "0.1.0-2", path = "./mmal-sys" }
libc = "0.2"
parking_lot = {version = "0.5", features = ["nightly"]}
lock_api = "0.1.3"
parking_lot = "0.6"
scopeguard = "0.3.3"

[features]
Expand Down
14 changes: 9 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
//!
//! [mmal-sys]: https://crates.io/crates/mmal-sys
#![feature(ptr_internals)]
extern crate libc;
extern crate mmal_sys as ffi;
extern crate parking_lot;
extern crate lock_api;
#[macro_use(defer_on_unwind)]
extern crate scopeguard;
// extern crate futures;
Expand All @@ -24,6 +24,7 @@ use std::sync::{Arc, Once, ONCE_INIT};
use std::sync::mpsc;
use std::ptr;
use parking_lot::Mutex;
use lock_api::RawMutex;

mod error;
mod settings;
Expand Down Expand Up @@ -947,12 +948,15 @@ impl SeriousCamera {
}

pub fn take(&mut self) -> Result<mpsc::Receiver<Option<BufferGuard>>, CameraError> {
self.mutex.raw_lock();
unsafe {
self.mutex.raw().lock();
}

let mut buffer_port_ptr = ptr::null_mut();
let mutex = Arc::clone(&self.mutex);

defer_on_unwind!{{
unsafe { mutex.raw_unlock() };
unsafe { mutex.force_unlock() };
}}

self.do_take(&mut buffer_port_ptr).map_err(|e| {
Expand All @@ -962,7 +966,7 @@ impl SeriousCamera {
{
drop_port_userdata(buffer_port_ptr);
}
self.mutex.raw_unlock();
self.mutex.force_unlock();
}
e
})
Expand Down Expand Up @@ -1221,7 +1225,7 @@ impl SimpleCamera {
pub fn drop_port_userdata(port: *mut ffi::MMAL_PORT_T) {
unsafe {
let userdata: Box<Userdata> = Box::from_raw((*port).userdata as *mut Userdata);
userdata._guard.raw_unlock();
userdata._guard.force_unlock();
drop(userdata);
(*port).userdata = ptr::null_mut() as *mut ffi::MMAL_PORT_USERDATA_T;
}
Expand Down

0 comments on commit d1bce8e

Please sign in to comment.