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: Rework media error types #399

Merged
merged 1 commit into from
Jun 16, 2023
Merged

ndk: Rework media error types #399

merged 1 commit into from
Jun 16, 2023

Conversation

MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented Jun 15, 2023

CC @paxbun

  • Clean up the names: we're already in the ndk crate so no need to repeat that in the type name;
  • Make the types available outside the media module, so that they can be used in AMidi bindings which are not located inside libmediandk.so (but libamidi.so);
  • Add documentation comments;
  • Guard dead_code helper functions with the right feature bound.

@MarijnS95 MarijnS95 requested review from msiglreith and rib June 15, 2023 14:54
@MarijnS95
Copy link
Member Author

Thinking of doing the same little tweaks to BitmapResult and friends.

@paxbun
Copy link
Contributor

paxbun commented Jun 16, 2023

LGTM! By the way, construct or construct_never_null emit unused warnings when both media or midi are not enabled. Is that okay? IIRC, I tried to put some #[cfg(...)] to remove those warnings, but we kept it unchanged because of this rewriting.

@MarijnS95
Copy link
Member Author

MarijnS95 commented Jun 16, 2023

Yes indeed. It has bothered me too, but not enough to come up with a more restrictive cfg bound. Those are generally error-prone and would require extensive checking of all media, api-level-24, api-level-26, and later midi combinations of features in the CI.

With this PR MediaError::from_status() is also added to the list, fwiw :)

@MarijnS95
Copy link
Member Author

I'm considering at least constraining this with media, then you can add midi to it in #353.

@MarijnS95
Copy link
Member Author

MarijnS95 commented Jun 16, 2023

@paxbun done, moved and fixed the cfg feature bounds. You'll have to add midi to the top-level #![cfg(feature = "media")] -> #![cfg(any(feature = "media", feature = "midi"))] but can hopefully leave the other cfgs intact as they automatically get enabled via "midi" -> "api-level-29" -> "api-level-24".

Though as you don't use construct_never_null(), this might need yet another bound :(

@MarijnS95
Copy link
Member Author

Otherwise I might as well switch back to #[allow(dead_code)] (while still guarding the module as a whole) and document that the cfgs are nontrivial and would be hard to test and maintain all combinations.

@MarijnS95
Copy link
Member Author

Though as you don't use construct_never_null(), this might need yet another bound :(

Yup it does :(

- Clean up the names: we're already in the `ndk` crate so no need to
  repeat that in the type name;
- Make the types available outside the `media` module, so that they can
  be used in `AMidi` bindings which are not located inside
  `libmediandk.so` (but `libamidi.so`);
- Add documentation comments;
- Guard `dead_code` helper functions with the right `feature` bound.
@paxbun
Copy link
Contributor

paxbun commented Jun 16, 2023

I also think guarding the whole module with cfg and adding #[allow(dead_code)] to each function is the best now. This would be the case where we should use explicit allow.

@MarijnS95 MarijnS95 requested a review from dvc94ch June 16, 2023 08:41
@MarijnS95 MarijnS95 added the impact: breaking API/ABI-breaking change label Jun 16, 2023
Copy link
Contributor

@rib rib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

@MarijnS95 MarijnS95 merged commit eec7b60 into master Jun 16, 2023
@MarijnS95 MarijnS95 deleted the ndk-rework-media-error branch June 16, 2023 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: breaking API/ABI-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants