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

aaudio capture noise with microphone, but it's fine when connecting a wired headphone #2160

Open
lhran99 opened this issue Feb 13, 2025 · 5 comments
Assignees

Comments

@lhran99
Copy link

lhran99 commented Feb 13, 2025

The shell script output is as follows

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
vivo
vivo
V2005A
PD2005
arm64-v8a
PD2005-user 10 QP1A.190711.020 compiler03141158 release-keys
qcom

Problem:
We find a problem that some device such as vivo V2005A capture noise by aaudio with microphone,but it's fine when connecting a wired headphone.

Test Step:

  1. Open Oboe Tester and choose RECORD AND PLAY button, then set aaudio params as follows:
Image
  1. Without the wired headphone, Click RECORD and say something, and Click STOP and Play.

  2. Then we find some noise obviously , the wav is here.
    oboe_recording_20250213-170230.wav.zip

  3. Then we connect a wired headphone to vivo V2005A and repeat RECORD again, when we find the capture is find and without any noise, the was is here
    oboe_recording_20250213-170536.wav.zip

Analysis:

  1. It seems that some parameters has changed when the vivo V2005A connect a wired headphone, But the aaudio record log has nothing different and both are as follows:
sample rate=48000, channels=2, bytes per frame=4, format=I16, sharing mode=Shared, performance mode=LowLatency, direction=Input, device id=567, audio api=AAudio, buffer capacity=1536, frames per burst=96

And both use the mmap capture.
2. I guess maybe the hardware audio dma period is different, for device V2005A, it's mmap dma period is more shorter than the scene when it connect a wired headphone, but i do not know whether the reason make sense or not.

@lhran99 lhran99 added the bug label Feb 13, 2025
@philburk
Copy link
Collaborator

@lhran99 - Thanks for the bug report and for including the WAV files.

I normalized the bad microphone file and then zoomed in to see individual samples.
The file has displaced blocks that are 48 frames long. These occur every 480 frames.
The distorted sound is consistent with this observation. See screenshot.

Image

I believe this may be caused by the CPU reads colliding with the DSP writes in the FIFO.
That can be caused by inaccuracy in the MMAP timestamps.

As an experiment, try increasing the "Input Margin" radio button form "0" to 1, 2, 3 or 4.
That will move the CPU position away from the DSP position.
Does that sound better?
If so then it is an important clue.

I will pass this information along to Qualcomm.

And both use the mmap capture.

Note that checking the MMAP checkbox does not guarantee MMAP capture.
When the stream is recording, does it show "MMAP YES" or "MMAP NO".

Can you please capture a screenshot with MIC and USB while recording, or after recording?

@philburk
Copy link
Collaborator

I believe this phone uses a Qualcomm Snapdragon 765G SM7250-AB.

@lhran99
Copy link
Author

lhran99 commented Feb 19, 2025

@lhran99 - Thanks for the bug report and for including the WAV files.

I normalized the bad microphone file and then zoomed in to see individual samples. The file has displaced blocks that are 48 frames long. These occur every 480 frames. The distorted sound is consistent with this observation. See screenshot.

Image

I believe this may be caused by the CPU reads colliding with the DSP writes in the FIFO. That can be caused by inaccuracy in the MMAP timestamps.

As an experiment, try increasing the "Input Margin" radio button form "0" to 1, 2, 3 or 4. That will move the CPU position away from the DSP position. Does that sound better? If so then it is an important clue.

I will pass this information along to Qualcomm.

And both use the mmap capture.

Note that checking the MMAP checkbox does not guarantee MMAP capture. When the stream is recording, does it show "MMAP YES" or "MMAP NO".

Can you please capture a screenshot with MIC and USB while recording, or after recording?

The mmap is both "YES" when recording with MIC and USB,the screenshots are here.

Recording with MIC:
Image

Recording with USB:
Image

And the burst and capacity both are same from the screenshots.

Image

As an experiment, try increasing the "Input Margin" radio button form "0" to 1, 2, 3 or 4. That will move the CPU position away from the DSP position. Does that sound better? If so then it is an important clue.

We have tried increasing the "Input Margin" radio button form "0" to 1, 2, 3 or 4. But it still has noise and sound the same as before.

The wav is as follows.
wav.zip

@lhran99
Copy link
Author

lhran99 commented Feb 19, 2025

I believe this phone uses a Qualcomm Snapdragon 765G SM7250-AB.

The Device information screenshot:
Image

and the /proc/cpuinfo is here:

Processor	: AArch64 Processor rev 14 (aarch64)
processor	: 0
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 1
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 2
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 3
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 4
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 5
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xd
CPU part	: 0x805
CPU revision	: 14

processor	: 6
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xf
CPU part	: 0x804
CPU revision	: 14

processor	: 7
BogoMIPS	: 38.40
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer	: 0x51
CPU architecture: 8
CPU variant	: 0xf
CPU part	: 0x804
CPU revision	: 14

Hardware	: Qualcomm Technologies, Inc SM7250

@lhran99
Copy link
Author

lhran99 commented Feb 19, 2025

It seems that there is no different aaudio paramter between mic and usb,maybe the problem is caused by some difference in kernel driver?
It is possible to let third app detect similar problem by oboe?

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

No branches or pull requests

2 participants