mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-19 20:32:15 +02:00
libobs: Add "monitoring by default" source cap
(This also modifies the UI module) Adds the ability for a source to monitor by default. This is mainly aimed at browser sources, so that they do not stop outputting audio by default like they used to.
This commit is contained in:
parent
916d89a73b
commit
aee84cc743
@ -197,6 +197,14 @@ bool AddNew(QWidget *parent, const char *id, const char *name,
|
||||
|
||||
newSource = source;
|
||||
|
||||
/* set monitoring if source monitors by default */
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
if ((flags & OBS_SOURCE_MONITOR_BY_DEFAULT) != 0) {
|
||||
obs_source_set_monitoring_type(
|
||||
source,
|
||||
OBS_MONITORING_TYPE_MONITOR_ONLY);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +139,12 @@ enum obs_balance_type {
|
||||
*/
|
||||
#define OBS_SOURCE_CAP_DISABLED (1 << 10)
|
||||
|
||||
/**
|
||||
* Source should enable monitoring by default. Monitoring should be set by the
|
||||
* frontend if this flag is set.
|
||||
*/
|
||||
#define OBS_SOURCE_MONITOR_BY_DEFAULT (1 << 11)
|
||||
|
||||
/** @} */
|
||||
|
||||
typedef void (*obs_source_enum_proc_t)(obs_source_t *parent,
|
||||
|
15
libobs/obs.c
15
libobs/obs.c
@ -1733,6 +1733,8 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
|
||||
double volume;
|
||||
double balance;
|
||||
int64_t sync;
|
||||
uint32_t prev_ver;
|
||||
uint32_t caps;
|
||||
uint32_t flags;
|
||||
uint32_t mixers;
|
||||
int di_order;
|
||||
@ -1743,6 +1745,9 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
|
||||
|
||||
obs_data_release(hotkeys);
|
||||
|
||||
prev_ver = (uint32_t)obs_data_get_int(source_data, "prev_ver");
|
||||
caps = obs_source_get_output_flags(source);
|
||||
|
||||
obs_data_set_default_double(source_data, "volume", 1.0);
|
||||
volume = obs_data_get_double(source_data, "volume");
|
||||
obs_source_set_volume(source, (float)volume);
|
||||
@ -1795,6 +1800,14 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
|
||||
source, (enum obs_deinterlace_field_order)di_order);
|
||||
|
||||
monitoring_type = (int)obs_data_get_int(source_data, "monitoring_type");
|
||||
if (prev_ver < MAKE_SEMANTIC_VERSION(24, 0, 0)) {
|
||||
if ((caps & OBS_SOURCE_MONITOR_BY_DEFAULT) != 0) {
|
||||
/* updates older sources to enable monitoring
|
||||
* automatically if they added monitoring by default in
|
||||
* version 24 */
|
||||
monitoring_type = OBS_MONITORING_TYPE_MONITOR_ONLY;
|
||||
}
|
||||
}
|
||||
obs_source_set_monitoring_type(
|
||||
source, (enum obs_monitoring_type)monitoring_type);
|
||||
|
||||
@ -1921,6 +1934,8 @@ obs_data_t *obs_save_source(obs_source_t *source)
|
||||
hotkey_data = hotkeys;
|
||||
}
|
||||
|
||||
obs_data_set_int(source_data, "prev_ver", LIBOBS_API_VER);
|
||||
|
||||
obs_data_set_string(source_data, "name", name);
|
||||
obs_data_set_string(source_data, "id", id);
|
||||
obs_data_set_obj(source_data, "settings", settings);
|
||||
|
Loading…
Reference in New Issue
Block a user