Skip to content

Conversation

@mhoyer-streamlabs
Copy link

Description

Game Capture sources have a volmeter even when "Capture Audio" isn't checked in settings.

When the option to capture audio was added to game capture, OBS_SOURCE_AUDIO was added to output_flags on obs_register_source for ALL game capture sources. The fix is to check the source's settings and update output_flags accordingly. This is handled in game_capture_update because that is where new settings are processed. A source's output_flags aren't directly editable so I added a function to obs-source.c to handle this, similar to the streamlabs_force_source_ui_refresh function.

Motivation and Context

Asana ticket

How Has This Been Tested?

Tested game capture with audio turned on and off to verify volmeters only show when needed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue

Checklist:

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

sandboxcoder
sandboxcoder previously approved these changes Nov 11, 2025
@avoitenko-logitech
Copy link

avoitenko-logitech commented Nov 11, 2025

I wonder if this approach works 100% properly.
force_source_ui_refresh function does not interfere with already set OBS flags. My main concern is this case:

  • A source is created with the audio flag, memory allocated and some audio-related initialization is done
  • Flag is removed
    ...
  • Source is removed
  • During the deinitialization the audio flag is checked
  • Flag is not present, the audio-related code is not called
  • Result: memory leak

Please explore the function is_audio_source and its usage in libobs\obs-source.c

sandboxcoder

This comment was marked as outdated.

@sandboxcoder sandboxcoder dismissed their stale review November 11, 2025 18:11

Waiting on Alekxander

@mhoyer-streamlabs
Copy link
Author

I wonder if this approach works 100% properly. force_source_ui_refresh function does not interfere with already set OBS flags. My main concern is this case:

  • A source is created with the audio flag, memory allocated and some audio-related initialization is done
  • Flag is removed
    ...
  • Source is removed
  • During the deinitialization the audio flag is checked
  • Flag is not present, the audio-related code is not called
  • Result: memory leak

Please explore the function is_audio_source and its usage in libobs\obs-source.c

In obs_source_destroy, the flag is checked before freeing the audio callback list (da_free(source->audio_cb_list);). Changing the flag will cause this to be skipped, but the callbacks themselves are removed from the list when the flag is toggled so it's just an empty list; obs_source_destroy also sets the source for a deferred destroy. obs_source_destroy_defer actually calls da_free(source->audio_cb_list); again, but without checking the audio source flag so this will always be called, avoiding the memory leak. With the audio init/deinit happening when the flag is toggled and the FE updates, and the duplicate freeing of the callback list, I don't believe there should be issues. Please let me know if you see anything I missed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants