Skip to content

[DO NOT MERGE]Feature/macos screen audio capture#65

Draft
d3xvn wants to merge 4 commits intomainfrom
feature/macos-screen-audio-capture
Draft

[DO NOT MERGE]Feature/macos screen audio capture#65
d3xvn wants to merge 4 commits intomainfrom
feature/macos-screen-audio-capture

Conversation

@d3xvn
Copy link

@d3xvn d3xvn commented Feb 5, 2026

No description provided.

d3xvn added 4 commits February 5, 2026 23:06
Use ScreenCaptureKit (macOS 13.0+) to capture system audio and mix it
into the microphone audio stream when screen sharing with audio: true.

- ScreenAudioCapturer: wraps SCStream to capture system audio into a
  thread-safe ring buffer (mono float32, 48kHz)
- ScreenAudioMixer: ExternalAudioProcessingDelegate that reads from
  the ring buffer and mixes system audio into the mic's RTCAudioBuffer
- FlutterRTCDesktopCapturer: parses audio constraint in getDisplayMedia,
  starts/stops screen audio capture lifecycle
- Weakly links ScreenCaptureKit so the plugin still works on macOS 10.15+
- Excludes current process audio by default to prevent echo
Use consistent flags (kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment)
in both the sizing and retrieval calls to
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer. The alignment flag
increases the required buffer size, so using flags=0 for sizing and the
alignment flag for retrieval produced an undersized allocation.
Temporary debug logs at 4 checkpoints to identify where audio is lost:
1. SCStream audio callback firing (format, frame count)
2. Ring buffer state after write (available frames)
3. Mixer invocation (called? capturer ready?)
4. Frames read + sample values (system audio vs mic scale)

Rate-limited to every 100th callback to avoid log flooding.
The screen audio capture feature is working correctly; remove the
debug checkpoints that were added to trace the audio flow.
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