Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
sound playback in games run through Wine
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
Lovot
Tux's lil' helper
Tux's lil' helper


Joined: 04 Aug 2015
Posts: 84

PostPosted: Tue Dec 17, 2019 4:10 am    Post subject: sound playback in games run through Wine Reply with quote

This may, or may not actually belong here, but I have been having a problem with audio playback when running games through wine, the current one giving me grief is Skyrim, this does not seem to be restricted to any Wine version. The Wine sound test works, weather or not there are other audio streams going to the card I'm using.

Once Skyrim starts things get weird, if there are other audio streams on startup, the sound for the Bethesda intro works, if there are no other sound streams it doesn't.
The button sounds in the main menu do not work if there were other sound streams on startup, if there are no sound streams on startup button sounds work, but it seems like the game gets a lock on the sound card, no other applications can use the card until the game closes.
No in-game music works at all, if the main menu has music that doesn't work either
No voices work
all other sounds work

I have no asound.conf, or .asoundrc, they seem to cause problems whenever I try to configure ALSA that way, ALSA configuration is basically dark sorcery to me at this point.
This might be able to be partly solved by creating a dummy card for the game to lock on to that re-samples everything to 44100 HZ, then sends it to the actual card, but, I don't know how to do that.

Pulseaudio always causes more problems for me than it solves,
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2729

PostPosted: Tue Dec 17, 2019 4:38 am    Post subject: Reply with quote

Issues with audio in wine are rarely related to the alsa/pulse audio backend. Usually it's because of the faudio's xaudio implementation not working as expected or being outdated (or not used, but it's a default flag on gentoo). I wish gentoo kept faudio releases more up to date too, they constantly fix things (thankfully there's faudio-9999).

Either way, a usually viable solution is to just use native xaudio. A "winetricks xact" or "winetricks xact_x64" (if the application is 64bit) usually does the job.

I never played skyrim though, so I can't really say more.
Edit: Especially without seeing some logs to know what's going on, libasound(alsa) is also able to resample/mix as needed, given proper configs anyway, but I don't really know what gentoo does by default for libasound (I use JACK personally with a fancy zita's alsa2jack bridge given the alsa jack plugins are wonky with Wine. PulseAudio would probably give you less grief in general given you make sure applications actually use it rather than alsa, I may start using PA with a JACK sink again myself and try to weed out libasound-users for things not jack-native).
Back to top
View user's profile Send private message
Lovot
Tux's lil' helper
Tux's lil' helper


Joined: 04 Aug 2015
Posts: 84

PostPosted: Tue Dec 17, 2019 5:09 am    Post subject: Reply with quote

Ionen wrote:
Issues with audio in wine are rarely related to the alsa/pulse audio backend. Usually it's because of the xaudio's faudio implementation not working as expected or being outdated (or not used, but it's a default flag on gentoo). I wish gentoo kept faudio releases more up to date too, they constantly fix things (thankfully there's faudio-9999).

Either way, a usually viable solution is to just use native xaudio. A "winetricks xact" or "winetricks xact_x64" (if the application is 64bit) usually does the job.

I never played skyrim though, so I can't really say more.
Edit: Especially without seeing some logs to know what's going on, ALSA is also able to resample/mix as needed, given proper configs anyway. I don't really know what gentoo does by default for ALSA (I use JACK personally with a fancy alsa2jack bridge given the alsa jack plugins are wonky with Wine. PulseAudio would probably give you less grief in general given you take the time to set it up right)


Alredy have xact installed

Looks like ALSA is using dmix automatically, and as such I shouldn't be having this problem, I alt-tabbed out of Skyrim with it's card lock active, and this is what I get when attempting to play audio:

Code:

ALSA lib /usr/portage/media-libs/alsa-lib-1.1.9/work/alsa-lib-1.1.9/src/pcm/pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
aplay: main:828: audio open error: Device or resource busy


I did try routing Wine through a different sound card, with ...interesting results, the intro used the sound card as directed, then the game locked on to the main card. Be really nice if there were a way to figure out exactly what's going on.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2729

PostPosted: Tue Dec 17, 2019 5:50 am    Post subject: Reply with quote

Yeah this is alsa after all. My best guess is that something is trying to either use the hardware device directly, or "somehow" using a different dmix device (ipc_key in config files is used to identify them). What output device is wine using? (mentioned in winecfg, system default?). Output of "aplay -L" and "aplay -l" may be useful.

I typically find it better to use a proper .asoundrc/asound.conf and disable all those weirdo outputs I never use with a single plug:dmix as default (my aplay -L only shows 2 devices :)). I'd give you my config as example but mine is a weird setup with a loopback device.

Maybe someone else can help better.
Back to top
View user's profile Send private message
Lovot
Tux's lil' helper
Tux's lil' helper


Joined: 04 Aug 2015
Posts: 84

PostPosted: Tue Dec 17, 2019 1:24 pm    Post subject: Reply with quote

i'm using card 0, 1 also works
Code:
# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: VT2020 Analog [VT2020 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: VT2020 Digital [VT2020 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 2: VT2020 Alt Analog [VT2020 Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA ATI HDMI], device 3: Generic Digital [Generic Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: DG [Xonar DG], device 0: Multichannel [Multichannel]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: DG [Xonar DG], device 1: Digital [Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Code:



# aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pulse
    PulseAudio Sound Server
default:CARD=SB
    HDA ATI SB, VT2020 Analog
    Default Audio Device
sysdefault:CARD=SB
    HDA ATI SB, VT2020 Analog
    Default Audio Device
front:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    Front speakers
surround21:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    4.0 Surround output to Front and Rear speakers
surround41:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Analog
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=SB,DEV=0
    HDA ATI SB, VT2020 Digital
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=SB
    HDA ATI SB
    USB Stream Output
hdmi:CARD=HDMI,DEV=0
    HDA ATI HDMI, Generic Digital
    HDMI Audio Output
usbstream:CARD=HDMI
    HDA ATI HDMI
    USB Stream Output
default:CARD=DG
    Xonar DG, Multichannel
    Default Audio Device
sysdefault:CARD=DG
    Xonar DG, Multichannel
    Default Audio Device
front:CARD=DG,DEV=0
    Xonar DG, Multichannel
    Front speakers
surround21:CARD=DG,DEV=0
    Xonar DG, Multichannel
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=DG,DEV=0
    Xonar DG, Multichannel
    4.0 Surround output to Front and Rear speakers
surround41:CARD=DG,DEV=0
    Xonar DG, Multichannel
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=DG,DEV=0
    Xonar DG, Multichannel
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=DG,DEV=0
    Xonar DG, Multichannel
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=DG,DEV=0
    Xonar DG, Multichannel
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=DG,DEV=0
    Xonar DG, Multichannel
    IEC958 (S/PDIF) Digital Audio Output
usbstream:CARD=DG
    Xonar DG
    USB Stream Output


If you could post your asoundrc, it may help, it does look like it's trying to directly use the card.
Back to top
View user's profile Send private message
Chiitoo
Administrator
Administrator


Joined: 28 Feb 2010
Posts: 2587
Location: Here and Away Again

PostPosted: Tue Dec 17, 2019 6:22 pm    Post subject: ><)))°€ Reply with quote

This may or may not help at all, but if I remember things correctly, I've seen some stuff pretty much ignore ALSA configuration, default or user, and do what ever they please.

This was with native Linux builds though, and while I have had some Windows applications give me similar trouble, I can't remember the details...

Main offender being FMOD, which the Unity game engine used at least at some point. I have no idea what Skyrim does. Definitely seems strange that parts of it work differently at times. Perhaps the intro is more like a video file, or something to that effect, while the other things do, well, other things?

One problem I remember with FMOD, was that it wasn't even seeing my custom 'pcm', which I noticed by messing with their example code. Somehow I noticed that adding a 'hint' to the ALSA configuration helped, and indeed allowed me to make it use what I wanted it to use.

So for example, my 'pcm.!default' looks like this:

Code:
pcm.!default
{
   type asym
   playback.pcm "correctedSurround"
   capture.pcm "loopRecord"

   hint
   {
      show on
   }
}

Again though, I'm not sure if this ever helped me with running something via Wine, but perhaps it's worth putting it out here.
_________________
Kindest of regardses.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2729

PostPosted: Tue Dec 17, 2019 6:45 pm    Post subject: Reply with quote

Like I said it won't be much of a reference either (probably better off looking up normal examples in google). Personally I set my own dmix device like
Code:
pcm.loop_in_dmix {
        type dmix
        ipc_key 1024
        ipc_key_add_uid false
        ipc_gid audio
        ipc_perm 0660
        slave {
                pcm "loop_in" # this would be your sound card, in my case it's a loopback device
                period_size 1024
                buffer_size 4096
        }
}
(mine is set in /etc/asound.conf globally rather than .asoundrc, and group audio (ipc_gid) has access to it)

And then disabled all the entries that alsa set by default by using things like:
Code:
pcm.!sysdefault default
pcm.!dmix null
pcm.!dsnoop null
pcm.!front null
pcm.!surround21 null
(...and it goes on)

I don't use libasound for capture (dsnoop is the opposite of dmix for capture by the way), but still wanted to let devices connect to capture should they really want to for compatibility, so my asym default is like this
Code:
pcm.!default {
        type asym

        playback.pcm "plug:loop_in_dmix"
        capture.pcm  "null"

        hint {
                show on
                description "Loopback bridge to JACK"
        }
}


Leaving me with this complete aplay -L output
Code:
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Loopback bridge to JACK

...which I'd hope would not let anything use the wrong device. Hardware device is permanently in-use by jack too (which is started system-wide by openrc as jack:audio and granted access by group audio), and I've never seen anything else try to use it, wine or otherwise (albeit they ""could"" still try to be funny and select hw:0,0 directly).

Edit: I kinda like my setup, but it's generally simpler to just give up and install PulseAudio :| dmix/asound isn't really great too, it's just a fallback for me (notably for Wine until it brings back jack support). On a pure libasound system it's just a pain to do simple things like work with specific applications, adjust/disconnect/connect them as needed, etc.. I guess I _could_ make a really fancy asound.conf but still. And of course there's latency too given with asound all the work is done in normal userland and with no RT priority thread (unless the whole application is RT).
Back to top
View user's profile Send private message
Lovot
Tux's lil' helper
Tux's lil' helper


Joined: 04 Aug 2015
Posts: 84

PostPosted: Wed Dec 18, 2019 3:05 am    Post subject: Reply with quote

Quick question: would a card with a hardware mixer still work when something attempts to directly use the card?
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2729

PostPosted: Wed Dec 18, 2019 3:12 am    Post subject: Reply with quote

Lovot wrote:
Quick question: would a card with a hardware mixer still work when something attempts to directly use the card?
I don't think many cards have driver support for this. Personally never got to use/see this with alsa (only used with my old SB Live! back with emu10k1 and OSS, recall it had a 4 connection limit or so too, not sure), but I guess it would work.

There's this https://alsa-project.org/wiki/Matrix:Tag-HWMIX as reference maybe?
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Dec 18, 2019 7:48 am    Post subject: Reply with quote

ALSA supports hardware mixing fine. Worked on my au8830 (theoretical max of 32 streams), at least for normal desktop and game use.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
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