From f7a12b09f7ac2942275a7fc441e86d7bb5bd63f7 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sat, 30 Mar 2013 20:56:01 +0100 Subject: [PATCH] Better Player queue completion limited by time --- src/Player.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Player.php b/src/Player.php index 3120f8ec..924d2944 100644 --- a/src/Player.php +++ b/src/Player.php @@ -156,14 +156,11 @@ class Player{ } if($time > $this->timeout){ $this->close("timeout"); - }else{ - if($this->nextBuffer <= $time and strlen($this->buffer) > 0){ - $this->sendBuffer(); - } - + }else{ if(!empty($this->queue)){ $cnt = 0; - while($cnt < 4){ + $maxtime = $time + 0.025; + while(microtime(true) < $maxtime){ $p = array_shift($this->queue); if($p === null){ break; @@ -179,6 +176,10 @@ class Player{ ++$cnt; } } + + if($this->nextBuffer <= $time and strlen($this->buffer) > 0){ + $this->sendBuffer(); + } } }