Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HL] No way to find out whether loading a sound failed #1442

Open
MoritzBrueckner opened this issue Dec 17, 2022 · 0 comments
Open

[HL] No way to find out whether loading a sound failed #1442

MoritzBrueckner opened this issue Dec 17, 2022 · 0 comments

Comments

@MoritzBrueckner
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant