crdroidandroid / issue_tracker

all crDroid related issues should go here
13 stars 1 forks source link

USB-C Audiorouting doesn't work #367

Closed Detlev1 closed 4 months ago

Detlev1 commented 6 months ago

Issue type

User interface

Device

begonia

crDroid version

crDroid 8

Exact version / Build date

10.4 / 2024.04.12

Bug description

The phone doesn't detect USB-C headphones as speakers and instead chooses to charge them. The phone acts as if there are no headphones are connected at all.

Steps to reproduce

  1. Connect USB-C headphones
  2. Try to use them

Relevant log (logcat/build log)

I´ll attach a log file in the screenshots section

Screenshots or videos

2024-04-13-22-20-39.txt

Solution

No response

Additional context

No response

Acknowledgements

recallmenot commented 5 months ago

Hello, I can confirm the issue. Trying to use an USB Audio DAC, Questyle M12i (ES9281AC-based) it does not want to connect. I was able to use it on other devices just fine.

OnePlus 7Pro guacamole GM1911 crDroid 10.4 build AP1A.240405.002.A1

The DAC's gain led lights up but the data leds stay dark. I can hear periodic faint clicking on the connected earphones for 5 seconds, then silence. Android does not recognize a new audio device. If audio was played back prior to this it keeps being played back on the speaker of the phone.

I think it might have something to do with:

apm::HwModule: createDevice: could not find HW module for device type AUDIO_DEVICE_OUT_USB_HEADSET

I tried editing 'usbv2_audio_policy_configuration.xml', somehow the module is named usbv2 which I've seen nowhere else.

As a last ditch effort I copied the lineage config files to '/vendor/etc'.

After the reboot, the DAC was detected immediately.

First, I copied the files to Documents/Lineage, then:

adb shell
su
mount -o rw,remount /vendor
cp /storage/emulated/0/Documents/Lineage/* /vendor/etc/ 
mount -o ro,remount /vendor

I've noticed the lineage files do not move all the USB audio stuff into a separate file (and module). Maybe that is it?

Why the crDroid files worked in testing previously might be due to differences between how UAC1.0 and UAC2.0 audio devices are handled, afaik M12i is a UAC2.0 device without backward compatibility.

I've used logfox to create two logs: DAC_rejected.log DAC_connected.log

7d107aec26840c9c11f1deb80fd2c2c4344d3e2d may be the culprit. As for why, it might be that putting the USB stuff into its own module isolates it from the "routes" in the main audio policy config module. The apps use these to play back audio, thus the device is never addressed.

Reverting the commit may be the easiest fix, tough I'd also add/enable higher sample rates and 24-bit audio for the USB devices since HiRes music is a thing and we might as well if we're here.

recallmenot commented 5 months ago

@ShevT what do you think? Does USB-C audio work for you on sm8150 based devices?

ShevT commented 5 months ago

@ShevT what do you think? Does USB-C audio work for you on sm8150 based devices?

Yes, it works well

recallmenot commented 4 months ago

@gwolf2u would it be possible to re-open this issue? I've ordered two other USB-C dongles to test with, the second should be arriving soon. I've also found a related issue where the new AOSP audio policy change of putting the USB audio config into a different module had to be reverted. Apparently it does not affect all USB-C audio dongles but some. My theory right now is that it's UAC 2.0 audio devices that won't work.

recallmenot commented 4 months ago

maybe @yzyhk904 might have an idea why the "new" AOSP-style separate usb audio config module might not work on some USB-C dacs but on others, while the "old" style of having the usb config inside the audio_policy_config.xml like lineage does works fine.

@ShevT which USB audio DACs are you using that work, specifically?

yzyhk904 commented 4 months ago

I don't know the reason, but "usbv2" module is nothing to do with UAC 2.0. Google introduced this for their spatial audio or AOC.

I think the same issue might already happen on Alioth v9.17 (see XDA post405 and XDA post426).

Detlev1 commented 4 months ago

Maybe look at the Pixel Experience trees. I was previously using it and opened an issue there as well. The maintainer originally closed it as not fixable, but it was fixed eventually when moving from android 12 to 13

recallmenot commented 4 months ago

@Detlev1 do you mean this issue? If I know what device you were using I could locate the corresponding files and look through the commits. Maybe whoever fixed it left a hint.

Detlev1 commented 4 months ago

Yes, that's the issue. I was using begonia (Redmi Note 8 pro).

Detlev1 commented 4 months ago

But the PE maintainer also has commits to the device trees on the begonia-dev repo. So there is a good chance he was using the same device trees as the official crdroid builds for begonia.

chrisrnj commented 2 months ago

I have the same issue on crdroid 10.6, also using a Redmi Note 8 Pro (begonia).