View previous topic :: View next topic |
Author |
Message |
krumpf Apprentice
Joined: 15 Jul 2018 Posts: 191
|
Posted: Wed Sep 22, 2021 9:03 pm Post subject: Alsa, Wine & Surround sound |
|
|
Hi Gentoo gamers !
I've been trying to get surround sound to work in wine on a pure alsa system, I managed to make it work by tweaking .asoundrc file, but this made me lose sound in firefox.
More details here, on winehq forums.
It seems to be the "type plug" alsa plugin that breaks things when using alsa & wine, but without that plugin, firefox won't play sounds anymore.
Are there people around using a 5.1 speaker setup & Alsa only who could confirm/deny the results of my experimentations ?
If anyone managed to make everything work at once, please let me know, I'd rather avoid to install pulseaudio (but it feels like the only solution) |
|
Back to top |
|
|
psycho Guru
Joined: 22 Jun 2007 Posts: 543 Location: New Zealand
|
Posted: Thu Sep 23, 2021 12:40 am Post subject: |
|
|
Hi Krumpf. I'm seeing similar issues and would be interested in some up-to-date advice around this stuff, too. I'm running pure ALSA (no pulseaudio) on all my Gentoo boxes, and this is fine for stereo (Gentoo's firefox, built from source with pulseaudio disabled, works just fine with ALSA), but firefox just won't give me sound through my surround (HDMI->receiver) systems. I haven't got any surround WINE stuff to test, but can confirm this much, on the boxes using the surround receiver:
* ALSA can do surround, no problem (e.g. if I use mplayer with -channels 6 to playback a surround audio file, all six channels light up as inputs on the receiver, and more importantly it sounds right)
* Chrome plays sound through pure ALSA too, no problem
* Firefox can't play audio under any circumstances at all...it's a silent browser, be it Gentoo's firefox, or firefox-bin via apulse (and with the necessary about:config edits).
My guess is that it's my .asoundrc messing firefox up (like yours it uses "type plug", for both playback and capture), so I could probably just swap that out for another one as part of launching firefox, but that's a nuisance if it disables surround for everything else while it's running, especially when it's so easy just to use chrome instead on the surround boxes...so it would be great if there's a fix that makes firefox behave the way other software (like mplayer) does, using pure ALSA for the HDMI->receiver audio. I don't understand why firefox is behaving any differently, when it works on the stereo setups, and other ALSA audio software works perfectly well on the surround setup even when it's only playing stereo (e.g. chrome, or mplayer with a normal mp3 works just fine...two channels light up on the receiver).
It would be nice if it were simply an obscure about:config setting or something, to get firefox to work properly. |
|
Back to top |
|
|
krumpf Apprentice
Joined: 15 Jul 2018 Posts: 191
|
Posted: Thu Sep 23, 2021 6:18 am Post subject: |
|
|
Firefox officially dropped Alsa support in favor of Pulseaudio (see last item in the "Changed" list here). Gentoo still allows building FF with alsa, but unless someone takes care about the source code, I doubt you'll get any improvement.
Even with alsa upmix plugin, 5.1 certified sounds (like those from fraunhofer) played through FF will default to stereo.
About Wine:
I've been tinkering a bit with my asoundrc, the "plug" plugin can work with 5.1 sound, need to add a line about channels for the slave device, so my current asoundrc looks like that now
Code: | pcm.!default {
type asym
playback.pcm "convert"
capture.pcm "D2capture"
}
###### format conversion ######
pcm.convert {
type plug
slave.pcm "dmixer"
rate_converter "samplerate_medium"
slave.channels "unchanged" # added this line
}
########### mixer ##############
pcm.dmixer {
type dmix
ipc_key 1337
ipc_key_add_uid true
slave {
pcm "XonarD2"
channels 6
period_size 1024 # fixes cracks (Talos Principle, Witcher 3)
}
}
########### capture ############
pcm.D2capture {
type dsnoop
ipc_key 31416
ipc_key_add_uid true
slave.pcm "XonarD2"
}
####### Xonar D2 Analog #######
pcm.XonarD2 {
type hw
card D2
device 0
} |
Edit: using this asoundrc, 5.1 sound works in games, but I got no more sound from Firefox
Adding the alsa upmix, like this
Code: | ###### format conversion ######
pcm.convert {
type plug
slave.pcm "upmix6ch"
rate_converter "samplerate_medium"
slave.channels "unchanged"
}
########## 5.1 upmix ###########
pcm.upmix6ch {
type upmix
slave.pcm "dmixer"
} |
allows Firefox to play sounds again, but it seems Wine then default to stereo and games get their sounds upmixed (need more testing) |
|
Back to top |
|
|
psycho Guru
Joined: 22 Jun 2007 Posts: 543 Location: New Zealand
|
Posted: Thu Sep 23, 2021 8:18 pm Post subject: |
|
|
It's great that you've figured out a good 5.1 config for WINE...thanks for posting it as I'll experiment with something similar...and that's really the main thing, that you can in fact get ALSA working with both WINE and firefox, even if not simultaneously. Of course it will be even better if we can find a way to configure .asoundrc so that it all works all the time, but I've already resorted to different configs for different scenarios, and it's perfectly OK...in fact I assume it's roughly what pulseaudio does behind the scenes, re-configuring ALSA for each different setup (otherwise, if there were some magical .asoundrc that worked for all setups, everyone would simply use that instead of pulseaudio).
I prefer using a little panel menu to switch between audio setups (.asoundrc symlinks), but you can use dbus or inotify or whatever to make it happen automatically in response to particular system events (pairing with bluetooth headphones or whatever), and in your case I guess you could just add it to your launchers for WINE stuff. In other words you could have a range of asoundrc configurations (in ~/.local/etc or wherever) and just make your .asoundrc a symlink to the appropriate one, setting things up so they're selected automatically as required. Obviously it would be better to find a way to make firefox work with that surround setup (all with the one consistent .asoundrc), so I'm still hopeful we'll find that solution...but having working configs for each scenario means it's basically doable with this workaround. |
|
Back to top |
|
|
krumpf Apprentice
Joined: 15 Jul 2018 Posts: 191
|
Posted: Thu Sep 23, 2021 8:40 pm Post subject: |
|
|
I tried some more stuff with asoundrc - link to the winehq forums post
It just leaves me with more questions
I start to wonder if I'll decide to install pulseaudio (which would induce quite some rebuilds amongst installed packages) before I lose my mental sanity. |
|
Back to top |
|
|
psycho Guru
Joined: 22 Jun 2007 Posts: 543 Location: New Zealand
|
Posted: Fri Sep 24, 2021 6:29 am Post subject: |
|
|
It does make this kind of thing (choosing among lots of different audio setups) easy, so yes, maybe it's not worth the effort, in your case, to avoid it. I couldn't get pulseaudio to do what I needed (maybe the selective one-set-of-bluetooth-headphones or both-simultaneously thing...I can't remember) so was quite happy to have an excuse to go back to ALSA out of necessity...because in principle I prefer pure ALSA to layering on a pile of additional stuff...but, if it actually achieves something you want and are unable to achieve without it, then it's basically doing its job and worth installing: I can't see the point in avoiding it on principle, if in practice it does what you need. |
|
Back to top |
|
|
krumpf Apprentice
Joined: 15 Jul 2018 Posts: 191
|
Posted: Sat Sep 25, 2021 7:18 pm Post subject: |
|
|
I got too much free time, so I did install pulseaudio, and recompiled wine with PA support, read about it here on winehq forums.
TLDR version: I've already removed pulseaudio from my system. |
|
Back to top |
|
|
krumpf Apprentice
Joined: 15 Jul 2018 Posts: 191
|
Posted: Mon Sep 27, 2021 10:57 am Post subject: |
|
|
Finally found the solution \o/
Code: | pcm.!default {
type asym
playback {
pcm {
@func getenv
vars [ ALSAPLUG ]
default "convert"
}
}
capture.pcm "D2capture"
}
###### format conversion ######
defaults.pcm.rate_converter "samplerate_medium"
pcm.convert {
type plug
slave.pcm "dmixer"
}
pcm.convertWine {
type plug
slave.pcm "dmixer"
slave.channels "unchanged"
}
[...rest of asoundrc file...] |
That asoundrc makes all sounds go through the default alsa route -here my "convert" plugin- which is nice for most apps like Firefox;
and it also creates a new env variable ALSAPLUG, that can be used in commandline/script to force an app to use another alsa route.
My launcher scripts for games with 5.1 sound support now include export ALSAPLUG="convertWine" so Wine feeds 6 channels sound to Alsa.
Edit: Tested with SkyrimSE in Steam, it works ! Just gotta add ALSAPLUG="convertWine" %command% in game's launch options |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|