-
Notifications
You must be signed in to change notification settings - Fork 616
Description
Android version(s): Android Canary 202512
Android device(s): Pixel 7a
Oboe version:
App name used for testing: OboeTester at latest commit (650dfef) with small patch:
diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java
index 83abd871..2799faa5 100644
--- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java
+++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java
@@ -35,6 +35,7 @@ import android.media.AudioAttributes;
import android.media.AudioDeviceInfo;
import android.media.AudioFocusRequest;
import android.media.AudioManager;
+import android.media.AudioMixerAttributes;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -59,6 +60,8 @@ import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.Locale;
/**
@@ -744,6 +747,39 @@ abstract class TestAudioActivity extends AppCompatActivity implements AudioManag
// Always close existing streams before opening new ones.
closeAudioLocked();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ List<AudioDeviceInfo> info = Arrays.asList(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS));
+ for (AudioDeviceInfo device : info) {
+ List<AudioMixerAttributes> attr = audioManager.getSupportedMixerAttributes(device);
+ if (attr.isEmpty()) continue;
+ attr.sort((a, b) -> {
+ if (a.getMixerBehavior() != b.getMixerBehavior()) {
+ return a.getMixerBehavior() == AudioMixerAttributes.MIXER_BEHAVIOR_BIT_PERFECT ? 1 : -1;
+ }
+ if (a.getFormat().getSampleRate() != b.getFormat().getSampleRate()) {
+ return Math.abs(a.getFormat().getSampleRate()-88200) > Math.abs(b.getFormat().getSampleRate()-88200) ? 1 : -1;
+ }
+ if (a.getFormat().getChannelCount() != b.getFormat().getChannelCount()) {
+ return a.getFormat().getChannelCount() > b.getFormat().getChannelCount() ? 1 : -1;
+ }
+ if (a.getFormat().getEncoding() != b.getFormat().getEncoding()) { // :)
+ return a.getFormat().getEncoding() > b.getFormat().getEncoding() ? 1 : -1;
+ }
+ return 0;
+ });
+ audioManager.setPreferredMixerAttributes(new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_MEDIA)
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
+ .build(), device, attr.get(0));
+ }
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
updateNativeAudioParameters();
if (!isTestConfiguredUsingBundle()) {
@@ -1061,6 +1097,19 @@ abstract class TestAudioActivity extends AppCompatActivity implements AudioManag
onStopAllContexts();
}
}
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
+ AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+ List<AudioDeviceInfo> info = Arrays.asList(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS));
+ for (AudioDeviceInfo device : info) {
+ List<AudioMixerAttributes> attr = audioManager.getSupportedMixerAttributes(device);
+ if (attr.isEmpty()) continue;
+ audioManager.clearPreferredMixerAttributes(new AudioAttributes.Builder()
+ .setUsage(AudioAttributes.USAGE_MEDIA)
+ .setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
+ .build(), device);
+ }
+ }
}
public void runTest() {Short description
When using the setPreferredMixerAttributes API, playback does not work. Either OboeTester says the stream was closed or OboeTester thinks the stream is playing but aocd log-spams with invalid state error:
Steps to reproduce
1.Plug in USB dac that supports 88.2k and 192k sample rate among others (did not test with others)
2.install & open patched OboeTester
3.Test Output
4.Open, Start
Expected behavior
Normal OboeTester tone
Actual behavior
No sound and error spam in logcat:
2026-01-31 20:53:13.181 916-14410 audio_hw_waves android.hardware.audio.service D waves_usecase_event: hifi-playback stop
2026-01-31 20:53:13.181 1168-1168 AOC aocd D F1:MSG: controller.cc, 275: AudioOutCtrl: cmd ID: 0x010f, tag: 0xb9 [cntr = 14922]
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:Unregistered Source 13 [USBHiFi] from Sink 3 [USB]
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:AT Map:0 (LL:0), 0 EPs active, Power: Yes, Config: No
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:Mixer 3 configuration changed: (0)
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:Sink 3 Configuration changed: ULL (disabled)
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:MSG: usb.cc, 567: Stop playback, TX enabled = 0, RX enabled = 0
2026-01-31 20:53:13.182 1168-1168 AOC aocd D F1:MSG: controller.cc, 910: AudioOutCtrl: ipc: audio_output_co, cmd ID: 0x010f, tag: 0xb9, rc: 0
2026-01-31 20:53:13.183 1168-1168 AOC aocd D H0:Mixer AMixUSB: 480 samples (0000/0000) (OFF)
2026-01-31 20:53:13.199 916-916 writer android.hardware.audio.service W type=1400 audit(0.0:3872): avc: denied { read } for name="u:object_r:default_prop:s0" dev="tmpfs" ino=182 scontext=u:r:hal_audio_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=0
2026-01-31 20:53:13.202 916-14410 audio_hw android.hardware.audio.service D prepare hifi-playback
2026-01-31 20:53:13.203 916-14410 audio_hw android.hardware.audio.service D hifi-playback:
2026-01-31 20:53:13.203 916-14410 audio_hw android.hardware.audio.service D rx:
2026-01-31 20:53:13.203 916-14410 audio_hw android.hardware.audio.service D #0: OUT_USB_HEADPHONE_BE_CFG 2
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service E select_capability: fail to convert to index for fmt 0x0 endian 0
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D refine_setting: card 1 dev 0x4000000
2026-01-31 20:53:13.203 916-14410 audio_hw android.hardware.audio.service D select bit 32 rate 88200 ch 2 for intf USB_RX
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D update_device_active_state: active_device_mask 0x1
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D apply_setting: card 1 dev 0x4000000
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D apply_setting: ep: 1 bit 32 ch 2 rate 88200
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D usb_device_config: rx proxy open (is_active 0)
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service D usb_device_config: bit 32, format 0x3, rate 88200 chan 2
2026-01-31 20:53:13.203 916-14410 audio_hw_usb android.hardware.audio.service W Invalid sample rate 88200 - using default 48000.
2026-01-31 20:53:13.204 1168-1168 AOC aocd D F1:MSG: controller.cc, 275: AudioOutCtrl: cmd ID: 0x0112, tag: 0xba [cntr = 14923]
2026-01-31 20:53:13.204 916-14410 libc android.hardware.audio.service W Access denied finding property "ro.audio.usb.period_us"
2026-01-31 20:53:13.204 1168-1168 AOC aocd E F1:ERR: audio_hardware_sink_usb.cc, 453: USB TX: Unsupported sample rate requested (88200)!
2026-01-31 20:53:13.204 1168-1168 AOC aocd E F1:ERR: controller.cc, 906: AudioOutCtrl: ipc: audio_output_co, cmd ID: 0x0112, tag: 0xba, rc: -1
2026-01-31 20:53:13.205 916-14410 audio_hw_usb android.hardware.audio.service W usb_device_config: usb_alsa_repare failed ret -22
2026-01-31 20:53:13.205 916-14410 audio_hw_usb android.hardware.audio.service E apply_setting: usb_device_config failed -22
2026-01-31 20:53:13.205 916-14410 audio_hw_soundtrigger android.hardware.audio.service D st_comm_aud_event_monitor:codec dev:17 active
2026-01-31 20:53:13.205 916-14410 audio_hw_aoc android.hardware.audio.service I Mode Ambient is already selected
2026-01-31 20:53:13.205 916-14410 audio_route android.hardware.audio.service D Apply path: hifi-playbackP usb-headphone
2026-01-31 20:53:13.206 1168-1168 AOC aocd D F1:MSG: controller.cc, 275: AudioOutCtrl: cmd ID: 0x010f, tag: 0xbb [cntr = 14924]
2026-01-31 20:53:13.206 916-14410 audio_hw_aoc_route android.hardware.audio.service D hifi-playbackP usb-headphone 1
2026-01-31 20:53:13.206 1168-1168 AOC aocd D F1:Source 13 [USBHiFi] mastered by sink 3 [USB]
2026-01-31 20:53:13.206 1168-1168 AOC aocd D F1:AT Map:2000 (LL:0), 1 EPs active, Power: Yes, Config: No
2026-01-31 20:53:13.207 1168-1168 AOC aocd D F1:Mixer 3 configuration changed: (2000)
2026-01-31 20:53:13.207 1168-1168 AOC aocd D F1:Sink 3 Configuration changed: ULL (enabled)
2026-01-31 20:53:13.207 1168-1168 AOC aocd D F1:AHWSinkUSB started: 48 samples (32-bit,2 ch,48 kHz) block 384 ts_en 0
2026-01-31 20:53:13.207 916-14410 audio_hw_waves android.hardware.audio.service D waves_usecase_event: hifi-playback start
2026-01-31 20:53:13.207 916-14410 audio_hw_waves android.hardware.audio.service D waves_usecase_event: trigger to update tuning when first track is running.
2026-01-31 20:53:13.208 1168-1168 AOC aocd E F1:ERR: audio_hardware_sink_usb.cc, 2116: Attempt to start playback without configuration
Notably: USB TX: Unsupported sample rate requested (88200)! - then 1. why is it exposed in API that lists supported sample rates? 2. Why not just support it, it's just software limitation anyway..
Device
Pixel 7a
Any additional context
This is a regression from Android 14 QPR3 where playback was working but using wrong sample rate (which was what I was trying to find out if it's fixed now). Well that's to say it never worked properly on this device as far as I know.
Also, if you replace 88200 with 192000 in the patch above, then playback will work but it sounds like its constantly underrunning and the tone also seems too high. So I assume nobody had validated this API on Pixel 7a.