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

Huawei P30: AAudio a sound is corrupted and OpenSL has a high latency #952

Closed
banburubi opened this issue Jul 21, 2020 · 6 comments
Closed
Assignees
Labels
bug Huawei specific to Huawei devices

Comments

@banburubi
Copy link

Android version(s): 10 (10.1.0.123 (C431E22R2P5))
Android device(s): Huawei P30 (ELE-L29)
Oboe version: 1.4.2
App name used for testing: Similar to LiveEffect

Short description
Steps to reproduce
In voice related application, I'm working on, I'm having some issues on Huawei P30 related to how AAudio and OpenSL behave. On other tested phones of different vendors it works without any issues.

The application has almost the same setup as LiveEffect. There are 2 streams: one for input and another for output, both a requested in Exclusive, Low-latency, I16 mode. Input stream has 1 channel, Output stream has 2 channels. Callback is attached to the output stream. Sample rate and frames per callback are set using this method: https://github.com/google/oboe/blob/master/docs/GettingStarted.md#obtaining-optimal-latency

After requesting streams I'm getting such parameters:

========
AAudio:

Output:

  • Frames per burst: 240
  • Buffer size in frames: 480
  • Channels: 2
  • Sample rate: 48000
  • Sharing mode: Shared
  • Performance mode: Low-latency

Input:

  • Frames per burst: 240
  • Buffer size in frames: 3840
  • Channels: 1
  • Sample rate: 48000
  • Sharing mode: Shared
  • Performance mode: Low-latency

========
OpenSL:

Output:

  • Frames per burst: 960
  • Buffer size in frames: 1920
  • Channels: 2
  • Sample rate: 48000
  • Sharing mode: Shared
  • Performance mode: None

Input:

  • Frames per burst: 960
  • Buffer size in frames: 15360
  • Channels: 1
  • Sample rate: 48000
  • Sharing mode: Shared
  • Performance mode: None

========

Expected behavior
On Huawei P30: With AAudio the sound is not corrupted. With OpenSL the latency is low.

Actual behavior
On Huawei P30: With AAudio the sound is corrupted. With OpenSL the latency is high.

Looking forward to your feedback.

Thank you very much.

P.S. Probably these issues are related:
#525
#386

Best,
Vladymyr.

@banburubi banburubi added the bug label Jul 21, 2020
@philburk
Copy link
Collaborator

Some Huawei devices do not support mono recording properly. Try recording in stereo and then just use the first channel.

Some Huawei devices disable the FAST mixer so they will have higher than expected latency for OpenSL ES.

We can try to workaround the mono input issue. Can you please tell me what you get for these properties?

adb shell getprop ro.product.manufacturer
adb shell getprop ro.hardware.chipname
adb shell getprop ro.arch

@banburubi
Copy link
Author

Thank you very much for the reply.

I will try to use stereo mic. - will tell you tomorrow.

Regarding the properties:

  • Huawei
  • [it was empty] but it is: kirin980_cs
  • [it was empty] but from abi property: arm64-v8a

@banburubi
Copy link
Author

I have tried to use 2 channels for the input stream as you suggested before. For Huawei P30 it still does not work, on other phones it works fine. Is there anything else I can do?
Thank you very much.

@philburk
Copy link
Collaborator

The mono recording problem was fixed in Q for Mate 20 and possibly for P30 as well. They both use the Kirin 980.
This is tracked internally at b/119549057

I have tried to use 2 channels for the input stream as you suggested before. For Huawei P30 it still does not work,

So this may be a different issue. It may be related to the CPU performance.

@banburubi - Is there any improvement if you tap on the screen while running? That can boost the CPU frequencies on some devices.

Does LiveEffect have the same problem on the P30?

Have you tried the "ECHO INPUT to OUTPUT" test in OboeTester?

To find more information about the device you can run this ADB script on Linux or Mac.

for p in \
    ro.product.brand ro.product.manufacturer ro.product.model \
    ro.product.device ro.product.cpu.abi ro.build.description \
    ro.hardware ro.hardware.chipname ro.arch "| grep aaudio";
    do echo "$p = $(adb shell getprop $p)"; done

@banburubi
Copy link
Author

banburubi commented Sep 7, 2020

Hey, update from my side. I've tested it on also on Huawei P Smart 2019, with default Android 9.0. It has the same issue with the sound corruption.
Looking through the code on my side and after several tries the issues was fixed:

  1. First way (not low latency):
  • Disable MMAP
  • Use 2 channels for microphone
  1. Second way (low latency):
  • Use 2 channels for microphone
  • Do not set samples per callback value from device defaults.

Thank you very much.

@philburk philburk added the Huawei specific to Huawei devices label Feb 2, 2021
philburk added a commit that referenced this issue Aug 6, 2022
The OpenSL ES buffer queue length controls the allocated size of
the internal buffer. So we can use that to make sure there is enough
capacity to protect against glitches when setting a callback size
or a high capacity.

Fixes #744
It might help with #952
philburk added a commit that referenced this issue Aug 30, 2022
The OpenSL ES buffer queue length controls the allocated size of
the internal buffer. So we can use that to make sure there is enough
capacity to protect against glitches when setting a callback size
or a high capacity.

Fixes #744
Fixes #1599

It might help with #952

Bump Oboe to version 1.6.4
@philburk
Copy link
Collaborator

User has solved their problem.
OpenSL ES buffering improving.
Closing as Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Huawei specific to Huawei devices
Projects
None yet
Development

No branches or pull requests

2 participants