Skip to content

Conversation

@Umair-Syed
Copy link
Contributor

@Umair-Syed Umair-Syed commented Jan 16, 2026

🎯 Goal

Fixes #1151 - iOS: Microphone becomes unusable for other audio packages after leaving a call with 2 participants.

When another participant speaks during a call, WebRTC's Audio Device Module (ADM) starts audio playout. When the call ends, the ADM's playout Audio Unit continues to hold a reference to AVAudioSession, blocking other audio packages (like record, flutter_sound) from accessing the microphone. This results in silent recordings (0.00 amplitude) with no microphone indicator appearing.

🛠 Implementation details

Added pauseAudioPlayout() call in the _clear() method to stop the ADM's audio playout before disposing other resources.

On iOS, AVAudioSession is a shared resource that manages both input (microphone) and output (speaker). When remote audio is played, the ADM creates an Audio Unit that holds an active reference to the audio session. Without explicitly stopping this playout via pauseAudioPlayout() (which calls [adm stopPlayout] on the native side), the Audio Unit continues to "own" the audio session even after the call ends.

The fix ensures the audio output is properly stopped, releasing the audio session so other packages can take over.

🎨 UI Changes

No UI changes - this is an internal audio session management fix.

🧪 Testing

Steps to reproduce the issue (before fix):

  1. Create an app that uses both stream_video_flutter and another audio recording package (e.g., record)
  2. Record audio - verify it works (non-zero amplitude)
  3. Join a Stream video call with another participant
  4. Have the other participant speak (their audio plays on your device)
  5. Leave the call
  6. Attempt to record audio again
  7. Before fix: Recording shows 0.00 amplitude, no microphone indicator

Steps to verify the fix:

  1. Same setup as above
  2. After the fix, recording should work normally after leaving the call (non-zero amplitude, microphone indicator visible)
Test patch for verification
// In your app, after leaving a Stream call:
import 'package:stream_webrtc_flutter/stream_webrtc_flutter.dart' as rtc;

// Before calling call.leave(), add:
await rtc.Helper.pauseAudioPlayout();

// Then proceed with normal leave flow
await call.leave();


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * iOS audio session is now released when leaving a call, allowing other audio apps to access the microphone.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

@Umair-Syed Umair-Syed requested a review from a team as a code owner January 16, 2026 13:39
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Pauses iOS audio playout during RTC manager disposal so the iOS audio session is released when leaving a call, preventing the microphone from remaining unusable for other audio packages.

Changes

Cohort / File(s) Summary
Changelog
packages/stream_video/CHANGELOG.md
Adds note that iOS audio session is released when leaving a call so other audio packages can access the microphone.
RTC manager dispose logic
packages/stream_video/lib/src/webrtc/rtc_manager.dart
On iOS, calls RtcMediaDeviceNotifier.instance.pauseAudioPlayout() inside dispose (try/catch, logs failures) before disposing publisher/subscriber.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • renefloor
  • xsahil03x

Poem

🐰
The mic was trapped, now hops away,
A gentle pause clears out the fray.
iOS breathes, the session freed,
Other apps can now proceed. 🥕🎧

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: pausing audio playout on iOS when leaving a call to release the audio session.
Description check ✅ Passed The description covers Goal, Implementation details, UI Changes, and Testing with reproduction steps and verification instructions, mostly following the template.
Linked Issues check ✅ Passed The changes address the core requirement from #1151: adding pauseAudioPlayout() call to release the iOS audio session when leaving a call so other audio packages can access the microphone.
Out of Scope Changes check ✅ Passed All changes are directly related to #1151: CHANGELOG entry documents the fix, and RtcManager modification implements the audio playout pause on iOS.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Umair-Syed Umair-Syed changed the title fix(llc): pause audio playout when leaving call to release iOS audio … fix(ui): pause audio playout when leaving call to release iOS audio … Jan 16, 2026
@Brazol
Copy link
Contributor

Brazol commented Jan 23, 2026

Hi @Umair-Syed, thanks for taking the time to contribute this!

If you’re okay spending a bit more time on it, I think the dispose() method in RtcManager would be a better place to make this call. Please also wrap it in a platform check (CurrentPlatform.isIos), since it’s only relevant on iOS. Finally, we’ll need to add an entry to the changelog for CI to pass.

If you’d prefer not to spend any more time on this, just let us know—we can open a separate PR that builds on your changes. Thanks again!

@Umair-Syed
Copy link
Contributor Author

Hi @Umair-Syed, thanks for taking the time to contribute this!

If you’re okay spending a bit more time on it, I think the dispose() method in RtcManager would be a better place to make this call. Please also wrap it in a platform check (CurrentPlatform.isIos), since it’s only relevant on iOS. Finally, we’ll need to add an entry to the changelog for CI to pass.

If you’d prefer not to spend any more time on this, just let us know—we can open a separate PR that builds on your changes. Thanks again!

Thanks! Sure, I’ll take care of it and update as soon as I get the time.

@Umair-Syed Umair-Syed force-pushed the fix/ios-audio-session-release-1151 branch from 56b3a61 to ce34c92 Compare January 24, 2026 12:26
@Umair-Syed Umair-Syed changed the title fix(ui): pause audio playout when leaving call to release iOS audio … fix(llc): pause audio playout when leaving call to release iOS audio session Jan 24, 2026
@Umair-Syed Umair-Syed force-pushed the fix/ios-audio-session-release-1151 branch from ce34c92 to d6f3151 Compare January 24, 2026 12:30
@Umair-Syed
Copy link
Contributor Author

Hi @Umair-Syed, thanks for taking the time to contribute this!

If you’re okay spending a bit more time on it, I think the dispose() method in RtcManager would be a better place to make this call. Please also wrap it in a platform check (CurrentPlatform.isIos), since it’s only relevant on iOS. Finally, we’ll need to add an entry to the changelog for CI to pass.

If you’d prefer not to spend any more time on this, just let us know—we can open a separate PR that builds on your changes. Thanks again!

@Brazol I updated the PR as per your suggestions. Please check and let me know if there is anything else.

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 6.44%. Comparing base (c507e53) to head (d6f3151).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...kages/stream_video/lib/src/webrtc/rtc_manager.dart 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1155      +/-   ##
========================================
- Coverage   6.44%   6.44%   -0.01%     
========================================
  Files        600     600              
  Lines      41975   41978       +3     
========================================
  Hits        2705    2705              
- Misses     39270   39273       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@Brazol Brazol left a comment

Choose a reason for hiding this comment

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

LGTM

@Brazol Brazol merged commit f69e458 into GetStream:main Jan 26, 2026
15 of 16 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.

BUG: iOS: Microphone becomes unusable for other audio packages after leaving a call with 2 participants

2 participants