Search code examples
androidaudioandroid-ndkoboe

What could possibly change sound output


I'm working on an Android app dealing with a device to which I need to send some signal (like a specific square wave, hardcoded in the device's firmware).

Everything worked fine with Superpowered Audio, but now that I'm migrating to Oboe, these signals don't work anymore. My code for the signal generation hasn't change, so I wonder where could the output be changed.

In my broadcast receiver, I have this piece of code to set the output volume to the max:

audioManager.setStreamVolume(
          AudioManager.STREAM_MUSIC,
          audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
          0);

The manifest contains these:

  <uses-feature android:name="android.hardware.usb.host" android:required="true"/>
  <uses-feature android:name="android.hardware.microphone" android:required="true" />
  <uses-feature android:name="android.hardware.audio.output" android:required="true" />

  <uses-permission android:name="android.permission.RECORD_AUDIO" />
  <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

The playback stream is configured like that:

builder->setCallback(this)
      ->setDeviceId(outputDeviceId)
      ->setDirection(oboe::Direction::Output)
      ->setChannelCount(oboe::ChannelCount::Stereo)
      ->setFormat(oboe::AudioFormat::I16)
      ->setSampleRate(samplerate)
      ->setSharingMode(oboe::SharingMode::Exclusive)
      ->setPerformanceMode(oboe::PerformanceMode::LowLatency)
      ->setInputPreset(oboe::InputPreset::Unprocessed);

Some sound is played, I can hear it when I listen to it so my callback works correctly, but the device cannot parse the signal. The phone is not in "Do Not Disturb" mode, and I disabled the equalizer.

I'm testing all of this on a OnePlus 5t running OxygenOS 9.0.6 (Android 9), and I'm out of ideas.


Solution

  • It seems that the issue is not with Oboe. I tried my app on a Nexus 5 and it works correctly. I suspect some OxygenOS settings, but I can't find what it is, and I'm slowly starting to give up...