Jump to content
The Dark Mod Forums

A patch to fix the problem with popping audio under Linux


Recommended Posts

I've created a patch to fix the problem where audio would sometimes start popping/crackling when the game starts. And in the cosole this would be seen repeated:

snd_pcm_writei 4096 frames failed: Broken pipe

preparing audio device for output

I have a feeling that this fix is more of a kludge that works around the issue, rather than fixes it at the source. However, it does appear to work well enough to mask the problem.

Changes:
-If a call to snd_pcm_writei() returns an EPIPE error it will re-prepare the connection and then try to send the audio data again, but it will also try to send a partial duplicate. The number of frames duplicated is set by 's_alsa_underrun_extrafill'.


I've only tested it on Linux Mint 17.2, 64 bit.

 

tdm-linux-sound-fix.txt

  • Like 2
Link to post
Share on other sites

Is there any chance this is related to #4148 do you think? That happened a lot at map start, and randomly at other times. The bug is still in the current TDM 2.03 release, but it'll be fixed in the next version.

 

The bug was in the calculation of 3d sound propagation, so only happened during play. If your bug happens on menu screens, that'd be different. What the bug does is cause the result of a division-by-zero (a NaN) to be fed into the sound card.

Link to post
Share on other sites

Good to see somebody working on the Linux issues. I suppose the "gold standard" solution to this issue would be to add full PulseAudio support (for better or worse, PA is now the standard on Linux desktops), but obviously that would require somebody with a lot of time and familiarity with PulseAudio client development.

Link to post
Share on other sites
  • 2 weeks later...

In the patch, the CVAR added should be some sort of integer and capped to some sabe values, like mininum 256 (or something > 0) and maximum (4096?). Otherwise a wrong setting of that variable could cause havoc.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to post
Share on other sites

I forgot the specifics, but it is possible to declare CVARS as int (so nobody can set it to "4.5" or even "abc" :) and add min/max values.

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to post
Share on other sites

I forgot the specifics, but it is possible to declare CVARS as int (so nobody can set it to "4.5" or even "abc" :) and add min/max values.

CVAR_INTEGER in the flags. But I see from the tracker update that NagaHuntress got to it already.
Link to post
Share on other sites

Thanks again for another patch. Committed at rev 6529.

 

I can't test-compile code hidden from my MS system by compiler switches, but I'll ask grayman for the release packaging software so I can check the build works with any changes. I'm a bit clueless around OSes.

Link to post
Share on other sites

I've figured out how to set the CVar as an integer and how to clamp it's range. I've uploaded a new patch to the bug tracker.

 

Thank you kindly. :)

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to post
Share on other sites
  • 2 years later...

Thanx for your fix! Unfortunately I do not know how implement it (copy it somewhere I gues?!). Fortunately I found out that I have to switch my card to 44.1 Khz before starting the game. There're diferent ways to do that on Linux, so maybe that might help someone.

 

I use an E-MU1212m with a creative chipset and the emu10k1 driver, btw.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...