`default-fragment-size-msec` is wrong by default
Well I have some odd news to report on all of the audio issues that I have been reporting both here and through Steam Support. In short: setting default-fragment-size-msec = 5 in /etc/pulse/daemon.conf fixes ALL of my audio problems, even ones that were completely unrelated.
With that line commented out (which it was out-of-box for my Syber Steam Machine P), I got these results:
- Sound did not consistently output from my TV via HDMI. It might work at first, and then after launching a game, there would be no audio. Sometimes, changing the volume on the TV restored audio output.
- Sound stuttered in Civ V, Metro 2033 Redux, Talos Principle, possibly others, when using my USB headset.
- SteamOS would forget my preferred audio output after every reboot.
- Audio calibrator in Crypt of the NecroDancer showed 0ms audio latency. (Tested multiple times.)
With the line uncommented and the value set to 5, I now get these results:
- Sound consistently outputs from my TV via HDMI, no fiddling required.
- Sound doesn't stutter under any circumstances, fixing issue #421 for me.
- SteamOS would remember my preferred audio output after every reboot, fixing issue #358 for me.
- Audio calibrator in Crypt of the NecroDancer shows ~70ms audio latency. (Tested multiple times.)
I tested this by commenting out the line, rebooting, testing everything, then uncommenting it, rebooting, and testing everything again. I did this multiple times to ensure I'm not crazy.
And this is the only change I made to my system configuration. Before testing this, I reverted the fix that I had previously applied from this post: http://steamcommunity.com/groups/steamuniverse/discussions/1/648814395855559064/
That workaround had basically just disabled my Analog Audio output to force HDMI output to be default on each boot. But as you can see from above, this workaround isn't necessary if default-fragment-size-msec is set correctly. I don't understand why this works, but these are my results.
Now if I remember correctly, all the lines were commented out by default in SteamOS's /etc/pulse/daemon.conf. So I went into the /etc/pulse/daemon.conf of an Ubuntu 14.04 install and found that the following lines were not commented out and were set as shown below:
resample-method = speex-float-1
flat-volumes = no
default-fragments = 8
default-fragment-size-msec = 10
deferred-volume-safety-margin-usec = 1
Ubuntu doesn't have any audio problems with Steam games that I'm aware of, and just for comparison's sake, I did the audio calibrator in Crypt of the NecroDancer and got ~52ms. It's unfortunate that having a perfectly working system requires audio latency but that seems to be the case.
I haven't bothered testing any values for default-fragment-size-msec other than 5 because I'm just so happy to have a perfectly working system now. But I would be willing to do further tests if it's helpful.
Addendum: I'm getting far better results using the fragment settings from Ubuntu. It seems when I moved the machine back to the living room TV after doing all those tests at my desk, it was back to its old behavior of forgetting the preferred audio output and not consistently sending audio through HDMI. Fixed by using the same numbers as Ubuntu for default-fragments and default-fragment-size-msec.
Thanks for the detailed report. Can you tell us what version of the kernel you were using when you ran these experiments?
Linux steamos 4.1.0-0.steamos.3-amd64 #1 SMP Debian 4.1.6-2+steamos3 (2015-10-22) x86_64 GNU/Linux
I want to post an update on this issue.
After more extended testing with the configuration from Ubuntu (default-fragments 8, default-fragment-size-msec 10), I have reverted to the original recommendation I made in the first post, which is just to use default-fragment-size-msec = 5 and no other changes in /etc/pulse/daemon.conf. This seems to work the most reliably under the widest variety of environments.
I spent the holidays over several different houses with different TVs to do my testing. The only issue I ever encountered with this configuration is that with one TV, the sound would disappear for a very short amount of time while playing a game, for maybe 1 second or less, and then return. That TV never has any sound issues with any other system.
Now I want to draw your attention to a couple pages on the Internet confirming that the default sound settings are indeed wrong. See this video here: https://youtu.be/LBIFHo03V-4?t=225
He seems to experience a similar problem to what I did, with the audio sometimes working and sometimes not. One difference with his audio problems though are that unlike him, I never experienced the clicking sound, which you can hear in the video.
And there is also this: https://www.reddit.com/r/SteamOS/comments/3z5tvw/stuttering_audio_with_usbconnected_bose_speakers/
He fixed his USB audio problems by using precisely the configuration change that I recommended above.
Where i could get manual about why those settings default and which better or worse? Arch for example has
; default-fragments = 4
; default-fragment-size-msec = 25
According to this guide those settings specific for each audio devices and should be calculated each time. https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Setting_the_default_fragment_number_and_buffer_size_in_PulseAudio
Where i could get manual about why those settings default and which better or worse? Arch for example has
; default-fragments = 4 ; default-fragment-size-msec = 25According to this guide those settings specific for each audio devices and should be calculated each time. https://wiki.archlinux.org/index.php/PulseAudio/Troubleshooting#Setting_the_default_fragment_number_and_buffer_size_in_PulseAudio
The default value causes latency issue in games if the default sample rate is higher than 48KHz