fgsfdsfgs / ioq3

Nintendo Switch port of ioquake3
https://www.ioquake3.org/
GNU General Public License v2.0
21 stars 4 forks source link

SDL2 preemptive multithreading #1

Closed Cpasjuste closed 5 years ago

Cpasjuste commented 5 years ago

Hi @fgsfdsfgs , i just implemented preemptive multithreading in SDL2, would it be possible for you to test it to see if there is no issues with it (mainly audio) before pushing it to pacman packages?

Thanks.

libSDL2.zip

fgsfdsfgs commented 5 years ago

While ioq3 doesn't seem to explicitly use SDL2 threads, the audio appears to work fine in both SDL2 and OpenAL audio backends. I'll test some of my other ports and report back.

fgsfdsfgs commented 5 years ago

Quake2, Quakespasm and Doom 3 are fine. Got a new bug in Doom64EX: the thread playing the current music track sometimes seems to not stop on music change or something. The synth that plays the music uses several libnx (actually C11) threads with different priorities for multichannel stuff. Maybe that's related to your change? I'll revert to stable SDL2 and see later.

Cpasjuste commented 5 years ago

Hi @fgsfdsfgs , thanks for the reports. In fact libnx c11 threads does not allow thread priority changes if i'm correct, it works in a preemptive mode (priority is handled by the device if i'm correct again), which should now also be the case for sdl2 threads (audio and custom ones). Can you link me to the revelent code in doom64EX, i guess i should take a closer look too.

fgsfdsfgs commented 5 years ago

Oh, I was not aware of that. The relevant code is in the fluidsynth-lite library it uses for sequenced music. https://github.com/fgsfdsfgs/fluidsynth-lite/blob/master/src/utils/fluid_sys.c#L434 Threading code is scattered around this file. Some of the functions you might be interested in are at https://github.com/fgsfdsfgs/fluidsynth-lite/blob/master/src/utils/fluid_sys.c#L624 https://github.com/fgsfdsfgs/fluidsynth-lite/blob/master/src/utils/fluid_sys.c#L930 and also this https://github.com/fgsfdsfgs/fluidsynth-lite/blob/master/src/utils/fluid_sys.h#L223

fgsfdsfgs commented 5 years ago

I guess there hasn't been any issues with this, so whatever.