Skip to content

Commit

Permalink
Add an extra assertion verifying video frame size, and fix an incorre…
Browse files Browse the repository at this point in the history
…ct variable name (#10)
  • Loading branch information
pheki authored and koute committed Aug 7, 2019
1 parent 5798ebb commit 9248d74
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,15 @@ pub struct RuntimeHandle {
impl RuntimeHandle {
pub fn upload_video_frame( &mut self, data: &[u8] ) {
assert!( self.upload_video_frame_already_called == false, "You can only call upload_video_frame() once per frame!" );
assert!( data.len() as u32 >= self.video_width * self.video_height * self.video_frame_bytes_per_pixel, "Data too small to upload!" );

self.upload_video_frame_already_called = true;
let bytes = data.as_ptr() as *const libc::c_void;
let width = self.video_width as libc::c_uint;
let height = self.video_height as libc::c_uint;
let bytes_per_pixel = (self.video_width * self.video_frame_bytes_per_pixel) as usize;
let bytes_per_line = (self.video_width * self.video_frame_bytes_per_pixel) as usize;
unsafe {
(self.video_refresh_callback)( bytes, width, height, bytes_per_pixel );
(self.video_refresh_callback)( bytes, width, height, bytes_per_line );
}
}

Expand Down

0 comments on commit 9248d74

Please sign in to comment.