Removed extraKeepAway value, superseded by MinKeepAway from track metadata

This commit is contained in:
Thulinma 2022-11-28 10:50:57 +01:00
parent 213128e82a
commit b571d1c0c5
4 changed files with 7 additions and 15 deletions

View file

@ -99,7 +99,6 @@ namespace Mist{
isInitialized = false; isInitialized = false;
isBlocking = false; isBlocking = false;
needsLookAhead = 0; needsLookAhead = 0;
extraKeepAway = 0;
lastStats = 0xFFFFFFFFFFFFFFFFull; lastStats = 0xFFFFFFFFFFFFFFFFull;
maxSkipAhead = 7500; maxSkipAhead = 7500;
uaDelay = 10; uaDelay = 10;
@ -823,7 +822,7 @@ namespace Mist{
HIGH_MSG("Skipping track %zu, not in tracks", ti->first); HIGH_MSG("Skipping track %zu, not in tracks", ti->first);
continue; continue;
}// ignore missing tracks }// ignore missing tracks
if (M.getLastms(ti->first) < seekPos + needsLookAhead + extraKeepAway + M.getMinKeepAway(ti->first)){ if (M.getLastms(ti->first) < seekPos + needsLookAhead + M.getMinKeepAway(ti->first)){
good = false; good = false;
break; break;
} }
@ -1054,11 +1053,9 @@ namespace Mist{
if (M.getMinKeepAway(ti->first) > r){r = M.getMinKeepAway(ti->first);} if (M.getMinKeepAway(ti->first) > r){r = M.getMinKeepAway(ti->first);}
} }
//Limit the value to the maxKeepAway setting //Limit the value to the maxKeepAway setting
//Also lowers extraKeepAway if needed
uint64_t maxKeepAway = M.getMaxKeepAway(); uint64_t maxKeepAway = M.getMaxKeepAway();
if (maxKeepAway){ if (maxKeepAway){
if (r > maxKeepAway){r = maxKeepAway;} if (r > maxKeepAway){r = maxKeepAway;}
if (r+extraKeepAway > maxKeepAway){extraKeepAway = maxKeepAway - r;}
} }
return r; return r;
} }
@ -1079,10 +1076,9 @@ namespace Mist{
if (!maxSkipAhead){ if (!maxSkipAhead){
bool noReturn = false; bool noReturn = false;
uint64_t newSpeed = 1000; uint64_t newSpeed = 1000;
if (extraKeepAway > 0){extraKeepAway--;}//Reduce extra latency if possible if (lMs - mKa - needsLookAhead > cTime + 50){
if (lMs - mKa - needsLookAhead - extraKeepAway > cTime + 50){
// We need to speed up! // We need to speed up!
uint64_t diff = (lMs - mKa - needsLookAhead - extraKeepAway) - cTime; uint64_t diff = (lMs - mKa - needsLookAhead) - cTime;
if (!rateOnly && diff > 3000){ if (!rateOnly && diff > 3000){
noReturn = true; noReturn = true;
newSpeed = 1000; newSpeed = 1000;
@ -1095,7 +1091,7 @@ namespace Mist{
} }
} }
if (realTime != newSpeed){ if (realTime != newSpeed){
HIGH_MSG("Changing playback speed from %" PRIu64 " to %" PRIu64 "(%" PRIu64 " ms LA, %" PRIu64 " ms mKA, %" PRIu64 " eKA)", realTime, newSpeed, needsLookAhead, mKa, extraKeepAway); HIGH_MSG("Changing playback speed from %" PRIu64 " to %" PRIu64 "(%" PRIu64 " ms LA, %" PRIu64 " ms mKA)", realTime, newSpeed, needsLookAhead, mKa);
firstTime = Util::bootMS() - (cTime * newSpeed / 1000); firstTime = Util::bootMS() - (cTime * newSpeed / 1000);
realTime = newSpeed; realTime = newSpeed;
} }
@ -1117,7 +1113,7 @@ namespace Mist{
HIGH_MSG("Skipping track %zu, not in tracks", ti->first); HIGH_MSG("Skipping track %zu, not in tracks", ti->first);
continue; continue;
}// ignore missing tracks }// ignore missing tracks
if (meta.getLastms(ti->first) < seekPos + needsLookAhead + extraKeepAway + mKa){ if (meta.getLastms(ti->first) < seekPos + needsLookAhead + mKa){
good = false; good = false;
break; break;
} }
@ -1131,8 +1127,8 @@ namespace Mist{
// if yes, seek here // if yes, seek here
if (good){ if (good){
HIGH_MSG("Skipping forward %" PRIu64 "ms (%" PRIu64 " ms LA, %" PRIu64 HIGH_MSG("Skipping forward %" PRIu64 "ms (%" PRIu64 " ms LA, %" PRIu64
" ms mKA, %" PRIu64 " eKA, > %" PRIu32 "ms, mSa %" PRIu64 " ms)", " ms mKA, > %" PRIu32 "ms, mSa %" PRIu64 " ms)",
seekPos - cTime, needsLookAhead, mKa, extraKeepAway, seekCount * 100, maxSkipAhead); seekPos - cTime, needsLookAhead, mKa, seekCount * 100, maxSkipAhead);
if (seekCount < 20){++seekCount;} if (seekCount < 20){++seekCount;}
seek(seekPos); seek(seekPos);
return true; return true;
@ -1164,7 +1160,6 @@ namespace Mist{
void Output::playbackSleep(uint64_t millis){ void Output::playbackSleep(uint64_t millis){
if (realTime && M.getLive() && buffer.getSyncMode()){ if (realTime && M.getLive() && buffer.getSyncMode()){
firstTime += millis; firstTime += millis;
extraKeepAway += millis;
} }
Util::wait(millis); Util::wait(millis);
} }

View file

@ -114,7 +114,6 @@ namespace Mist{
std::string UA; ///< User Agent string, if known. std::string UA; ///< User Agent string, if known.
uint64_t uaDelay; ///< Seconds to wait before setting the UA. uint64_t uaDelay; ///< Seconds to wait before setting the UA.
uint64_t lastRecv; uint64_t lastRecv;
uint64_t extraKeepAway;
uint64_t dataWaitTimeout; ///< How long to wait for new packets before dropping a track, in tens of milliseconds. uint64_t dataWaitTimeout; ///< How long to wait for new packets before dropping a track, in tens of milliseconds.
uint64_t firstTime; ///< Time of first packet after last seek. Used for real-time sending. uint64_t firstTime; ///< Time of first packet after last seek. Used for real-time sending.
virtual std::string getConnectedHost(); virtual std::string getConnectedHost();

View file

@ -134,7 +134,6 @@ namespace Mist{
} }
} }
if (thisTime > statSourceMs){statSourceMs = thisTime;} if (thisTime > statSourceMs){statSourceMs = thisTime;}
extraKeepAway = 0;
needsLookAhead = 0; needsLookAhead = 0;
maxSkipAhead = 0; maxSkipAhead = 0;
if (!sendFirst){ if (!sendFirst){

View file

@ -149,7 +149,6 @@ namespace Mist{
} }
while (!presegs[currPreSeg].fullyRead && conf.is_active){Util::sleep(100);} while (!presegs[currPreSeg].fullyRead && conf.is_active){Util::sleep(100);}
presegs[currPreSeg].data.assign(0, 0); presegs[currPreSeg].data.assign(0, 0);
extraKeepAway = 0;
needsLookAhead = 0; needsLookAhead = 0;
maxSkipAhead = 0; maxSkipAhead = 0;
packCounter = 0; packCounter = 0;