Linux
如何創建輸出到 HDMI 和耳機插孔的 ALSA 虛擬設備?
我可以告訴我的程序輸出到 HDMI或耳機插孔就好了,但是有沒有辦法在 asound.conf 中創建一個同時輸出到兩者的虛擬設備?
這個配置非常接近工作,但它會在耳機插孔上產生一種脈衝噪音。
pcm.internal { type hw card 1 device 0 } pcm.hdmi_hw { type hw card 0 device 7 } pcm.hdmi_complete { type softvol slave.pcm hdmi_hw control.name hdmi_volume control.card 1 } pcm.sirmix { type plug slave.pcm { type multi slaves { a { channels 2 pcm "internal" } b { channels 2 pcm "hdmi_complete" } } bindings { 0 { slave a channel 0 } 1 { slave a channel 1 } 2 { slave b channel 0 } 3 { slave b channel 1 } } } ttable [ [ 1 0 1 0 ] [ 0 1 0 1 ] ] }
gst-launch-1.0 audiotestsrc !音頻轉換!alsasink device=“sirmix”
所以顯然上面的設置和管道基本上是好的,如果你去 ALSA 論壇,他們會推薦類似上面的東西,但是
rate
你的輸出匹配是必須另外考慮的。pcm.internal { type hw card 1 device 0 rate 48000 } pcm.hdmi_hw { type hw card 0 device 7 rate 48000 }
我的最終配置文件如下:
pcm.m_headphone_mixed { type dmix ipc_key 595900 ipc_perm 0666 slave { pcm "hw:1,0" rate 48000 period_time 0 period_size 1024 buffer_size 4096 format S16_LE } bindings { 0 0 1 1 } } pcm.m_headphone_rate_adjusted { type rate slave { pcm "m_headphone_mixed" rate 48000 } } pcm.m_headphone { type softvol slave.pcm m_headphone_rate_adjusted control.name m_headphone_volume control.card 1 } pcm.m_hdmi_mixed { type dmix ipc_key 595901 ipc_perm 0666 slave { pcm "hw:0,7" rate 48000 period_time 0 period_size 1024 buffer_size 4096 format S16_LE channels 2 } bindings { 0 0 # channel 0 -> channel 0 1 1 } } pcm.m_hdmi { type softvol slave.pcm "m_hdmi_mixed" control.name m_hdmi_volume control.card 1 } pcm.m_all_base { type plug slave.pcm { type multi slaves { a { channels 2 pcm "m_hdmi" } b { channels 2 pcm "m_headphone" } } bindings [ { slave a channel 0 } { slave a channel 1 } { slave b channel 0 } { slave b channel 1 } ] } } pcm.m_all_routed { type route slave.pcm "m_all_base" slave.channels 4 ttable [ [ 1 0 1 0 ] # route left to channels 0,2 [ 0 1 0 1 ] # route right to channels 1,3 ] } pcm.m_all { type softvol; control.name m_all_volume; control.card 1 slave.pcm "m_all_routed" } pcm.!default "m_all"
這樣做是為了讓標準戴爾台式 PC 同時輸出到耳機插孔和 DisplayPort。