mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 18:20:34 +00:00
devices: virtio: video: Ensure failures are logged
BUG=b:170062417 TEST=Compiles Change-Id: I12236ce7cb5498086f9ede0e3c3de4aff7d4b78e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2461150 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Chih-Yu Huang <akahuang@chromium.org> Commit-Queue: David Stevens <stevensd@chromium.org>
This commit is contained in:
parent
e341d0ab7b
commit
27fdbba0d2
1 changed files with 16 additions and 7 deletions
|
@ -45,8 +45,6 @@ const QUEUE_SIZES: &[u16] = &[QUEUE_SIZE, QUEUE_SIZE];
|
|||
/// An error indicating something went wrong in virtio-video's worker.
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// Failed to create a libvda instance.
|
||||
LibvdaCreationFailed(libvda::Error),
|
||||
/// Creating PollContext failed.
|
||||
PollContextCreationFailed(SysError),
|
||||
/// A DescriptorChain contains invalid data.
|
||||
|
@ -70,7 +68,6 @@ impl Display for Error {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use Error::*;
|
||||
match self {
|
||||
LibvdaCreationFailed(e) => write!(f, "failed to create a libvda instance: {}", e),
|
||||
PollContextCreationFailed(e) => write!(f, "failed to create PollContext: {}", e),
|
||||
InvalidDescriptorChain(e) => write!(f, "DescriptorChain contains invalid data: {}", e),
|
||||
DescriptorNotAvailable => {
|
||||
|
@ -217,16 +214,28 @@ impl VirtioDevice for VideoDevice {
|
|||
VideoDeviceType::Decoder => thread::Builder::new()
|
||||
.name("virtio video decoder".to_owned())
|
||||
.spawn(move || {
|
||||
let vda = libvda::decode::VdaInstance::new(libvda::decode::VdaImplType::Gavda)
|
||||
.map_err(Error::LibvdaCreationFailed)?;
|
||||
let vda = match libvda::decode::VdaInstance::new(
|
||||
libvda::decode::VdaImplType::Gavda,
|
||||
) {
|
||||
Ok(vda) => vda,
|
||||
Err(e) => {
|
||||
error!("Failed to initialize vda: {}", e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let device = decoder::Decoder::new(&vda);
|
||||
worker.run(cmd_queue, event_queue, device)
|
||||
if let Err(e) = worker.run(cmd_queue, event_queue, device) {
|
||||
error!("Failed to start decoder worker: {}", e);
|
||||
};
|
||||
// Don't return any information since the return value is never checked.
|
||||
}),
|
||||
VideoDeviceType::Encoder => thread::Builder::new()
|
||||
.name("virtio video encoder".to_owned())
|
||||
.spawn(move || {
|
||||
let device = encoder::Encoder::new();
|
||||
worker.run(cmd_queue, event_queue, device)
|
||||
if let Err(e) = worker.run(cmd_queue, event_queue, device) {
|
||||
error!("Failed to start encoder worker: {}", e);
|
||||
}
|
||||
}),
|
||||
};
|
||||
if let Err(e) = worker_result {
|
||||
|
|
Loading…
Reference in a new issue