// Copyright 2020 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34//! Errors that can happen while encoding or decoding.56use remain::sorted;7use thiserror::Error as ThisError;89use crate::virtio::video::control::CtrlType;1011/// An error indicating something went wrong while encoding or decoding.12/// Unlike `virtio::video::Error`, `VideoError` is not fatal for `Worker`.13#[sorted]14#[derive(Debug, ThisError)]15pub enum VideoError {16/// Backend-specific error.17#[error("backend failure: {0:#}")]18BackendFailure(anyhow::Error),19/// Invalid argument.20#[error("invalid argument")]21InvalidArgument,22/// No suitable format is supported.23#[error("invalid format")]24InvalidFormat,25/// Invalid operation.26#[error("invalid operation")]27InvalidOperation,28/// Invalid parameters are specified.29#[error("invalid parameter")]30InvalidParameter,31/// Invalid resource ID is specified.32#[error("invalid resource ID {resource_id} for stream {stream_id}")]33InvalidResourceId { stream_id: u32, resource_id: u32 },34/// Invalid stream ID is specified.35#[error("invalid stream ID {0}")]36InvalidStreamId(u32),37/// Unsupported control type is specified.38/// This is only used by the encoder for now, ignore warning if it is compiled out.39#[allow(dead_code)]40#[error("unsupported control: {0:?}")]41UnsupportedControl(CtrlType),42}4344pub type VideoResult<T> = Result<T, VideoError>;454647