Skip to content

frontend, libobs: Fix volume control state desync#13378

Open
Warchamp7 wants to merge 4 commits intoobsproject:masterfrom
Warchamp7:volume-control-state-fix
Open

frontend, libobs: Fix volume control state desync#13378
Warchamp7 wants to merge 4 commits intoobsproject:masterfrom
Warchamp7:volume-control-state-fix

Conversation

@Warchamp7
Copy link
Copy Markdown
Member

Description

This PR accomplishes two goals:

  1. Fixes the volume control button state getting desynced when using plugins/scripts to change mute/monitoring
  2. Makes it so monitoring while muted is handled directly in libobs instead of the frontend

Motivation and Context

  1. This fixes Audio Mixer UI buttons desync when controlled via WebSocket #13246. libobs sends the signals for the relevant state changes before the state is actually applied to the object. This means if you respond to a signal for mute by calling obs_source_muted() you are going to get a stale value at best or a race condition at worst. Instead the VolumeControl now updates a local value using the new value from the signal, so that the up to date value can be used for updating the mixer state.

  2. Currently in the new audio mixer, the ability to hear a monitored source when it was muted was handled via frontend logic. This logic would consider the UI input and only actually mute a source if monitoring was disabled. This led to some inconsistencies when things like the Advanced Audio Properties window or websockets tried to update these settings, as they would not flow through that logic.

This approach was taken as I naively assumed that a muted source would never even make it to the part of the audio pipeline where monitoring would be considered. However after further investigation thanks to @PatTheMav, we gleaned that monitoring itself is done via audio callback and had specific handling for the muted state already.

How Has This Been Tested?

Changed the mute and monitoring state of multiple audio sources via the mixer, the Advanced Audio Properties window, and via obs-websockets.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@Warchamp7 Warchamp7 added the kind/bug Categorizes issue or PR as related to a bug. label Apr 30, 2026
@Warchamp7 Warchamp7 force-pushed the volume-control-state-fix branch from a971f00 to 5c97df9 Compare April 30, 2026 15:23
Comment thread libobs/audio-monitoring/osx/coreaudio-output.c Outdated
@Warchamp7 Warchamp7 force-pushed the volume-control-state-fix branch 2 times, most recently from 5178a68 to eacca15 Compare May 1, 2026 03:50
@Warchamp7 Warchamp7 force-pushed the volume-control-state-fix branch 3 times, most recently from e420190 to cafc4da Compare May 1, 2026 04:16
@Warchamp7 Warchamp7 force-pushed the volume-control-state-fix branch from cafc4da to 764fb8f Compare May 1, 2026 04:52
}

static void on_audio_playback(void *param, obs_source_t *source, const struct audio_data *audio_data, bool muted)
static void on_audio_playback(void *param, obs_source_t *source, const struct audio_data *audio_data, bool)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this works, because that's usually a C++ feature, so maybe a GNU extension?

Copy link
Copy Markdown
Member

@RytoEX RytoEX May 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have C extensions enabled for Linux because libobs doesn't compile without them there.

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_C_EXTENSIONS FALSE)
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows")
set(OS_WINDOWS TRUE)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_C_EXTENSIONS FALSE)
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos")
set(OS_MACOS TRUE)
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
set(CMAKE_CXX_EXTENSIONS FALSE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep we need that for stuff like POSIX threads to work IIRC, was just wondering if that's the reason why that works on Linux, because it won't on macOS and I'm not sure whether MSVC accepts it either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Audio Mixer UI buttons desync when controlled via WebSocket

3 participants