ioctl: dqbuf: remove CorruptedBuffer error
This is not an error, but a flag of the dequeued buffer and should be
treated as such.
diff --git a/lib/src/decoder/stateful.rs b/lib/src/decoder/stateful.rs
index 611f989..5f3add3 100644
--- a/lib/src/decoder/stateful.rs
+++ b/lib/src/decoder/stateful.rs
@@ -5,7 +5,6 @@
poller::{DeviceEvent, PollError, PollEvent, Poller, Waker},
queue::{
direction::{Capture, Output},
- dqbuf::DqBuffer,
handles_provider::HandlesProvider,
qbuf::{
get_free::{GetFreeBufferError, GetFreeCaptureBuffer, GetFreeOutputBuffer},
@@ -17,7 +16,9 @@
},
AllocatedQueue, Device, DeviceConfig, DeviceOpenError, Stream, TryDequeue,
},
- ioctl::{self, subscribe_event, BufferCapabilities, Fmt, FormatFlags, StreamOnError},
+ ioctl::{
+ self, subscribe_event, BufferCapabilities, DqBufError, Fmt, FormatFlags, StreamOnError,
+ },
memory::{BufferHandles, PrimitiveBufferHandles},
FormatConversionError,
};
@@ -336,8 +337,6 @@
}
#[allow(type_alias_bounds)]
-type DequeueOutputBufferError<OP: BufferHandles> = ioctl::DqBufError<DqBuffer<Output, OP>>;
-#[allow(type_alias_bounds)]
type CanceledBuffers<OP: BufferHandles> =
Vec<<Queue<Output, BuffersAllocated<OP>> as Stream>::Canceled>;
@@ -491,7 +490,7 @@
}
/// Attempts to dequeue and release output buffers that the driver is done with.
- fn dequeue_output_buffers(&self) -> Result<(), DequeueOutputBufferError<OP>> {
+ fn dequeue_output_buffers(&self) -> Result<(), DqBufError> {
let output_queue = &self.state.output_queue;
while output_queue.num_queued_buffers() > 0 {
@@ -511,7 +510,7 @@
// Make this thread sleep until at least one OUTPUT buffer is ready to be
// obtained through [`Decoder::try_get_buffer()`].
- fn wait_for_output_buffer(&mut self) -> Result<(), GetBufferError<OP>> {
+ fn wait_for_output_buffer(&mut self) -> Result<(), GetBufferError> {
for event in self.state.output_poller.poll(None)? {
match event {
PollEvent::Device(DeviceEvent::OutputReady) => {
@@ -540,9 +539,9 @@
}
#[derive(Debug, Error)]
-pub enum GetBufferError<OP: BufferHandles> {
+pub enum GetBufferError {
#[error("error while dequeueing buffer")]
- DequeueError(#[from] DequeueOutputBufferError<OP>),
+ DequeueError(#[from] DqBufError),
#[error("error during poll")]
PollError(#[from] PollError),
#[error("error while obtaining buffer")]
@@ -551,7 +550,7 @@
/// Let the decoder provide the buffers from the OUTPUT queue.
impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>
- GetFreeOutputBuffer<'a, OP, GetBufferError<OP>>
+ GetFreeOutputBuffer<'a, OP, GetBufferError>
for Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>
where
Queue<Output, BuffersAllocated<OP>>: GetFreeOutputBuffer<'a, OP>,
@@ -566,7 +565,7 @@
///
/// This method will return None immediately if all the allocated buffers
/// are currently queued.
- fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError<OP>> {
+ fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError> {
self.dequeue_output_buffers()?;
Ok(self.state.output_queue.try_get_free_buffer()?)
}
@@ -577,7 +576,7 @@
impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>
Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>
where
- Self: GetFreeOutputBuffer<'a, OP, GetBufferError<OP>>,
+ Self: GetFreeOutputBuffer<'a, OP, GetBufferError>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
@@ -596,7 +595,7 @@
/// to be available if needed.
pub fn get_buffer(
&'a mut self,
- ) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError<OP>> {
+ ) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError> {
let output_queue = &self.state.output_queue;
// If all our buffers are queued, wait until we can dequeue some.
@@ -627,7 +626,7 @@
/// that owns the decoder every time a decoded frame is produced.
/// That way the client can recycle its input buffers
/// and the decoding process does not get stuck.
- pub fn kick(&self) -> Result<(), DequeueOutputBufferError<OP>> {
+ pub fn kick(&self) -> Result<(), DqBufError> {
info!("Kick!");
self.dequeue_output_buffers()
}
diff --git a/lib/src/device/queue.rs b/lib/src/device/queue.rs
index 1aaf6d9..35388d3 100644
--- a/lib/src/device/queue.rs
+++ b/lib/src/device/queue.rs
@@ -483,14 +483,8 @@
type Dequeued = DqBuffer<D, P>;
fn try_dequeue(&self) -> DqBufResult<Self::Dequeued> {
- let mut error_flag_set = false;
-
let dqbuf: ioctl::DqBuffer = match ioctl::dqbuf(&self.inner, self.inner.type_) {
Ok(dqbuf) => dqbuf,
- Err(DqBufError::CorruptedBuffer(dqbuf)) => {
- error_flag_set = true;
- dqbuf
- }
Err(DqBufError::Eos) => return Err(DqBufError::Eos),
Err(DqBufError::NotReady) => return Err(DqBufError::NotReady),
Err(DqBufError::IoctlError(e)) => return Err(DqBufError::IoctlError(e)),
@@ -520,11 +514,7 @@
let dqbuffer = DqBuffer::new(self, buffer_info, plane_handles, dqbuf, fuse);
- if error_flag_set {
- Err(DqBufError::CorruptedBuffer(dqbuffer))
- } else {
- Ok(dqbuffer)
- }
+ Ok(dqbuffer)
}
}
diff --git a/lib/src/encoder.rs b/lib/src/encoder.rs
index 8272fa4..a9f31ac 100644
--- a/lib/src/encoder.rs
+++ b/lib/src/encoder.rs
@@ -305,18 +305,15 @@
// Safe because all Rcs are internal and never leaked outside of the struct.
unsafe impl<S: EncoderState> Send for Encoder<S> {}
-#[allow(type_alias_bounds)]
-type DequeueOutputBufferError<OP: BufferHandles> = DqBufError<DqBuffer<Output, OP>>;
-
pub enum CompletedOutputBuffer<OP: BufferHandles> {
Dequeued(DqBuffer<Output, OP>),
Canceled(CanceledBuffer<OP>),
}
#[derive(Debug, Error)]
-pub enum GetBufferError<OP: BufferHandles> {
+pub enum GetBufferError {
#[error("error while dequeueing buffer")]
- DequeueError(#[from] DequeueOutputBufferError<OP>),
+ DequeueError(#[from] DqBufError),
#[error("error during poll")]
PollError(#[from] PollError),
#[error("error while obtaining buffer")]
@@ -379,7 +376,7 @@
}
/// Attempts to dequeue and release output buffers that the driver is done with.
- fn dequeue_output_buffers(&self) -> Result<(), DequeueOutputBufferError<OP>> {
+ fn dequeue_output_buffers(&self) -> Result<(), DqBufError> {
let output_queue = &self.state.output_queue;
while output_queue.num_queued_buffers() > 0 {
@@ -399,7 +396,7 @@
// Make this thread sleep until at least one OUTPUT buffer is ready to be
// obtained through `try_get_buffer()`, dequeuing buffers if necessary.
- fn wait_for_output_buffer(&mut self) -> Result<(), GetBufferError<OP>> {
+ fn wait_for_output_buffer(&mut self) -> Result<(), GetBufferError> {
for event in self.state.output_poller.poll(None)? {
match event {
PollEvent::Device(DeviceEvent::OutputReady) => {
@@ -427,7 +424,7 @@
}
/// Let the encoder provide the buffers from the OUTPUT queue.
-impl<'a, OP, P, InputDoneCb, OutputReadyCb> GetFreeOutputBuffer<'a, OP, GetBufferError<OP>>
+impl<'a, OP, P, InputDoneCb, OutputReadyCb> GetFreeOutputBuffer<'a, OP, GetBufferError>
for Encoder<Encoding<OP, P, InputDoneCb, OutputReadyCb>>
where
Queue<Output, BuffersAllocated<OP>>: GetFreeOutputBuffer<'a, OP>,
@@ -441,7 +438,7 @@
///
/// This method will return None immediately if all the allocated buffers
/// are currently queued.
- fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError<OP>> {
+ fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError> {
self.dequeue_output_buffers()?;
Ok(self.state.output_queue.try_get_free_buffer()?)
}
@@ -451,7 +448,7 @@
// method.
impl<'a, OP, P, InputDoneCb, OutputReadyCb> Encoder<Encoding<OP, P, InputDoneCb, OutputReadyCb>>
where
- Self: GetFreeOutputBuffer<'a, OP, GetBufferError<OP>>,
+ Self: GetFreeOutputBuffer<'a, OP, GetBufferError>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: Fn(CompletedOutputBuffer<OP>),
@@ -464,7 +461,7 @@
/// to be available if needed.
pub fn get_buffer(
&'a mut self,
- ) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError<OP>> {
+ ) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError> {
let output_queue = &self.state.output_queue;
// If all our buffers are queued, wait until we can dequeue some.
diff --git a/lib/src/ioctl/dqbuf.rs b/lib/src/ioctl/dqbuf.rs
index d6385c4..b0ef3f6 100644
--- a/lib/src/ioctl/dqbuf.rs
+++ b/lib/src/ioctl/dqbuf.rs
@@ -210,18 +210,16 @@
}
#[derive(Debug, Error)]
-pub enum DqBufError<T: Debug> {
+pub enum DqBufError {
#[error("end-of-stream reached")]
Eos,
#[error("no buffer ready for dequeue")]
NotReady,
- #[error("buffer with ERROR flag dequeued")]
- CorruptedBuffer(T),
#[error("ioctl error: {0}")]
IoctlError(Error),
}
-impl<T: Debug> From<Error> for DqBufError<T> {
+impl From<Error> for DqBufError {
fn from(error: Error) -> Self {
match error {
Errno::EAGAIN => Self::NotReady,
@@ -231,7 +229,7 @@
}
}
-pub type DqBufResult<T> = Result<T, DqBufError<T>>;
+pub type DqBufResult<T> = Result<T, DqBufError>;
/// Safe wrapper around the `VIDIOC_DQBUF` ioctl.
pub fn dqbuf<T: DqBuf + Debug, F: AsRawFd>(fd: &F, queue: QueueType) -> DqBufResult<T> {