From a7159434478f15d60a8b274652d5e2c6a7db0108 Mon Sep 17 00:00:00 2001 From: ozzay Date: Tue, 25 Feb 2014 14:34:01 +0100 Subject: [PATCH] CloseOnError added --- lib/dtsc.cpp | 4 ++-- lib/dtsc.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index b22f1971..a4d2190e 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -185,7 +185,7 @@ void DTSC::Stream::endStream() { /// Blocks until either the stream has metadata available or the sourceSocket errors. /// This function is intended to be run before any commands are sent and thus will not throw away anything important. /// It will time out after 3 seconds, disconnecting the sourceSocket. -void DTSC::Stream::waitForMeta(Socket::Connection & sourceSocket) { +void DTSC::Stream::waitForMeta(Socket::Connection & sourceSocket, bool closeOnError){ bool wasBlocking = sourceSocket.isBlocking(); sourceSocket.setBlocking(false); //cancel the attempt after 5000 milliseconds @@ -210,7 +210,7 @@ void DTSC::Stream::waitForMeta(Socket::Connection & sourceSocket) { } sourceSocket.setBlocking(wasBlocking); //if the timeout has passed, close the socket - if (Util::getMS() - start >= 3000) { + if (Util::getMS() - start >= 3000 && closeOnError){ sourceSocket.close(); //and optionally print a debug message that this happened DEBUG_MSG(DLVL_DEVEL, "Timing out while waiting for metadata"); diff --git a/lib/dtsc.h b/lib/dtsc.h index a6f4c0f8..9ff6b4a7 100644 --- a/lib/dtsc.h +++ b/lib/dtsc.h @@ -425,7 +425,7 @@ namespace DTSC { bool isNewest(DTSC::livePos & pos, std::set & allowedTracks); DTSC::livePos getNext(DTSC::livePos & pos, std::set & allowedTracks); void endStream(); - void waitForMeta(Socket::Connection & sourceSocket); + void waitForMeta(Socket::Connection & sourceSocket, bool closeOnError = true); void waitForPause(Socket::Connection & sourceSocket); protected: void cutOneBuffer();