diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp index 290c4afd..84b5f9fe 100644 --- a/lib/dtscmeta.cpp +++ b/lib/dtscmeta.cpp @@ -120,7 +120,7 @@ namespace DTSC { while (src.connected()){ if (!toReceive && src.Received().available(8)){ if (src.Received().copy(2) != "DT"){ - INFO_MSG("Invalid DTSC Packet header encountered (%s)", src.Received().copy(4).c_str()); + WARN_MSG("Invalid DTSC Packet header encountered (%s)", src.Received().copy(4).c_str()); break; } toReceive = Bit::btohl(src.Received().copy(8).data() + 4); @@ -131,10 +131,11 @@ namespace DTSC { return; } if(!src.spool()){ - if (sleepCount++ > 60){ + if (sleepCount++ > 50){ + WARN_MSG("Waiting for packet on connection timed out"); return; } - Util::sleep(100); + Util::wait(100); } } } diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 72a182f4..f78275db 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -766,6 +766,10 @@ namespace IPC { DEBUG_MSG(DLVL_FAIL, "Creating semaphore failed: %s", strerror(errno)); return; } + if (!mySemaphore.tryWaitOneSecond()){ + WARN_MSG("Force unlocking sharedServer semaphore to prevent deadlock"); + } + mySemaphore.post(); semGuard tmpGuard(&mySemaphore); newPage(); } diff --git a/src/input/input.cpp b/src/input/input.cpp index 4213c5e1..626490fa 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -277,7 +277,7 @@ namespace Mist { snprintf(userPageName, NAME_BUFFER_SIZE, SHM_USERS, streamName.c_str()); nProxy.userClient = IPC::sharedClient(userPageName, PLAY_EX_SIZE, true); - DEBUG_MSG(DLVL_DEVEL, "Input for stream %s started", streamName.c_str()); + INFO_MSG("Input for stream %s started", streamName.c_str()); if (!openStreamSource()){ FAIL_MSG("Unable to connect to source"); @@ -310,7 +310,7 @@ namespace Mist { getNext(); nProxy.userClient.keepAlive(); } - + closeStreamSource(); nProxy.userClient.finish(); @@ -318,7 +318,7 @@ namespace Mist { pullLock.post(); pullLock.close(); pullLock.unlink(); - DEBUG_MSG(DLVL_DEVEL, "Pull input for stream %s closing clean", streamName.c_str()); + INFO_MSG("Stream input %s closing clean", streamName.c_str()); return; } diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index b54127b2..156c534c 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -787,6 +787,7 @@ namespace Mist { //Store a reference for easier access std::map & locations = bufferLocations[tNum]; char * mappedPointer = nProxy.metaPages[tNum].mapped; + if (!mappedPointer){return;} //First detect all entries on metaPage for (int i = 0; i < 8192; i += 8) { diff --git a/src/input/input_dtsc.cpp b/src/input/input_dtsc.cpp index 8fa84313..e13b0595 100644 --- a/src/input/input_dtsc.cpp +++ b/src/input/input_dtsc.cpp @@ -232,7 +232,7 @@ namespace Mist { } for (std::set::iterator it = newTracks.begin(); it != newTracks.end(); it++){ - INFO_MSG("Adding track %d to internal metadata", *it); + INFO_MSG("Reset: adding track %d", *it); myMeta.tracks[*it] = newMeta.tracks[*it]; continueNegotiate(*it, true); } @@ -246,12 +246,12 @@ namespace Mist { } for(std::set::iterator it = deletedTracks.begin(); it != deletedTracks.end(); it++){ - INFO_MSG("Deleting track %d from internal metadata", *it); + INFO_MSG("Reset: deleting track %d", *it); myMeta.tracks.erase(*it); } //Read next packet before returning - thisPacket.reInit(srcConn); + return getNext(smart); }else{ myMeta = DTSC::Meta(); } @@ -270,11 +270,11 @@ namespace Mist { } for (std::set::iterator it = newTracks.begin(); it != newTracks.end(); it++){ - INFO_MSG("Adding track %d to internal metadata", *it); + INFO_MSG("New header: adding track %d (%s)", *it, newMeta.tracks[*it].type.c_str()); myMeta.tracks[*it] = newMeta.tracks[*it]; continueNegotiate(*it, true); } - thisPacket.reInit(srcConn); + return getNext(smart); } }else{ if (smart) { diff --git a/src/output/output.cpp b/src/output/output.cpp index d154948c..c2df029f 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -68,6 +68,10 @@ namespace Mist { myConn.setBlocking(isBlocking); } + uint32_t Output::currTrackCount() const{ + return buffer.size(); + } + void Output::updateMeta(){ //read metadata from page to myMeta variable if (nProxy.metaPages[0].mapped){ diff --git a/src/output/output.h b/src/output/output.h index 53a61c7c..128e5696 100644 --- a/src/output/output.h +++ b/src/output/output.h @@ -65,6 +65,7 @@ namespace Mist { void selectDefaultTracks(); bool connectToFile(std::string file); static bool listenMode(){return true;} + uint32_t currTrackCount() const; virtual bool isReadyForPlay(); //virtuals. The optional virtuals have default implementations that do as little as possible. virtual void sendNext() {}//REQUIRED! Others are optional.