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

Replace ndk-glue with ndk-context #42

Merged
merged 1 commit into from
Feb 20, 2022
Merged

Replace ndk-glue with ndk-context #42

merged 1 commit into from
Feb 20, 2022

Conversation

zmerp
Copy link
Contributor

@zmerp zmerp commented Feb 16, 2022

Related issues: RustAudio/cpal#641 rust-mobile/ndk#211

Unfortunately I cannot test. I need help for this

let vm = Arc::new(unsafe { JavaVM::from_raw(activity.vm())? });
let activity = activity.activity();
let vm = Arc::new(unsafe { JavaVM::from_raw(context.vm().cast())? });
let activity = context.context() as jobject;
Copy link

@MarijnS95 MarijnS95 Feb 16, 2022

Choose a reason for hiding this comment

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

Perhaps rename activity to context everywhere for consistency? Otherwise, should AndroidContext have a method to Optionally test if - and downcast - the context back to an Activity JObject?

Copy link
Contributor Author

@zmerp zmerp Feb 16, 2022

Choose a reason for hiding this comment

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

Done. No, I believe ndk-context can keep the ambiguity in the API. It's the downstream libraries that can do checks to verify that the pointer is an activity or not.

Choose a reason for hiding this comment

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

It would of course be an additional helper function, .context() continues to exist as it is. However, without dependency on jni it wouldn't be possible to implement it.

Copy link
Contributor Author

@zmerp zmerp Feb 16, 2022

Choose a reason for hiding this comment

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

I think the virtue of ndk-context is how small in scope it is. I don't feel we need to add helper functions. ndk-context will be used by low level crates anyway.

Choose a reason for hiding this comment

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

Excactly, hence why we don't have and will probably never add the jni dependency.

@katyo katyo merged commit 8931366 into katyo:master Feb 20, 2022
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