fix(ios): don't mix recording with other apps' audio#214
Open
skrtdev wants to merge 1 commit into
Open
Conversation
The AVAudioSession options used when configuring a recording session currently include .mixWithOthers, which keeps other audio apps (Spotify, Apple Music, Podcasts, …) playing through the speaker during the recording. The microphone picks that audio up and bleeds it into the recorded file — turning every voice recording into a mix of the user's voice and whatever music was playing. Drop .mixWithOthers from the recorder session so starting a recording interrupts other audio. Recording should always own the audio route exclusively. The player session (AudioPlayer.swift) is unrelated and not touched here.
There was a problem hiding this comment.
Pull request overview
This PR adjusts the iOS recorder’s AVAudioSession configuration to prevent other apps’ audio from continuing during an active recording, avoiding speaker-to-mic bleed being captured in recorded files.
Changes:
- Removed
.mixWithOthersfrom the recorder session’sAVAudioSession.CategoryOptions. - Added an inline comment explaining why mixing is undesirable for recording sessions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The AVAudioSession options passed to
setCategory(.playAndRecord, options:)inAudioRecorder.startRecordingcurrently include.mixWithOthers:.mixWithOtherstells AVAudioSession to let other audio apps (Spotify, Apple Music, Podcasts, system sounds, …) keep playing through the speaker for the duration of the recording. While that is the right behaviour for a playback session, for a recording session it has a nasty side effect: the device microphone picks up the speaker output and bleeds it straight into the recorded file. Every voice memo recorded while music is playing ends up being a mix of the user's voice and the music.This is almost never what users want — the expected behaviour, and the behaviour every native voice-recording app on iOS implements, is that starting a recording interrupts other audio for the duration of the recording.
Change
Drop
.mixWithOthersfrom the recorder's category options:Starting a recording now interrupts other apps' audio, the recording captures only what the microphone hears (user's voice + ambient), and the previously-playing app resumes when the recording session ends. No other code changes.
The player session (
AudioPlayer.swift) is unrelated and not touched.Test plan
🤖 Generated with Claude Code