From 18f9d2682fdf99a886f8151a7872987929c94cc6 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Fri, 20 Jul 2018 14:22:46 +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 9e8f75d3..90a37054 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -400,6 +400,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(); @@ -650,6 +651,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(); } uint64_t lastBuffered = 0; @@ -657,6 +659,7 @@ namespace Mist { uint64_t byteCounter = 0; 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(); @@ -666,7 +669,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 d5687db4..2165c53f 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -294,7 +294,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 649679cf..6ae934a2 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -899,10 +899,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);