google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.68k stars 560 forks source link

Moto G 5S+: Input is silent if stream is OpenSL with preset `Unprocessed` #1147

Open rpattabi opened 3 years ago

rpattabi commented 3 years ago

Android version: 8.1.0 Android device: Moto G 5S+ (Board: msm8953 Hardware: qcom Build: OPS28.65-36-14 Fingerprint: motorola/sanders_n/sanders_n:8.1.0/OPS28.65-36-14/63857:user/release-keys) Oboe version: ee39453cb1637460f7c4321f9d4d7c4f63d544c0 App name used for testing: Shruti Carnatic Tuner and Our internal audio tests

Short description Moto G 5S+ gives digital silence for OpenSL input stream with preset Unprocessed.

We get signal if we use AAudio with any input preset. We also get signal if we use OpenSL with other input presets such as VoiceRecognition, Generic, and Camcorder.

Steps to reproduce As this issue is based on the report by our user, we couldn't ask her to run OboeTester. We were able to run our internal audio tests and arrived at the above conclusions. We are sure similar behavior can be observed through OboeTester.

Though OpenSL with Unprocessed gives digital silence, we were able to confirm that the callbacks happen correctly and in the timely manner.

Expected behavior OpenSL input stream with Unprocessed input preset should provide signal.

Actual behavior No signal (digital silence) in case of OpenSL input stream with Unprocessed.

Device As mentioned above, the device is Moto G 5S+. It does not have MMap support. More details about the configuration we used:

DEVICE PROPERTIES
Native samplerate: 48000 Hz
Native Buffer size: 240 samples

ACTUAL VALUES
Current samplerate: 48000 Hz
Input audioApi: OpenSLES
Input bufferCapacityInFrames: 2048
Input bufferSizeInFrames: 2048
Input framesPerBurst: 1024
Input framesPerCallback: 1024
Input deviceId: 0
Input inputPreset: Unprocessed

Additional Context

Log for our internal audio test suite run is here. Please look for preset=Unprocessed api=OpenSL channels=1 to locate the problem entries.

If you look for NativeTest tag, they point to the different tests that we ran. For example, the following is where the particular test for this issue, InputStreamTest.inputShouldNotBeSilence for OpenSL_Unprocessed, starts here:

2021-01-03 10:46:11.000 2012  D/NativeTest: [ RUN      ] Input/InputStreamTe
2021-01-03 10:46:11.000 2012  D/NativeTest: st.inputShouldNotBeSilence/OpenSL_Unprocessed

log entry was broken due to the hack we had to use to log from gtest to logcat

Another test of this issue's interest, InputStreamTest.capturesPlayedFreq for OpenSL_Unprocessed, starts here:

2021-01-03 10:47:14.000 2012  D/NativeTest: [ RUN      ] Input/InputStreamTest.capturesPlayedFreq/OpenSL_Unprocessed
philburk commented 3 years ago

Thanks for reporting this. We should make the QuirksManager switch to a different InputPreset on these broken devices.

rpattabi commented 3 years ago

In QuirksManager, would it be done as board specific fix (Board: msm8953 Hardware: qcom) or only for this device model (sanders_n)? This insight will help us to come up with sensible defaults in our app.