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 浏览: 128
这段代码看起来像是一个 Android 系统的音频输出设备选择器,它会根据一定的优先级选择可用的音频输出设备。其中,优先级最高的是有线设备(Wired),其次是 A2DP,然后是 HDMI 和 SPDIF,最后是扬声器(Speaker)。其中,如果策略是媒体播放(STRATEGY_MEDIA),则会考虑 ARC 和 AUX_LINE 这两种设备。另外,如果开启了 HDMI 系统音频模式(HDMI_SYSTEM_AUDIO_ENFORCED),则会将扬声器设备从输出列表中移除。
相关问题
if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { // no sonification on aux digital (e.g. HDMI) devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL); } //priority Wired > a2dp > hdmi > hdmi 1 > spdif > spdif 1 if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HDMI_1); } 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); }
这段代码是关于Android平台上的音频输出设备选择的代码。首先判断是否有可用的输出设备,并且当前的策略不是声音提示(sonification)。如果没有可用设备,则按照优先级选择不同类型的设备,包括有线耳机、蓝牙A2DP、HDMI、SPDIF、模拟音频接口等。如果强制使用音频扬声器的话,则使用音频扬声器作为输出设备。
阅读全文