Conversation
OpenLocked divides the requested buffer size by channel_num_ and PrepareBuffersLocked converts the buffer to microseconds by dividing by sample_rate_, so a zero from the caller faults the process instead of failing the way every other bad configuration does. oto does not check the two options when the default buffer size is used, and the extern entry point is callable on its own.
Member
|
Could we put this validation in the common There is already a This would also avoid sending these configuration errors through Android's asynchronous initialization error path, which currently records the error without closing Posted by Codex on behalf of @hajimehoshi. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What issue is this addressing?
No issue filed yet. Found during an audit of the Android binding.
What type of issue is this addressing?
bug
What this PR does | solves
Stream::Play(internal/oboe/binding_android.cpp) storeschannel_num_andsample_rate_without validation, and later code divides by them:If the caller ever passes
0(e.g. aNewContextOptionswithSampleRate/ChannelCountleft at their zero value reaching the binding unchecked), this faults with SIGFPE on the audio thread instead of returning a configuration error. Note the Go side does not currently reject zero values either, so the binding is the last line of defense.The fix
Validate both arguments up front and return a descriptive error string, matching the existing
const char *error contract ofoto_oboe_Play:The error propagates back to
newContextin driver_android.go and is reported throughc.err.Joinas usual.