Skip to content

Commit

Permalink
Clone and take instead of emptying buffer on read to allow multiple r…
Browse files Browse the repository at this point in the history
…ead access (HULKs#1069)
  • Loading branch information
tuxbotix authored Jun 26, 2024
1 parent 330028d commit 1d3810f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/hulk_webots/src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::arch::x86_64::{
};

use color_eyre::{
eyre::{eyre, WrapErr},
eyre::{OptionExt, WrapErr},
Result,
};
use parking_lot::{Condvar, Mutex};
Expand Down Expand Up @@ -67,8 +67,9 @@ impl Camera {
let mut bgra_buffer = self.buffer.lock();
self.buffer_updated.wait(&mut bgra_buffer);
bgra_buffer
.clone()
.take()
.ok_or_else(|| eyre!("no updated image found"))?
.ok_or_eyre("no updated image found")?
};
assert_eq!(bgra_buffer.len(), 4 * 640 * 480);
let mut ycbcr_buffer = vec![
Expand Down

0 comments on commit 1d3810f

Please sign in to comment.