xan1242 / XNFSMusicPlayer

Xan's NFS Music Player - Custom music player replacement and a BASS library interface for NFS.
MIT License
28 stars 3 forks source link

[All] Implement BASS stream creation on a separate thread to avoid lag #6

Open Sonic49PH opened 2 years ago

Sonic49PH commented 2 years ago

I had tried the latest release of the XNFSMusicPlayer, but in-game without music, it just halts for a split-second.

xan1242 commented 2 years ago

Yeah so this happens because the BASS library runs in the same thread as the game.

Meaning that if your storage is slow it can cause these kinds of issues (it's especially noticeable with online streams).

This entire music player needs a rewrite anyways so I don't think I can fix these issues right now. Maybe moving the playback to a separate thread could work.

xan1242 commented 2 years ago

This is very noticeable once you add a frametime graph like MangoHUD. It's definitively visible on larger streams. Maybe it's caused by BASS_STREAM_PRESCAN flag, I'm not too sure, but the solution definitively is moving all music processing to a separate thread and only use the game thread for messaging.

xan1242 commented 2 years ago

Branch multithread was created for this purpose:

https://github.com/xan1242/XNFSMusicPlayer/tree/multithread

Idea is simple - add a simple push/pop queue messaging system and pass that info to the second thread through a message buffer.