mpv icon indicating copy to clipboard operation
mpv copied to clipboard

ao/aaudio: implement aaudio backend for android

Open jambonmcyeah opened this issue 1 year ago • 10 comments

jambonmcyeah avatar Aug 27 '23 08:08 jambonmcyeah

Are the advantages over ao_audiotrack significant enough that it warrants merging this and having yet another AO to maintain?

sfan5 avatar Aug 27 '23 09:08 sfan5

well, using JNI is infamously slow and is more resource intensive. Also this is way cleaner compared to the JNI code and should be easier to maintain.

jambonmcyeah avatar Aug 27 '23 09:08 jambonmcyeah

@sfan5 Another reason is the audiotrack doesn't support exclusive mode audio, which bypasses android's resampling improving audio quality.

jambonmcyeah avatar Aug 28 '23 21:08 jambonmcyeah

opensles does support exlusive mode audio, but only supports 2 channes, while AAudio supports multichannels.

jambonmcyeah avatar Aug 28 '23 21:08 jambonmcyeah

switching to push seems to fix the underrun issues, this is ready for review

jambonmcyeah avatar Sep 08 '23 19:09 jambonmcyeah

Hello @jambonmcyeah, I was just wondering, is the aaudio output set on push exclusive mode by default in mpv? Or should I enable it somehow? Thanks in advance!

romain8991 avatar Dec 23 '23 00:12 romain8991

well right now this PR not merged by the MPV developers yet. So if you want to use it you have to compile it yourself

jambonmcyeah avatar Dec 23 '23 10:12 jambonmcyeah

and it's now push only, since there were a lot of underruns with pull which I don't know how to fix

jambonmcyeah avatar Dec 23 '23 10:12 jambonmcyeah

and it's now push only, since there were a lot of underruns with pull which I don't know how to fix

Thanks for the response and involvement. My bad, I thought it was already implemented, that's weird, since I don't know what audio driver output my Android device is using right now, especially since I can't get any logs. Anyway, I'll wait for it to be included then, considering my knowledge in programming is rather limited, though.

romain8991 avatar Dec 23 '23 10:12 romain8991

well right now this PR not merged by the MPV developers yet. So if you want to use it you have to compile it yourself

Hello again,

I actually ended up trying to compile it myself, using Android Studio, but I don't know where to add the ao_aaudio.c file inside the source code of the Android port of mpv. Could you please help me somehow/give some informations? Thanks in advance, that would be greatly appreciated: https://github.com/mpv-android/mpv-android/tree/master

romain8991 avatar Feb 14 '24 16:02 romain8991

I tried Building it from the mpv-android buildscripts but it had missing libraries here is my partial log https://0x0.st/H536.txt

gamernoob24 avatar Feb 24 '24 04:02 gamernoob24

mpv-android builds with API 21, AAudio was introduced with API 26. I don't have plans to raise the API currently, especially not for a new audio driver when audio already works perfectly fine.

If you want to test you can edit the API level in buildscripts/buildall.sh and app/build.gradle.

sfan5 avatar Feb 24 '24 08:02 sfan5

So addition of this AO should be behind meson option and auto-detected.

kasper93 avatar Feb 24 '24 08:02 kasper93

mpv-android builds with API 21, AAudio was introduced with API 26. I don't have plans to raise the API currently, especially not for a new audio driver when audio already works perfectly fine.

Consider adding an option to toggle, and this option only appears on API26+ devices

zhengqwe avatar Feb 24 '24 11:02 zhengqwe

Consider adding an option to toggle, and this option only appears on API26+ devices

UI isn't the main problem. If I build the native code with api level 26 it will not work on 25 and lower. A possible workaround on the mpv side is to load methods dynamically: https://github.com/mpv-player/mpv/blob/ab3a63285a44e6b41e171e737950d8d266ca79db/video/out/hwdec/hwdec_aimagereader.c#L108

sfan5 avatar Feb 25 '24 16:02 sfan5