nihed-cros-libva: use simple error enum instead of anyhow crate
[nihav-player.git] / nihed-cros-libva / src / image.rs
index 804414568f213875f5650a4f186060e92b3a24d8..f40059e64713418521ba4d0bf92e5dba36014cde 100644 (file)
@@ -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<Self> {
+    ) -> VAResult<Self> {
         // 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<PictureSync>,
         image: &mut bindings::VAImage,
-    ) -> Result<bool> {
-        let status = Status(unsafe {
+    ) -> VAResult<bool> {
+        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 {