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

AESinkAudioTrack: Try to aim 200 ms buffer and 50 ms periods #16870

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

fritsch
Copy link
Member

@fritsch fritsch commented Nov 5, 2019

Adjust Audio-Buffers to match other platforms.

A sink works as follows:
It has a buffer, which consists of certain amount of periods of audio.
If period size is too large, e.g. only 2 fit into a buffer, we might underrun if just 1 period comes too late.
If period size is far too small, you get a cpu problem, with e.g. 10 ms period you have to come back 100 times per second.

On pulse and on Alsa we aim at 200 to 400 ms buffer and have periods of around 50 ms. This has proven as a good ratio among cpu load, underruns, etc.

For Android, we used two times the minimum buffer allowed and half of it as period. The PR at hand increases the buffer size and tries to keep the period size as it was before to not create more load but to be more failsafe, when e.g. listening to high quality audio and switching towards the menu where a thread could get stuck for too long.

Old Audiotrack: 64 ms buffer and 32 ms period
New Audiotrack (on same hardware): 250 ms buffer and therefore 60 ms periods.

This solves issues for @HitcherUK when listening to music and going into the menus.

@fritsch
Copy link
Member Author

fritsch commented Nov 5, 2019

In an ideal world, it would be good if the periods / buffers actually reflect the hw settings, but those are - in opposite to ALSA - not exposed for audio track.

@Hitcher
Copy link
Contributor

Hitcher commented Nov 5, 2019

Backport for 18.5 as this is a fix please.

@fritsch
Copy link
Member Author

fritsch commented Nov 5, 2019

Needs a lot regression testing on several devices.

For example: AMLogic devices feedback (the old ones), FireTV 4K, etc.

Also: TrueHD, DTS-HD, etc. needs testing. Those are quite sensitiv when it comes to buffer / periods ratio.

@Hitcher
Copy link
Contributor

Hitcher commented Nov 5, 2019

@fritsch DTS-MA and Dolby-HD both working correctly.

@CiNcH83
Copy link

CiNcH83 commented Nov 5, 2019

Might this also have an impact on the audio resample behavior for live sources? Frequency/rr fluctuations are still high on BRAVIA, causing audible distortion.

@fritsch
Copy link
Member Author

fritsch commented Nov 5, 2019

@CiNcH83 Don't think so - rather sounds like a shitty mediacodec implementation which fluctuates all over the place.

Copy link
Contributor

@peak3d peak3d left a comment

Choose a reason for hiding this comment

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

Tested on wetek HUB with no issues.

@fritsch fritsch added this to the Matrix 19.0-alpha 1 milestone Nov 8, 2019
@fritsch fritsch added the Type: Fix non-breaking change which fixes an issue label Nov 8, 2019
@fritsch fritsch merged commit 5d715ea into xbmc:master Nov 13, 2019
Maven85 pushed a commit to Maven85/kodi that referenced this pull request Jan 21, 2020
AESinkAudioTrack: Try to aim 200 ms buffer and 50 ms periods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants