Skip to content

Fix audio capture never attaching when the selected source is not ready at startup - #15

Open
Poste2Travail wants to merge 28 commits into
justflood:mainfrom
Poste2Travail:main
Open

Poste2Travail wants to merge 28 commits into
justflood:mainfrom
Poste2Travail:main

Conversation

@Poste2Travail

@Poste2Travail Poste2Travail commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where Flood-tuber only looked up the selected microphone once, so if the source did not exist yet, it was never connected. The plugin now remembers the selected source name and keeps retrying until the source appears.

This also fixes MSVC build errors in flood_tuber_update, which passed a weak source reference (obs_weak_source_t *) to APIs that expect a strong obs_source_t *.

Bug

The audio source was looked up only when settings changed. If the microphone had not loaded yet (for example, a device that initializes after OBS starts), capture was never attached and the avatar never reacted to sound until the settings were changed again.

Changes

  • Added flood_tuber_try_audio_capture(): when a source name is set but not yet attached, it looks the source up by name and attaches the capture callback. It stores a weak reference and retries at most every 3 seconds.
  • Added flood_tuber_remove_audio_capture(): resolves the weak reference to a strong one, removes the callback, releases the strong reference, then releases the weak reference.
  • flood_tuber_update stores the selected source name and calls the helpers when the selection changes or is cleared.
  • flood_tuber_tick calls flood_tuber_try_audio_capture() every frame, so capture attaches as soon as the source exists.
  • Removed the inline teardown at the start of flood_tuber_update that passed the weak reference directly to OBS APIs. It disconnected audio on every settings change, leaving a gap of up to 3 seconds.
  • Removed an unused obs_get_source_by_name call that leaked a strong source reference.

Testing

  • Project builds on Windows with MSVC
  • Selecting an audio source starts capture
  • Changing the audio source switches capture to the new source
  • Clearing the audio source stops capture
  • Changing unrelated settings does not interrupt audio capture
  • A source that does not exist at startup is captured once it appears (within about 3 seconds)
  • A source that is removed and re-added is captured again

Notes for reviewers

  • flood_tuber_update runs on the UI thread, while flood_tuber_tick runs on the graphics thread and also reads and writes audio_source. Please confirm whether OBS serializes these calls for this source, or whether audio_source needs a guard.

Poste2Travail and others added 27 commits October 28, 2026 09:57
Updated audio source type and added new fields for audio source name and capture check time.
Replace strncpy with memcpy for safer string copy.
Removed unnecessary closing brace for BOUNCE effect.
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.

1 participant