Android11 如何配置耳机和HDMI音频同时输出?

请先 登录 后评论

1 个回答

Luffy

修改hardware/rockchip/audio/tinyalsa_hal/audio_hw.c 文件,audio_hw.c

--- a/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c
+++ b/hardware/rockchip/audio/tinyalsa_hal/audio_hw.c
@@ -873,6 +873,7 @@ static int start_output_stream(struct stream_out *out)
     // set defualt value to true for compatible with mid project


+    out->device |= AUDIO_DEVICE_OUT_AUX_DIGITAL;
     ALOGD("%s:%d out = %p,device = 0x%x,outputs[OUTPUT_HDMI_MULTI] = %p",__FUNCTION__,__LINE__,out,out->device,adev->outputs[OUTPUT_HDMI_MULTI]);
     if (out == adev->outputs[OUTPUT_HDMI_MULTI]) {
         force_non_hdmi_out_standby(adev);
@@ -890,9 +891,11 @@ static int start_output_stream(struct stream_out *out)
 #endif

     out_dump(out, 0);
-    route_pcm_card_open(adev->dev_out[SND_OUT_SOUND_CARD_SPEAKER].card, getRouteFromDevice(out->device));

     if (out->device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
+        audio_devices_t route_device = out->device & AUDIO_DEVICE_OUT_AUX_DIGITAL;
+        route_pcm_card_open(adev->dev_out[SND_OUT_SOUND_CARD_HDMI].card, getRouteFromDevice(route_device));
+
         if (adev->owner[SOUND_CARD_HDMI] == NULL) {
             card = adev->dev_out[SND_OUT_SOUND_CARD_HDMI].card;
             device =adev->dev_out[SND_OUT_SOUND_CARD_HDMI].device;
@@ -923,10 +926,13 @@ static int start_output_stream(struct stream_out *out)
             out->device |= AUDIO_DEVICE_OUT_SPEAKER;
         }
     }
-
     if (out->device & (AUDIO_DEVICE_OUT_SPEAKER |
                        AUDIO_DEVICE_OUT_WIRED_HEADSET |
                        AUDIO_DEVICE_OUT_WIRED_HEADPHONE)) {
+        audio_devices_t route_device = out->device & (AUDIO_DEVICE_OUT_SPEAKER |
+                                                      AUDIO_DEVICE_OUT_WIRED_HEADSET |
+                                                      AUDIO_DEVICE_OUT_WIRED_HEADPHONE);
+        route_pcm_card_open(adev->dev_out[SND_OUT_SOUND_CARD_SPEAKER].card, getRouteFromDevice(route_device));
         card = adev->dev_out[SND_OUT_SOUND_CARD_SPEAKER].card;
         device = adev->dev_out[SND_OUT_SOUND_CARD_SPEAKER].device;
         if(card != (int)SND_OUT_SOUND_CARD_UNKNOWN) {
请先 登录 后评论
  • 1 关注
  • 0 收藏,230 浏览
  • Luffy 提出于 2023-08-17 18:59

相似问题