Multithreaded Core Speed Issues

Hi all,

I’m developing a new libretro based frontend, and while I was able to run some opengl accelerated cores like Mupen64 and Flycast, both suffer from weird changes in A/V speed and pitch from time to time while running. After some trial and error, I found out that the issue was only happening when threaded video options were enabled in both cores, so that when disabled, both worked fine with no issues.

Apart from unloading multithreaded cores special functionality, I was not able to find any reference in the API or core documentation talking about any special procedure when running multithreaded cores, so not sure what I’m doing wrong or missing.

Any advise on this topic?

I was able to found out that when cores are running in threaded mode, they are doing many extra calls to the audio batch callback function sending silence. These silences are “breaking” the sound resampler forcing a pitch modification.

Is this something intended?

This is actually something expected to my knowledge. Threaded Video option isn’t actually the same as when the core was built with multithreading/multicore in mind. Normally you want Threaded Video to be set off on a computer that is powerful enough to run the game/core at fullspeed. It’s basically sort of “hack” for hardware that is a bit too weak. When you use this option, then correct synchronization between video and audio is not possible anymore.

Threaded Video:

If your video driver has very bad performance, it is possible to run it on a thread to avoid almost all video driver overhead. Set video_threaded = true in config. Butter smooth VSync behavior in this case is impossible however, and latency might increase slighly. Use only if you cannot obtain full speed otherwise.

Optimal V-Sync:

Settings->Video->Output->Threaded Video is well known to interfere with smooth frame pacing and audio sync, but can be the only choice for hardware otherwise too weak for the intended content to run at near the correct frame rate at all.

@rTomas Sorry for the OT, unfortunately I can’t help with this issue, but I wanted to say that it’s been a while that I’am following your dev-log on yt and you are doing a great work! keep it up! :+1: