http://bugs.winehq.org/show_bug.cgi?id=22498
Summary: Stuttering sound - winealsa.drv regression? Product: Wine Version: 1.1.43 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: myself@rojer.pp.ru
here's a mail i sent more than a year ago to the person who introduced what seems like a regression to me. i don't remember the details anymore, but the bug - stuttering when playing HoMM3 - is still there (just verified with 1.1.43).
--- the regression manifests itself as rather annoying audio skipping and stuttering. having spent some time tracing and looking at the code, i believe that the problem was introduced by this change to dlls/winealsa.drv/waveout.c made on Oct 4:
http://source.winehq.org/git/wine.git/?a=commitdiff;h=717df5b2972b3cb998ca5a...
specifically, this line
+ wwo->dwPlayedTotal += lpWaveHdr->reserved - wwo->dwPlayedTotal;
advances the dwPlayedTotal watermark when i believe it shouldn't. fundamentally, only DSP can report how much has been played, updating this pointer after reporting that a sample has been played makes no sense. DSP has reported that it has played up to a certain point that covers the sample in question, we are reporting this back and removing the sample. we should *not* be changing the value DSP sent us.
i don't know what was the specific issue you were addressing with the patch in question, but i'd like you to take one more look at it, because removing this one line fixes skipping and stuttering for me. ---
http://bugs.winehq.org/show_bug.cgi?id=22498
Wylda wylda@volny.cz changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |m.b.lankhorst@gmail.com, | |wylda@volny.cz
--- Comment #1 from Wylda wylda@volny.cz 2010-04-26 10:32:08 ---
So lets add Maarten to CC.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #2 from Maarten Lankhorst m.b.lankhorst@gmail.com 2010-04-26 12:04:03 --- Can you try the winealsa rewrite?
http://www.winehq.org/pipermail/wine-patches/2010-April/087699.html
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #3 from Deomid Ryabkov myself@rojer.pp.ru 2010-04-26 13:59:33 --- attachment url returns an empty page. i tried getting the patch from other source (http://permalink.gmane.org/gmane.comp.emulators.wine.patches/80333) but it does not apply cleanly:
$ patch -p 1 -l < ../winealsa.patch patching file dlls/winealsa.drv/waveout.c Hunk #3 FAILED at 53. 1 out of 3 hunks FAILED -- saving rejects to file dlls/winealsa.drv/waveout.c.rej
hunk #3 is too big for me to merge it by hand, can you please attach the new waveout.c to this bug? thanks.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #4 from Maarten Lankhorst m.b.lankhorst@gmail.com 2010-04-26 14:49:07 --- Created an attachment (id=27568) --> (http://bugs.winehq.org/attachment.cgi?id=27568) my waveout.c
You will have to remove the line that says "ALSA_WaveInit();" otherwise bad things might occur.
http://bugs.winehq.org/show_bug.cgi?id=22498
Raymond superquad.vortex2@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |superquad.vortex2@gmail.com
--- Comment #5 from Raymond superquad.vortex2@gmail.com 2010-04-26 21:59:00 --- (In reply to comment #4)
Created an attachment (id=27568)
--> (http://bugs.winehq.org/attachment.cgi?id=27568) [details]
my waveout.c
You will have to remove the line that says "ALSA_WaveInit();" otherwise bad things might occur.
it seem that you changed the period time and buffer time in your waveout.c
rate = 10000; snd_pcm_hw_params_set_period_time_near(wwo->pcm, hw_params, &rate, NULL); rate = 100000; snd_pcm_hw_params_set_buffer_time_near(wwo->pcm, hw_params, &rate, NULL);
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #6 from Raymond superquad.vortex2@gmail.com 2010-04-26 22:11:06 --- (In reply to comment #2)
Can you try the winealsa rewrite?
http://www.winehq.org/pipermail/wine-patches/2010-April/087699.html
what kind of multiple waveopens are you trying to support ?
1) open sound card A , B or C ? 2) open multiple subdevices of hardware mixing sound card A ?
do alsa-pulse plugin allow wine to open two pulse sessions ?
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #7 from Maarten Lankhorst m.b.lankhorst@gmail.com 2010-04-26 23:07:00 --- Do the changed times matter?
Also, multiple waveopens to the same device
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #8 from Deomid Ryabkov myself@rojer.pp.ru 2010-04-27 02:40:42 --- tried the new waveout - yes, it solves the problem. also verified my old fix - it still works, too.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #9 from Raymond superquad.vortex2@gmail.com 2010-04-27 20:08:45 --- (In reply to comment #7)
Do the changed times matter?
Also, multiple waveopens to the same device
yes, you are expecting 4 periods per buffer in vodTick but 10 periods per buffer
static void CALLBACK wodTick(UINT id, UINT msg, DWORD_PTR dwUser,
snd_pcm_hw_params_get_buffer_size(cur->hw_params, &buflen); snd_pcm_hw_params_get_period_size(cur->hw_params, &psize, NULL); if (buflen > 4 * psize) buflen = 4 * psize;
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #10 from Raymond superquad.vortex2@gmail.com 2010-04-27 20:23:39 --- (In reply to comment #7)
Also, multiple waveopens to the same device
if you are implementing for hardware mixing or multistreaming of HDA
http://www.intel.com/design/chipsets/hdaudio.htm
Intel HD Audio features multi-streaming capabilities that give users the ability to send two or more different audio streams to different locations at the same time, from the same PC.
The hardware mixing sound cards support a fixed number of voices and there should be voice management and pulseaudio also has limit on the number of client connections too.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #11 from Maarten Lankhorst m.b.lankhorst@gmail.com 2010-04-28 02:05:17 --- That was intentional, is it causing any regressions?
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #12 from Raymond superquad.vortex2@gmail.com 2010-04-28 08:37:37 --- (In reply to comment #11)
That was intentional, is it causing any regressions?
not sure that it is regression ,
but underrun occur at the end of playing audio
ALSA lib pcm.c:7234:(snd_pcm_recover) underrun occured
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #13 from Raymond superquad.vortex2@gmail.com 2010-04-28 18:38:52 --- (In reply to comment #11)
That was intentional, is it causing any regressions?
I don't understand your intention , can you explain ?
how about those sound cards which only support 2 periods per buffer
your waveout.c try to configure about 10 periods , but modTick use 4 periods when periods > 4
http://bugs.winehq.org/show_bug.cgi?id=22498
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|Stuttering sound - |Stuttering sound when |winealsa.drv regression? |playing HoMM3
http://bugs.winehq.org/show_bug.cgi?id=22498
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |regression
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #14 from Raymond superquad.vortex2@gmail.com 2010-04-29 19:23:33 --- (In reply to comment #8)
tried the new waveout - yes, it solves the problem. also verified my old fix - it still works, too.
if the game use dsound , using the new waveout.c cannot fix your problem and only change in dsoutput.c
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #15 from Deomid Ryabkov myself@rojer.pp.ru 2010-04-30 02:57:20 ---
if the game use dsound , using the new waveout.c cannot fix your problem
well, believe it or not, it does. the bug is rather obvious in the game, i have no problem determining whether it is present or not.
there are 3 ways of fixing it:
1) switching to OSS audio in winecfg. 2) using old waveout with dwPlayedTotal fix. 3) using new waveout by Maarten.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #16 from Raymond superquad.vortex2@gmail.com 2010-05-05 21:33:59 --- (In reply to comment #15)
if the game use dsound , using the new waveout.c cannot fix your problem
well, believe it or not, it does. the bug is rather obvious in the game, i have no problem determining whether it is present or not.
there are 3 ways of fixing it:
- switching to OSS audio in winecfg.
- using old waveout with dwPlayedTotal fix.
- using new waveout by Maarten.
cat /proc/asound/card0/pcm0p/sub0/hw_params
you will know the hardware parameters of your sound card while using oss and alsa
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #17 from Deomid Ryabkov myself@rojer.pp.ru 2010-05-06 05:23:17 --- (In reply to comment #16)
cat /proc/asound/card0/pcm0p/sub0/hw_params
you will know the hardware parameters of your sound card while using oss and alsa
i don't see how this is useful, but here goes.
ALSA:
rojer@nbx:~/Desktop$ cat /proc/asound/card0/pcm0p/sub0/hw_params access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 44096 buffer_size: 88192
OSS:
rojer@nbx:~/Desktop$ cat /proc/asound/card0/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 256 buffer_size: 4096 OSS format: S16_LE OSS channels: 1 OSS rate: 22050 OSS period bytes: 256 OSS periods: 16 OSS period frames: 256
both taken while playing HoMM3.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #18 from Raymond superquad.vortex2@gmail.com 2010-05-07 20:31:09 --- (In reply to comment #17)
ALSA:
rojer@nbx:~/Desktop$ cat /proc/asound/card0/pcm0p/sub0/hw_params access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 44096 buffer_size: 88192
OSS:
rojer@nbx:~/Desktop$ cat /proc/asound/card0/pcm0p/sub0/hw_params access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 256 buffer_size: 4096 OSS format: S16_LE OSS channels: 1 OSS rate: 22050 OSS period bytes: 256 OSS periods: 16 OSS period frames: 256
both taken while playing HoMM3.
As you can see , the latency of oss emulation is much lower than the alsa driver
Are you using dmix ?
aplay -v -D default any.wav
The major problem of winealsa.drv is waveout/wavein/dsoutput/capture ignore any error returned by alsa-lib functions
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #19 from Deomid Ryabkov myself@rojer.pp.ru 2010-05-08 03:03:15 --- (In reply to comment #18)
As you can see , the latency of oss emulation is much lower than the alsa driver
that may or may not be responsible for slight latency between action and sound effect in the game but that's actually not what i'm complaining about here.
Are you using dmix ?
not a slightest idea :) this is Ubuntu 10.04, FWIW. but the problem was originally found on 9.04. there is nothing in ~/.asoundrc.
aplay -v -D default any.wav
had to lame --decode an mp3 to get a reasonable test wav file. sound is playing fine, no problems:
rojer@nbx:~/Local/Audio$ aplay -v -D default test.wav Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 44100 exact rate : 44100 (44100/1) msbits : 16 buffer_size : 22050 period_size : 5512 period_time : 125000 tstamp_mode : NONE period_step : 1 avail_min : 5512 period_event : 0 start_threshold : 22050 stop_threshold : 22050 silence_threshold: 0 silence_size : 0 boundary : 1445068800 ^CAborted by signal Interrupt...
The major problem of winealsa.drv is waveout/wavein/dsoutput/capture ignore any error returned by alsa-lib functions
what are you looking for, anyway? have you looked at what my fix does? i didn't find it just by chance, i spent some time digging up and remember that the problem with the logic was quite obvious at the time.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #20 from Raymond superquad.vortex2@gmail.com 2010-05-08 08:02:25 --- (In reply to comment #19)
aplay -v -D default any.wav
had to lame --decode an mp3 to get a reasonable test wav file. sound is playing fine, no problems:
rojer@nbx:~/Local/Audio$ aplay -v -D default test.wav Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo ALSA <-> PulseAudio PCM I/O Plugin Its setup is: stream : PLAYBACK access : RW_INTERLEAVED format : S16_LE subformat : STD channels : 2 rate : 44100 exact rate : 44100 (44100/1) msbits : 16 buffer_size : 22050 period_size : 5512 period_time : 125000 tstamp_mode : NONE period_step : 1 avail_min : 5512 period_event : 0 start_threshold : 22050 stop_threshold : 22050 silence_threshold: 0 silence_size : 0 boundary : 1445068800 ^CAborted by signal Interrupt...
you problem is using alsa-pulse plugin instead of dmix
you are using pulseaudio ( alsa-pulse plugin ) which accept the period time/buffer time requested by wine but PA server is running at
access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 44096 buffer_size: 88192
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #21 from Deomid Ryabkov myself@rojer.pp.ru 2010-05-08 12:28:52 --- (In reply to comment #20)
you problem is using alsa-pulse plugin instead of dmix
you are using pulseaudio ( alsa-pulse plugin ) which accept the period time/buffer time requested by wine but PA server is running at
access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 44096 buffer_size: 88192
i am using a plain vanilla install of Ubuntu, a fairly popular distro, with no special tweaks made to the sound subsystem and everything else working fine. if all other applications are able to deal with this, so should Wine, shouldn't it?
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #22 from Raymond superquad.vortex2@gmail.com 2010-05-09 18:47:34 --- (In reply to comment #21)
(In reply to comment #20)
you problem is using alsa-pulse plugin instead of dmix
you are using pulseaudio ( alsa-pulse plugin ) which accept the period time/buffer time requested by wine but PA server is running at
access: MMAP_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 44096 buffer_size: 88192
i am using a plain vanilla install of Ubuntu, a fairly popular distro, with no special tweaks made to the sound subsystem and everything else working fine. if all other applications are able to deal with this, so should Wine, shouldn't it?
if you have studied my_waveout.c or the latest waveout.c in git
that is almost a complete rewrite of winealsa.drv
Previously I can run winmm_test/dsound_test without any underrun for my two sound card , now I get underrun at the end
It is not easy to find out which part of the patch causing the underrun problem
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #23 from Deomid Ryabkov myself@rojer.pp.ru 2010-05-09 19:42:18 --- (In reply to comment #22)
Previously I can run winmm_test/dsound_test without any underrun for my two sound card , now I get underrun at the end
It is not easy to find out which part of the patch causing the underrun problem
ok, it's up to you guys to figure out unittests and such. all i can say is that there is a problem now, it's a problem with Wine (and not my mixer setup which works just fine), we have two possible solutions here and i'll be happy if either of them is adopted in some form. let me know if you'd like me to test more patches against HoMM3.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #24 from Raymond superquad.vortex2@gmail.com 2010-05-10 01:37:02 --- actually those tests ( winmm_test and dsound_test ) only play silence , it is impossible to know any distortion or shuttering occur
I have doubt about the usefullness of those tests especially when the code ignore any error returned from those alsa-lib functions
http://bugs.winehq.org/show_bug.cgi?id=22498
Nicky nheart@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nheart@gmail.com
--- Comment #25 from Nicky nheart@gmail.com 2010-06-09 17:34:14 --- I can confirm the problem, using OSSv4 on 1.2rc2.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #26 from Raymond superquad.vortex2@gmail.com 2010-06-09 19:25:34 --- (In reply to comment #25)
I can confirm the problem, using OSSv4 on 1.2rc2.
The patch is for winealsa.drv , so it does not has any relationship with wineoss.drv
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #27 from Nicky nheart@gmail.com 2010-06-15 00:20:32 --- (In reply to comment #26)
(In reply to comment #25)
I can confirm the problem, using OSSv4 on 1.2rc2.
The patch is for winealsa.drv , so it does not has any relationship with wineoss.drv
Then the oss issue something else, thank you for the clarification.
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #28 from Raymond superquad.vortex2@gmail.com 2010-09-23 19:52:15 CDT --- (In reply to comment #7)
Do the changed times matter?
Also, multiple waveopens to the same device
what kind of PCM device ? since users can define their own "default" device
1) hw:0,0 2) plughw:0,0 3) dmix:0 4) pulse
For hw:0,0 and plughw:0,0 , only those hardwaremixing sound with multiple subdevices ( snd_pcm_info_get_sudevice_count() > 0 ) support multiple open
but need to add IDsDriverBufferImpl *secondary[16] for each hardware secondary buffer ( ALSA subdevice )
struct IDsDriverImpl { /* IUnknown fields */ const IDsDriverVtbl *lpVtbl; LONG ref;
/* IDsDriverImpl fields */ IDsDriverBufferImpl* primary; UINT wDevID; };
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #29 from Raymond superquad.vortex2@gmail.com 2010-12-20 21:17:49 CST --- (In reply to comment #7)
Do the changed times matter?
Also, multiple waveopens to the same device
if ALSA_waveinit (In reply to comment #4)
Created an attachment (id=27568)
--> (http://bugs.winehq.org/attachment.cgi?id=27568) [details]
my waveout.c
You will have to remove the line that says "ALSA_WaveInit();" otherwise bad things might occur.
But ALSA_WodNumDevs is computed in ALSA_waveinit() , so the waveout_count is the number of pcm devices in your system
Removing the ALSA_waveinit() imply the driver cannot provide a correct waveoutcaps to the application since waveoutcaps is computed in ALSA_ComputeCaps() inside ALSA_waveinit()
This mean that you must configure ALSA to have one sound card with playback/capture device to test your patch
static DWORD wodInit(void) { DWORD i = 0; ALSA_WaveInit(); waveout_count = ALSA_WodNumDevs;
when you have used up the subdevices of hardware mixing sound card, MMSYSERR_NOTENABLED seem not a correct error
err = snd_pcm_open(&wwo->pcm, WOutDev[dev->devid].pcmname, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); if (err < 0) { FIXME("Could not open sound device: %s\n", snd_strerror(err)); ret = MMSYSERR_NOTENABLED; goto error; }
http://bugs.winehq.org/show_bug.cgi?id=22498
--- Comment #30 from Raymond superquad.vortex2@gmail.com 2010-12-23 21:54:32 CST --- (In reply to comment #7)
Do the changed times matter?
Also, multiple waveopens to the same device
The problem in your waveout.c
waveout_count = ALSA_WodNumDevs;
ALSA_WodNumDevs is the total numbers of playback device 0 of alsa sound cards
So you need at least two sound cards so that waveout_count > 1 for your waveout.c to allow multiple open
if AutoScanDevices="Y", this will be the number of all playback devices ( including spdif, hdmi, ...) of alsa sound cards
for hardware mixing sound cards, the therotical maximum number is the value returned by snd_pcm_info_get_subdevice_count();
**** List of PLAYBACK Hardware Devices **** card 0: Live [SBLive! Platinum [CT4760P]], device 0: emu10k1 [ADC Capture/Standard PCM Playback] Subdevices: 32/32
however the practical number can be reduced when the other application is using the WaveTable Synth
you can try waveout.c in bug#22880 comment#4
which limit the maximum number of waveoutopen to 16
Allow multiple waveoutopen to the same device is depend on the result of snd_pcm_open
Not sure wine can open "plug:dmix" or "pulse" device how many times ?
http://bugs.winehq.org/show_bug.cgi?id=22498
Deomid Ryabkov myself@rojer.pp.ru changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |patrakov@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=22498
Henri Verbeet hverbeet@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Regression SHA1| |717df5b2972b3cb998ca5a43279 | |ae2283b117eaa
http://bugs.winehq.org/show_bug.cgi?id=22498
Alex Bradbury asb@asbradbury.org changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |aeikum@codeweavers.com, | |asb@asbradbury.org
--- Comment #31 from Alex Bradbury asb@asbradbury.org 2012-02-18 17:01:46 CST --- Is this problem still reproducible in wine 1.4-rc4?
How about using the demo? http://www.gamefront.com/files/Heroes+of+Might+and+Magic+III+Demo+Win/;19911...
http://bugs.winehq.org/show_bug.cgi?id=22498
Reinhard Berger geist1@sms.at changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |geist1@sms.at
--- Comment #32 from Reinhard Berger geist1@sms.at 2012-03-19 13:01:11 CDT --- (In reply to comment #31)
Is this problem still reproducible in wine 1.4-rc4?
How about using the demo? http://www.gamefront.com/files/Heroes+of+Might+and+Magic+III+Demo+Win/;19911...
I can not find any sound problem in wine for heroes 3 shadow of death since wine version 1.2 or higher.
Tested under kubuntu 10.11 with the following wine versions : 1.2 - 1.3 - 1.4rc6
Karte 0: NVidia [HDA NVidia], Gerät 0: AD198x Analog [AD198x Analog] Sub-Geräte: 1/1 Sub-Gerät #0: subdevice #0 Karte 0: NVidia [HDA NVidia], Gerät 1: AD198x Digital [AD198x Digital] Sub-Geräte: 1/1 Sub-Gerät #0: subdevice #0
Analog Sound was tested, not digital.
http://bugs.winehq.org/show_bug.cgi?id=22498
Jerome Leclanche adys.wh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |adys.wh@gmail.com Resolution| |FIXED
--- Comment #33 from Jerome Leclanche adys.wh@gmail.com 2012-03-23 12:08:56 CDT --- Reported fixed. waveout.c no longer exists apparently.
http://bugs.winehq.org/show_bug.cgi?id=22498
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #34 from Alexandre Julliard julliard@winehq.org 2012-03-30 13:35:29 CDT --- Closing bugs fixed in 1.5.1.