-
Notifications
You must be signed in to change notification settings - Fork 365
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
Android support via Oboe #468
Conversation
What status of Android support here? Why this PR closed? |
Still need to figure out a way to include oboe library to the .apk builds that depend on it. |
e7f2ba8
to
bd08f86
Compare
Is there any update on this? |
This comment has been minimized.
This comment has been minimized.
bd08f86
to
ac8eca5
Compare
This should in theory work and be ready for merge. I tested it in the past on Android 10 with the older version of |
@endragor I tried to add this to Bevy and I was able to build an app for Android. But when I add this system: fn audio(asset_server: Res<AssetServer>, audio_output: Res<AudioOutput>) {
let music = asset_server.load("sounds/Windless Slopes.mp3").unwrap();
audio_output.play(music);
} It breaks after rendering some Bevy graphics with the pub fn native_activity() -> &'static NativeActivity {
unsafe { NATIVE_ACTIVITY.as_ref().unwrap() }
} I'm not sure but maybe something wrong with get_activity or where it gets called. Any ideas? Some of my changes: |
Hey @endragor, thanks for such an epic PR! As I don't have an Android device available to me, it's difficult to test this out locally. It would be great to have at list once other contributor be able to confirm this is running before landing this. Also, it would be great if a CI job could be added for building and testing this backend (see |
I'm trying to run it on my Mi Mix 2 and getting pretty weird errors. First, I wasn't able to proceed without updating I don't know when exactly errors appear but I'm sure that it panics during playback!
Any ideas? |
I placed my logs in Pastebin analog here. I tried to clear them from gfx & bevy spam logs and it clearly shows what happens. But I'm not sure how to fix it. |
@enfipy I'm planning to do some testing on the weekend. At a glance the stack trace looks like |
ac8eca5
to
a63cfee
Compare
a63cfee
to
4e9d272
Compare
I've added a repo for others to quickly test Android support: https://github.com/endragor/cpal-android-test I've tested it on Honor 10i running Android 10. It'd be great to test on older Android versions. If Android emulator works for you (it does not for me), you may test it there, too. @mitchmindtree I've added CI jobs to check clippy errors and compilation of examples for Android target. We can't actually run anything on an Android device from CI, so I don't think there is much else to do there. By the way, I noticed there are clippy warnings (unrelated to this PR) and yet the clippy job finishes successfully. Is that expected? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works amazingly! Superb work!
@est31 Hey, may you consider to review this one so we can proceed with this? |
Awesome stuff @endragor, looking good to me! And thanks @enfipy for testing. Maybe it would also be useful to have a Happy to merge! |
This code compiles (assuming my PR into
oboe-rs
gets merged), but has not been tested yet, because there are problems with including multiple .so in a single .apk (katyo/oboe-rs#5). In the meantime I'd like to ask for clarifications for a couple of questions that occurred during implementation:StreamInstant
for callbacks.It's unclear whether CPAL guarantees any relations between different
StreamInstant
values. For example, shouldcallback
andcapture
fields ofInputStreamTimestamp
be comparable in any way? ShouldInputStreamTimestamp
values for different streams be comparable?Oboe provides only the number of frames read/written from/to the stream. Based on the number of frames and sample rate it's possible to compute the duration. This is how I provide values for
capture
andplayback
fields ofInputStreamTimestamp
andOutputStreamTimestamp
. Forcallback
fields I simply usestd::time::Instant
, providing the time elapsed since the stream creation. Is that OK?i32::MAX
as the maximum buffer size. Providing this value should theoretically work, but the implementation may reduce the value to something more meaningful. Again, is this fine or is there a better approach?