xan1242 / XNFSMusicPlayer

Xan's NFS Music Player - Custom music player replacement and a BASS library interface for NFS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

Sonic49PH opened this issue · comments

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

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.

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.

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.