tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
836 stars 42 forks source link

Fix compilation on android #53

Open ghashy opened 11 months ago

ghashy commented 11 months ago

I have managed to launch audio with kira on ios, but on android I got compilation issue:

Screenshot 2023-07-14 at 17 44 43

I figured out that error was caused by oboe crate from cpal deps, which requires shared-stdcxx feature enabled on android build. With this changes kira works on android perfectly :)

NiklasEi commented 11 months ago

Also see #51

which requires shared-stdcxx feature enabled on android build.

Are you saying that there is no other way to use oboe than with the shared libraries? In the linked pr I quote docs that claim something else (but I have no experience there).

ghashy commented 11 months ago

Hello, I accidentally missed your pr. I have read it, and now I'm not sure if there is no other way. In Bevy the shared-stdcxx feature is required on android, but we can try to set it up in macroquad engine, for testing purposes

tesselode commented 11 months ago

I'm watching this thread to see what you all find out. I don't have an Android development environment set up right now.

NiklasEi commented 11 months ago

I guess https://github.com/rust-mobile/rust-android-examples/tree/main/agdk-oboe shows that oboe can in general be used without the shared-stdcxx feature.

ghashy commented 11 months ago

I didn't managed how to successfully compile macroquad on android, but I compiled a simple winit app on android, then I added code for playing audio with kira 0.8.4 but I got the same __cxa_pure_virtual error, not on compilation stage, but when launched app and read logcat

Screenshot 2023-07-16 at 14 41 38

Then I switched kira dependency to my local branch with shared-stdcxx fix, and there was no __cxa_pure_virtual error in logcat, but there wasn't sound either. Logcat says that AAudioStream_requestStop(s#1) was called, so I didn't found out the reason why its happening, I have tried to sleep the thread with std::time::thread::sleep(), but it didn't worked, so the reason is not because of AudioManager and StaticSoundData are out of scope.

Screenshot 2023-07-16 at 15 04 03
ghashy commented 11 months ago

I have just been reading the logcat and found this line:

Screenshot 2023-07-16 at 15 23 35

It says that the audio file wasn't located. I've packed audio file the same way I did in bevy, and it seems that this is the wrong way to pack an audio file to apk in this context. I think that if one'll do it right, it will work with shared-stdcxx enabled.

trobanga commented 6 months ago

I can confirm that it only works with shared-stdcxx enabled.