Spinner samples in this skin will fail to play and stay in a weird state (having Playing == false but Looping == true) The core of the problem is here:
Bass.SampleLoad can fail due to an invalid format, for instance. Bass.LastError is not checked, and the function returns 0 as documented in that case.
Worse yet this 0 handle can be passed to Bass.ChannelBytes2Seconds which will rightfully complain and return a -1, which then the above code unhelpfully interprets as a length in seconds, therefore returning a sample that has Length == -1000 which is obviously wrong.
This is probably a bigger issue all over as we don't generally check Bass.LastError all that much.
Noticed during review of https://github.com/ppy/osu/pull/10925. Can be reproduced game-side with this skin:
IAmUseless (Android 4+ (modified)) (IAmUseless29).zip
Spinner samples in this skin will fail to play and stay in a weird state (having
Playing == false
butLooping == true
) The core of the problem is here:https://github.com/ppy/osu-framework/blob/ca72e336a2deb77d1e4523544b8953291cd4385f/osu.Framework/Audio/Sample/SampleBass.cs#L60-L76
Several issues with this code:
Bass.SampleLoad
can fail due to an invalid format, for instance.Bass.LastError
is not checked, and the function returns 0 as documented in that case.Bass.ChannelBytes2Seconds
which will rightfully complain and return a -1, which then the above code unhelpfully interprets as a length in seconds, therefore returning a sample that hasLength == -1000
which is obviously wrong.This is probably a bigger issue all over as we don't generally check
Bass.LastError
all that much.