]> git.nihav.org Git - nihav-player.git/commitdiff
videoplayer: limit prefill iterations in case something goes wrong master
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 14 Feb 2026 19:42:12 +0000 (20:42 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 14 Feb 2026 19:42:12 +0000 (20:42 +0100)
videoplayer/src/main.rs

index 83e162be80c1c39dd4859a7408684a7eec6c76cf..b06cb5388b7bca75705cdd77c6f41558e724fd51 100644 (file)
@@ -571,7 +571,8 @@ impl Player {
         debug_log!(self; {" prefilling"});
         let mut got_video = !self.has_video;
         let mut got_audio = !self.has_audio;
-        while !(got_video && got_audio) {
+        let mut iters = 0;
+        while !(got_video && got_audio) && iters < 10 {
             // phase 1 - try to send packets for decoding
             loop {
                 let mut try_send = self.acontrol.get_queue_size() < FRAME_QUEUE_LEN && (!self.has_video || (!self.vcontrol.is_filled(FRAME_QUEUE_LEN) && !disp_queue.is_full()));
@@ -622,6 +623,7 @@ impl Player {
             if self.has_audio && self.acontrol.get_fill() > 0 {
                 got_audio = true;
             }
+            iters += 1;
         }
         debug_log!(self; {format!(" prefilling done, frames {}-{} audio {}", disp_queue.start, disp_queue.end, self.acontrol.get_fill())});
         Ok(())