joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.67k stars 378 forks source link

Intermittent but reproducible audio dropouts in SDL2 Linux build running under PipeWire. #3688

Open KynikossDragonn opened 2 years ago

KynikossDragonn commented 2 years ago

Describe the bug

Running PipeWire 0.3.56, DOSBox-X's audio is really unreliable. It intermittently drops out and crackles no matter what cycles count I chose, no matter what NICE value is in use. pw-top doesn't list any error accumulation either.

What's more annoying is any single time the video mode changes inside of DOSBox-X it goes through a whole bunch of motions, XRandR, etc. This causes the sound to completely drop out.

Clicking outside of the window (making DOSBox-X lose focus) and regaining focus again causes dropouts, even if I have priority set to "higher,higher".

I've tried all kinds of blocksize and prebuffer settings and nothing seems to help. The prebuffer even makes things crackle and stutter worse which sounds massively counter-intuitive to what that option is supposed to do? Setting SDL_AUDIODRIVER back to "alsa" seems only slightly resilient to the problem but will continue to suffer from it especially if the video mode changes inside of the emulated system.

I can't get audio dropouts to happen in anything else; Standalone FluidSynth daemon running via ALSA with a period size of 256. Every OpenAL Soft using program using the native "pipewire" backend, no matter what period size I select (though going under 64 is bad news) mainline DOSBox is okay as well but is still stuck on dated SDL 1.2 of course. Other SDL2 programs like openmpt123 and whatever else also seem to work okay. Wine doesn't have any dropouts even when running with a quant of 256 as winealsa.drv seems to enjoy requesting everytime.

pipewire runs with a NICE of -11 like pulseaudio.

Steps to reproduce the behaviour

  1. Run anything using any kind of audio.
  2. Click outside of the window and back repetitively
  3. OR, cause the program to change it's video mode while audio continues to play.

Expected behavior

The audio should not be cutting out this badly even if the video mode changes, even if the user unfocuses DOSBox-X and refocuses it later or repetitively. It especially should not even be cutting out when running very older speed sensitive games that require very low (<8000) cycles counts.

What operating system(s) this bug have occurred on?

Void Linux x86_64 (Kernel 5.18.17_1)

What version(s) of DOSBox-X have this bug?

2022.08.0 SDL2 autotools commit d0066f0e585d45679577722b3abec5a8cb098a82

Used configuration

[sdl]
fullscreen              = false
fulldouble              = false
fullresolution              = 1920x1080
windowresolution            = 1280x960
windowposition              = 0,0
display                 = 0
output                  = openglpp
videodriver             = x11
transparency                = 0
maximize                = false
autolock                = false
autolock_feedback           = beep
middle_unlock               = none
clip_mouse_button           = right
clip_key_modifier           = shift
clip_paste_bios             = default
clip_paste_speed            = 30
sensitivity             = 100
usesystemcursor             = false
mouse_emulation             = locked
mouse_wheel_key             = -1
waitonerror             = true
priority                = higher,higher
mapperfile              = mapper-dosbox-x.map
usescancodes                = auto
overscan                = 0
titlebar                = 
showbasic               = false
showdetails             = false
showmenu                = false

[log]
logfile                 = 
vga                 = never
vgagfx                  = never
vgamisc                 = never
int10                   = never
sblaster                = never
dma_control             = never
fpu                 = never
cpu                 = never
paging                  = never
fcb                 = never
files                   = never
ioctl                   = never
exec                    = never
dosmisc                 = never
pit                 = never
keyboard                = never
pic                 = never
mouse                   = never
bios                    = never
gui                 = never
misc                    = never
io                  = never
pci                 = never
sst                 = never
int21                   = never
fileio                  = never
debuggerrun             = debugger

[dosbox]
language                    = 
title                       = 
fastbioslogo                    = true
disable graphical splash            = true
startbanner                 = true
bannercolortheme                = default
dpi aware                   = false
quit warning                    = false
allow quit after warning            = true
working directory option            = custom
working directory default           = ~/dosbox-x
show advanced options               = false
resolve config path             = true
hostkey                     = mapper
mapper send key                 = ctrlaltdel
ime                     = false
synchronize time                = false
keyboard hook                   = false
weitek                      = false
bochs debug port e9             = false
machine                     = svga_s3
captures                    = capture
autosave                    = 
saveslot                    = 1
savefile                    = 
saveremark                  = true
forceloadstate                  = false
compresssaveparts               = true
show recorded filename              = true
skip encoding unchanged frames          = false
capture chroma format               = auto
capture format                  = default
shell environment size              = 0
private area size               = 32768
a20                     = mask
turn off a20 gate on boot           = true
cbus bus clock                  = std10
isa bus clock                   = std8.3
pci bus clock                   = std33.3
call binary on reset                = 
unhandled irq handler               = 
call binary on boot             = 
ibm rom basic                   = 
rom bios allocation max             = 0
rom bios minimum size               = 0
irq delay ns                    = -1
iodelay                     = 0
iodelay16                   = 0
iodelay32                   = 0
acpi                        = off
acpi rsd ptr location               = auto
acpi sci irq                    = -1
acpi iobase                 = 0
acpi reserved size              = 0
memsize                     = 11
memsizekb                   = 0
dos mem limit                   = 0
isa memory hole at 512kb            = false
reboot delay                    = -1
memalias                    = 0
nocachedir                  = false
freesizecap                 = cap
convertdrivefat                 = true
convert fat free space              = 250
convert fat timeout             = 4
leading colon write protect image       = true
locking disk image mount            = true
unmask keyboard on int 16 read          = true
int16 keyboard polling undocumented cf behavior = false
allow port 92 reset             = true
enable port 92                  = true
enable 1st dma controller           = true
enable 2nd dma controller           = true
allow dma address decrement         = true
enable 128k capable 16-bit dma          = auto
enable dma extra page registers         = true
dma page registers write-only           = false
cascade interrupt never in service      = false
cascade interrupt ignore in service     = auto
enable slave pic                = true
enable pc nmi mask              = true
allow more than 640kb base memory       = false
enable pci bus                  = true

[render]
frameskip               = 0
aspect                  = true
aspect_ratio                = 4:3
char9                   = false
euro                    = -1
doublescan              = false
scaler                  = none
glshader                = none
pixelshader             = none
autofit                 = false
monochrome_pal              = green

[pc98]
pc-98 BIOS copyright string     = false
pc-98 fm board              = auto
pc-98 enable 256-color          = true
pc-98 enable 16-color           = true
pc-98 enable grcg           = true
pc-98 enable egc            = true
pc-98 bus mouse             = true
pc-98 force ibm keyboard layout     = auto
pc-98 try font rom          = true
pc-98 anex86 font           = 

[dosv]
dosv                    = off
getsysfont              = true
fontxsbcs               = 
fontxsbcs16             = 
fontxsbcs24             = 
fontxdbcs               = 
fontxdbcs14             = 
fontxdbcs24             = 
showdbcsnodosv              = auto
yen                 = false
del                 = true
fepcontrol              = both
vtext1                  = svga
vtext2                  = xga
use20pixelfont              = false
j3100                   = off
j3100type               = default
j3100colorscroll            = false

[video]
vmemdelay               = 0
vmemsize                = 4
vmemsizekb              = 0
high intensity blinking         = true

[vsync]
vsyncmode               = off
vsyncrate               = 60

[cpu]
core                    = dynamic_x86
fpu                 = true
segment limits              = true
interruptible rep string op     = 0
cputype                 = pentium
cycles                  = max 105% limit 80000
cycleup                 = 100
cycledown               = 100
turbo                   = false
apmbios                 = false
isapnpbios              = false

[keyboard]
aux                 = true
allow output port reset         = true
controllertype              = at
auxdevice               = intellimouse

[ttf]
font                    = 
fontbold                = 
fontital                = 
fontboit                = 
colors                  = 
outputswitch                = auto
winperc                 = 60
ptsize                  = 0
lins                    = 0
cols                    = 0
righttoleft             = false
wp                  = 
bold                    = true
italic                  = true
underline               = true
strikeout               = false
printfont               = true
autodbcs                = true
blinkc                  = true
gbk                 = false
chinasea                = false
dosvfunc                = false

[voodoo]
voodoo_card             = false
voodoo_maxmem               = false
glide                   = false
lfb                 = none
splash                  = false

[mixer]
nosound                 = false
sample accurate             = true
swapstereo              = false
rate                    = 48000
blocksize               = 1024
prebuffer               = 21

[midi]
mpu401                  = intelligent
mpubase                 = 0
mididevice              = alsa
midiconfig              = 128:0
samplerate              = 48000
mpuirq                  = -1

[sblaster]
sbtype                  = sbpro2
sbbase                  = 220
irq                 = 5
dma                 = 1
hdma                    = 5
enable speaker              = true
sbmixer                 = true
oplmode                 = opl3
oplemu                  = nuked
oplrate                 = 48000
oplport                 = 
retrowave_bus               = serial
retrowave_port              = 
hardwarebase                = 220
goldplay                = true
blaster environment variable        = true
sample rate limits          = false

[gus]
gus                 = false
gusrate                 = 48000
gusmemsize              = -1
gus master volume           = 0.00
gusbase                 = 240
gusirq                  = 5
gusdma                  = 3
gustype                 = classic
ultradir                = Z:\ULTRASND

[innova]
innova                  = false
samplerate              = 48000
sidbase                 = 280
quality                 = 3

[speaker]
pcspeaker               = false
pcspeaker clock gate enable at startup  = true
pcrate                  = 48000
tandy                   = off
tandyrate               = 48000
disney                  = false
ps1audio                = off
ps1audiorate                = 48000

[joystick]
joysticktype                = none
timed                   = false
autofire                = false
swap34                  = false
buttonwrap              = false

[mapper]
joy1deadzone0-              = 0.60
joy1deadzone0+              = 0.60
joy1deadzone1-              = 0.60
joy1deadzone1+              = 0.60
joy1deadzone2-              = 0.60
joy1deadzone2+              = 0.60
joy1deadzone3-              = 0.60
joy1deadzone3+              = 0.60
joy1deadzone4-              = 0.60
joy1deadzone4+              = 0.60
joy1deadzone5-              = 0.60
joy1deadzone5+              = 0.60
joy1deadzone6-              = 0.60
joy1deadzone6+              = 0.60
joy1deadzone7-              = 0.60
joy1deadzone7+              = 0.60
joy2deadzone0-              = 0.60
joy2deadzone0+              = 0.60
joy2deadzone1-              = 0.60
joy2deadzone1+              = 0.60
joy2deadzone2-              = 0.60
joy2deadzone2+              = 0.60
joy2deadzone3-              = 0.60
joy2deadzone3+              = 0.60
joy2deadzone4-              = 0.60
joy2deadzone4+              = 0.60
joy2deadzone5-              = 0.60
joy2deadzone5+              = 0.60
joy2deadzone6-              = 0.60
joy2deadzone6+              = 0.60
joy2deadzone7-              = 0.60
joy2deadzone7+              = 0.60

[serial]
serial1                 = dummy
serial2                 = dummy
serial3                 = disabled
serial4                 = disabled
serial5                 = disabled
serial6                 = disabled
serial7                 = disabled
serial8                 = disabled
serial9                 = disabled
phonebookfile               = phonebook-dosbox-x.txt

[parallel]
parallel1               = disabled
parallel2               = disabled
parallel3               = disabled
parallel4               = disabled
parallel5               = disabled
parallel6               = disabled
parallel7               = disabled
parallel8               = disabled
parallel9               = disabled
dongle                  = false

[printer]
printer                 = false
dpi                 = 360
width                   = 85
height                  = 110
printoutput             = png
multipage               = false
device                  = -
docpath                 = .
fontpath                = FONTS
openwith                = 
openerror               = 
printdbcs               = auto
shellhide               = false
timeout                 = 0

[dos]
xms                 = true
xms handles             = 0
shell configuration as commands     = false
hma                 = true
hard drive data rate limit      = -1
floppy drive data rate limit        = -1
ansi.sys                = true
log console             = false
share                   = true
file access tries           = 0
network redirector          = true
minimum mcb free            = 0
ems                 = true
umb                 = true
quick reboot                = false
ver                 = 
lfn                 = auto
fat32setversion             = ask
shellhigh               = auto
automount               = true
automountall                = false
mountwarning                = true
autofixwarning              = false
startcmd                = false
starttranspath              = true
startwait               = true
startquiet              = false
int33                   = true
keyboardlayout              = auto
customcodepage              = 
dbcs                    = true
dos clipboard device enable     = false
dos clipboard device name       = CLIP$
dos clipboard api           = true

[ipx]
ipx                 = false

[ne2000]
ne2000                  = false
nicbase                 = 300
nicirq                  = 3
macaddr                 = AC:DE:48:88:99:AA
backend                 = auto

[ethernet, pcap]
realnic                 = list
timeout                 = default

[ethernet, slirp]
ipv4_network                = 10.0.2.0
ipv4_netmask                = 255.255.255.0
ipv4_host               = 10.0.2.2
ipv4_nameserver             = 10.0.2.3
ipv4_dhcp_start             = 10.0.2.15

[ide, primary]
enable                  = true
pnp                 = true

[ide, secondary]
enable                  = true
pnp                 = true

[ide, tertiary]
enable                  = false
pnp                 = true

[ide, quaternary]
enable                  = false
pnp                 = true

[ide, quinternary]
enable                  = false
pnp                 = true

[ide, sexternary]
enable                  = false
pnp                 = true

[ide, septernary]
enable                  = false
pnp                 = true

[ide, octernary]
enable                  = false
pnp                 = true

[fdc, primary]
enable                  = false
pnp                 = true
mode                    = ps2

[4dos]

[config]
break                   = off
numlock                 = 
shell                   = 
dos                 = high, umb
fcbs                    = 100
files                   = 200
country                 = 
lastdrive               = a
set path                = Z:\;Z:\SYSTEM;Z:\BIN;Z:\DOS;Z:\4DOS;Z:\DEBUG;Z:\TEXTUTIL
set prompt              = $P$G
set temp                = 
install                 = 
installhigh             = 
device                  = 
devicehigh              = 

[autoexec]

Output log

$ SDL_AUDIODRIVER=pipewire vblank_mode=0 ./dosbox-x 
LOG: Early LOG Init complete
LOG: DOSBox-X's working directory: /home/kynikos/dosbox-x
LOG: Logging init: beginning logging proper. This is the end of the early init logging
LOG: Logging: No logfile was given. All further logging will be discarded.
LOG: DOSBox-X version 2022.08.0 (Linux SDL2)
LOG: Host keyboard layout is now us (US English)
LOG: Mapper keyboard layout is now us (US English)
LOG: SDL2 reports desktop display mode 1920 x 1080
ATTENTION: default value of option vblank_mode overridden by environment.
ATTENTION: option value of option vblank_mode ignored.
ATTENTION: option value of option vblank_mode ignored.
LOG: Configured windowposition: 0,0
LOG: SDL: Current window pixel format: SDL_PIXELFORMAT_RGB888
LOG: SDL: You are running in 24 bpp mode, this will slow down things!
LOG: X11 main window is 640 x 400 maximized=0
LOG: X11 extension XRANDR is available
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(640,400) match=(320,225)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: ISA BCLK: 8333333.333Hz (25000000/3)
LOG: monopal: green, 
LOG: Active save slot: 1 [Empty]
LOG: USING AVI+ZMBV
LOG: Max 3670016 sz 11264
LOG: Final 11264
LOG: MIDI:Opened device:alsa
LOG: Pentium CMPXCHG8B emulation is enabled
LOG: VOODOO LFB now at d0000000
LOG: Serial1: BASE 3f8h
LOG: Serial2: BASE 2f8h
LOG: MPU-401 Registering I/O ports as if IBM PC MPU-401 at base 330h
LOG: X11 main window is 640 x 400 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(640,400) match=(320,225)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: X11 main window is 640 x 400 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(640,400) match=(320,225)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: xxxx
LOG: VGA ROM BIOS init callback
LOG: WARNING: No translation support (to host) for code page 0
LOG: XMS: 50 handles allocated for use by the DOS environment
LOG: EMS page frame at 0xe000-0xefff
LOG: COMMAND.COM env size:             720 bytes
LOG: COMMAND.COM environment block:    0x0701 sz=0x002d
LOG: COMMAND.COM main body (PSP):      0x072f sz=0x009a
LOG: COMMAND.COM stack:                0x0749
LOG: pixratio 1.200, dw false, dh false
LOG: Aspect ratio: 4 x 3  xToY=1.333 yToX=0.750
LOG: menuScale=2
LOG: OpenGL PP: [1280x960]: 640x400 (1.20) -> [2x2] -> 1280x800 (1.00)
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: font texture id=2 will make 128 x 256
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: pixratio 1.200, dw true, dh true
LOG: Aspect ratio: 4 x 3  xToY=1.333 yToX=0.750
LOG: menuScale=2
LOG: OpenGL PP: [1280x960]: 320x200 (1.20) -> [3x4] -> 960x800 (1.33)
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: font texture id=2 will make 128 x 256
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: pixratio 1.200, dw false, dh false
LOG: Aspect ratio: 4 x 3  xToY=1.333 yToX=0.750
LOG: menuScale=2
LOG: OpenGL PP: [1280x960]: 640x400 (1.20) -> [2x2] -> 1280x800 (1.00)
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)
LOG: font texture id=2 will make 128 x 256
LOG: X11 main window is 1280 x 960 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1920,1080) outputs=1
LOG: Our window lies on this CRTC display (window pos=(0,25) size=(1280,960) match=(640,505)).
LOG:   Goes to output 0: name='DP-1' size_mm=(476 x 268)
LOG: Screen report: Method 'XRandR' (1920.000 x 1080.000 pixels) at (0.000 x 0.000) (476.000 x 268.000 mm) (18.740 x 10.551 in) (102.454 x 102.358 DPI)

Additional information

Linux 5.18.17_1 #1 SMP PREEMPT_DYNAMIC Fri Aug 12 13:53:18 UTC 2022 x86_64 GNU/Linux
PipeWire 0.3.56
SDL2 2.0.22
Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
Mesa Intel(R) Iris(R) Pro Graphics 580 (SKL GT4) (0x193b)
Mesa 22.1.7

Have you checked that no similar bug report(s) exist?

Code of Conduct & Contributing Guidelines

datajerk commented 2 years ago

I have the same problem on the steamdeck with the latest flatpak build (8/1/2022). As you said, worse with video transitions.

-set "cpu cycles=fixed 26800"

Appears to and fixed my problem.

KynikossDragonn commented 2 years ago

Well, unfortunately for my case it doesn't matter what "fixed cycles count" I even pick, the audio has sounds of underrunning despite nothing telling me there's an actual underrun happening. I could even be running something at aprox. "286 speed" cycles count and me just task switching causes a drop in audio. Game switching video modes? Massively abrupt audio interruption. Starting/Restarting CD-AUDIO track? Yet another massively abrupt audio interruption.

Unless you mean literally launch DOSBox-X with a command line argument to set CPU cycles as opposed to selecting a value in the conf file, but I have no idea why that would make any difference.

datajerk commented 2 years ago

CLI vs. .conf should be the same. BTW I just updated to the latest flatpak on steamdeck and the audio issue is back for me as well. I restored the older flatpak from a backup and audio is fine for me again. IOW, 2022.08.0 works for me 2022.09.0 (0.84.3) does not.