Skip to content

Commit

Permalink
Fixed crash on missing volmeter
Browse files Browse the repository at this point in the history
  • Loading branch information
avoitenko-logitech committed Dec 10, 2024
1 parent 5b014bf commit 5e9af34
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions obs-studio-server/source/osn-volmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,27 @@ void osn::Volmeter::getAudioData(uint64_t id, std::vector<ipc::value> &rval)
{
std::unique_lock<std::mutex> 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<std::mutex> 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);
Expand Down

0 comments on commit 5e9af34

Please sign in to comment.