-
Notifications
You must be signed in to change notification settings - Fork 3k
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
ao/aaudio: implement aaudio backend for android #12261
base: master
Are you sure you want to change the base?
Conversation
a6c9f63
to
74f7f0c
Compare
Are the advantages over ao_audiotrack significant enough that it warrants merging this and having yet another AO to maintain? |
well, using JNI is infamously slow and is more resource intensive. |
@sfan5 Another reason is the audiotrack doesn't support exclusive mode audio, which bypasses android's resampling improving audio quality. |
opensles does support exlusive mode audio, but only supports 2 channes, while AAudio supports multichannels. |
switching to push seems to fix the underrun issues, this is ready for review |
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! |
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 |
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. |
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 |
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.
From the aaudio point of view code looks ok. But please fix all style issues. It doesn't adhere to mpv coding style. You can read https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md and look at other files in the repository or ask questions if something is unclear. For starters we use 4 spaces, not 2 and many more tiny issues. I'm doing archeology here, but it popped out after recent bump.
I tried Building it from the mpv-android buildscripts but it had missing libraries |
mpv-android builds with API 21, AAudio was introduced with API 26. If you want to test you can edit the API level in |
So addition of this AO should be behind meson option and auto-detected. |
Consider adding an option to toggle, and this option only appears on API26+ devices |
UI isn't the main problem. mpv/video/out/hwdec/hwdec_aimagereader.c Line 108 in ab3a632
|
52cc972
to
5e6845e
Compare
implemented the requested fixes, and used the method described in https://developer.android.com/ndk/guides/using-newer-apis to load the symbols dynamically. |
d6cbe04
to
d187e66
Compare
No need to bump the API version to 26 for mpv-android, this results in all devices with API lower than 26 no longer being able to install mpv-android. Only need to add a detection mechanism. If the API does not meet the conditions, the relevant options will not be displayed or prompts unavailable. |
So the conditional thing actually seems pointless, because meson just doesn't find
Then why use the |
429fceb
to
498f9b2
Compare
@sfan5 yeah, I searched up some more. The weak symbol thing doesn't work if the library doesn't exist, so I'm changing it to just |
Now it builds fine using API level 21 |
a5d1705
to
a357fdb
Compare
Did some minor cleanups, should be ready for review |
Wearing earphones I hear some crackling/popping occasionally, is that just me? They might be subtle enough to not be audible when using speakers. |
When crackling/popping occurs, does mpv have a prompt similar to |
Without specifying a buffer capacity:
The default buffer capacity or specifically setting the one apparently reported by device in config both lead to crackling.
Acquiring exclusive device access from Android app is probably not trivial. I'm not using that mode. |
@obscenelyvague I reproduced on my own device as well. Should be fixed now. Also fixed a bug where the player would get stuck on device disconnection. |
Seems ok for the most part. What's a little strange is that I can't seem to set buffer capacity to a value lower than 9600 anymore. Higher values tend to make player startup/exit a little jankier. |
@obscenelyvague I'm tested setting |
Additionally, Android won't give you a buffer capacity that's too low, the lowest I can get is 5772 even with |
@obscenelyvague Figured out the reason for the jank with large buffer capacities, should be fixed now as well. |
Alright seems there's a bug with AAudio where it doesn't returning timing or returning garbage timing after a flush. |
No description provided.