From adf52c51a338f26b309918ba14b5d3d4d7b055a6 Mon Sep 17 00:00:00 2001 From: JelliiDev <249418615+JelliiDev@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:01:52 +0300 Subject: [PATCH] Fixed error parsing for functions that return size. --- ndk/src/audio.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ndk/src/audio.rs b/ndk/src/audio.rs index 0be6e1c3..05e1fadb 100644 --- a/ndk/src/audio.rs +++ b/ndk/src/audio.rs @@ -479,14 +479,15 @@ impl AudioError { ptr.to_string_lossy() } - /// Returns [`Ok`] on [`ffi::AAUDIO_OK`], [`Err`] otherwise (including positive values). + /// Returns [`Ok`] on [`ffi::AAUDIO_OK`] or any positive value, for example, size, [`Err`] otherwise. /// /// Note that some known error codes (currently only for `AMediaCodec`) are positive. pub(crate) fn from_result(status: ffi::aaudio_result_t) -> Result<()> { - match status { - ffi::AAUDIO_OK => Ok(()), - x => Err(Self::from(x)), + if status >= ffi::AAUDIO_OK { + return Ok(()) } + + Err(Self::from(status)) } }