Back
Featured image of post Resolving Audio Issues with Microsoft Teams on macOS

Resolving Audio Issues with Microsoft Teams on macOS

Recently, I encountered a situation where colleagues started asking, "Do you have a new headset? Your microphone quality is terrible!"

Interestingly, I had not changed my headset at all. The only recent change was that I reinstalled my Mac and installed Microsoft Teams from scratch.

Initial Troubleshooting Steps

My first step was to check the Teams settings. I toggled the Automatically adjust mic sensitivity option, hoping it would resolve the issue since it had already worked for me in the past.

Unfortunately, this made no difference. Next, I cleared the cache of my Teams client, but this also did not improve the audio quality.

Digging a bit deeper: MSTeamsAudioDevice driver

Wanting to get to the root cause of the issue, I dug a bit deeper and discovered that the MSTeamsAudioDevice driver appeared to be the root cause.

My initial thought was that updating the driver with a full installation of Microsoft Teams and selecting the option to update the driver would fix the problem.

However, even after performing a full installation and trying to update the driver, the issue remained unresolved.

Next Step: Removing the problematic MSTeamsAudioDevice driver

Because none of the earlier steps solved the problem, the next logical step was to remove the MSTeamsAudioDevice driver entirely.

#!/usr/bin/env bash
#set -x # Enable debugging
#set -euo pipefail # Strict error handling
IFS=$'\n\t' # Set IFS to handle spaces in filenames correctly

# Script to clear Microsoft Teams cache and restart the application on macOS
# The MSTeamsAudioDevice driver is removed to fix audio issues in Microsoft Teams

# Just in case!
if [ "$(uname -s)" != "Darwin" ]; then
 error "This script runs only on macOS systems."
 exit 2
fi

TEAMS_APP_NAME="Microsoft Teams"

# Close Microsoft Teams if it's running
if pgrep -f "$TEAMS_APP_NAME" >/dev/null 2>&1; then
 osascript -e "tell application \"${TEAMS_APP_NAME}\" to quit" >/dev/null 2>&1 || true
 sleep 2
fi

# Kill all for the Microsoft Teams processes to ensure complete closure
if pgrep -f "$TEAMS_APP_NAME" >/dev/null 2>&1; then
 echo "Forcing kill for $TEAMS_APP_NAME"
 pkill -f "$TEAMS_APP_NAME" >/dev/null 2>&1 || true
 sleep 1
fi

# Define directories to clear
declare -a PATHS_TO_HANDLE=(
 "$HOME/Library/Containers/com.microsoft.teams2/Data/Library/Application\ Support/Microsoft/MSTeams/"
 "$HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.teams/"
 "$HOME/Library/Containers/com.microsoft.teams2/com.microsoft.teams2.notificationcenter/"
 "$HOME/Library/Containers/com.microsoft.teams2/com.microsoft.teams2.respawn/"
 "$HOME/Library/Containers/com.microsoft.teams2/com.microsoft.teams2.widgetextension/"
 "$HOME/Library/Containers/com.microsoft.teams2/Data/Library/Caches/com.microsoft.teams2/"
)

# Do the clearing
for TARGET_PATH in "${PATHS_TO_HANDLE[@]}"; do
 if [ -d "$TARGET_PATH" ]; then
  echo "Clearing contents of: $TARGET_PATH"
  rm -rfv "${TARGET_PATH:?}/"* || echo "Failed to clear contents of: $TARGET_PATH"
 else
  echo "Directory does not exist, skipping: $TARGET_PATH"
 fi
done

# Remove the MSTeamsAudioDevice.driver if it exists
if [ -d "/Library/Audio/Plug-Ins/HAL/MSTeamsAudioDevice.driver" ]; then
 sudo rm -rfv "/Library/Audio/Plug-Ins/HAL/MSTeamsAudioDevice.driver" || echo "Failed to remove driver"

 # Kill all for the Coreaudio process to reset audio services (twice for reliability)
 if pgrep -f "$pattern" >/dev/null 2>&1; then
  echo "Forcing kill for pattern: $pattern"
  sudo pkill -f "$pattern" || true
 fi
 sleep 1
 if pgrep -f "$pattern" >/dev/null 2>&1; then
  iechonfo "Forcing kill for pattern: $pattern"
  sudo pkill -f "$pattern" || true
 fi

 sleep 1

 if sudo launchctl kickstart -k system/com.apple.audio.coreaudiod >/dev/null 2>&1; then
  echo "Used launchctl kickstart to restart coreaudiod"
 else
  echo "launchctl method failed, falling back to killall"
  sudo killall coreaudiod || true
 fi

 sleep 2

 if pgrep -x coreaudiod >/dev/null 2>&1; then
  echo "coreaudiod running again after restart"
 else
  echo "coreaudiod not running after restart attempt"
 fi
fi

# Restart Microsoft Teams (Take longer time to launch due to cache clearing)
open -a "$TEAMS_APP_NAME" >/dev/null 2>&1 || warn "Failed to open $TEAMS_APP_NAME with open -a"
sleep 5

# Verify if Teams is running
if pgrep -f "$TEAMS_APP_NAME" >/dev/null 2>&1; then
 echo "$TEAMS_APP_NAME is running. If audio issues persist, reboot or re-login may be required."
else
 echo "Failed to start $TEAMS_APP_NAME."
fi

The script removes all audio-related files from Microsoft Teams, clears some Teams releated cache, and removes the MSTeamsAudioDevice.driver from macOS. Therefore, you need administrative permission (sudo is invoked within the script).

Microsoft Teams will then restart. Please be aware that the initial restart may take slightly longer than usual.

Prevent this in the future

Make sure to unselect “Teams Audio Driver” when you install or manually update Microsoft Teams.

unselect Teams Audio Driver

If you update Microsoft Teams either through the Autoupdate feature or by using the update function from the app itself, the MSTeamsAudioDevice.driver should not be automatically installed.

You can keep the script above on your Mac and run it if the MSTeamsAudioDevice.driver is reinstalled.