From 5e9af34b38752001bd98f2e4eea99d7a801d3064 Mon Sep 17 00:00:00 2001 From: Aleksandr Voitenko Date: Tue, 10 Dec 2024 15:19:57 +0000 Subject: [PATCH] Fixed crash on missing volmeter --- obs-studio-server/source/osn-volmeter.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/obs-studio-server/source/osn-volmeter.cpp b/obs-studio-server/source/osn-volmeter.cpp index c6c35929e..72314e31d 100644 --- a/obs-studio-server/source/osn-volmeter.cpp +++ b/obs-studio-server/source/osn-volmeter.cpp @@ -207,16 +207,27 @@ void osn::Volmeter::getAudioData(uint64_t id, std::vector &rval) { std::unique_lock ulockMutex(mtx); + // Client expects that we send at least some minimal data related to the volmeter back + const auto createMinimalResponse = [&]() { + rval.push_back(ipc::value("")); + rval.push_back(ipc::value(2)); + rval.push_back(ipc::value(true)); + }; + auto meter = Manager::GetInstance().find(id); if (!meter) { - PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid Meter reference."); + createMinimalResponse(); + blog(LOG_ERROR, "Invalid AudioMeter reference: %" PRIu64, id); + return; } std::unique_lock ulock(meter->current_data_mtx); const auto source = osn::Source::Manager::GetInstance().find(meter->uid_source); if (!source) { - PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Volmeter source not found."); + createMinimalResponse(); + blog(LOG_ERROR, "Volmeter source not found.: %" PRIu64, meter->uid_source); + return; } bool isMuted = obs_source_muted(source);