Menü schliessen
Created: September 12th 2024
Categories: Linux
Author: Marcus Fleuti

Fix Audio Delays and Missing Audio Notifications in Ubuntu and Linux Mint: Disabling Pipewire and Wireplumber SUSPEND

Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

Fix Pipewire Wireplumber Audio Delays and Missing Notifications in Ubuntu and Linux Minte

Introduction

Are you experiencing frustrating audio issues on your Ubuntu or Linux Mint system? Short sounds like notification alerts not playing, or experiencing delays in audio playback? You're not alone. This comprehensive guide will walk you through a common problem with the Pipewire audio server and provide a step-by-step solution to fix these annoying audio glitches.

Understanding the Problem: Pipewire and Wireplumber Suspend Mode

Before we dive into the solution, let's briefly explain what's causing this issue:

  • Pipewire: This is a modern audio and video server for Linux systems, designed to replace PulseAudio and JACK.
  • Wireplumber: A session and policy manager for Pipewire, handling the configuration and routing of audio streams.

The root of the problem lies in Pipewire's default behavior: it's configured to enter suspend mode after just 5 seconds of inactivity. While this might seem like a good idea for power saving, it can cause short sounds (like notification alerts) to be cut off or not play at all.

The Impact: Missing Notifications and Audio Delays

This default setting leads to two main issues:

  1. Short notification sounds may not play at all.
  2. There might be a slight delay when audio playback starts after a period of silence.

These problems can be particularly annoying for users who rely on audio cues for notifications or those who frequently start and stop audio playback.

The Solution: Modifying Wireplumber Configuration

To resolve this issue, we need to modify the Wireplumber configuration to either disable the suspend functionality entirely or set a much longer timeout. Here's how to do it:

Step 1: Create a Custom Configuration File

First, we need to create a new configuration file in your user directory. This ensures our changes won't be overwritten by system updates.

mkdir -p ~/.config/wireplumber/main.lua.d/
nano ~/.config/wireplumber/main.lua.d/50-disable-session-suspend.lua

Step 2: Add the Configuration

In the newly created file, add the following content :

table.insert (alsa_monitor.rules, {
  matches = {
    {
      -- Matches all sources.
      { "node.name", "matches", "alsa_input.*" },
    },
    {
      -- Matches all sinks.
      { "node.name", "matches", "alsa_output.*" },
    },
  },
  apply_properties = {
    ["session.suspend-timeout-seconds"] = 86400,  -- 0 disables suspend - on some systems this won't work and you need to set a high value like 86400 (1 day) instead
  },
})

This configuration sets the suspend timeout to 86400 seconds (24 hours), effectively preventing the audio server from entering suspend mode during normal usage. Check if the name of your Sink is also starting with "alsa_output" since the rules in the code above are programmed to match all sinks starting with "alsa_output". You might need to change that on your system. See Verifying the Fix chapter below for more information.

Step 3: Restart the Audio Server

After saving the file, you need to restart the Pipewire and Wireplumber services to apply the changes:

systemctl --user restart pipewire wireplumber

Verifying the Fix

To check if the fix has been applied successfully, you can monitor the status of your audio sinks using the following command:

watch -cd -n .1 pactl list short sinks

This command will continuously update and show the status of your audio sinks. You should see "IDLE" instead of "SUSPENDED" for your audio devices.

Considerations and Potential Drawbacks

While this solution effectively resolves the audio delay and missing notification issues, there are a few points to consider:

  • Slightly Increased Power Consumption: Keeping the audio device active may result in a minimal increase in power usage. However, for most desktop users, this difference will be negligible.
  • System-Specific Behavior: On some systems, setting the timeout to 0 (to completely disable suspend) might not work. In such cases, setting a high value like 86400 (1 day) is the recommended approach.
  • Future Updates: Keep in mind that major system updates might reset these settings, so you may need to reapply this fix after significant upgrades.

Compatibility and Testing

This solution has been tested by us and confirmed to work with:

  • Pipewire version 1.0.5
  • Linux Mint 22.0
  • Ubuntu 24.04 LTS (the Linux Mint 22.0 base system)

While primarily observed in GNOME/X11 environments (the standard Linux Mint desktop), this issue and its solution may also apply to KDE and Wayland-based systems, as the root cause lies within the Pipewire audio server itself.

Troubleshooting Common Issues

If you're still experiencing problems after applying this fix, consider the following troubleshooting steps:

  1. Check File Permissions: Ensure that the configuration file you created has the correct read permissions.
  2. Verify Pipewire Status: Run systemctl --user status pipewire to check if Pipewire is running correctly.
  3. Examine Logs: Look for any error messages in the system logs related to Pipewire or audio playback.
  4. Test with Different Applications: If the issue persists, try playing audio from various sources to isolate whether it's an application-specific problem.

Conclusion

By adjusting the Pipewire and Wireplumber settings as described in this guide, you should now be able to enjoy uninterrupted audio playback and timely notification sounds on your Ubuntu or Linux Mint system. This fix addresses a common frustration for many Linux users and demonstrates the flexibility and configurability of open-source audio solutions.

Remember, while this solution works for many users, audio configurations can be complex and vary between systems. If you continue to experience issues, don't hesitate to seek help from the Ubuntu or Linux Mint community forums.

We hope this guide has helped you resolve your audio issues and improved your Linux experience. Happy listening!