diff --git a/lib/procs.cpp b/lib/procs.cpp index 263ae8ae..439c16be 100644 --- a/lib/procs.cpp +++ b/lib/procs.cpp @@ -63,7 +63,7 @@ void Util::Procs::exit_handler() { break; } if (!listcopy.empty()) { - Util::sleep(20); + Util::wait(20); ++waiting; } } @@ -91,7 +91,7 @@ void Util::Procs::exit_handler() { break; } if (!listcopy.empty()) { - Util::sleep(20); + Util::wait(20); ++waiting; } } @@ -119,7 +119,7 @@ void Util::Procs::exit_handler() { break; } if (!listcopy.empty()) { - Util::sleep(20); + Util::wait(20); ++waiting; } } diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 39b50e1b..242f54e6 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -405,7 +405,7 @@ namespace IPC { int i = 0; do { if (i != 0) { - Util::sleep(1000); + Util::wait(1000); } handle = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, name.c_str()); i++; @@ -438,7 +438,7 @@ namespace IPC { int i = 0; while (i < 10 && handle == -1 && autoBackoff) { i++; - Util::sleep(1000); + Util::wait(1000); handle = shm_open(name.c_str(), O_RDWR, ACCESSPERMS); } } @@ -558,7 +558,7 @@ namespace IPC { int i = 0; while (i < 10 && handle == -1 && autoBackoff) { i++; - Util::sleep(1000); + Util::wait(1000); handle = open(std::string(Util::getTmpFolder() + name).c_str(), O_RDWR, (mode_t)0600); } } diff --git a/lib/stream.cpp b/lib/stream.cpp index c93399ec..2a129e39 100644 --- a/lib/stream.cpp +++ b/lib/stream.cpp @@ -313,7 +313,7 @@ bool Util::startInput(std::string streamname, std::string filename, bool forkFir unsigned int waiting = 0; while (!streamAlive(streamname) && ++waiting < 40){ - Util::sleep(250); + Util::wait(250); } return streamAlive(streamname); diff --git a/src/input/input.cpp b/src/input/input.cpp index b1a637cd..de3d2e99 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -238,7 +238,7 @@ namespace Mist { } /*LTS-END*/ if (config->is_active){ - Util::sleep(1000); + Util::wait(1000); } } finish(); diff --git a/src/output/output.cpp b/src/output/output.cpp index fabb320a..6cec416c 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -228,10 +228,10 @@ namespace Mist { } updateMeta(); if (myMeta.live && !isReadyForPlay()){ - unsigned int maxWaits = 15; + unsigned long long waitUntil = Util::epoch() + 15; while (!isReadyForPlay()){ Util::sleep(1000); - if (--maxWaits == 0){ + if (Util::epoch() > waitUntil){ FAIL_MSG("Giving up waiting for playable tracks"); break; } @@ -1002,7 +1002,7 @@ namespace Mist { DEBUG_MSG(DLVL_DEVEL, "Empty packet on track %u (%s) @ key %lu (next=%d) - could not reload, dropping track.", nxt.tid, myMeta.tracks[nxt.tid].type.c_str(), nxtKeyNum[nxt.tid]+1, nextPage); } //keep updating the metadata at 250ms intervals while waiting for more data - Util::sleep(250); + Util::wait(250); updateMeta(); }else{ //if we're not live, we've simply reached the end of the page. Load the next key. @@ -1043,7 +1043,7 @@ namespace Mist { while(counter < 10 && myMeta.tracks[nxt.tid].getKey(nxtKeyNum[nxt.tid]).getTime() != thisPacket.getTime()){ if (counter++){ //Only sleep 500ms if this is not the first updatemeta try - Util::sleep(500); + Util::wait(500); } updateMeta(); nxtKeyNum[nxt.tid] = getKeyForTime(nxt.tid, thisPacket.getTime()); @@ -1109,9 +1109,9 @@ namespace Mist { if (nxt.offset < nProxy.curPage[nxt.tid].len){ unsigned long long nextTime = getDTSCTime(nProxy.curPage[nxt.tid].mapped, nxt.offset); int ctr = 0; - //sleep at most half a second for new data. + //sleep for at most 5 seconds for new data. while (!nextTime && ++ctr < 5){ - Util::sleep(1000); + Util::wait(1000); nextTime = getDTSCTime(nProxy.curPage[nxt.tid].mapped, nxt.offset); } if (nextTime){ diff --git a/src/output/output_hds.cpp b/src/output/output_hds.cpp index c17ca117..ca5fb2a9 100644 --- a/src/output/output_hds.cpp +++ b/src/output/output_hds.cpp @@ -243,7 +243,7 @@ namespace Mist { myConn.close(); break; } - Util::sleep(500); + Util::wait(500); updateMeta(); } mstime = myMeta.tracks[tid].getKey(myMeta.tracks[tid].fragments[fragNum - myMeta.tracks[tid].missedFrags].getNumber()).getTime(); diff --git a/src/output/output_hls.cpp b/src/output/output_hls.cpp index 1e383f45..79322018 100644 --- a/src/output/output_hls.cpp +++ b/src/output/output_hls.cpp @@ -453,7 +453,7 @@ namespace Mist { myConn.close(); break; } - Util::sleep(500); + Util::wait(500); updateMeta(); } } while (myConn && seekable > 0); diff --git a/src/output/output_hss.cpp b/src/output/output_hss.cpp index 65cc650e..90b3f0c4 100644 --- a/src/output/output_hss.cpp +++ b/src/output/output_hss.cpp @@ -134,7 +134,7 @@ namespace Mist { myConn.close(); break; } - Util::sleep(500); + Util::wait(500); updateMeta(); } }while (myConn && seekable > 0); diff --git a/src/output/output_push.cpp b/src/output/output_push.cpp index 8fed2405..a1ffa8fb 100644 --- a/src/output/output_push.cpp +++ b/src/output/output_push.cpp @@ -218,7 +218,7 @@ void pushThread(void * nullPointer){ while (pConf->is_active){ pushFirstElement(myThread); if (!pushableSegments[myThread].size()){ - Util::sleep(1000); + Util::wait(1000); } }