From 27baee7994eee4ca1d80d4092b339f685c2ad052 Mon Sep 17 00:00:00 2001 From: badaix Date: Mon, 16 Oct 2017 22:07:26 +0200 Subject: [PATCH] fix dry out time --- server/streamreader/pipeStream.cpp | 13 +++++++------ server/streamreader/processStream.cpp | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/server/streamreader/pipeStream.cpp b/server/streamreader/pipeStream.cpp index 6bbfe1a0..86b48094 100644 --- a/server/streamreader/pipeStream.cpp +++ b/server/streamreader/pipeStream.cpp @@ -72,8 +72,8 @@ void PipeStream::worker() chronos::systemtimeofday(&tvChunk); tvEncodedChunk_ = tvChunk; long nextTick = chronos::getTickCount(); - int idleFrames = 0; - int maxIdleFrames = sampleFormat_.rate*dryoutMs_/1000; + int idleBytes = 0; + int maxIdleBytes = sampleFormat_.rate*sampleFormat_.frameSize*dryoutMs_/1000; try { if (fd_ == -1) @@ -88,10 +88,10 @@ void PipeStream::worker() do { int count = read(fd_, chunk->payload + len, toRead - len); - if (count < 0 && idleFrames < maxIdleFrames) + if (count < 0 && idleBytes < maxIdleBytes) { memset(chunk->payload + len, 0, toRead - len); - idleFrames += toRead - len; + idleBytes += toRead - len; len += toRead - len; continue; } @@ -103,9 +103,10 @@ void PipeStream::worker() } else if (count == 0) throw SnapException("end of file"); - else { + else + { len += count; - idleFrames = 0; + idleBytes = 0; } } while ((len < toRead) && active_); diff --git a/server/streamreader/processStream.cpp b/server/streamreader/processStream.cpp index 5437c58e..b5b0fb4e 100644 --- a/server/streamreader/processStream.cpp +++ b/server/streamreader/processStream.cpp @@ -158,8 +158,8 @@ void ProcessStream::worker() chronos::systemtimeofday(&tvChunk); tvEncodedChunk_ = tvChunk; long nextTick = chronos::getTickCount(); - int idleFrames = 0; - int maxIdleFrames = sampleFormat_.rate*dryoutMs_/1000; + int idleBytes = 0; + int maxIdleBytes = sampleFormat_.rate*sampleFormat_.frameSize*dryoutMs_/1000; try { while (active_) @@ -171,10 +171,10 @@ void ProcessStream::worker() do { int count = read(process_->getStdout(), chunk->payload + len, toRead - len); - if (count < 0 && idleFrames < maxIdleFrames) + if (count < 0 && idleBytes < maxIdleBytes) { memset(chunk->payload + len, 0, toRead - len); - idleFrames += toRead - len; + idleBytes += toRead - len; len += toRead - len; continue; } @@ -186,9 +186,10 @@ void ProcessStream::worker() } else if (count == 0) throw SnapException("end of file"); - else { + else + { len += count; - idleFrames = 0; + idleBytes = 0; } } while ((len < toRead) && active_);