From 0e55b66e7d6a68e144c466fb1eb83d015a94fb06 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 4 Sep 2015 17:24:28 +0200 Subject: [PATCH] Improved track removal timings. --- src/input/input_buffer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index 0bdbc8d6..eb67d220 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -193,13 +193,19 @@ namespace Mist { } for (std::map::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++) { //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 - lastUpdated[it->first]) > (bufferTime / 1000) || (compareLast && (time - lastUpdated[it->first]) > 5 && ((myMeta.tracks[it->first].firstms - compareLast) > bufferTime || (compareFirst - myMeta.tracks[it->first].lastms) > bufferTime))) { + if ((long long int)(time - lastUpdated[it->first]) > (long long int)(bufferTime / 1000) || + (compareLast && (long long int)(time - lastUpdated[it->first]) > 5 && ( + (compareLast < it->second.firstms && (long long int)(it->second.firstms - compareLast) > bufferTime) + || + (compareFirst > it->second.lastms && (long long int)(compareFirst - it->second.lastms) > bufferTime) + )) + ){ unsigned int tid = it->first; //erase this track - if ((time - lastUpdated[it->first]) > (bufferTime / 1000)){ - INFO_MSG("Erasing track %d because not updated for %ds (> %ds)", it->first, (time - lastUpdated[it->first]), bufferTime / 1000); + if ((long long int)(time - lastUpdated[it->first]) > (long long int)(bufferTime / 1000)){ + INFO_MSG("Erasing track %d because not updated for %ds (> %ds)", it->first, (long long int)(time - lastUpdated[it->first]), (long long int)(bufferTime / 1000)); }else{ - INFO_MSG("Erasing inactive track %d because it contains data (%ds - %ds), while active tracks are (%ds - %ds), which is more than %ds seconds apart.", it->second.firstms / 1000, it->second.lastms / 1000, compareFirst/1000, compareLast/1000, bufferTime / 1000); + INFO_MSG("Erasing inactive track %u because it was inactive for 5+ seconds and contains data (%us - %us), while active tracks are (%us - %us), which is more than %us seconds apart.", it->first, it->second.firstms / 1000, it->second.lastms / 1000, compareFirst/1000, compareLast/1000, bufferTime / 1000); } lastUpdated.erase(tid); /// \todo Consider replacing with eraseTrackDataPages(it->first)?