Odroid-RetroArena / RetroPie-Setup

Shell script to set up a Raspberry Pi/Odroid/PC with RetroArch emulator and various cores
Other
6 stars 0 forks source link

Use alsathread as default audio driver instead of pulse #7

Open mrvanes opened 6 years ago

mrvanes commented 6 years ago

As pulse is only a wrapper around alsa and there is no need to mix other sound sources, there is some latency gain in configuring alsathread as a default retroarch audio driver instead of pulse. Also, pulse should be stopped from autospawning then.

/opt/retropie/config/all/retroarch.cfg

audio_driver = "alsathread"

/etc/pulse/client.conf

autospawn = no
mrvanes commented 6 years ago

The emulationstation errors about 'Failed to find mixer elements!' can be resolved by replacing /etc/asound.conf with (it is looking for a volume control called 'Master' which isn't available on the HDMI audio device)

pcm.!default {
        type             plug
        slave.pcm       "softvol"
}

ctl.!default {
        type hw card 0
}

pcm.softvol {
        type softvol
        slave.pcm "hw:0,0"
        control {
                name "Master"
                card 0
        }
}
Jmanning6600 commented 6 years ago

Mr vanes I appreciate all of your recommendations but I believe changing the default audio driver to alsa thread will do more harm than good myself and the team have spent months at this point configuring these cores and one thing I can say is they are very temperamental. Something as simple as disabling a hack could be night and day difference in a core. We could test alsa thread with every core which is a ton of work and see which ones show improvement but to do it all at once is a recipe for disaster.

slappymcphee commented 6 years ago

Thanks for the input (pardon the pun) @mrvanes . We will investigate and test the alsa audio suggest as well as the update to asound.conf. This manual building for audio devices that I had to do to get things working was and is still new to me so the suggestion is def appreciated.

mrvanes commented 6 years ago

btw, I forgot to say that the asound.conf file needs to be read by an alsa capable application to register once:

$ speaker-test -c2 -twav

Then, alsamixer should show the new softvol controller 'Master'.

mrvanes commented 6 years ago

lr-prdoom and lr-tyrquake seem to suffer from alsa(thread) audio_driver. I had to set it to pulse for them to keep audio. I set default sink of pulse to alsa softvol so that pulse still only sounds as loud as what ES and/or alsamixer has set it to. Pulse softvol can tested using

$ speaker-test -Dpulse -c2 -twav

While lowering/increasing volume with alsamixer in another console.

slappymcphee commented 6 years ago

looks like you are making good progress with coding and testing. hmu on Discord if you feel like you might want to discuss further engagement with the team.

mrvanes commented 6 years ago

Well... to be honest my first entrance wasn't received very warm by sarge, I nevertheless enjoy tinkering with the xu4 and retropie, so I thought I'd resort to the somewhat more organised issues on github to discuss my findings and opinion.

slappymcphee commented 6 years ago

I have initiated a DM thread with you on our Discord when you have the chance to read it.

mrvanes commented 6 years ago

Ok, some more insights. I turns out all retroarch libretro cores prefer pulse over alsa, even if alsa is configured as the audio device. Further, a client-spawned pulseaudio daemon is unstable, hence my loss of audio in quake and doom. If I disable autospawning in /etc/pulse/client.conf and force alsa as audio_driver all is well, even in quake and doom. pulseaudio takes 50% cpu on 1 of the big cpu's, so that's a serious gain in performance I'd say.