The reason why it is done this way is because the on-focus configuration focuses on delivering the smallest latency possible. However, doing that increases CPU usage, which can be inferred via the small values of BASS_CONFIG_UPDATEPERIOD and BASS_CONFIG_DEV_PERIOD. This is not favorable when the game just acts as a music player, hence why the configuration is switched in-between.
The configuration is switched via BASS_Init with the BASS_DEVICE_REINIT flag. However, it has come to my attention that reinitializing BASS can cause a crash from BASS native libraries that we are unable to control. Here is a captured log:
Unfortunately, this means that we cannot reinitialize BASS to switch between configurations. Another way to do so is to free BASS and initialize it with the new configurations. However, freeing BASS will also free sample channels, which means a lot more work needs to be done (i.e., reloading samples in ResourceManager). It also does not help that under on-focus configurations, the music player stutters (likely due to the small BASS_CONFIG_BUFFER value, which is required to achieve small latency).
So unless I'm missing something, I can only think of two solutions:
Free BASS, initialize it, and reload all samples (such as the ones in ResourceManager). This is harder than the other solution because we will also need to change other stuff (i.e., there is no easy way to get sample sources)
Remove the music player, which is the easiest solution, but may spin the community up. Therefore, it needs more discussion.
I'm open to other possible solutions. I hope to resolve this issue before the next release.
Ever since the 1.6.8 release, the game uses two BASS configuration "presets". The first preset is used when the game is on focus. https://github.com/osudroid/osu-droid/blob/460da295c4070c39ab5fe3cf301c906535ab7ce2/src/ru/nsu/ccfit/zuev/audio/BassAudioProvider.java#L38-L55
The second preset is used when the game acts as a music player. https://github.com/osudroid/osu-droid/blob/460da295c4070c39ab5fe3cf301c906535ab7ce2/src/ru/nsu/ccfit/zuev/audio/serviceAudio/BassAudioFunc.java#L42-L63
The reason why it is done this way is because the on-focus configuration focuses on delivering the smallest latency possible. However, doing that increases CPU usage, which can be inferred via the small values of
BASS_CONFIG_UPDATEPERIOD
andBASS_CONFIG_DEV_PERIOD
. This is not favorable when the game just acts as a music player, hence why the configuration is switched in-between.The configuration is switched via
BASS_Init
with theBASS_DEVICE_REINIT
flag. However, it has come to my attention that reinitializing BASS can cause a crash from BASS native libraries that we are unable to control. Here is a captured log:Unfortunately, this means that we cannot reinitialize BASS to switch between configurations. Another way to do so is to free BASS and initialize it with the new configurations. However, freeing BASS will also free sample channels, which means a lot more work needs to be done (i.e., reloading samples in
ResourceManager
). It also does not help that under on-focus configurations, the music player stutters (likely due to the smallBASS_CONFIG_BUFFER
value, which is required to achieve small latency).So unless I'm missing something, I can only think of two solutions:
ResourceManager
). This is harder than the other solution because we will also need to change other stuff (i.e., there is no easy way to get sample sources)I'm open to other possible solutions. I hope to resolve this issue before the next release.