Author Topic: Strange behaviour in SDL2  (Read 41200 times)

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Strange behaviour in SDL2
« on: May 23, 2023, 10:00:51 am »
So, I'm working on PrBoom again and I noticed a strange behaviour:
Sometimes when I start the program, there is sound. Sometimes, when I use the volume program, the sound become audible, even if I press the plus sign only once, so that the volume is going down or up one point. The direction doesn't matter.
I'm running a T480 with the newest ArcaNoae Uniaud (I also tried Paul's newer version, no change there). SDL2 is locally build copy of the most recent repo.

The question is, whether somebody knows this phenomenom and point me to some solution.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4815
  • Karma: +42/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Strange behaviour in SDL2
« Reply #1 on: May 23, 2023, 02:55:51 pm »
Hi Jochen

I'm using this version of PRBoom+
  https://github.com/josch1710/prboom-plus/releases/download/v2.6um-alpha1/prboom-plus-2.6um-alpha1.zip
To run PRBoom+ it is needed:
  yum install flac fluidsynth SDL2_image

I also experience a problem with the sound. The "action sounds" of the menu and the shots of selecting the menu items sounds fine on the startup, but later when I start up the game the sound is gone. If I close the game and start it over, sometimes I get the menu sound back and sometime don't. 
I made this quick video: https://youtu.be/ssjtBMSdwis

I don't see the SDL Mixer on the exe, which is the audio stuff for SDL. Maybe is some issue with flac.
I haven't added MIDI support to my system to see if the background music works.

Regards
« Last Edit: May 23, 2023, 03:40:47 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #2 on: May 24, 2023, 10:57:51 am »
Hi Martin,

thanks for the feedback. At least, I'm not alone.
My working copy has SDL Mixer linked, that doesn't seem to be the issue.
My current hunch is, that something in SDL2 in conjunction with PrBoom goes wrong.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4815
  • Karma: +42/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Strange behaviour in SDL2
« Reply #3 on: May 24, 2023, 02:19:46 pm »
Hi Jochen

You may already know about this, we have two distros of SDL and SDL2.
One on Netlabs rpm (I guess from BitWise Works) and the other from Digi (http://os2.snc.ru/product-SDL.html)

Maybe you would like to test a release with Digi's SDL and see if there is any improvement.  Is that what you did to don't have the issue?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #4 on: May 24, 2023, 04:16:18 pm »
Hi Jochen

You may already know about this, we have two distros of SDL and SDL2.
One on Netlabs rpm (I guess from BitWise Works) and the other from Digi (http://os2.snc.ru/product-SDL.html)

Maybe you would like to test a release with Digi's SDL and see if there is any improvement.  Is that what you did to don't have the issue?

Regards
No, I didn't test Digi's SDL.
Also I don't get what you mean by your last sentence.
 

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4815
  • Karma: +42/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Strange behaviour in SDL2
« Reply #5 on: May 24, 2023, 04:40:49 pm »
Hi Jochen,

Sorry my last sentence was confusing because  I didn't understand this:
My working copy has SDL Mixer linked, that doesn't seem to be the issue.
I got confused there, please ignore my last sentence.

I guess that it would be good to try to use Digi's SDL2 and if the problem gets solve like magic, it most be some issue with the Netlabs RPM SDL2.

Just in case I have Digi's SDL2 source code copied here:
- https://github.com/OS2World/LIB-SDL2/tree/master/packages
- Original source: ftp://digi.os2.snc.ru/pub/SDL

while Netlabs RPM Bitwise Source code is here:
- https://github.com/bitwiseworks/SDL2-os2
- https://github.com/bitwiseworks/SDL2_mixer-os2
- https://github.com/bitwiseworks/SDL2_image-os2
... and others

Regards
« Last Edit: May 24, 2023, 04:53:49 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #6 on: May 25, 2023, 09:18:40 am »
Hi Martin.

Thanks for the hints, but I know them, because I made some fixes on them and use them for debugging.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #7 on: June 20, 2023, 09:55:06 am »
Upon further research, I noticed that the multimedia system, just doesn't do anything with the supplied data. The callback, when the buffer is played, never gets called, until I use the master volume application. Then suddenly the buffer is played and everything is fine. Any ideas why?

Another issue, which bugs me, is that OS/2 reports two sound card while onyl one is in my T480. One of the SDL2 test programs tries to open all reported devices, but the second one is already locked.
Any ideas why?

Lars

  • Hero Member
  • *****
  • Posts: 1298
  • Karma: +65/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #8 on: June 22, 2023, 07:10:32 am »
Can you use an USB sound device (with the corresponding drivers of course) and see if that makes a difference? If yes, it must be the UNIAUD drivers. Or AUDIOIF.DLL (that provides the interface between MMPM and the audio drivers and that I replaced for the USB audio drivers with my own version).

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #9 on: June 22, 2023, 02:55:23 pm »
I will try that on sunday.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4815
  • Karma: +42/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Strange behaviour in SDL2
« Reply #10 on: June 25, 2023, 03:11:08 pm »
Hi Jochen, Lars

I recently tried PRBoom+ on my Thinkpad L420 with the USB Audio headset (HP Gaming Headset H320GS)

I'm using this version of PRBoom+
  https://github.com/josch1710/prboom-plus/releases/download/v2.6um-alpha1/prboom-plus-2.6um-alpha1.zip
To run PRBoom+ it is needed:
  yum install flac fluidsynth SDL2_image

I used Lars' USB Audio drivers (Included in usbdrv).

I have some kind of different results:
- Sound works better than before, but eventually I loose the sound completely (less than one minute playing or watching the demo), it comes and go while I play. If I alt+tab to the desktop, the sound gets back.
- I exited and reenter the program like three times, and sound kept working, not like before that I got no sound on the second or third try.
- The volume master control worked, I alt+tab to the desktop, reduced the volume and returned to PRBoom+ with the adjusted volume.
- The volume controls inside PRBoom+ also worked to change the music or SFX
- It even works with the MIDI music, because I have installed Ksoftseq some time ago.

I'm not sure if the sound issue is now caused by the MIDI support or my hardware. But on the ArcaOS desktop I have run without interruptions 2 minutes MIDI file (with the USB Headset) without any issues.
But sound is working better with the USB headset than with Uniaud on my case.

It would be interesting if someone else can test PRBoom+ on their machine, specify if using UniAud or USB Audio, just let it run for two to five minutes running the self running demo and check if the sound remains steady for that time.

Regards



« Last Edit: June 25, 2023, 05:44:28 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Lars

  • Hero Member
  • *****
  • Posts: 1298
  • Karma: +65/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #11 on: June 27, 2023, 09:22:07 am »
As a test I now installed ksoftseq (and all of its prerequisites of course).

For me, ksoftseq does not work reliably. Some MIDI files just won't play but the files are not the problem because they play fine with the timidity.exe and kmidi.exe and kmidimmio.exe (the two latter from the kmididec package) command line players.

What I experience is a much delayed playing of the file because apparently, the .SF2 file is loaded every single time when a MIDI file is selected for playing (and unloaded afterwards). What I also observe is a complete system hang when I double click a MIDI file to play every now and then.
I suspect the problem lies in ksoftseq MCD implementation. I have added two issues to the ksoftseq Github repo.

I have not tried PRBoom+ yet.

Jochen Schäfer

  • Sr. Member
  • ****
  • Posts: 361
  • Karma: +29/-0
    • View Profile
Re: Strange behaviour in SDL2
« Reply #12 on: June 27, 2023, 09:48:36 am »
Yesterday, I got around to testing with a USB headset and the following are my observations:
  • SDL detects the audio devices by sending MCI_SYSINFO_QUANTITY with type set to MCI_DEVTYPE_AUDIO_AMPMIX.
    This only detects the selected default audio and it always gets two devices. Since the second is always locked, when the first is used, I suspect, the system returns one device for output and one for input. I already tried to get the device capabilities, but failed.
    I also don't whether the detection of only the default device is the expected behaviour.
  • Starting PrBoom with the USB headset plugged in, the sound is not starting sometimes. But the trick to change the master volume doesn't work here. Also, I also see Martin's observation that, when the sound starts, it will run (with occasional hickups) and not cut out, like the builtin sound card.
I really don't know whether it's any drivers fault, or whether PrBoom does things, it will get away with on other systems.

Wim Brul

  • Sr. Member
  • ****
  • Posts: 295
  • Karma: +25/-0
    • View Profile
    • Wim's home page
Re: Strange behaviour in SDL2
« Reply #13 on: June 27, 2023, 06:12:42 pm »
I did some tests on my Dell Latitude e6500 laptop with ArcaOS 5.0 and Lars' USB 10.249 drivers installed.

1) USBAUDIO.SYS selected as default audio device. Every time I start PrBoom I get sound and PrBoom keeps running with sound. Its SfxVolume control works. Its Music Volume has no effect. Perhaps because I have no MIDI support installed. With rocksndiamonds there is always sound.

2) USBAUD2.SYS selected as default audio device. Every time I start PrBoom I rarely get sound and PrBoom keeps running that way. Once I use its SfxVolume control then most of the time only the next invokation of PrBoom produces sound. With rocksndiamonds there is never sound.

Once USBAUD2.SYS does not get an audio buffer in time it stops sending audio to the device.
This is a flaw in USBAUD2.SYS. I have prepared a fix for that.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4855
  • Karma: +102/-1
    • View Profile
Re: Strange behaviour in SDL2
« Reply #14 on: June 28, 2023, 07:38:09 am »
Testing here, using UniAud 3.1.4 from Arca Noae, sound usually works, occasionally it doesn't and I need to touch the master volume control, adjust volume or mute/unmute then it works fine. Haven't got the midi to work yet, even after following Martin's procedure to get midi working on the desktop, always get "Error loading song: Couldn't open /etc/timidity/freepats.cfg" guess I haven't set it up correctly.
As far as I can see, only one sound card is found, which is correct as I do have only one. Jochen, are you sure you don't have 2 sound cards, pci.exe will show if there are two and there often are. One regular and one for HDMI, often on the graphics card, which I guess is built in to your laptop.
My /etc/timidity/freepats.cfg
Code: [Select]
dir w:/mmos2
source ksoftseq.sf2