ValveSoftware / steam-for-linux

Issue tracking for the Steam for Linux beta client
4.24k stars 175 forks source link

Steam Remote Play plays sound on both the client and the host, when the "Play sound on host" option is disabled. #6512

Open baatochan opened 5 years ago

baatochan commented 5 years ago

Your system information

Please describe your issue in as much detail as possible:

So the problem looks like Steam on Manjaro can't or don't create a fake output device. It plays the sound on one of the existing ones (you're lucky if it's not used). The situation looks like (when the chosen output is used) the sound is played on normal output and in fact the sound is played on normal speakers and remote TV speakers (the checkbox in settings to leave a sound on the host pc is unchecked).

The only workaround as for now is to leave sound on that output set to 1% because it's barely heard then and on TV speakers everything stays fine (you can't mute the output however because then the stream audio is muted as well).

I can confirm that this bug can be reproduced on 3 manjaro running PCs, while on one linux mint PC everything is fine and the fake output is getting created.

Steps for reproducing this issue:

  1. Install Steam on Manjaro
  2. Connect from Steam Link
  3. Try to play any audio on Manjaro PC
baatochan commented 5 years ago

I'm pretty sure that this reddit post is about that problem (it's not mine post): https://www.reddit.com/r/Steam_Link/comments/c1krmv/steam_link_on_manjaro_audio_issue/

u83rmensch commented 4 years ago

I dont suppose there has been any progress on this issue? I too have the same problem across different distros. audio plays on host and client (in this case steam link (and app) from Pop_Os/Manjaro

ghost commented 4 years ago

Chiming in to say I have the same issue on two separate manjaro installs.

atylmo commented 4 years ago

I have this problem with Ubuntu, although I think my cause is a little different. I'm connecting from Ubuntu to Windows, and the audio will play on both or only the host. I found a little workaround by disabling the HDMI audio out on Windows but then I have no sound otherwise (when not streaming) because that's how my speakers are connected. I guess in my case it's not specifically related to Linux.

Not all games have issues, but two that do are Sega Mega Drive/Genesis Classics Collection and Atari Vault. On those I get sound only on the host (Windows) unless I disable HDMI audio. The Steam Link app doesn't have this issue and mutes the host correctly.

devonallie commented 4 years ago

Same issue on Pop_OS 19.10

UndeadKernel commented 4 years ago

Experiencing the same problem using Arch. I tried copying the Pulseaudio configuration used in SteamOs into my Arch installation and I was still not able to fix the problem.

Has anybody being able to test if this issue is also there in SteamOs?

ArtemSmaznov commented 4 years ago

I have the same problem when hosting Steam on any of my Arch installs (Vanilla Arch and Manjaro) - sound is played on Host when streaming via Steam Link or from another PC with steam on in. Corresponding checkbox is off. My workaround is to mute all sounds on Host machine before I try Streaming

atylmo commented 4 years ago

Another game I'm having this issue with is DiRT Rally 2.0. I'm streaming from my Windows 10 PC to Ubuntu 19.10 and the sound only plays on the Windows side.

Edit: Changing the client streaming quality to "Beautiful" makes it work.

Edit 2: Actually, changing the client quality setting to anything else seems to reset the audio to make it work. You can then change it back and it will still work. I should add that the host is connected to a KVM switch so that might throw a wrench into things.

joeknock90 commented 4 years ago

Same issue Arch to Arch and Arch to Steam Link. Audio plays on host no matter what. Changing streaming quality did not do anything for me.

LarnuUK commented 4 years ago

Having the issue as well. "Play audio on Host" is not enabled (in fact, turning it on and off does absolutely nothing, it's a pointless button) and yet the host still plays the sound. I shouldn't have to go into the room the host is in and plug a set of headphones in to spot hearing the game noise in the distant background.

gamerminstrel commented 4 years ago

I am on a vanilla install of Ubuntu 20.04 and am experiencing this issue as well. Play Audio on Host is unchecked, but streaming to any other device outputs sound from both the client and the host devices.

parkerlreed commented 4 years ago

Same here. Arch to Steam Link hardware/application. Never mutes host. Been an issue for as long as I can remember.

green3g commented 4 years ago

My issue is similar - audio plays on the host but not on the client (which I have an android nvidia shield). Anyone have tips to getting the audio to play to the shield at least? I can manually turn down my monitor on the host. Host: Manjaro Kernel: 5.7.0.3-MANJARO

Update: July 13 - its working now. I didn't necessarily change anything obvious but maybe an update triggered it to work .

pingubot commented 3 years ago

Same happens for me on Opensuse Tumbleweed

DeviceLimit commented 3 years ago

Encountering this issue on EndeavorOS (Arch based) with kernel 5.13. Play Audio on Host is unchecked but still audio comes from the host

contentfree commented 3 years ago

Same issue on macOS Mojave.

sunsetrain commented 3 years ago

Same. Windows 10 pro >>> Ubuntu 21.04 LTS

goffy59 commented 3 years ago

Streaming from Linux Host to Steam Link on PopOS 21.04. I had the same issue. My build in speaker on my desktop was playing and so was my steam link/hdmi. Found a possible fix for this. I went to settings on my steam link and re ran the audio wizard. I changed the outpour from the built in speaker to the built in output (not headset or speaker). I’m thinking either the wizard just needed to be ran or in my case I had to switch the output device since by putting it on built in line out there is no speaker attached. So now all the sound comes through my steam link and works great. Not sure if this can help everyone but I hope it helps some people and please let me know if you want clarification. I wrote this on my phone so I apologize for any miss spellings or confusion.

pratith commented 3 years ago

It has been what two years now since this issue has been reported? Valve could easily fix this but don't seem to be interested to, so here is my workaround that I confirmed works with my Steam Link hardware and Manjaro and Pop OS.

NOTE: This automatically mutes the Linux host when you start remote play, but you have to manually restore audio on the host after you stop remote play. More details below. For this workaround, you need to have pulseaudio, pacmd and perl installed.

First, we need to add a null sink to redirect all the audio streams to. So add this line in /etc/pulse/default.pa for system wide or ~/.config/pulse/default.pa for per user settings, and reboot:

load-module module-null-sink sink_name=steamNullSink sink_properties="device.description='Steam Null Sink'"

Second, I had problems with some apps switching active audio streams to a different sink on the fly, so create a file ~/.alsoftrc with the following content to fix that:

[pulse]
allow-moves=yes

Next, create a directory to place all the scripts we are going to create. I placed them in /home/\<your-username>/workspace/steam-null-sink.

switch-sink.sh:

This script takes in a sink name as an argument and sets it as the default sink, switches all the applications' audio streams to redirect to the specified sink, and then makes Steam's recorder to monitor this sink.

#!/usr/bin/env bash

case "${1:-}" in
  (""|list)
    pacmd list-sinks |
      grep -E 'index:|name:'
    ;;
  ([a-zA-Z0-9_.-]*)
    echo switching default
    pacmd set-default-sink $1 ||
      echo failed
    echo switching applications
    pacmd list-sink-inputs |
      awk '/index:/{print $2}' |
      xargs -r -I{} pacmd move-sink-input {} $1 ||
        echo failed
    echo switching steam recorder to monitor this source
    pacmd list-source-outputs |
      tr '\n' '\r' |
      perl -pe 's/.*? *index: ([0-9]+).+?application\.process\.binary = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' |
      tr '\r' '\n'|
      awk -F ":" '/steam/ {print $2}'|
      xargs -r -I{} pacmd move-source-output {} $1.monitor ||
        echo failed
    ;;
  (*)
    echo "Usage: $0 [|list|<sink name to switch to>]"
    ;;
esac

steam-remote-play-monitor-start.sh:

This script monitors Steam's streaming log to check if remote play to Steam Link hardware has started, backs up the current audio device (sink) so that we can restore it later after remote play is stopped, and automatically switches the sink to the null sink we created in the first step using switch-sink.sh!

Now, change STEAMNULLSINK_HOME, STEAM_HOME according to what you are using, change $STEAM_HOME/steam/logs/streaming_log.txt to $STEAM_HOME/debian-installation/logs/streaming_log.txt for Pop OS, and you may have to change the search string "Streaming started to Steam Link" to something else if you aren't using Steam Link hardware like me, not sure.

#!/usr/bin/env bash

export XDG_RUNTIME_DIR="/run/user/$(id -u)"

USERNAME=$(whoami)
STEAMNULLSINK_HOME="/home/$USERNAME/workspace/steam-null-sink"
STEAM_HOME="/home/$USERNAME/.steam"

tail -n 0 -F $STEAM_HOME/steam/logs/streaming_log.txt |
grep --line-buffered 'Streaming started to Steam Link' |
while read; do DEFAULT_SINK=$(pacmd info |  awk -F ":" '/Default sink name:/ {print $2}'); if [[ $DEFAULT_SINK != " steamNullSink" ]]; then echo "$DEFAULT_SINK" > $STEAMNULLSINK_HOME/default-sink.backup; fi; $STEAMNULLSINK_HOME/switch-sink.sh steamNullSink; done

switch-to-default-sink.desktop:

Unfortunately, I couldn't find a way to automatically switch the audio sink back to the original one after stopping remote play on Steam Link. I couldn't find anything in Steam's logs that indicates that remote play has stopped. So I created this desktop shortcut and pinned it to my taskbar so that I can switch back to the original audio sink with just a click. Change all paths again as necessary.

[Desktop Entry]
Version=1.0
Exec=sh -c 'USERNAME=$(whoami); STEAMNULLSINK_HOME="/home/$USERNAME/workspace/steam-null-sink"; DEFAULT_SINK=$(cat $STEAMNULLSINK_HOME/default-sink.backup); $STEAMNULLSINK_HOME/switch-sink.sh $DEFAULT_SINK'
Name=Switch To Default Audio Sink
GenericName=Script
Path=/home/<your-username>/workspace/steam-null-sink
Icon=speaker-icon.jpg
Encoding=UTF-8
Terminal=false
Type=Application
Categories=Utilities;

Give executable permission to all these scripts we have created:

sudo chmod +x steam-remote-play-monitor-start.sh
sudo chmod +x switch-sink.sh
sudo chmod +x switch-to-default-sink.desktop

Finally, schedule cron job to start steam-remote-play-monitor-start.sh automatically at boot: crontab -e Then paste this line in the file, save and reboot: @reboot /home/<your-username>/workspace/steam-null-sink/steam-remote-play-monitor-start.sh

Hope this helps others as well.

J-Rios commented 2 years ago

This issue hit me too...

SO:

$ uname -a

Linux USER-HOSTNAME 5.11.0-43-generic #47~20.04.2-Ubuntu SMP Mon Dec 13 11:06:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Steam client application:

Built: Dec 16 2021, at 22:39:26
Steam API: v020
Steam package version: 1639697812
sontarin commented 2 years ago

I'm seeing this issue as well on Fedora 35:

[user@host01 ~]$ uname -a Linux host01 5.16.7-200.fc35.x86_64 #1 SMP PREEMPT Sun Feb 6 19:53:54 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Built: Jan 16 2022, at 17:34:49 Steam API: v020 Steam package version: 1642451672

azlekayn commented 2 years ago

Seeing the same issue on Endeavor OS

5.16.14-arch1-1

dusankx commented 2 years ago

Same issue on Steam Deck.

YourHuckleberry commented 2 years ago

Same issue.

CKWarner commented 2 years ago

Potentially relevant detail from #8810 : using the volume buttons on a Steam Deck client gets passed through to the host to affect its volume settings (volume notification pops up on the host).

StephenWetzel commented 2 years ago

I have this problem too, I came up with my own hacky work around, inspired by https://github.com/ValveSoftware/steam-for-linux/issues/6512#issuecomment-917795983 above. Mine is much simpler and may break at any moment.

I just ran ps aux before and during Steam streaming and looked for any new processes. The only new one I found was called steam_monitor. I confirmed that does not show up for me when playing a Steam game directly on my PC. If this breaks, then I may try parsing the logs like @pratith did above.

Then I wrote a shell script that looks for that process and then sets the volume to 10% if it sees it. That's it. You have to set to volume back up later when you are on your PC. 10% was low enough for me, but of course you can choose whatever you want, including 0%. I have the name of the process as an argument you pass into the script so that it's easier to change if that process gets renamed. I just run the script every minute with cron.

I use KDE with PulseAudio, if you use something else you may have to change the pactl command.

#!/bin/sh

# run in cron with:
# * * * * * ~/bin/steam_link_sound.sh steam_monitor >> ~/logs/steam_link_sound.log 2>&1

# ps aux lists all processes
# grep -v grep removes the grep command from that list
# grep -v `basename $0` remove this shell script from that list
# grep -c $1 gets the count of processes that match whatever was passed in as an argument when running this shell script
running=$(ps aux | grep -v grep | grep -v `basename $0` | grep -c $1)

# echo $running

if [ $running -ne 0 ]; then
  # if any processes were found, then set the volume level to 10%
  pactl set-sink-volume @DEFAULT_SINK@ 10%
fi
allstar87 commented 2 years ago

Same thing on Mint Cinnamon. I'm guessing this just won't get addressed?

jeffshee commented 2 years ago

Same issue on Fedora 36

joshsheedy commented 1 year ago

Same issue on Ubuntu 22.04

irfanhakim-as commented 1 year ago

Same issue on EndeavourOS (6.0.9-arch1-1)

CKWarner commented 1 year ago

Along with this issue and #6749 and doing inappropriate things with the audio stream, if there is audio playing on the host (such as a YouTube video, say) that audio also gets passed through to the remote stream. This is not correct behaviour. The Remote Play audio should only be audio from the game that's being played, and only needs to be synchronised to the game and the video stream. There shouldn't be other audio mixed in, and it shouldn't output to the host unless that is additionally requested as a separate audio output.

gongtao0607 commented 1 year ago

Same issue on Arch (6.3.1-arch2-1) and Steam Deck on year 2023.

ddulic commented 1 year ago

I ended up solving this by using an HDMI/DP Dummy Plug and switching to that display via https://github.com/phillipberndt/autorandr when using Remote Play.

joeknock90 commented 6 months ago

It's been almost 4.5 years since this issue has been reported. It doesn't seem like this would be that difficult to fix.

Moonlight seems to handle this entire situation by loading a null sink and switching audio over to it based on configurable settings.

It would be even pretty easy to write a bash script to this. It would be a nice feature to allow for a script to be run on the host when starting stream. Unfortunately to emulate that we need to use hacky cron jobs to accomplish that. I digress.

I would love to take a crack at fixing this myself, but unfortunately that's not the nature of closed source software.

I hope this doesn't come off as rude. Is there any progress on this? Is there some sort of blocker stopping what seems like it should be just a few lines of bash? We've fortunately seen some much needed improvements to Remote Play in the last few months which I am thankful for, but the feature still leaves much to be desired, and still feels somewhat ignored for Linux hosts.

cammelspit commented 4 months ago

This issue is obviously a bug and is a massive inconvenience for me. Proton makes Linux usable for day to day gaming but this issue really hampers usability for a lot of people. I am disabled and do much of my gaming in my bedroom but my gaming PC is an Arch VM running on my server, I know it's niche but there are a lot of reasons people user Remote Play daily. For now I have to use the Link to mute audio manually before loading up a game directly through Steam. The jump scare for my wife or son when the sound system in the living room pops on with a game intro without warning is just a normal thing right now if I forget to mute it manually...

FriendlyTroll commented 4 months ago

@cammelspit Maybe look into moonlight and sunshine combo for streaming since this issue is obviously ignored.