Skip to content

Fix microphone muting immediately after joining a call#1626

Open
rahul-lohra wants to merge 3 commits intodevelopfrom
bugfix/rahullohra/mic-toggle-before-track-publish
Open

Fix microphone muting immediately after joining a call#1626
rahul-lohra wants to merge 3 commits intodevelopfrom
bugfix/rahullohra/mic-toggle-before-track-publish

Conversation

@rahul-lohra
Copy link
Contributor

@rahul-lohra rahul-lohra commented Mar 9, 2026

Goal

Fix: Microphone audio leaks to remote participants after muting on call join

Problem: When a user joins a call and turns off their microphone immediately, other participants can still hear them despite the mic being toggled off.

Implementation

Investigation

If the microphone is toggled between JoinCallResponseEvent and TrackPublishedEvent, the mute state is not correctly reflected to other participants.

Microphone toggling works as expected after TrackPublishedEvent is received, where a subsequent mute action results in a TrackUnpublishedEvent being emitted.

Proposal -
After getting TrackPublishedEvent in RtcSession, we should check if mic is toggled off-or not. If set to off then set it to mute via

if (event.trackType == TrackType.TRACK_TYPE_AUDIO) {
    if (!isMicEnabled) {
        setMuteState(isEnabled = false, event.trackType) 
        publisher?.unpublishStream(event.trackType)
     }
 }

🎨 UI Changes

None

Testing

  1. Join a video room with User A and User B. User B will act as the remote participant to verify whether any audio leaks while User A is muted.
  2. Pass the lobby and enter the call.
  3. As soon as StreamCallActivity appears and the microphone is visible as enabled, immediately toggle the mic off.
  4. Wait for ~3–4 seconds until the TrackPublishedEvent is received.
  5. Speak into the microphone and confirm that no audio is heard by User B, ensuring that audio is not leaking despite the mic being muted.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed audio track handling when the microphone is disabled. Audio streams now properly unpublish and track state is correctly updated when microphone is turned off.

@rahul-lohra rahul-lohra self-assigned this Mar 9, 2026
@rahul-lohra rahul-lohra requested a review from a team as a code owner March 9, 2026 08:27
@rahul-lohra rahul-lohra added the pr:bug Fixes a bug label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@rahul-lohra rahul-lohra changed the title Improve Microphone audio toggle state [AND-1105] Improve Microphone audio toggle state Mar 9, 2026
@rahul-lohra rahul-lohra changed the title [AND-1105] Improve Microphone audio toggle state Improve Microphone audio toggle state Mar 9, 2026
@rahul-lohra rahul-lohra changed the title Improve Microphone audio toggle state Improve Microphone muting immediately after joining call Mar 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

This change adds a local microphone state validation during audio track publishing events. When an audio track is published, the code now checks if the microphone is enabled and automatically mutes the track and unpublishes the audio stream if the microphone is disabled.

Changes

Cohort / File(s) Summary
Audio Track Publishing Control
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt
Adds microphone state check in TrackPublishedEvent handler; mutes and unpublishes audio tracks when microphone is disabled during publishing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A microphone whispers in the Android dawn,
When audio tracks are published, control stays strong,
If the mic is silenced, the stream must pause,
The track obeys the microphone's laws! 🔇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix microphone muting immediately after joining a call' directly aligns with the PR's primary objective of preventing microphone audio leakage when a user mutes immediately after joining, and accurately reflects the main change.
Description check ✅ Passed The pull request description addresses the required sections: Goal clearly explains the microphone audio leak issue, Implementation details the investigation and proposed fix with code example, Testing section provides reproduction steps.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/rahullohra/mic-toggle-before-track-publish

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt`:
- Around line 1298-1303: The current block runs mute/unpublish for any published
audio track; restrict it to the local participant by adding a guard that only
runs this logic when the TrackPublishedEvent belongs to the local session (e.g.,
check event.participantId == localParticipant?.id or event.isLocal if available)
before calling setMuteState(isEnabled = false, event.trackType) and
publisher?.unpublishStream(event.trackType); keep the existing
TrackType.TRACK_TYPE_AUDIO check and use the existing symbols isMicEnabled,
setMuteState, publisher?.unpublishStream and event.trackType/event.participantId
or event.isLocal to locate and implement the guard.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2a6fc701-1f11-487d-8318-9a7d22e3fa34

📥 Commits

Reviewing files that changed from the base of the PR and between 94feaea and 60f2c78.

📒 Files selected for processing (1)
  • stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt

@rahul-lohra rahul-lohra changed the title Improve Microphone muting immediately after joining call Fix microphone muting immediately after joining a call Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.00 MB 12.00 MB 0.00 MB 🟢
stream-video-android-ui-xml 5.68 MB 5.68 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.27 MB 6.27 MB 0.00 MB 🟢

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant