X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=nihed-cros-libva%2Fsrc%2Fimage.rs;h=f40059e64713418521ba4d0bf92e5dba36014cde;hb=49bf1d79384ecf1b28822101233719fb1c1b29b1;hp=804414568f213875f5650a4f186060e92b3a24d8;hpb=683627242f69bed0b818d976d4b03d651e529697;p=nihav-player.git diff --git a/nihed-cros-libva/src/image.rs b/nihed-cros-libva/src/image.rs index 8044145..f40059e 100644 --- a/nihed-cros-libva/src/image.rs +++ b/nihed-cros-libva/src/image.rs @@ -2,12 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use anyhow::Result; - use crate::bindings; use crate::picture::Picture; use crate::picture::PictureSync; -use crate::status::Status; +use crate::status::*; /// Wrapper around `VAImage` that is tied to the lifetime of a given `Picture`. /// @@ -50,7 +48,7 @@ impl<'a> Image<'a> { width: u32, height: u32, derive: bool, - ) -> Result { + ) -> VAResult { // An all-zero byte-pattern is a valid initial value for `VAImage`. let mut image: bindings::VAImage = Default::default(); let mut addr = std::ptr::null_mut(); @@ -66,7 +64,7 @@ impl<'a> Image<'a> { // Safe since `picture.inner.context` represents a valid `VAContext` and `image` has been // successfully created at this point. - match Status(unsafe { + match (unsafe { bindings::vaMapBuffer(picture.display().handle(), image.buf, &mut addr) }) .check() @@ -104,18 +102,18 @@ impl<'a> Image<'a> { format: &mut bindings::VAImageFormat, width: u32, height: u32, - ) -> Result<()> { + ) -> VAResult<()> { let dpy = picture.display().handle(); // Safe because `picture.inner.context` represents a valid // VAContext. - Status(unsafe { bindings::vaCreateImage(dpy, format, width as i32, height as i32, image) }) + (unsafe { bindings::vaCreateImage(dpy, format, width as i32, height as i32, image) }) .check()?; // Safe because `picture.inner.context` represents a valid VAContext, // `picture.surface` represents a valid VASurface and `image` represents // a valid `VAImage`. - if let Err(e) = Status(unsafe { + if let Err(e) = (unsafe { bindings::vaGetImage( dpy, picture.surface().id(), @@ -146,12 +144,12 @@ impl<'a> Image<'a> { fn derive_image( picture: &'a Picture, image: &mut bindings::VAImage, - ) -> Result { - let status = Status(unsafe { + ) -> VAResult { + let status = unsafe { bindings::vaDeriveImage(picture.display().handle(), picture.surface().id(), image) - }); + }; - if status.0 == bindings::constants::VA_STATUS_ERROR_OPERATION_FAILED as i32 { + if status == bindings::constants::VA_STATUS_ERROR_OPERATION_FAILED as i32 { // The implementation can't derive, try the create API instead. Ok(false) } else {