https://bugs.winehq.org/show_bug.cgi?id=37890
--- Comment #3 from debuser debuser1@mt2014.com --- Created attachment 50468 --> https://bugs.winehq.org/attachment.cgi?id=50468 Check wBitsPerSample in PCM_StreamOpen()
This is a bug in wine: wav-file contains 24-bit audio. Pulse-alsa plugin only advertises S16 and S32, no S24 format (see `aplay -v --dump-hw-params -d1 -Ddefault /dev/zero`). When attempting to set it snd_pcm_hw_params_set_format() fails to set S24_3LE, failing winealsa:AudioClient_Initialize. WINMM_OpenDevice catches the fail and calls WINMM_MapDevice to try other rates/formats. 16-bit one succeeds, calling acmStreamOpen, which calls PCM_StreamOpen, which sets cvtKeepRate to one of PCM_ConvertKeepRate[] values. This where things break.
PCM_StreamOpen assumes that wBitsPerSample is either 8 or 16, so it sets conversion to 8->16 bits instead of 24->16 bits that it does not support. When sound plays acmStreamConvert->PCM_StreamConvert->cvtKeepRate->cvtSS816K gets called and turns 24-bit sound into noise.
Attached is a tiny patch for PCM_StreamOpen to fail if format is not 8 or 16-bit. It's not a workaround but it stops wine from producing noise.
The bug never happens with alsa because alsa provides a default=plug->softvol->dmix->hw chain, and its "plug" autoconversion module supports any possible input format, so snd_pcm_hw_params_set_format() never fails and wine's conversion code never gets called.
To reproduce the bug and hear the noise without pulseaudio, using just alsa, you need a "broken" ~/.asoundrc bypassing plug autoconversion and limited supported formats, for example: pcm.!default { type hw card 0 format S16_LE rate 44100 channels 2 }
The workaround for pulseaudio is to fix its alsa-plugin config (usually /usr/share/alsa/alsa.conf.d/pulse.conf or /usr/share/alsa/pulse-alsa.conf or similar) adding "plug" autoconversion there replacing: pcm.!default { type pulse } with pcm.!default { type plug slave.pcm { type pulse } }