mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
virtio: video: rename GuestObjectHandle to VirtioObjectHandle
This is a more accurate name since the object does not initially come from the guest. BUG=b:161774071 BUG=b:209523781 TEST="emerge-hatch chromeos-base/crosvm" passes. Change-Id: I618419dc7cfb7203669a5c72b015d5acea50ff24 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340693 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
parent
54cf834c7e
commit
c9b4c23601
6 changed files with 17 additions and 17 deletions
|
@ -134,7 +134,7 @@ impl<'a> VideoCmd {
|
|||
} = r.read_obj()?;
|
||||
|
||||
let input_resource_type = match in_mem_type.into() {
|
||||
VIRTIO_VIDEO_MEM_TYPE_VIRTIO_OBJECT => ResourceType::Object,
|
||||
VIRTIO_VIDEO_MEM_TYPE_VIRTIO_OBJECT => ResourceType::VirtioObject,
|
||||
_ => {
|
||||
error!("mem_type must be VIRTIO_OBJECT");
|
||||
return Err(InvalidArgument);
|
||||
|
@ -142,7 +142,7 @@ impl<'a> VideoCmd {
|
|||
};
|
||||
|
||||
let output_resource_type = match out_mem_type.into() {
|
||||
VIRTIO_VIDEO_MEM_TYPE_VIRTIO_OBJECT => ResourceType::Object,
|
||||
VIRTIO_VIDEO_MEM_TYPE_VIRTIO_OBJECT => ResourceType::VirtioObject,
|
||||
_ => {
|
||||
error!("mem_type must be VIRTIO_OBJECT");
|
||||
return Err(InvalidArgument);
|
||||
|
|
|
@ -179,7 +179,7 @@ impl DecoderSession for VdaDecoderSession {
|
|||
offset: u32,
|
||||
bytes_used: u32,
|
||||
) -> VideoResult<()> {
|
||||
let GuestResourceHandle::Object(handle) = resource;
|
||||
let GuestResourceHandle::VirtioObject(handle) = resource;
|
||||
|
||||
Ok(self.vda_session.decode(
|
||||
bitstream_id,
|
||||
|
@ -207,7 +207,7 @@ impl DecoderSession for VdaDecoderSession {
|
|||
picture_buffer_id: i32,
|
||||
resource: GuestResource,
|
||||
) -> VideoResult<()> {
|
||||
let GuestResourceHandle::Object(handle) = resource.handle;
|
||||
let GuestResourceHandle::VirtioObject(handle) = resource.handle;
|
||||
let vda_planes: Vec<libvda::FramePlane> = resource.planes.iter().map(Into::into).collect();
|
||||
|
||||
Ok(self.vda_session.use_output_buffer(
|
||||
|
|
|
@ -521,7 +521,7 @@ impl<'a, D: DecoderBackend> Decoder<D> {
|
|||
};
|
||||
|
||||
let resource = match resource_type {
|
||||
ResourceType::Object => GuestResource::from_virtio_object_entry(
|
||||
ResourceType::VirtioObject => GuestResource::from_virtio_object_entry(
|
||||
// Safe because we confirmed the correct type for the resource.
|
||||
unsafe { resource.object },
|
||||
&self.resource_bridge,
|
||||
|
|
|
@ -16,7 +16,7 @@ use crate::virtio::video::format::{
|
|||
use crate::virtio::video::{
|
||||
encoder::encoder::*,
|
||||
error::{VideoError, VideoResult},
|
||||
resource::{GuestObjectHandle, GuestResource, GuestResourceHandle},
|
||||
resource::{GuestResource, GuestResourceHandle, VirtioObjectHandle},
|
||||
};
|
||||
|
||||
impl From<Bitrate> for libvda::encode::Bitrate {
|
||||
|
@ -287,7 +287,7 @@ impl EncoderSession for LibvdaEncoderSession {
|
|||
force_keyframe: bool,
|
||||
) -> VideoResult<InputBufferId> {
|
||||
let input_buffer_id = self.next_input_buffer_id;
|
||||
let GuestResourceHandle::Object(GuestObjectHandle { desc, .. }) = resource.handle;
|
||||
let GuestResourceHandle::VirtioObject(VirtioObjectHandle { desc, .. }) = resource.handle;
|
||||
|
||||
let libvda_planes = resource
|
||||
.planes
|
||||
|
@ -319,7 +319,7 @@ impl EncoderSession for LibvdaEncoderSession {
|
|||
size: u32,
|
||||
) -> VideoResult<OutputBufferId> {
|
||||
let output_buffer_id = self.next_output_buffer_id;
|
||||
let GuestResourceHandle::Object(GuestObjectHandle { desc, .. }) = resource;
|
||||
let GuestResourceHandle::VirtioObject(VirtioObjectHandle { desc, .. }) = resource;
|
||||
|
||||
self.session.use_output_buffer(
|
||||
output_buffer_id as i32,
|
||||
|
|
|
@ -602,7 +602,7 @@ impl<T: Encoder> EncoderDevice<T> {
|
|||
}
|
||||
|
||||
let resource = match stream.src_params.resource_type {
|
||||
ResourceType::Object => GuestResource::from_virtio_object_entry(
|
||||
ResourceType::VirtioObject => GuestResource::from_virtio_object_entry(
|
||||
// Safe because we confirmed the correct type for the resource.
|
||||
unsafe { resource.object },
|
||||
&self.resource_bridge,
|
||||
|
@ -628,7 +628,7 @@ impl<T: Encoder> EncoderDevice<T> {
|
|||
}
|
||||
|
||||
let resource = match stream.dst_params.resource_type {
|
||||
ResourceType::Object => GuestResource::from_virtio_object_entry(
|
||||
ResourceType::VirtioObject => GuestResource::from_virtio_object_entry(
|
||||
// Safe because we confirmed the correct type for the resource.
|
||||
unsafe { resource.object },
|
||||
&self.resource_bridge,
|
||||
|
|
|
@ -18,12 +18,12 @@ use crate::virtio::video::protocol::virtio_video_object_entry;
|
|||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum ResourceType {
|
||||
/// Resources are backed by virtio objects.
|
||||
Object,
|
||||
VirtioObject,
|
||||
}
|
||||
|
||||
impl Default for ResourceType {
|
||||
fn default() -> Self {
|
||||
ResourceType::Object
|
||||
ResourceType::VirtioObject
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ impl fmt::Debug for UnresolvedGuestResource {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct GuestObjectHandle {
|
||||
pub struct VirtioObjectHandle {
|
||||
/// Descriptor for the object.
|
||||
pub desc: SafeDescriptor,
|
||||
/// Modifier to apply to frame resources.
|
||||
pub modifier: u64,
|
||||
}
|
||||
|
||||
impl GuestObjectHandle {
|
||||
impl VirtioObjectHandle {
|
||||
pub fn try_clone(&self) -> Result<Self, base::Error> {
|
||||
Ok(Self {
|
||||
desc: self.desc.try_clone()?,
|
||||
|
@ -59,13 +59,13 @@ impl GuestObjectHandle {
|
|||
}
|
||||
|
||||
pub enum GuestResourceHandle {
|
||||
Object(GuestObjectHandle),
|
||||
VirtioObject(VirtioObjectHandle),
|
||||
}
|
||||
|
||||
impl GuestResourceHandle {
|
||||
pub fn try_clone(&self) -> Result<Self, base::Error> {
|
||||
Ok(match self {
|
||||
Self::Object(handle) => Self::Object(handle.try_clone()?),
|
||||
Self::VirtioObject(handle) => Self::VirtioObject(handle.try_clone()?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ impl GuestResource {
|
|||
};
|
||||
|
||||
Ok(GuestResource {
|
||||
handle: GuestResourceHandle::Object(GuestObjectHandle {
|
||||
handle: GuestResourceHandle::VirtioObject(VirtioObjectHandle {
|
||||
// Safe because `buffer_info.file` is a valid file descriptor and we are stealing
|
||||
// it.
|
||||
desc: unsafe {
|
||||
|
|
Loading…
Reference in a new issue