Skip to content

Commit f454d78

Browse files
committed
align with blocking version
1 parent 69b2344 commit f454d78

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/capturer/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,17 @@ impl Capturer {
142142

143143
/// Attempts to return the next captured frame without blocking.
144144
pub fn try_get_next_frame(&self) -> Result<Option<Frame>, mpsc::RecvError> {
145-
match self.rx.try_recv() {
146-
Ok(res) => {
147-
if let Some(frame) = self.engine.process_channel_item(res) {
148-
return Ok(Some(frame));
145+
loop {
146+
match self.rx.try_recv() {
147+
Ok(res) => {
148+
if let Some(frame) = self.engine.process_channel_item(res) {
149+
return Ok(Some(frame));
150+
}
151+
// Item filtered, try next without blocking
149152
}
150-
return Ok(None);
153+
Err(mpsc::TryRecvError::Empty) => return Ok(None),
154+
Err(mpsc::TryRecvError::Disconnected) => return Err(mpsc::RecvError),
151155
}
152-
Err(mpsc::TryRecvError::Empty) => Ok(None),
153-
Err(mpsc::TryRecvError::Disconnected) => Err(mpsc::RecvError),
154156
}
155157
}
156158

0 commit comments

Comments
 (0)