nihed-cros-libva: use simple error enum instead of anyhow crate
[nihav-player.git] / nihed-cros-libva / src / config.rs
index af1db852bc659a8fe726053fdea854be2ac4438c..4ae3fc7766c4ee7896c199947a86cd65d87cc812 100644 (file)
@@ -4,12 +4,10 @@
 
 use std::rc::Rc;
 
-use anyhow::Result;
-
 use crate::bindings;
 use crate::display::Display;
 use crate::generic_value::GenericValue;
-use crate::status::Status;
+use crate::status::*;
 
 /// A configuration for a given [`Display`].
 pub struct Config {
@@ -25,14 +23,14 @@ impl Config {
         mut attrs: Vec<bindings::VAConfigAttrib>,
         profile: bindings::VAProfile::Type,
         entrypoint: bindings::VAEntrypoint::Type,
-    ) -> Result<Self> {
+    ) -> VAResult<Self> {
         let mut config_id = 0u32;
 
         // Safe because `self` represents a valid `VADisplay`.
         //
         // The `attrs` vector is also properly initialized and its actual size is passed to
         // `vaCreateConfig`, so it is impossible to write past the end of its storage by mistake.
-        Status(unsafe {
+        (unsafe {
             bindings::vaCreateConfig(
                 display.handle(),
                 profile,
@@ -60,12 +58,12 @@ impl Config {
     // This function queries for all supported attributes for this configuration. In particular, if
     // the underlying hardware supports the creation of VA surfaces in various formats, then this
     // function will enumerate all pixel formats that are supported.
-    fn query_surface_attributes(&mut self) -> Result<Vec<bindings::VASurfaceAttrib>> {
+    fn query_surface_attributes(&mut self) -> VAResult<Vec<bindings::VASurfaceAttrib>> {
         // Safe because `self` represents a valid VAConfig. We first query how
         // much space is needed by the C API by passing in NULL in the first
         // call to `vaQuerySurfaceAttributes`.
         let attrs_len: std::os::raw::c_uint = 0;
-        Status(unsafe {
+        (unsafe {
             bindings::vaQuerySurfaceAttributes(
                 self.display.handle(),
                 self.id,
@@ -79,7 +77,7 @@ impl Config {
         // Safe because we allocate a vector with the required capacity as
         // returned by the initial call to vaQuerySurfaceAttributes. We then
         // pass a valid pointer to it.
-        Status(unsafe {
+        (unsafe {
             bindings::vaQuerySurfaceAttributes(
                 self.display.handle(),
                 self.id,
@@ -103,7 +101,7 @@ impl Config {
     pub fn query_surface_attributes_by_type(
         &mut self,
         attr_type: bindings::VASurfaceAttribType::Type,
-    ) -> Result<Vec<GenericValue>> {
+    ) -> VAResult<Vec<GenericValue>> {
         let surface_attributes = self.query_surface_attributes()?;
 
         surface_attributes
@@ -118,7 +116,7 @@ impl Drop for Config {
     fn drop(&mut self) {
         // Safe because `self` represents a valid Config.
         let status =
-            Status(unsafe { bindings::vaDestroyConfig(self.display.handle(), self.id) }).check();
+            (unsafe { bindings::vaDestroyConfig(self.display.handle(), self.id) }).check();
         if status.is_err() {
             println!("vaDestroyConfig failed: {}", status.unwrap_err());
         }