[HL] No way to find out whether loading a sound failed
MoritzBrueckner opened this issue · 0 comments
From #1441:
- Errors when loading .wav files are handled with
kinc_affirm()
and not passed to Kha. Instead the user either sees "Unknown Error" or the application just crashes.- Errors when loading .ogg files result in a Haxe exception. I'm not sure whether you would be ok with wrapping the entire call to
new kha.korehl.Sound()
in a try/catch, because otherwise I don't think there is a nice way of calling a failed callback in the current API.
wav:
Instead of returning null if a wav sound could not be loaded or a wav file is corrupted in some way, Kha uses kinc_affirm()
(source, another example usage). This makes it impossible to call the failed
callback in the LoaderImpl of the HL backend. Is this by purpose?
ogg:
kha.korehl.Sound.initOgg()
fails with an exception if the sound could not be loaded. We can either wrap just the call to File.getBytes()
into a try/catch block and then return something in case of an error (+ printing the error?) or we do this when we construct the sound in the LoadImpl. What do you prefer? In the first case we would still construct a Sound
object and then we need to somehow retrieve the error state from that (also, the exception would not be thrown even if kha.korehl.Sound
is constructed in some other place), and in the second case there would be a needless try/catch even if we try to load a wav file.