itdelatrisu / opsu

opsu! ~ an open-source osu! client
https://itdelatrisu.github.io/opsu/
GNU General Public License v3.0
763 stars 123 forks source link

Change SoundController loading to fallback if a sound-file is corrupted/invalid #326

Open Lyonlancer5 opened 7 years ago

Lyonlancer5 commented 7 years ago

Overview

If opsu! is loading hit sounds and sound effects in custom skins (or even the defaults if the downloaded JAR is corrupted) and it encounters something that it cannot read, it will throw an UnsupportedAudioFileException, but would still continue to load if the user presses the close button on the error message.

The exception to what happens is when sound files are 0 bytes (intended for use with "silent" hitsounds), those load normally (with a null AudioInputStream passed)

This may be the cause of issues #320, #311 and #259 when loading hitsounds/SFX from incompletely downloaded skins/custom skins with partially downloaded sounds.

This is supported by a test via modifying a WAV file's first four bytes (artificial "corruption") in the default skin's applause.wav found in the res/ folder with the use of a hex editor and a USB corruption during a copy between PCs.


Test

Do note the first four highlighted bytes in the hex editor to the left, that is what I used to test my hypothesis on this issue.

Normal applause.wav - First four hex-values are 52 49 46 46, normal WAV header soundcontroller-1

"Corrupted" applause.wav - First four hex-values are 00 00 00 00, null header soundcontroller-2


A possible solution to this would be:

itdelatrisu commented 7 years ago

I doubt that most of these reports had been caused by corrupted files. There have been a lot of actual bugs with audio decoding in the past (e.g. in different Linux setups), and that's also the reason I want to keep showing the crash report window.

If there's an easy way to tell if loading failed due to a corrupted file vs. unsupported formats, though, it'd be nice to only show an in-game alert for the former.

Lyonlancer5 commented 7 years ago

Although in the issues mentioned here, the systems have been running Windows. I still have to try the Linux side of things, having recently installed Ubuntu 16.04 LTS dual booting on my main PC.

If anyone running into this issue on Linux-based systems could post what their installed packages and sound configuration are, then this would've made discovering whether its an issue with audio decoding or simply a corrupted file.