joncampbell123 / dosbox-x

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

Can't init SDL Could not setup connection to PulseAudio #2104

Open RayAndrews56 opened 3 years ago

RayAndrews56 commented 3 years ago

Hi Jon:

LOG: E_Exit: Can't init SDL Could not setup connection to PulseAudio E_Exit: Can't init SDL Could not setup connection to PulseAudio

First effort with dosbox-x and I get the above message at command line. I'm resurrecting an old DOS chess program and all I need to do is print off a few of the saved games so PulseAudio is of zero import. Can I get doxbox-x to just ignore that? FWIW my system seems to still use ALSA not that I care, my sound works.

joncampbell123 commented 3 years ago

Agreed. If PulseAudio isn't there, don't complain about it.

RayAndrews56 commented 3 years ago

So can I get her to load so that I can try to print? Some 'ignore sound' option of some sort?

joncampbell123 commented 3 years ago

The ideal fix is that if PulseAudio fails, try another interface, which I or a contributor will need to do.

In the meantime, see if setting environment variable SDL_AUDIODRIVER=alsa then running DOSBox-X helps.

Wengier commented 3 years ago

Perhaps this is because of the default FluidSynth fluid.driver setting of PulseAudio on Linux platform? If this is the case, @rderooy may also want to look at it because I think he made this the default driver for FluidSynth on Linux.

RayAndrews56 commented 3 years ago

"SDL_AUDIODRIVER=alsa"

No change Jon. Same message.

Wengier commented 3 years ago

@RayAndrews56 What if you change the fluid.driver setting (in [midi] section) to something like alsa?

RayAndrews56 commented 3 years ago

God knows. Point me to it and I'll try. I have no idea what 'fluid.driver is or where to find it.

joncampbell123 commented 3 years ago

@Wengier Ah, I didn't think of FluidSynth

Wengier commented 3 years ago

@joncampbell123 Not entirely sure actually, but when I searched for "PulseAudio ", FluidSynth settings showed up..

@RayAndrews56 You can find fluid.driver in the config file, or there is a graphical Configuration Tool for editing the configuration.

RayAndrews56 commented 3 years ago

There's no config file to be found. From what I read this should work:

"flatpak run com.dosbox_x.DOSBox-X -startgui"

... but the error is the same as before. Can I run the executable directly? This is my first experience with flatpak.

rderooy commented 3 years ago

I'm not sure what would cause this. It would appear audio is mis-configured or broken on your system.

I simply install the flatpak:

$ flatpak install -y com.dosbox_x.DOSBox-X
Looking for matches…

com.dosbox_x.DOSBox-X permissions:
    ipc      network      pulseaudio      x11     devices     file access [1]

    [1] home

        ID                             Branch          Op          Remote          Download
 1. [✓] com.dosbox_x.DOSBox-X          stable          i           flathub         6.4 MB / 6.5 MB

Installation complete.

And then run it.

]$ flatpak run com.dosbox_x.DOSBox-X
LOG: Early LOG Init complete
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 0.83.8 (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 1712 x 963
LOG: The default output for the video system: surface
LOG: Configured windowposition: 
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=(1712,963) outputs=1
LOG: Our window lies on this CRTC display (window pos=(526,273) size=(640,400) match=(846,473)).
LOG:   Goes to output 0: name='XWAYLAND0' size_mm=(310 x 170)
LOG: Screen report: Method 'XRandR' (1712.000 x 963.000 pixels) at (0.000 x 0.000) (310.000 x 170.000 mm) (12.205 x 6.693 in) (140.274 x 143.884 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 16384
LOG: Final 16384
LOG: SDLNet_TCP_Open: Couldn't connect to remote host
LOG: TiMidity: can't open control connection (host=127.0.0.1, port=7777)
LOG: MIDI:fluidsynth: SoundFont not specified, and no system SoundFont found
LOG: MIDI:synth: Specify .SF2 sound font file with midiconfig=
LOG: MT32: Control ROM file not found
LOG: MT32 emulation cannot work without the PCM and CONTROL ROM files.
LOG: To eliminate this error message, either change mididevice= to something else, or
LOG: place the ROM files in what will be the "current working directory" for DOSBox-X
LOG: when it starts up and initializes MIDI emulation.
LOG: The ROM files are: CM32L_CONTROL.ROM, MT32_CONTROL.ROM, CM32L_PCM.ROM, MT32_PCM.ROM
LOG: MIDI:Opened device:none
LOG: Pentium CMPXCHG8B emulation is enabled
LOG: VOODOO LFB now at d0000000
LOG: MPU-401 Registering I/O ports as if IBM PC MPU-401 at base 330h
LOG: GetDesktopResolution reading X11 desktop resolution
LOG: Root window (ID 1332) is 1712 x 963
LOG: X11 main window is 640 x 400 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1712,963) outputs=1
LOG: Our window lies on this CRTC display (window pos=(526,273) size=(640,400) match=(846,473)).
LOG:   Goes to output 0: name='XWAYLAND0' size_mm=(310 x 170)
LOG: Screen report: Method 'XRandR' (1712.000 x 963.000 pixels) at (0.000 x 0.000) (310.000 x 170.000 mm) (12.205 x 6.693 in) (140.274 x 143.884 DPI)
LOG: Allocated APM BIOS pm entry point at f000:e88c
LOG: Writing code to fe88c
LOG: X11 main window is 640 x 400 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1712,963) outputs=1
LOG: Our window lies on this CRTC display (window pos=(526,273) size=(640,400) match=(846,473)).
LOG:   Goes to output 0: name='XWAYLAND0' size_mm=(310 x 170)
LOG: Screen report: Method 'XRandR' (1712.000 x 963.000 pixels) at (0.000 x 0.000) (310.000 x 170.000 mm) (12.205 x 6.693 in) (140.274 x 143.884 DPI)
LOG: ISA Plug & Play BIOS enabled
LOG: VGA ROM BIOS init callback
LOG: pixratio 1.000, dw false, dh false
LOG: Aspect ratio: 640 x 480  xToY=1.333 yToX=0.750
LOG: menuScale=1
LOG: surface consider=640x497 final=640x497
LOG: X11 main window is 640 x 497 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1712,963) outputs=1
LOG: Our window lies on this CRTC display (window pos=(526,273) size=(640,497) match=(846,521)).
LOG:   Goes to output 0: name='XWAYLAND0' size_mm=(310 x 170)
LOG: Screen report: Method 'XRandR' (1712.000 x 963.000 pixels) at (0.000 x 0.000) (310.000 x 170.000 mm) (12.205 x 6.693 in) (140.274 x 143.884 DPI)
LOG:    3023664 ERROR BIOS:Keyboard layout file auto not found
LOG:    3023664 ERROR BIOS:Keyboard layout file auto not found
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.350, dw false, dh false
LOG: Aspect ratio: 720 x 540  xToY=1.333 yToX=0.750
LOG: menuScale=1
LOG: surface consider=720x417 final=720x417
LOG: X11 main window is 720 x 417 maximized=0
LOG: XRandR CRTC 0: pos=(0,0) size=(1712,963) outputs=1
LOG: Our window lies on this CRTC display (window pos=(526,273) size=(720,417) match=(886,481)).
LOG:   Goes to output 0: name='XWAYLAND0' size_mm=(310 x 170)
LOG: Screen report: Method 'XRandR' (1712.000 x 963.000 pixels) at (0.000 x 0.000) (310.000 x 170.000 mm) (12.205 x 6.693 in) (140.274 x 143.884 DPI)

Regarding the config file, as mentioned on github https://github.com/flathub/com.dosbox_x.DOSBox-X : _Under the default Flatpak configuration, the DOSBox-X configuration files are located in ~/.var/app/com.dosboxx.DOSBox-X/config/dosbox-x/. To access it with a graphical file manager, you'll have to make hidden folders visible.

The config file will not initially exist after installing DOSBox-X, or upgrading to a new version. You can create one from the DOSBox-X command line by running config -wcd. To write all config options, type config -wcd -all.

RayAndrews56 commented 3 years ago

It would appear audio is mis-configured or broken on your system.

There does seem to be something amiss in terms of cranky 
messages every now and then, yet my sound does work fine.  
Anyway, it seemed to me that the obvious solution would 
be some way of simply ignoring sound issues since all 
I want is access to the printer:

$ flatpak run com.dosbox_x.DOSBox-X -no_sound

... you get the idea.

And then run it.

]$ flatpak run com.dosbox_x.DOSBox-X


Yeah that's what I'm doing.  I was just wondering if there was some
actually installed binary somewhere.  Flatpak is new to me.

OK, thanks, I found the config directory as you say:
~/.var/app/com.dosbox_x.DOSBox-X/config/dosbox-x/

Contents:

3 /root/.var/app/com.dosbox_x.DOSBox-X 3 $ t ,f 4
.
├── [ 12K]  cache
│   ├── [4.0K]  fontconfig
│   └── [4.0K]  tmp
├── [4.0K]  config
│   └── [   0]  user-dirs.dirs
└── [4.0K]  data

24K .

... but no files except one zero length.  
rderooy commented 3 years ago

Correct, as was mentioned in the quote I provided from the website, the config file does not exist by default. You need to start dosbox-x and run something like config -wcd -all to get a config file generated.

But since you cannot start dosbox-x in the first place, that won't help. You can however grab the dosbox-x.reference.full.conf from the root of the git repository here, and place it into that directory that I referenced named as dosbox-x-0.83.8.conf. You can then change the sound settings in the config file.

As to your question on running it outside a flatpak, you can try the binary directly, but since it is made to run in the flatpak ubuntu 20.08 type environment with working pulseaudio, you will probably just get an error that some lib is not found.

To locate the flatpak dosbox-x binary run:

find ~ -name dosbox-x -type f
./.local/share/flatpak/app/com.dosbox_x.DOSBox-X/x86_64/stable/39f07582f4b1d855692865ea51e718f33aa29d5d9238e77e76f1f88d67bc8429/files/bin/dosbox-x

That should find the binary if it was installed as a user package. If it was installed system, you instead need to search under /var/lib/flatpak/app

The only other alternative would be to compile it yourself.

RayAndrews56 commented 3 years ago

I tried two locations for it:

3 /root/.var/app/com.dosbox_x.DOSBox-X 3 $ t ,f 4 . ├── [ 12K] cache │   ├── [4.0K] fontconfig │   └── [4.0K] tmp ├── [191K] config │   ├── [187K] dosbox-x.reference.full.conf │   └── [ 0] user-dirs.dirs ├── [4.0K] data └── [187K] dosbox-x.reference.full.conf

400K .

But the message is:

3 /root/.var/app/com.dosbox_x.DOSBox-X/config 3 $ flatpak run com.dosbox_x.DOSBox-X -startui LOG: Early LOG Init complete 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 0.83.8 (Linux SDL2) LOG: E_Exit: Can't init SDL Could not setup connection to PulseAudio E_Exit: Can't init SDL Could not setup connection to PulseAudio

This was with or without the edit:

fluid.driver = default

fluid.driver = alsa

... so it seems strange it's still looking for PulseAudio.

rderooy commented 3 years ago

Question, why are you running as root? That should be avoided.

Also, it seems you did not rename the config file as I had said, and it seems you have the file in the wrong directory.

Here it is on my system:

$ ls ~/.var/app/com.dosbox_x.DOSBox-X/config/dosbox-x/dosbox-x-0.83.8.conf 
/home/robert/.var/app/com.dosbox_x.DOSBox-X/config/dosbox-x/dosbox-x-0.83.8.conf
RayAndrews56 commented 3 years ago

Ok, that subdirectory '/dosbox-x' was not created by the previous download. I created it, changed the name of the file. I created a logfile and pointed the conf to it and:

LOG: Early LOG Init complete LOG: 0 is outside the allowed range 512-65536 for variable: vga bios size override. It has been set to the closest boundary: 512. LOG: Logging init: beginning logging proper. This is the end of the early init logging LOG: Logging: failed to open logfile '/aMisc/logfile'. All further logging will be discarded. Error: No such file or directory LOG: DOSBox-X version 0.83.8 (Linux SDL2)

(process:18634): flatpak-WARNING **: Error writing credentials to socket: Error sending message: Broken pipe LOG: E_Exit: Can't init SDL Could not setup connection to PulseAudio E_Exit: Can't init SDL Could not setup connection to PulseAudio

... so it's at least found the config file, but why won't it log? I tried it both as just a directory destination and as an already created file.

rderooy commented 3 years ago

The dosbox-x sub-directory is normally created when you write your first config file from within dosbox-x, but since you never got that far, it did not exist.

And it is probably not logging, because the /aMisc directory does not exist, from the flatpak sandbox perspective. As mentioned on the github page, it is only sharing the users home directory with the flatpak, not the whole host filesystem. These restrictions are quite normal for flatpaks. In fact, sharing the whole users home directory is already frowned upon by some, who would prefer to restrict it even further.

You can try the following:

flatpak run --command=sh com.dosbox_x.DOSBox-X

This will open a shell into the flatpak sandbox. Your prompt will change and include a little box icon to indicate your inside the flatpak sandbox.

Now try to type the following:

SDL_AUDIODRIVER=alsa dosbox-x

However, from my quick test, that simply will not work as the SDL2 that is included with flatpak only has the pulseaudio driver compiled in.

[📦 com.dosbox_x.DOSBox-X gitlab.lxp.lu]$ SDL_AUDIODRIVER=alsa dosbox-x
LOG: Early LOG Init complete
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 0.83.8 (Linux SDL2)
LOG: E_Exit: Can't init SDL Audio target 'alsa' not available
E_Exit: Can't init SDL Audio target 'alsa' not available

If you where to run other SDL2 based applications as a flatpak, I'm fairly certain you would get a similar error on your system since pulseaudio is broken on your host system.

rderooy commented 3 years ago

p.s. If for some reason you don't want to have a working PulseAudio setup on your host system. The PipeWire replacement also works (0.3.18 tested).

rderooy commented 3 years ago

@joncampbell123 @Wengier this does not seem to have anything to do with FluidSynth.

The standard flatpak SDL2 that is part of flatpak 20.08 only supports PulseAudio as an audio backend. When SDL2 is initialised when dosbox-x starts, SDL attempts to setup the audio back-end and this fails, since PulseAudio (or the PipeWire replacement) is not running on the host.

This would require failing gracefully when a SDL Audio target is available, but cannot complete its setup, and continuing without audio support. I don't know if that is easy, or even realistically possible to implement without modifying SDL2 source code.

RayAndrews56 commented 3 years ago

"because the /aMisc directory does not exist, from the flatpak sandbox perspective."

Well God knows what exists from its 'perspective'. It exists from my perspective and from Linux's perspective, and as I'm running as root (to avoid any such permissions issues), it should be seen.

"as the SDL2 that is included with flatpak only has the pulseaudio driver compiled in."

So why is the 'alsa' option even there?

"If for some reason you don't want to have a working PulseAudio setup on your host system."

I never did figure out what's wrong with it. Reinstall didn't help and since I do have sound it seemed best to let sleeping dogs lie.

"This would require failing gracefully when a SDL Audio target is available, but cannot complete its setup, and continuing without audio support."

That's what I was sorta thinking. Not that you'd get my sound working, more that there'd be a way of simply ignoring it since I don't really care about sound. I just want to print off some chess games.

Look guys, I'm just trying to help you sort out a minor issue if that's what you want to do. If you don't care then neither do I and I'll figure out how to uninstall everything and sorry for bothering you. If you're interested, I'm your guinea pig.

rderooy commented 3 years ago

@RayAndrews56 Running as root will make no difference to a flatpak. It will still run in a sandbox without root permission. That is it's design. And it will not be able to access files outside your home directory.

If you run the command I mentioned above to get a shell inside the sandbox, and do an ls of the root directory, you will see there is no /aMisc directory.

And your mixing things up with regard to the alsa options.

RayAndrews56 commented 3 years ago

"only the pulseaudio option will work due to the flatpak design."

Ok then sorry for wasting you guy's time.

grapeli commented 3 years ago

PulseAudio and Pipewire are preferred by Flatpak developers. Because only they allow access to the sound from a real sandbox. When the developer of a flatpak application provides access to all devices (--device=all), these restrictions do not exist. Of course, he must know how to prepare such a flatpak properly. Use alsa-lib and add SDL2 with the alsa backend. It cannot use SDL2 shipped with freedesktop. This one only uses pulseaudio.

If someone decides to use Flatpak, they should also use PulseAudio crap.

rderooy commented 3 years ago

Our flatpak config does have --device=all specified, as it is the only way to support devices like joysticks. But I'm not going to add alsa-lib and rebuild SDL2 specifically for this fringe case. Flatpak simply means PulseAudio/PipeWire.

But as I mentioned, perhaps it is possible to catch the SDL init failure and allow DOSBox-X to continue if the SDL sound driver cannot initialise?

grapeli commented 3 years ago

SDL_AUDIODRIVER=dummy Adding an alsa for 0.1% of users doesn't make much sense. Flatpak users are mostly Fedora, Suse, Ubuntu, Mint users. It's really hard to do without PulseAudio there.

RayAndrews56 commented 3 years ago

"But I'm not going to add alsa-lib and rebuild SDL2 specifically for this fringe case."

No, and I'd not ask for it (tho I did wonder why the option appears to be there). What I've hoped for from the beginning is to simply bypass any worries about sound since I don't need sound to use the printer.

rderooy commented 3 years ago

@RayAndrews56 I mentioned what the audio options are for. If you compile DOSBox-X yourself, these options can be set to something other than PulseAudio.

In any case, @grapeli mentioned something interesting, the SDL dummy audio option.

Try to run this:

flatpak run --command=`SDL_AUDIODRIVER=dummy dosbox-x` com.dosbox_x.DOSBox-X

I just tried it, and it seems to work.

rderooy commented 3 years ago

If the above works, you get set the environment variable, such that you can run the flatpak normally:

flatpak override --env=SDL_AUDIODRIVER=dummy com.dosbox_x.DOSBox-X

After this you can run the flatpak with the normal run command (or run it from the desktop environment)

flatpak run com.dosbox_x.DOSBox-X

edit If you have the flatpak installed as user instead of system, you may have to add --user to the override command.

e.g.

flatpak override --user --env=SDL_AUDIODRIVER=dummy com.dosbox_x.DOSBox-X
RayAndrews56 commented 3 years ago

Close! zsh thinks it's two commands somehow:

$ flatpak run --command=SDL_AUDIODRIVER=dummy dosbox-x com.dosbox_x.DOSBox-X zsh: command not found: dosbox-x execvp : No such file or directory

rderooy commented 3 years ago

@RayAndrews56 that is because you did not include the single-quotes around the command like I had shown.

RayAndrews56 commented 3 years ago

I did in fact, but they got lost in the paste, somehow. And you show backticks, yes? I tried both single-quotes and backticks.

rderooy commented 3 years ago

It seems the alternative zsh shell your using works just different enough from standard bash to break quotes apparently. Try to run the following two commands to test as a workaround:

flatpak run --command=sh com.dosbox_x.DOSBox-X
SDL_AUDIODRIVER=dummy dosbox-x
RayAndrews56 commented 3 years ago

"to break quotes apparently"

What is 'broken' is sometimes debatable. Zsh fixes many bash bugs that have been there so long folks don't realize they're bugs anymore ;-)

But your code works! I'll let you guys know if I actually can print my chess games which is what this was all about.

rderooy commented 3 years ago

I have added the limitation of having a working PulseAudio setup to the list of known issues for the flatpak release https://github.com/flathub/com.dosbox_x.DOSBox-X

RayAndrews56 commented 3 years ago

Glad to know something came of this. Alas, the printer didn't work for me :(

rderooy commented 3 years ago

Did you follow the wiki guide on printing?

RayAndrews56 commented 3 years ago

I've already uninstalled. Nuts, maybe with a bit more work I could have done it. Strange project anyway, hardly important so I've moved on. Thanks for your attention to this.

Wengier commented 3 years ago

Just want to let you know that a new version of DOSBox-X (0.83.9) was just released today with improved printing system. Also, compared with version 0.83.8, both RPM and Flatpak packages are officially released for Linux for this new version. Unlike Flatpak, I don’t think the RPM package requires PulseAudio, so providing both packages does gives users more choices (even though RPM packages may not work on all Linux distributions).

P.S. The Wiki guide for printing can be found at:

https://dosbox-x.com/wiki/Guide%3ASetting-up-printing-in-DOSBox%E2%80%90X

RayAndrews56 commented 3 years ago

I'll keep you guys in mind. I have been thinking how much fun it might be to give some of my old DOS games a try just for the memories.