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

ndk: Replace HardwareBufferError with std::io::Error through new helper conversion function #295

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

MarijnS95
Copy link
Member

Depends on #294

These AHardwareBuffer functions all return standard errno.h error codes which can be communicated back to the user in ergonomic form instead of appearing as a newtyped struct holding a "meaningless" i32.

Perform the same conversion to just NativeWindow::set_buffers_geometry which also returns errno.h codes: this change is small enough to not warrant yet another PR, as we've already changed the exact same for InputQueueError in #292. (Note that this is intentionally omitted from the changelog since set_buffers_geometry() is only making its debut in the upcoming release, this change isn't breaking).

This pattern is now prevalent across the codebase (hardware_buffer, surface_texture, and native_window all use it), warranting the new status_to_io_result() helper function to be introduced in an also-new utils.rs module.

@MarijnS95
Copy link
Member Author

@dvc94ch Assuming you have more rights to this repo, can you turn on Always suggest updating pull request branches?

image

Thanks!

@dvc94ch
Copy link
Contributor

dvc94ch commented Jun 12, 2022

Nope, don't have access

@MarijnS95
Copy link
Member Author

@francesca64 maybe?

…helper conversion function

These `AHardwareBuffer` functions all return [standard `errno.h` error
codes] which can be communicated back to the user in ergonomic form
instead of appearing as a newtyped struct holding a "meaningless" `i32`.

Perform the same conversion to just `NativeWindow::set_buffers_geometry`
which also returns `errno.h` codes: this change is small enough to not
warrant _yet another_ PR, as we've already changed the exact same for
`InputQueueError` in [#292].
(Note that this is intentionally omitted from the changelog since
 `set_buffers_geometry()` is only making its debut in the upcoming
 release, this change isn't breaking).

This pattern is now prevalent across the codebase (`hardware_buffer`,
`surface_texture`, and `native_window` all use it), warranting the new
`status_to_io_result()` helper function to be introduced in an also-new
`utils.rs` module.

[standard `errno.h` error codes]: https://cs.android.com/android/platform/superproject/+/master:frameworks/native/libs/nativewindow/AHardwareBuffer.cpp;drc=4120991d92a0265ce480672f704612556328057e
[#292]: #292
@MarijnS95 MarijnS95 force-pushed the ndk-hardware-buffer-error-and-docs branch from a04d578 to d9e44b0 Compare July 5, 2022 17:04
@MarijnS95 MarijnS95 merged commit 2372f1d into master Jul 5, 2022
@MarijnS95 MarijnS95 deleted the ndk-hardware-buffer-error-and-docs branch July 5, 2022 17:37
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

Successfully merging this pull request may close these issues.

3 participants