我正在尝试编写一个 bash 命令来在音频设备(不是不同的卡)之间切换。我找到了有关该主题的AskUbuntu 帖子,然后我开始在下面的列表中尝试每个输出设备,以确定哪个是我的扬声器,哪个是我的耳机。有没有更好的方法?
我尝试了什么:
pactl set-card-profile 0 output:hdmi-surround71
对于每个音频设备,从扬声器到耳机输出没有变化。
$ pacmd list-cards | grep output\:
output:hdmi-stereo: Digital Stereo (HDMI) Output (priority 5400, available: unknown)
output:hdmi-surround: Digital Surround 5.1 (HDMI) Output (priority 300, available: unknown)
output:hdmi-surround71: Digital Surround 7.1 (HDMI) Output (priority 300, available: unknown)
output:hdmi-stereo-extra1: Digital Stereo (HDMI 2) Output (priority 5200, available: unknown)
output:hdmi-surround71-extra1: Digital Surround 7.1 (HDMI 2) Output (priority 100, available: unknown)
output:hdmi-stereo-extra2: Digital Stereo (HDMI 3) Output (priority 5200, available: unknown)
output:hdmi-surround-extra2: Digital Surround 5.1 (HDMI 3) Output (priority 100, available: unknown)
output:hdmi-surround71-extra2: Digital Surround 7.1 (HDMI 3) Output (priority 100, available: unknown)
output:hdmi-stereo-extra3: Digital Stereo (HDMI 4) Output (priority 5200, available: unknown)
output:hdmi-surround-extra3: Digital Surround 5.1 (HDMI 4) Output (priority 100, available: unknown)
output:hdmi-surround71-extra3: Digital Surround 7.1 (HDMI 4) Output (priority 100, available: unknown)
active profile: <output:hdmi-surround71>
output:analog-stereo: Analog Stereo Output (priority 6000, available: unknown)
output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (priority 6060, available: unknown)
output:analog-surround-21: Analog Surround 2.1 Output (priority 800, available: unknown)
output:analog-surround-21+input:analog-stereo: Analog Surround 2.1 Output + Analog Stereo Input (priority 860, available: unknown)
output:analog-surround-40: Analog Surround 4.0 Output (priority 700, available: unknown)
output:analog-surround-40+input:analog-stereo: Analog Surround 4.0 Output + Analog Stereo Input (priority 760, available: unknown)
output:analog-surround-41: Analog Surround 4.1 Output (priority 800, available: unknown)
output:analog-surround-41+input:analog-stereo: Analog Surround 4.1 Output + Analog Stereo Input (priority 860, available: unknown)
output:analog-surround-50: Analog Surround 5.0 Output (priority 700, available: unknown)
output:analog-surround-50+input:analog-stereo: Analog Surround 5.0 Output + Analog Stereo Input (priority 760, available: unknown)
output:analog-surround-51: Analog Surround 5.1 Output (priority 800, available: unknown)
output:analog-surround-51+input:analog-stereo: Analog Surround 5.1 Output + Analog Stereo Input (priority 860, available: unknown)
output:analog-surround-71: Analog Surround 7.1 Output (priority 700, available: unknown)
output:analog-surround-71+input:analog-stereo: Analog Surround 7.1 Output + Analog Stereo Input (priority 760, available: unknown)
output:iec958-stereo: Digital Stereo (IEC958) Output (priority 5500, available: unknown)
output:iec958-stereo+input:analog-stereo: Digital Stereo (IEC958) Output + Analog Stereo Input (priority 5560, available: unknown)
active profile: <output:analog-stereo+input:analog-stereo>
iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
$ pactl set-card-profile 0 output:hdmi-surround71
我的水槽:
$ pacmd list-sinks
2 sink(s) available.
* index: 10
name: <alsa_output.pci-0000_00_14.2.analog-stereo>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause:
priority: 9959
volume: front-left: 50462 / 77% / -6.81 dB, front-right: 50462 / 77% / -6.81 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 23.16 ms
max request: 4 KiB
max rewind: 64 KiB
monitor source: 11
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 1
linked by: 1
configured latency: 23.22 ms; range is 1.00 .. 371.52 ms
card: 1 <alsa_card.pci-0000_00_14.2>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC892 Analog"
alsa.id = "ALC892 Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "HDA ATI SB"
alsa.long_card_name = "HDA ATI SB at 0xfe200000 irq 16"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:14.2"
sysfs.path = "/devices/pci0000:00/0000:00:14.2/sound/card0"
device.bus = "pci"
device.vendor.id = "1002"
device.vendor.name = "Advanced Micro Devices, Inc. [AMD/ATI]"
device.product.id = "4383"
device.product.name = "SBx00 Azalia (Intel HDA)"
device.form_factor = "internal"
device.string = "front:0"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "Built-in Audio Analog Stereo"
alsa.mixer_name = "Realtek ALC892"
alsa.components = "HDA:10ec0892,1462f640,00100302"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
analog-output-lineout: Line Out (priority 9900, latency offset 0 usec, available: no)
properties:
analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: yes)
properties:
device.icon_name = "audio-headphones"
active port: <analog-output-headphones>
index: 14
name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9050
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max request: 0 KiB
max rewind: 0 KiB
monitor source: 15
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
configured latency: 0.00 ms; range is 0.50 .. 371.52 ms
card: 0 <alsa_card.pci-0000_01_00.1>
module: 6
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "HDMI 1"
alsa.id = "HDMI 1"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "7"
alsa.card = "1"
alsa.card_name = "HDA NVidia"
alsa.long_card_name = "HDA NVidia at 0xfe080000 irq 26"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:01:00.1"
sysfs.path = "/devices/pci0000:00/0000:00:02.0/0000:01:00.1/sound/card1"
device.bus = "pci"
device.vendor.id = "10de"
device.vendor.name = "NVIDIA Corporation"
device.product.id = "0fbb"
device.product.name = "GM204 High Definition Audio Controller"
device.string = "hdmi:1,1"
device.buffering.buffer_size = "65536"
device.buffering.fragment_size = "32768"
device.access_mode = "mmap+timer"
device.profile.name = "hdmi-stereo-extra1"
device.profile.description = "Digital Stereo (HDMI 2)"
device.description = "GM204 High Definition Audio Controller Digital Stereo (HDMI 2)"
alsa.mixer_name = "Nvidia GPU 71 HDMI/DP"
alsa.components = "HDA:10de0071,196e1131,00100100"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: yes)
properties:
device.icon_name = "video-display"
device.product.name = "ASUS VH238
"
active port: <hdmi-output-1>
来自@Julian 对 AskUbuntu关于更改音频接收器的评论:
切换到最后一个未使用的输出。这应该足以在您的输入之间切换。
我知道这不是您想要的答案,但测试表明,只需将一副耳机插入耳机插孔即可消除到扬声器插孔的任何输出。您可以通过如下所示的声音应用程序自行测试。运行它,拔下耳机,你会看到:
使用测试声音按钮确认您正在从扬声器中获得输出。
然后插入耳机。您将看到它们自动突出显示,如下所示:
如果您现在突出显示先前选择的输出(在我的情况下为模拟输出)并重复测试声音过程,您将不会从扬声器中获得任何信息,因为插入耳机的行为会改变硬件级别的路线。这通常使用内部看起来像这样的开关接触连接器来完成。
插入插孔后,插孔中的“弹簧加载”连接器都连接到公插头,并在内部与扬声器断开连接。
为了有任何机会这样做,您可能必须更换或修改耳机插孔,以确保插入时信号不会中断到扬声器。我不推荐这种做法,并且不会对您在尝试中对系统造成的任何损害负责。
然后,您必须使用该
find
命令来确定更改声音应用程序输出所需的几秒钟内更改了哪些文件,并分析更改以获取有关如何通过 CLI 复制它们的线索。这部分未经测试,我根据手头的信息进行了总体假设。资料来源:
测试
http://www.instructables.com/answers/How-do-I-make-a-headphone-jack-cancel-the-output-o/