Reputation: 1382
I want to extract the ports
for each device on the below:
index: 0
name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_5__sink>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9037
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: 0
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HDMI3 (*)"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "5"
alsa.card = "0"
alsa.card_name = "sof-hda-dsp"
alsa.long_card_name = "DellInc.-Inspiron5490--0YMVR1"
alsa.driver_name = "snd_soc_skl_hda_dsp"
device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "02c8"
device.string = "hw:sofhdadsp,5"
device.buffering.buffer_size = "65472"
device.buffering.fragment_size = "16320"
device.access_mode = "mmap+timer"
device.profile.name = "HiFi: hw:sofhdadsp,5: sink"
device.profile.description = "HDMI3/DP3 Output"
alsa.mixer_device = "hw:sofhdadsp"
device.description = "sof-hda-dsp HDMI3/DP3 Output"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
[Out] HDMI3: HDMI3/DP3 Output (priority 700, latency offset 0 usec, available: no)
properties:
active port: <[Out] HDMI3>
index: 1
name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_4__sink>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9036
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: 1
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HDMI2 (*)"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "4"
alsa.card = "0"
alsa.card_name = "sof-hda-dsp"
alsa.long_card_name = "DellInc.-Inspiron5490--0YMVR1"
alsa.driver_name = "snd_soc_skl_hda_dsp"
device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "02c8"
device.string = "hw:sofhdadsp,4"
device.buffering.buffer_size = "65472"
device.buffering.fragment_size = "16320"
device.access_mode = "mmap+timer"
device.profile.name = "HiFi: hw:sofhdadsp,4: sink"
device.profile.description = "HDMI2/DP2 Output"
alsa.mixer_device = "hw:sofhdadsp"
device.description = "sof-hda-dsp HDMI2/DP2 Output"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
[Out] HDMI2: HDMI2/DP2 Output (priority 600, latency offset 0 usec, available: no)
properties:
active port: <[Out] HDMI2>
index: 2
name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink>
driver: <module-alsa-card.c>
flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9035
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: 2
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
configured latency: 0,00 ms; range is 0,50 .. 341,00 ms
card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HDMI1 (*)"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "3"
alsa.card = "0"
alsa.card_name = "sof-hda-dsp"
alsa.long_card_name = "DellInc.-Inspiron5490--0YMVR1"
alsa.driver_name = "snd_soc_skl_hda_dsp"
device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "02c8"
device.string = "hw:sofhdadsp,3"
device.buffering.buffer_size = "65472"
device.buffering.fragment_size = "16320"
device.access_mode = "mmap+timer"
device.profile.name = "HiFi: hw:sofhdadsp,3: sink"
device.profile.description = "HDMI1/DP1 Output"
alsa.mixer_device = "hw:sofhdadsp"
device.description = "sof-hda-dsp HDMI1/DP1 Output"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
[Out] HDMI1: HDMI1/DP1 Output (priority 500, latency offset 0 usec, available: yes)
properties:
device.product.name = "2460G5"
active port: <[Out] HDMI1>
* index: 3
name: <alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink>
driver: <module-alsa-card.c>
flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
state: RUNNING
suspend cause: (none)
priority: 9032
volume: front-left: 56752 / 87% / -3,75 dB, front-right: 56752 / 87% / -3,75 dB
balance 0,00
base volume: 65536 / 100% / 0,00 dB
volume steps: 65537
muted: no
current latency: 19,83 ms
max request: 4 KiB
max rewind: 4 KiB
monitor source: 3
sample spec: s16le 2ch 48000Hz
channel map: front-left,front-right
Stereo
used by: 1
linked by: 1
configured latency: 23,22 ms; range is 0,50 .. 341,00 ms
card: 0 <alsa_card.pci-0000_00_1f.3-platform-skl_hda_dsp_generic>
module: 7
properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HDA Analog (*)"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "sof-hda-dsp"
alsa.long_card_name = "DellInc.-Inspiron5490--0YMVR1"
alsa.driver_name = "snd_soc_skl_hda_dsp"
device.bus_path = "pci-0000:00:1f.3-platform-skl_hda_dsp_generic"
sysfs.path = "/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.vendor.name = "Intel Corporation"
device.product.id = "02c8"
device.string = "hw:sofhdadsp"
device.buffering.buffer_size = "65472"
device.buffering.fragment_size = "16320"
device.access_mode = "mmap+timer"
device.profile.name = "HiFi: hw:sofhdadsp: sink"
device.profile.description = "Speaker + Headphones"
alsa.mixer_device = "hw:sofhdadsp"
device.description = "sof-hda-dsp Speaker + Headphones"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
ports:
[Out] Speaker: Speaker (priority 100, latency offset 0 usec, available: unknown)
properties:
[Out] Headphones: Headphones (priority 200, latency offset 0 usec, available: yes)
properties:
active port: <[Out] Headphones>
I can get each device index
with:
pacmd list-sinks | awk '/index:/ {print $0}
or with:
pacmd list-sinks | grep -e index
which results in:
index: 0
index: 1
index: 2
* index: 3
How can I go beyond that and compose commands to extract something like the lines bellow?
index: 0
ports:
[Out] HDMI3: HDMI3/DP3 Output (priority 700, latency offset 0 usec, available: no)
index: 1
ports:
[Out] HDMI2: HDMI2/DP2 Output (priority 600, latency offset 0 usec, available: no)
index: 2
ports:
[Out] HDMI1: HDMI1/DP1 Output (priority 500, latency offset 0 usec, available: yes)
* index: 3
ports:
[Out] Speaker: Speaker (priority 100, latency offset 0 usec, available: unknown)
[Out] Headphones: Headphones (priority 200, latency offset 0 usec, available: yes)
Upvotes: 0
Views: 95
Reputation: 12867
pacmd list-sinks | awk '/index/ { print } /active port:/ { pnt=0 } /ports:/ { print;pnt=1 } pnt==1 && /\[Out\]/ { print }'
Print the index line, then when we see "ports:", set a variable pnt to 1, print the line and skip to the next line. When pnt is equal to one and the line contains "[Out]", print the line. When we see "active port:" reset the pnt variable back to 0.
Upvotes: 2