android 声卡音频策略小记

来源:互联网 发布:围棋入门那个软件 编辑:程序博客网 时间:2024/06/07 02:50

5.1 以前应该是在 hardware/libhardware_legacy/audio/AudioPolicyManagerBase.cpp


5.1 的时候

Android5.1/frameworks/av/services/audiopolicy/


比如调节 USB 和 HEADPHONE,甚至 HDMI 的声音输出顺序。


这个要根据 stream type 来选不同的 device ..在优先级别方面调整其顺序就行了。

如 在没有强制设置成某device 的情况下,headphone 的优先级最高: headphone > usb sound card

--- a/frameworks/av/services/audiopolicy/AudioPolicyManager.cpp
+++ b/frameworks/av/services/audiopolicy/AudioPolicyManager.cpp
@@ -4725,12 +4725,13 @@ audio_devices_t AudioPolicyManager::getDeviceForStrategy(routing_strategy strate
                 device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
                 if (device) break;
             }
+            //edit Wade usb > headphone when call
+            device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_USB_DEVICE;
+            if (device) break;
             device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_WIRED_HEADPHONE;
             if (device) break;
             device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_WIRED_HEADSET;
             if (device) break;
-            device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_USB_DEVICE;
-            if (device) break;
             if (mPhoneState != AUDIO_MODE_IN_CALL) {
                 device = availableOutputDeviceTypes & AUDIO_DEVICE_OUT_USB_ACCESSORY;
                 if (device) break;


以上的调整为USB 的优先级高于耳机: usb sound card > headphone


在某些特殊的场景,可能会用到。

0 0
原创粉丝点击