Skip to content

fix(ios): don't mix recording with other apps' audio#214

Open
skrtdev wants to merge 1 commit into
SimformSolutionsPvtLtd:masterfrom
skrtdev:fix/recorder-mixwithothers
Open

fix(ios): don't mix recording with other apps' audio#214
skrtdev wants to merge 1 commit into
SimformSolutionsPvtLtd:masterfrom
skrtdev:fix/recorder-mixwithothers

Conversation

@skrtdev
Copy link
Copy Markdown

@skrtdev skrtdev commented May 21, 2026

Summary

The AVAudioSession options passed to setCategory(.playAndRecord, options:) in AudioRecorder.startRecording currently include .mixWithOthers:

let options: AVAudioSession.CategoryOptions = [.defaultToSpeaker, .allowBluetooth, .mixWithOthers]

.mixWithOthers tells 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 .mixWithOthers from the recorder's category options:

let options: AVAudioSession.CategoryOptions = [.defaultToSpeaker, .allowBluetooth]

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

  • Play music in Spotify (or Apple Music / Podcasts).
  • Start a recording with the library.
  • Confirm: other audio stops, the recorded file contains only mic input (no music in the background).
  • Stop the recording — other audio resumes (standard AVAudioSession behaviour).
  • Record with no other audio playing — recording still works as before.

🤖 Generated with Claude Code

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.
Copilot AI review requested due to automatic review settings May 21, 2026 11:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 .mixWithOthers from the recorder session’s AVAudioSession.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.

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