X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;ds=sidebyside;f=nihed-cros-libva%2Fsrc%2Fpicture.rs;h=0d28b517edace6d979468f410464572a9e62f5b5;hb=49bf1d79384ecf1b28822101233719fb1c1b29b1;hp=acb41b8eee01ce1123f103d8935f0ee6eb15857f;hpb=683627242f69bed0b818d976d4b03d651e529697;p=nihav-player.git diff --git a/nihed-cros-libva/src/picture.rs b/nihed-cros-libva/src/picture.rs index acb41b8..0d28b51 100644 --- a/nihed-cros-libva/src/picture.rs +++ b/nihed-cros-libva/src/picture.rs @@ -8,14 +8,11 @@ use std::cell::RefMut; use std::marker::PhantomData; use std::rc::Rc; -use anyhow::anyhow; -use anyhow::Result; - use crate::bindings; use crate::buffer::Buffer; use crate::context::Context; use crate::display::Display; -use crate::status::Status; +use crate::status::*; use crate::surface::Surface; // Use the sealed trait pattern to make sure that new states are not created in caller code. More @@ -143,10 +140,10 @@ impl Picture { } /// Wrapper around `vaBeginPicture`. - pub fn begin(self) -> Result> { + pub fn begin(self) -> VAResult> { // Safe because `self.inner.context` represents a valid VAContext and // `self.inner.surface` represents a valid VASurface. - Status(unsafe { + (unsafe { bindings::vaBeginPicture( self.inner.context.display().handle(), self.inner.context.id(), @@ -164,12 +161,12 @@ impl Picture { impl Picture { /// Wrapper around `vaRenderPicture`. - pub fn render(self) -> Result> { + pub fn render(self) -> VAResult> { // Safe because `self.inner.context` represents a valid `VAContext` and `self.inner.surface` // represents a valid `VASurface`. `buffers` point to a Rust struct and the vector length is // passed to the C function, so it is impossible to write past the end of the vector's // storage by mistake. - Status(unsafe { + (unsafe { bindings::vaRenderPicture( self.inner.context.display().handle(), self.inner.context.id(), @@ -188,9 +185,9 @@ impl Picture { impl Picture { /// Wrapper around `vaEndPicture`. - pub fn end(self) -> Result> { + pub fn end(self) -> VAResult> { // Safe because `self.inner.context` represents a valid `VAContext`. - Status(unsafe { + (unsafe { bindings::vaEndPicture( self.inner.context.display().handle(), self.inner.context.id(), @@ -206,7 +203,7 @@ impl Picture { impl Picture { /// Syncs the picture, ensuring that all pending operations are complete when this call returns. - pub fn sync(self) -> std::result::Result, (anyhow::Error, Self)> { + pub fn sync(self) -> std::result::Result, (VAError, Self)> { let res = self.inner.surface.borrow().sync(); match res { @@ -222,7 +219,7 @@ impl Picture { /// /// This call can be used to implement a non-blocking path, wherein a decoder queries the status /// of the surface after each decode operation instead of blocking on it. - pub fn query_status(&self) -> Result { + pub fn query_status(&self) -> VAResult { self.inner.surface.borrow_mut().query_status() } } @@ -252,10 +249,10 @@ impl Picture { impl Picture { /// Reclaim ownership of the Surface this picture has been created from, consuming the picture /// in the process. Useful if the Surface is part of a pool. - pub fn take_surface(self) -> Result { + pub fn take_surface(self) -> VAResult { match Rc::try_unwrap(self.inner.surface) { Ok(surface) => Ok(surface.into_inner()), - Err(_) => Err(anyhow!("Surface still in use")), + Err(_) => Err(VAError::SurfaceBusy), } }