if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { // no sonification on aux digital (e.g. HDMI) // devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL); devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HDMI_1); } //priority Wired > a2dp > hdmi > hdmi 1 > spdif > spdif 1 if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { // devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HDMI_1); devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL); } if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPDIF); } if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPDIF_1); } if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_DOCK) == AUDIO_POLICY_FORCE_ANALOG_DOCK)) { devices2 = availableOutputDevices.getDevicesFromType( AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET); } if (devices2.isEmpty()) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER); } DeviceVector devices3; if (strategy == STRATEGY_MEDIA) { // ARC and AUX_LINE can co-exist with others. devices3 = availableOutputDevices.getDevicesFromTypes({ AUDIO_DEVICE_OUT_HDMI_ARC, AUDIO_DEVICE_OUT_HDMI_EARC, AUDIO_DEVICE_OUT_AUX_LINE, }); } devices2.add(devices3); // device is DEVICE_OUT_SPEAKER if we come from case STRATEGY_SONIFICATION or // STRATEGY_ENFORCED_AUDIBLE, AUDIO_DEVICE_NONE otherwise devices.add(devices2); // If hdmi system audio mode is on, remove speaker out of output list. if ((strategy == STRATEGY_MEDIA) && (getForceUse(AUDIO_POLICY_FORCE_FOR_HDMI_SYSTEM_AUDIO) == AUDIO_POLICY_FORCE_HDMI_SYSTEM_AUDIO_ENFORCED)) { devices.remove(devices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER)); }
时间: 2024-04-25 19:26:44 浏览: 129
双栈.zip_C/C++__C/C++_
这段代码看起来像是一个 Android 系统的音频输出设备选择器,它会根据一定的优先级选择可用的音频输出设备。其中,优先级最高的是有线设备(Wired),其次是 A2DP,然后是 HDMI 和 SPDIF,最后是扬声器(Speaker)。其中,如果策略是媒体播放(STRATEGY_MEDIA),则会考虑 ARC 和 AUX_LINE 这两种设备。另外,如果开启了 HDMI 系统音频模式(HDMI_SYSTEM_AUDIO_ENFORCED),则会将扬声器设备从输出列表中移除。
阅读全文