diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index 1343902c..4a72471f 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -329,49 +329,6 @@ namespace Mist { /*LTS-END*/ myMeta.tracks[tid].parts.pop_front(); } - ///\todo Fix recording - /*LTS-START - ///\todo Maybe optimize this by keeping track of the byte positions - if (recFile.good()){ - long long unsigned int firstms = myMeta.tracks[tid].keys[0].getTime(); - long long unsigned int lastms = myMeta.tracks[tid].lastms; - if (myMeta.tracks[tid].keys.size() > 1){ - lastms = myMeta.tracks[tid].keys[1].getTime(); - } - DEBUG_MSG(DLVL_DEVEL, "Recording track %d from %llums to %llums", tid, firstms, lastms); - long long unsigned int bpos = 0; - DTSC::Packet recPack; - int pageLen = dataPages[tid][bufferLocations[tid].begin()->first].len; - char * pageMapped = dataPages[tid][bufferLocations[tid].begin()->first].mapped; - while( bpos < (unsigned long long)pageLen){ - int tmpSize = ((int)pageMapped[bpos + 4] << 24) | ((int)pageMapped[bpos + 5] << 16) | ((int)pageMapped[bpos + 6] << 8) | (int)pageMapped[bpos + 7]; - tmpSize += 8; - recPack.reInit(pageMapped + bpos, tmpSize, true); - if (tmpSize != recPack.getDataLen()){ - DEBUG_MSG(DLVL_DEVEL, "Something went wrong while trying to record a packet @ %llu, %d != %d", bpos, tmpSize, recPack.getDataLen()); - break; - } - if (recPack.getTime() >= lastms){/// \todo getTime never reaches >= lastms, so probably the recording bug has something to do with this - DEBUG_MSG(DLVL_HIGH, "Stopping record, %llu >= %llu", recPack.getTime(), lastms); - break; - } - if (recPack.getTime() >= firstms){ - //Actually record to file here - JSON::Value recJSON = recPack.toJSON(); - recJSON["bpos"] = recBpos; - recFile << recJSON.toNetPacked(); - recFile.flush(); - recBpos = recFile.tellp(); - recMeta.update(recJSON); - } - bpos += recPack.getDataLen(); - } - recFile.flush(); - std::ofstream tmp(std::string(recName + ".dtsh").c_str()); - tmp << recMeta.toJSON().toNetPacked(); - tmp.close(); - } - LTS-END*/ //remove the key itself myMeta.tracks[tid].keys.pop_front(); myMeta.tracks[tid].keySizes.pop_front(); diff --git a/src/io.cpp b/src/io.cpp index 9b9b3148..9f84ea97 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -204,6 +204,21 @@ namespace Mist { return; } unsigned long mapTid = nProxy.trackMap[tid]; + + DEBUG_MSG(DLVL_HIGH, "Removing page %lu on track %lu~>%lu from the corresponding metaPage", pageNumber, tid, mapTid); + int i = 0; + for (; i < 1024; i++) { + int * tmpOffset = (int *)(nProxy.metaPages[tid].mapped + (i * 8)); + if (ntohl(tmpOffset[0]) == pageNumber) { + tmpOffset[0] = 0; + tmpOffset[1] = 0; + break; + } + } + if (i == 1024){ + FAIL_MSG("Could not erase page %lu for track %lu->%lu stream %s from track index!", pageNumber, tid, mapTid, streamName.c_str()); + } + if (!nProxy.pagesByTrack.count(tid)){ // If there is no pagesByTrack entry, the pages are managed in local code and not through io.cpp (e.g.: MistInBuffer) return; @@ -229,14 +244,6 @@ namespace Mist { #endif toErase.master = true; //Remove the page from the tracks index page - DEBUG_MSG(DLVL_HIGH, "Removing page %lu on track %lu~>%lu from the corresponding metaPage", pageNumber, tid, mapTid); - for (int i = 0; i < 1024; i++) { - int * tmpOffset = (int *)(nProxy.metaPages[tid].mapped + (i * 8)); - if (ntohl(tmpOffset[0]) == pageNumber) { - tmpOffset[0] = 0; - tmpOffset[1] = 0; - } - } //Leaving scope here, the page will now be destroyed }