Fix -1 since last update error in Buffer

This commit is contained in:
Thulinma 2021-01-24 20:06:10 +01:00
parent 6f035f3bc6
commit dd5ae98002

View file

@ -432,20 +432,23 @@ namespace Mist{
}
for (std::set<size_t>::iterator idx = tracks.begin(); idx != tracks.end(); idx++){
size_t i = *idx;
uint64_t lastUp = M.getLastUpdated(i);
//Prevent issues when getLastUpdated > current time. This can happen if the second rolls over exactly during this loop.
if (lastUp >= time){continue;}
std::string codec = M.getCodec(i);
std::string type = M.getType(i);
uint64_t firstms = M.getFirstms(i);
uint64_t lastms = M.getLastms(i);
// if not updated for an entire buffer duration, or last updated track and this track differ
// by an entire buffer duration, erase the track.
if ((time - M.getLastUpdated(i) > (bufferTime / 1000) ||
(compareLast && activeTypes.count(type) && (time - M.getLastUpdated(i)) > 5 &&
if ((time - lastUp > (bufferTime / 1000) ||
(compareLast && activeTypes.count(type) && (time - lastUp) > 5 &&
((compareLast < firstms && (firstms - compareLast) > bufferTime) ||
(compareFirst > lastms && (compareFirst - lastms) > bufferTime))))){
// erase this track
if ((time - M.getLastUpdated(i)) > (bufferTime / 1000)){
if ((time - lastUp) > (bufferTime / 1000)){
WARN_MSG("Erasing %s track %zu (%s/%s) because not updated for %" PRIu64 "s (> %" PRIu64 "s)",
streamName.c_str(), i, type.c_str(), codec.c_str(), time - M.getLastUpdated(i),
streamName.c_str(), i, type.c_str(), codec.c_str(), time - lastUp,
bufferTime / 1000);
}else{
WARN_MSG("Erasing %s inactive track %zu (%s/%s) because it was inactive for 5+ seconds "