Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac-capture: Don't read channels for disconnected audio device #11477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcm93
Copy link
Contributor

@jcm93 jcm93 commented Nov 2, 2024

Description

When getting CoreAudio properties for an audio device source on macOS, make sure the source is active and initialized before trying to read channel information.

Motivation and Context

If we had an audio device source on macOS, and that device was subsequently disconnected from the machine, OBS would uninitialize the source, freeing the data associated with the audio channels. libobs however would still see the channel layout information, and when trying to get the source properties, would read from the previously freed channel data.

Fixes #11432, https://obsproject.com/forum/threads/crash-on-macos.181702/

Some other issues still abound in this code, and it is somewhat due for improvement, but for now, important to fix what is actually crashing.

How Has This Been Tested?

Tested locally on macOS 15.1; first reproduced the crash per the instructions in #11432. With the patch applied, the crash no longer occurs.

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 master 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.

Co-authored-by: PatTheMav <patthemav+github@gmail.com>
@WizardCM WizardCM added Bug Fix Non-breaking change which fixes an issue macOS Affects macOS labels Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue macOS Affects macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

macOS: Crash when selecting source associated with disconnected audio device
2 participants