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
}
/// Wrapper around `vaBeginPicture`.
- pub fn begin(self) -> Result<Picture<PictureBegin>> {
+ pub fn begin(self) -> VAResult<Picture<PictureBegin>> {
// 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(),
impl Picture<PictureBegin> {
/// Wrapper around `vaRenderPicture`.
- pub fn render(self) -> Result<Picture<PictureRender>> {
+ pub fn render(self) -> VAResult<Picture<PictureRender>> {
// 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(),
impl Picture<PictureRender> {
/// Wrapper around `vaEndPicture`.
- pub fn end(self) -> Result<Picture<PictureEnd>> {
+ pub fn end(self) -> VAResult<Picture<PictureEnd>> {
// Safe because `self.inner.context` represents a valid `VAContext`.
- Status(unsafe {
+ (unsafe {
bindings::vaEndPicture(
self.inner.context.display().handle(),
self.inner.context.id(),
impl Picture<PictureEnd> {
/// Syncs the picture, ensuring that all pending operations are complete when this call returns.
- pub fn sync(self) -> std::result::Result<Picture<PictureSync>, (anyhow::Error, Self)> {
+ pub fn sync(self) -> std::result::Result<Picture<PictureSync>, (VAError, Self)> {
let res = self.inner.surface.borrow().sync();
match res {
///
/// 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<bindings::VASurfaceStatus::Type> {
+ pub fn query_status(&self) -> VAResult<VASurfaceStatus> {
self.inner.surface.borrow_mut().query_status()
}
}
impl<S: PictureReclaimableSurface> Picture<S> {
/// 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<Surface> {
+ pub fn take_surface(self) -> VAResult<Surface> {
match Rc::try_unwrap(self.inner.surface) {
Ok(surface) => Ok(surface.into_inner()),
- Err(_) => Err(anyhow!("Surface still in use")),
+ Err(_) => Err(VAError::SurfaceBusy),
}
}