mirror of
https://github.com/bleackstorm/SteamFrame-FPV-Control-Center.git
synced 2026-12-03 07:31:57 +01:00
perf(video): immediate Annex-B burst flush for Android and Condvar frame wake-up on PC
This commit is contained in:
1 parent
f75dd39bd5
commit
4fdffe3393
3 files changed
+98
-5
No files matched your search
@@ -178,9 +178,14 @@ pub fn run_desktop_fallback_loop(ctx: &mut EngineWorkerRefs<'_>) {
|
||||
);
|
||||
|
||||
let elapsed = loop_start.elapsed();
|
||||
let target_dt = Duration::from_millis(8); // Jusqu'à 120 Hz sur les flux 90/120 FPS
|
||||
let target_dt = Duration::from_millis(8);
|
||||
if elapsed < target_dt {
|
||||
thread::sleep(target_dt - elapsed);
|
||||
let remaining = target_dt - elapsed;
|
||||
if let Some(rx) = ctx.video_rx_opt {
|
||||
rx.wait_for_frame(last_frame_id, remaining);
|
||||
} else {
|
||||
thread::sleep(remaining);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
-1
@@ -5,7 +5,7 @@ use gstreamer::prelude::*;
|
||||
use gstreamer_app as gst_app;
|
||||
use gstreamer_video as gst_video;
|
||||
use gstreamer_video::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use parking_lot::{Condvar, Mutex};
|
||||
use std::os::fd::{BorrowedFd, OwnedFd};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
||||
use std::sync::Arc;
|
||||
@@ -101,6 +101,8 @@ pub struct FrameMailbox {
|
||||
/// Horodatage de la dernière trame publiée (conservé même après consommation par l'UI/VR
|
||||
/// pour éviter les faux positifs "Signal vidéo perdu" entre deux trames).
|
||||
last_received_at: Option<Instant>,
|
||||
/// Signal événementiel pour réveiller instantanément la boucle Bureau dès qu'une trame arrive.
|
||||
frame_condvar: Arc<Condvar>,
|
||||
}
|
||||
|
||||
impl FrameMailbox {
|
||||
@@ -114,12 +116,14 @@ impl FrameMailbox {
|
||||
if self.spare_buf.capacity() > incoming.capacity() {
|
||||
std::mem::swap(&mut self.spare_buf, incoming);
|
||||
}
|
||||
self.frame_condvar.notify_all();
|
||||
}
|
||||
|
||||
/// Publie une trame DMA-BUF zéro-copie (sans aucune copie pixel côté CPU).
|
||||
fn publish_dmabuf(&mut self, dmabuf: DmaBufFrame) {
|
||||
self.last_received_at = Some(dmabuf.received_at);
|
||||
self.dmabuf_ready = Some(dmabuf);
|
||||
self.frame_condvar.notify_all();
|
||||
}
|
||||
|
||||
/// Récupère la dernière trame DMA-BUF si plus récente que `last_frame_id` et fraîche.
|
||||
@@ -323,6 +327,23 @@ impl UsbVideoReceiver {
|
||||
.take_if_newer(consumer_buf, last_frame_id, max_age)
|
||||
}
|
||||
|
||||
/// Attend de manière événementielle (`Condvar`) l'arrivée d'une trame plus récente que `last_frame_id`
|
||||
/// (jusqu'à `timeout`), supprimant le délai de polling fixe dans la boucle Bureau.
|
||||
pub fn wait_for_frame(&self, last_frame_id: u64, timeout: Duration) {
|
||||
let mut guard = self.mailbox.lock();
|
||||
let has_newer = guard
|
||||
.ready_meta
|
||||
.is_some_and(|m| m.frame_id != last_frame_id)
|
||||
|| guard
|
||||
.dmabuf_ready
|
||||
.as_ref()
|
||||
.is_some_and(|d| d.frame_id != last_frame_id);
|
||||
if !has_newer {
|
||||
let cv = Arc::clone(&guard.frame_condvar);
|
||||
cv.wait_for(&mut guard, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn metrics(&self) -> VideoLinkMetrics {
|
||||
self.metrics.lock().clone()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user