From fe7cee866657f7295edf236b998df57df18ba95b Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 13 Jul 2018 23:17:47 +0200 Subject: [PATCH] Added some helpful high-level debug messages to generic IO handlers, fixed missing track selection when streaming live input --- src/input/input.cpp | 5 ++++- src/io.cpp | 2 +- src/output/output.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/input/input.cpp b/src/input/input.cpp index f65473c9..9b579d72 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -559,6 +559,7 @@ namespace Mist { for (std::map::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){ it->second.firstms = 0; it->second.lastms = 0; + selectedTracks.insert(it->first); } std::string reason = streamMainLoop(); @@ -821,6 +822,7 @@ namespace Mist { getNext(); //in case earlier seeking was inprecise, seek to the exact point while (thisPacket && thisPacket.getTime() < (unsigned long long)myMeta.tracks[track].keys[keyNum - 1].getTime()) { + DONTEVEN_MSG("Skipping packet: %d@%llu, %llub", track, thisPacket.getTime(), thisPacket.getDataLen()); getNext(); } } @@ -840,6 +842,7 @@ namespace Mist { }else{ while (thisPacket && thisPacket.getTime() < stopTime) { if (thisPacket.getTime() >= lastBuffered){ + DONTEVEN_MSG("Buffering packet: %d@%llu, %llub", track, thisPacket.getTime(), thisPacket.getDataLen()); bufferNext(thisPacket); ++packCounter; byteCounter += thisPacket.getDataLen(); @@ -850,7 +853,7 @@ namespace Mist { } bufferFinalize(track); bufferTimer = Util::bootMS() - bufferTimer; - DEBUG_MSG(DLVL_DEVEL, "Done buffering page %d (%llu packets, %llu bytes, %llu-%llums) for track %d (%s) in %llums", keyNum, packCounter, byteCounter, myMeta.tracks[track].keys[keyNum - 1].getTime(), stopTime, track, myMeta.tracks[track].codec.c_str(), bufferTimer); + DEBUG_MSG(DLVL_DEVEL, "Done buffering page %d (%llu packets, %llu bytes, %llu-%llums -> %llums) for track %d (%s) in %llums", keyNum, packCounter, byteCounter, myMeta.tracks[track].keys[keyNum - 1].getTime(), stopTime, lastBuffered, track, myMeta.tracks[track].codec.c_str(), bufferTimer); pageCounter[track][keyNum] = 15; return true; } diff --git a/src/io.cpp b/src/io.cpp index 4edb2c44..c0026bf6 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -337,7 +337,7 @@ namespace Mist { size_t curOffset = pageData.curOffset; //Do nothing when there is not enough free space on the page to add the packet. if (pageData.dataSize - curOffset < pack.getDataLen()) { - FAIL_MSG("Trying to buffer a packet on page %lu for track %lu~>%lu, but we have a size mismatch. The packet is %d bytes long, so won't fit at offset %lu on a page of %llu bytes!", curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset, pageData.dataSize); + FAIL_MSG("Trying to buffer a packet (%llums) on page %lu for track %lu~>%lu, but we have a size mismatch. The packet is %d bytes long, so won't fit at offset %lu on a page of %llu bytes!", pack.getTime(), curPageNum[tid], tid, mapTid, pack.getDataLen(), curOffset, pageData.dataSize); return; } diff --git a/src/output/output.cpp b/src/output/output.cpp index fce5158e..c70d463b 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -1365,10 +1365,12 @@ namespace Mist{ loadPageForKey(nxt.tid, ++nxtKeyNum[nxt.tid]); nxt.offset = 0; if (nProxy.curPage.count(nxt.tid) && nProxy.curPage[nxt.tid].mapped){ - if (getDTSCTime(nProxy.curPage[nxt.tid].mapped, nxt.offset) < nxt.time){ + uint64_t newTime = getDTSCTime(nProxy.curPage[nxt.tid].mapped, nxt.offset); + VERYHIGH_MSG("New page %llu for track %llu, first timestamp is %llu ms", nxtKeyNum[nxt.tid], nxt.tid, newTime); + if (newTime < nxt.time){ dropTrack(nxt.tid, "time going backwards"); }else{ - nxt.time = getDTSCTime(nProxy.curPage[nxt.tid].mapped, nxt.offset); + nxt.time = newTime; //swap out the next object in the buffer with a new one buffer.erase(buffer.begin()); buffer.insert(nxt);