Support OBS 33 audio monitoring API changes
Some checks failed
debian-build / build (push) Has been cancelled
Push to master / Check Formatting 🔍 (push) Has been cancelled
Push to master / Build Project 🧱 (push) Has been cancelled
Push to master / Create Release 🛫 (push) Has been cancelled

This commit is contained in:
WarmUpTill
2026-10-28 19:32:07 +01:00
committed by WarmUpTill
parent e136086ca3
commit 1f2bbc0499
5 changed files with 73 additions and 22 deletions

View File

@@ -6,12 +6,52 @@
namespace advss {
void PopulateMonitorTypeSelection(QComboBox *list)
// OBS 33 replaced monitoring types with a bool and dropped "monitor only"
static constexpr bool monitorOnlySupported = LIBOBS_API_VER <
MAKE_SEMANTIC_VERSION(33, 0, 0);
void PopulateMonitorTypeSelection(QComboBox *list,
bool alwaysIncludeMonitorOnly)
{
list->addItem(obs_module_text("AdvSceneSwitcher.audio.monitor.none"));
list->addItem(
obs_module_text("AdvSceneSwitcher.audio.monitor.monitorOnly"));
list->addItem(obs_module_text("AdvSceneSwitcher.audio.monitor.both"));
list->addItem(obs_module_text("AdvSceneSwitcher.audio.monitor.none"),
OBS_MONITORING_TYPE_NONE);
if (monitorOnlySupported || alwaysIncludeMonitorOnly) {
list->addItem(
obs_module_text(
"AdvSceneSwitcher.audio.monitor.monitorOnly"),
OBS_MONITORING_TYPE_MONITOR_ONLY);
}
list->addItem(obs_module_text("AdvSceneSwitcher.audio.monitor.both"),
OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT);
}
obs_monitoring_type ToSupportedMonitoringType(obs_monitoring_type type)
{
if (!monitorOnlySupported && type == OBS_MONITORING_TYPE_MONITOR_ONLY) {
return OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT;
}
return type;
}
void SetMonitoringType(obs_source_t *source, obs_monitoring_type type)
{
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(33, 0, 0)
obs_source_set_monitoring_enabled(source,
type != OBS_MONITORING_TYPE_NONE);
#else
obs_source_set_monitoring_type(source, type);
#endif
}
obs_monitoring_type GetMonitoringType(const obs_source_t *source)
{
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(33, 0, 0)
return obs_source_get_monitoring_enabled(source)
? OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT
: OBS_MONITORING_TYPE_NONE;
#else
return obs_source_get_monitoring_type(source);
#endif
}
float DecibelToPercent(float db)

View File

@@ -1,9 +1,14 @@
#pragma once
#include <obs.h>
#include <QComboBox>
namespace advss {
void PopulateMonitorTypeSelection(QComboBox *list);
void PopulateMonitorTypeSelection(QComboBox *list,
bool alwaysIncludeMonitorOnly = false);
void SetMonitoringType(obs_source_t *source, obs_monitoring_type type);
obs_monitoring_type GetMonitoringType(const obs_source_t *source);
obs_monitoring_type ToSupportedMonitoringType(obs_monitoring_type type);
float DecibelToPercent(float db);
float PercentToDecibel(float percent);