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

media_error: Add MediaStatus::from_status_if_negative() helper #414

Merged
merged 1 commit into from
Aug 15, 2023

Commits on Aug 15, 2023

  1. media_error: Add MediaStatus::from_status_if_negative() helper

    Covers a prevalent `unwrap_err()` pattern for negative status codes,
    where we want to use any non-negative status code as a useful value and
    otherwise assert that `from_status()` turns the raw value into an
    appropriate error code (never into `Ok(())`, which should be unreachable
    in the current implementation).
    
    Note that we cannot rely on `from_status()` returning `Ok(())` or
    `Err(_)` and translate the `Ok(())` back to the original value, as it
    handles (as of writing) two positive error codes which only relate to a
    specific `AMediaCodec` API, and any unrecognized codes including >0 are
    treated as `UnknownStatus`.
    
    The function consumes `Into<isize>` instead of `i32/c_int` or
    `ffi::media_status_t` to support passing through numbers from various
    APIs that return 64-bit numbers (e.g. `MediaCodec`).  The value only
    needs to be truncated (with a panic on `try_into()`) when it is lower
    than zero and needs to be converted to `ffi::media_status_t`.
    MarijnS95 committed Aug 15, 2023
    Configuration menu
    Copy the full SHA
    8920257 View commit details
    Browse the repository at this point in the history