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

(1/2) Fix camera video A/V desync #3

Merged
merged 3 commits into from Jun 28, 2019

Conversation

@peat-psuwit
Copy link
Contributor

commented Jun 27, 2019

Prevent AudioCapture from sending late samples into /dev/socket/micshm, which will cause A/V desync because micshm doesn't accept timing. This is done by limiting maximum PA buffer size & flush buffer before first read.

This fixes ubports/ubuntu-touch#1116 to the point usable to most of the users (the audio is still around 300ms behind video on my FP2). With ubports/android_frameworks_av#4, the issue is completely fixed.

peat-psuwit added some commits Jun 26, 2019

AudioCapture: set PA stream's buffer attributes
On some device, it can take some time between pa_simple_new() below and
first pa_simple_read(). By setting these buffer attributes, we try to
make PulseAudio drop (initially) unread samples. Otherwise, we'll get
those samples and write them into /dev/socket/micshm, which expects
(roughly) realtime audio. This causes A/V desync as those extra samples
will advance /dev/socket/micshm's internal timestamp ahead.

I actually want to set PA_STREAM_ADJUST_LATENCY to the stream, but it
seems to be impossible with PA's simple API.
AudioCapture: flush PA buffer before first read
To reduce latency, try to flush samples not read before run() is called.

@Flohack74 Flohack74 self-requested a review Jun 28, 2019

@Flohack74 Flohack74 merged commit 17e228e into ubports:xenial Jun 28, 2019

2 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/jenkins/pr-merge This commit looks good
Details

@peat-psuwit peat-psuwit deleted the peat-psuwit:xenial_-_fix-av-desync branch Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.