diff --git a/internal/oboe/binding_android.cpp b/internal/oboe/binding_android.cpp index 05bc529..574ebd9 100644 --- a/internal/oboe/binding_android.cpp +++ b/internal/oboe/binding_android.cpp @@ -354,6 +354,15 @@ void Stream::DeferStartLocked() { const char *Stream::Play(int sample_rate, int channel_num, int buffer_size_in_bytes) { + // The frame counts and the read wait below divide by these, so a value the + // caller left at zero would fault instead of reporting a bad configuration. + if (sample_rate <= 0) { + return "oto_oboe_Play: sample rate must be positive"; + } + if (channel_num <= 0) { + return "oto_oboe_Play: channel count must be positive"; + } + std::lock_guard lock{mutex_}; sample_rate_ = sample_rate; channel_num_ = channel_num;