Skip to content

Input gives silence on AAudio except for VoiceCommunication preset (OpenSL input is fine for any input preset) #1110

@rpattabi

Description

@rpattabi
Android version: 10 (API 29)
Android device : Samsung S9+ / samsung SM-G965F (samsung star2lte)
         Build : QP1A.190711.020.G965FXXSBETH2
   Fingerprint : samsung/star2ltexx/star2lte:10/QP1A.190711.020/G965FXXSBETH2:user/release-keys
Oboe version   : At commit ee39453cb1637460f7c4321f9d4d7c4f63d544c0

App name used for testing: A custom app which has foreground UI which runs automated tests which exercise different audio apis and input presets.

Short Description

On the mentioned device, we find that AAudio streams for any input preset (except VoiceCommunication) received digital silence while OpenSL streams worked fine.

Verifying Silence in the Input

We wrote a set of tests to capture input and determine if input is actually working or just received digital silence. This is checked by calculating the RMS of all the samples in callbacks. On real devices, irrespective of input preset or effects processing, there should always be some signal as indicated by RMS. If RMS of data in input callback is exactly zero, it implies digital silence. This could only be caused by the system silencing the input.

Results

We ran these tests on both AAudio and OpenSL. The following are the results for the mentioned device:

AudioApi   InputPreset               Input Behavior
----------------------------------------------------
AAudio     VoiceCommunication        Works
AAudio     Generic                   Digital Silence
AAudio     VoiceRecognition          Digital Silence
AAudio     Unprocessed               Digital Silence
AAudio     Camcorder                 Digital Silence
AAudio     VoicePerformance          Digital Silence

OpenSL     VoiceCommunication        Works
OpenSL     Generic                   Works
OpenSL     VoiceRecognition          Works
OpenSL     Unprocessed               Works
OpenSL     Camcorder                 Works

Full log of the test run is here. If you look for NativeTest tag, you'll find the failed and succeeded tests. Failed tests log the RMS for each callback. Here is an entry of a failed test. As you see, for AAudio + VoiceRecognition stream received digital silence for over 3 seconds.

2020-11-24 08:37:26.000 25785 D/NativeTest: Expected: (nonSilentBins) >= (percentage(rmses.size(), MIN_DESIRED_AUDIBLE_BIN_PERCENTAGE)), actual: 0 vs 376
2020-11-24 08:37:26.000 25785 D/NativeTest: rms = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2020-11-24 08:37:26.000 25785 D/NativeTest: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2020-11-24 08:37:26.000 25785 D/NativeTest: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2020-11-24 08:37:26.000 25785 D/NativeTest: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2020-11-24 08:37:26.000 25785 D/NativeTest: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
2020-11-24 08:37:26.000 25785 D/NativeTest: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest:  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020-11-24 08:37:26.000 25785 D/NativeTest: [  FAILED  ] AudioApis_InputPresets/InputStreamTest.inputShouldNotBeSilence/AAudio_VoiceRecognition, where GetParam() = (4-byte
2020-11-24 08:37:26.000 25785 D/NativeTest:  object <02-00 00-00>, 6) (3618 ms)

We also log audio stream lifecycle and parameters using OboeStream tag. In this tag, you'll find the average RMS for each second of input audio. The following shows OpenSL stream with VoiceRecognition preset. Notice averageRMSes are non-zero.

2020-11-24 08:37:05.000 25785 D/OboeStream: INPUT state=Started preset=VoiceRecognition api=OpenSL channels=1 format=Float samplerate=48000 convQlty=Medium perfMode=LowLatency xrunsSupport=false deviceId=8 addr=0x73246926e0
2020-11-24 08:37:05.000 25785 D/OboeStream: buffer=2048 capacity=2048 burst=1024 callback=1024 frames
2020-11-24 08:37:05.000 25785 W/OboeStream: InputStream: initial callback latency (#0): 67 ms
2020-11-24 08:37:06.000 25785 D/OboeStream: InputStream: addr=0x73246926e0 callbacks=#0..47 (47) averageRMS=0.00962057
2020-11-24 08:37:07.000 25785 D/OboeStream: InputStream: addr=0x73246926e0 callbacks=#47..94 (47) averageRMS=0.01382109

Additional Context

This device is from one of our users. Google Assistant is off (we verified it).

As per Sharing Input, an app may receive based on various conditions. But our test app has activity visible during the test run and we expect it to receive audio input for any audio api and input preset. We don't find any reason why the app should receive silence as per any of the clauses mentioned in this document.

VoiceCommunication is privacy sensitive and it received signal through AAudio. If other presets receive silence due to any restriction, it is not clear why we get signal through OpenSL for any preset.

Questions

  • Is this a bug with AAudio that provides silence even if app's UI is on top? or
  • Is it bug in device's implementation that messed up the guidelines in sharing input?

We are wondering what can be done from our end to address this issue in our production app. One obvious workaround is to switch to OpenSL. As we can't know which devices may have this problem, we would be forced to switch to OpenSL for all devices (we suspect that this would bring in other problems).

Metadata

Metadata

Assignees

Labels

P1high prioritybuginput_presetBugs related to input presetsquirkDevice specific behaviour which requires a quirk/workaround in Oboe

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions