fix(video): try to optimize memory leaks
Some checks failed
build / checks-matrix (push) Has been cancelled
build / codecov (push) Has been cancelled
docs / docs (push) Has been cancelled
build / checks-build (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-12-25 06:28:52 +05:30
parent 5a0bdae84b
commit a2491695b3
5 changed files with 47 additions and 21 deletions

View File

@@ -99,11 +99,14 @@ impl iced_wgpu::Primitive for VideoFrame {
if video.ready.load(std::sync::atomic::Ordering::SeqCst) {
let now = std::time::Instant::now();
let frame = self.frame.lock().expect("BUG: Mutex poisoned");
let frame = frame
let buffer = frame
.buffer()
.and_then(|b| b.map_readable().ok())
.expect("BUG: Failed to get frame data from gst::Sample");
queue.write_buffer(&video.buffer, 0, &frame);
let data = buffer
.map_readable()
.expect("BUG: Failed to map gst::Buffer readable");
queue.write_buffer(&video.buffer, 0, &data);
video
.ready
.store(false, std::sync::atomic::Ordering::SeqCst);