From bbdc5bc823916717509b9fc0dd2cb4210d82b961 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Mon, 15 Jan 2024 23:45:33 -0800 Subject: [PATCH] requesthandler: Prevent NaN `outputCongestion` values (null) --- src/requesthandler/RequestHandler_Stream.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/requesthandler/RequestHandler_Stream.cpp b/src/requesthandler/RequestHandler_Stream.cpp index 1a0b6ee23..35936d0d9 100644 --- a/src/requesthandler/RequestHandler_Stream.cpp +++ b/src/requesthandler/RequestHandler_Stream.cpp @@ -44,12 +44,16 @@ RequestResult RequestHandler::GetStreamStatus(const Request &) uint64_t outputDuration = Utils::Obs::NumberHelper::GetOutputDuration(streamOutput); + float outputCongestion = obs_output_get_congestion(streamOutput); + if (std::isnan(outputCongestion)) // libobs does not handle NaN, so we're handling it here + outputCongestion = 0.0f; + json responseData; responseData["outputActive"] = obs_output_active(streamOutput); responseData["outputReconnecting"] = obs_output_reconnecting(streamOutput); responseData["outputTimecode"] = Utils::Obs::StringHelper::DurationToTimecode(outputDuration); responseData["outputDuration"] = outputDuration; - responseData["outputCongestion"] = obs_output_get_congestion(streamOutput); + responseData["outputCongestion"] = outputCongestion; responseData["outputBytes"] = (uint64_t)obs_output_get_total_bytes(streamOutput); responseData["outputSkippedFrames"] = obs_output_get_frames_dropped(streamOutput); responseData["outputTotalFrames"] = obs_output_get_total_frames(streamOutput);