mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-07-29 14:51:44 +08:00
fix: 修复 v4l2loopback 的 DQBUF 兼容问题
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::ioctl::ioctl_and_convert;
|
|||||||
use crate::ioctl::IoctlConvertError;
|
use crate::ioctl::IoctlConvertError;
|
||||||
use crate::ioctl::IoctlConvertResult;
|
use crate::ioctl::IoctlConvertResult;
|
||||||
use crate::ioctl::UncheckedV4l2Buffer;
|
use crate::ioctl::UncheckedV4l2Buffer;
|
||||||
|
use crate::memory::MemoryType;
|
||||||
use crate::QueueType;
|
use crate::QueueType;
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
@@ -51,12 +52,13 @@ pub type DqBufError<CE> = IoctlConvertError<DqBufIoctlError, CE>;
|
|||||||
pub type DqBufResult<O, CE> = IoctlConvertResult<O, DqBufIoctlError, CE>;
|
pub type DqBufResult<O, CE> = IoctlConvertResult<O, DqBufIoctlError, CE>;
|
||||||
|
|
||||||
/// Safe wrapper around the `VIDIOC_DQBUF` ioctl.
|
/// Safe wrapper around the `VIDIOC_DQBUF` ioctl.
|
||||||
pub fn dqbuf<O>(fd: &impl AsRawFd, queue: QueueType) -> DqBufResult<O, O::Error>
|
pub fn dqbuf<O>(fd: &impl AsRawFd, queue: QueueType, memory: MemoryType) -> DqBufResult<O, O::Error>
|
||||||
where
|
where
|
||||||
O: TryFrom<UncheckedV4l2Buffer>,
|
O: TryFrom<UncheckedV4l2Buffer>,
|
||||||
O::Error: std::fmt::Debug,
|
O::Error: std::fmt::Debug,
|
||||||
{
|
{
|
||||||
let mut v4l2_buf = UncheckedV4l2Buffer::new_for_querybuf(queue, None);
|
let mut v4l2_buf = UncheckedV4l2Buffer::new_for_querybuf(queue, None);
|
||||||
|
v4l2_buf.0.memory = memory as u32;
|
||||||
|
|
||||||
ioctl_and_convert(
|
ioctl_and_convert(
|
||||||
unsafe { ioctl::vidioc_dqbuf(fd.as_raw_fd(), v4l2_buf.as_mut()) }
|
unsafe { ioctl::vidioc_dqbuf(fd.as_raw_fd(), v4l2_buf.as_mut()) }
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ impl CaptureStream {
|
|||||||
pub fn next_into(&mut self, dst: &mut Vec<u8>) -> io::Result<CaptureMeta> {
|
pub fn next_into(&mut self, dst: &mut Vec<u8>) -> io::Result<CaptureMeta> {
|
||||||
self.wait_ready()?;
|
self.wait_ready()?;
|
||||||
|
|
||||||
let dqbuf: V4l2Buffer = ioctl::dqbuf(&self.fd, self.queue)
|
let dqbuf: V4l2Buffer = ioctl::dqbuf(&self.fd, self.queue, MemoryType::Mmap)
|
||||||
.map_err(|e| io::Error::other(format!("dqbuf failed: {}", e)))?;
|
.map_err(|e| io::Error::other(format!("dqbuf failed: {}", e)))?;
|
||||||
let index = dqbuf.as_v4l2_buffer().index as usize;
|
let index = dqbuf.as_v4l2_buffer().index as usize;
|
||||||
let sequence = dqbuf.as_v4l2_buffer().sequence as u64;
|
let sequence = dqbuf.as_v4l2_buffer().sequence as u64;
|
||||||
|
|||||||
Reference in New Issue
Block a user