Skip to content

libobs: mix scene-item audio when item canvas is unset#738

Merged
summeroff merged 1 commit into
streamlabsfrom
fix/scene-audio-null-canvas-guard
Jun 12, 2026
Merged

libobs: mix scene-item audio when item canvas is unset#738
summeroff merged 1 commit into
streamlabsfrom
fix/scene-audio-null-canvas-guard

Conversation

@summeroff

Copy link
Copy Markdown

Problem

A source's audio plays when the source is set directly as an output channel, but goes silent once the source is wrapped in a scene and the scene is the output source. Reported in streamlabs/obs-studio-node#1493.

Root cause

scene_audio_render_do (libobs/obs-scene.c) mixes each scene item's audio only into a canvas whose pointer exactly matches item->canvas:

if (item->canvas != obs->video.canvases.array[canvas_idx])
    continue;

A scene item's canvas defaults to NULL (scene items are zero-allocated; it is only set via obs_sceneitem_set_canvas, e.g. osn's sceneItem.video). With a NULL canvas the comparison never matches, so the item's audio is dropped on every canvas — while its video still renders, because the video path (scene_video_render) already special-cases NULL:

if (render_canvas != item->canvas && item->canvas != NULL)
    continue;

The asymmetry dates to the video path gaining its != NULL guard ("Fix video mix canvas identity", #720) while the audio path — rewritten separately in da3255b9 — did not.

Fix

Give the audio path the same escape hatch: a NULL item canvas means "mix into every canvas".

Test

Regression test mirroring the exact obsproject#1493 repro (scene-wrapped ffmpeg_source with the item canvas left unset must record non-silent audio): streamlabs/obs-studio-node PR — link added below.

Notes

  • One-line behavioral change plus a short comment; matches the file's existing wrapping.
  • Not built locally — verified by inspection against the parallel video path; relying on CI for the libobs build.

🤖 Generated with Claude Code

scene_audio_render_do gated each scene item's audio on an exact canvas
match, but a scene item whose canvas is NULL (the default until
obs_sceneitem_set_canvas is called) matched no canvas, so its audio was
dropped on every canvas while its video still rendered.

Add the item->canvas != NULL escape hatch that the video path
(scene_video_render) already has, so a NULL item canvas means "mix into
every canvas".

Ref: streamlabs/obs-studio-node#1493

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@summeroff

Copy link
Copy Markdown
Author

Regression test for this fix: streamlabs/obs-studio-node#1724

@summeroff summeroff merged commit 36a53d6 into streamlabs Jun 12, 2026
14 checks passed
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.

2 participants