Pulseaudio set/check default source
Asked Answered
D

2

5

So the question is,

  1. How can I set the default source?
  2. How can I list the current default source?

Details

I have 4 sound input sources on my linux device. Here is the result of pactl list sources:

1   alsa_input.pci-0000_00_1b.0.analog-stereo   module-alsa-card.c  s16le 2ch 44100Hz SUSPENDED
2   alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo    module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED
3   alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2  module-alsa-card.c  s16le 2ch 48000Hz   SUSPENDED
5   alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor    module-alsa-card.c  s16le 2ch 44100Hz   SUSPENDED

I tried to set the source 1 alsa_input.pci-0000_00_1b.0.analog-stereo as my default source by several ways:

1.change /etc/pulse/client.conf, add following lines:

default-sink = alsa_output.pci-0000_00_1b.0.hdmi-stereo

default-source = alsa_input.pci-0000_00_1b.0.analog-stereo

2.change /etc/pulse/default.pa, add following lines:

### Make some devices default
set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo

After configuration complete, I tried pulseaudio -D and reboot the device, but the config take no effect. I don't know how to list the current default source and sink, so I use following command to verify:

$> pactl load-module module-loopback latency_msec=500
$> pactl list sources short | grep RUNNING
   3    alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2  module-alsa-card.c  s16le 2ch 48000Hz   RUNNING

The pactl still use my usb camera's microphone as its default source.

System Info

Linux kernel:

Linux D2-A109 4.15.0-55-generic #60-Ubuntu SMP Tue Jul 2 18:22:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

PulseAudio version:

$> pulseaudio --version
   11.1

Any advice is welcome!

Debra answered 3/12, 2019 at 4:26 Comment(0)
D
6

Finally..I find it's just caused by the microphone "unplugged"... And the way to set the default source is correct.

And I find the answer of Q2."How can I list the current default source?":

$> pacmd list-sources | grep -e 'index:' -e device.string -e 'name:' -e 'available'
* index: 1
name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
    device.string = "front:0"
    analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
    analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: yes)
    analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
index: 2
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo>
    device.string = "plug:front:1"
    analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 3
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2>
    device.string = "plug:front:2"
    analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 7
name: <alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor>
    device.string = "0"

Corresponding to PulseAudio wiki, The * in front of the index indicates the current default input.

To avoid someone being stupit as me, we can determine if the microphone(source) is plugged, by checking 'available' in the printing result of sources.

Debra answered 3/12, 2019 at 7:39 Comment(0)
U
8

How can I list the current default source?

With pulseaudio 15.0 you can now just run pactl get-default-source to get the device string without resorting to running sed/awk/grep etc on the output.

Underexposure answered 29/9, 2021 at 14:23 Comment(3)
13.99.1 (from Ubuntu 20.04) also works with pactlAlbemarle
It doesn't though @Albemarle . I'm also on Ubuntu 20 with version 13.99.1 and the get-default-source command doesn't exist for meNauplius
@Shardj: you're right, as it was included at 14.99.1 (git.launchpad.net/ubuntu/+source/pulseaudio/commit/src/utils/…).Albemarle
D
6

Finally..I find it's just caused by the microphone "unplugged"... And the way to set the default source is correct.

And I find the answer of Q2."How can I list the current default source?":

$> pacmd list-sources | grep -e 'index:' -e device.string -e 'name:' -e 'available'
* index: 1
name: <alsa_input.pci-0000_00_1b.0.analog-stereo>
    device.string = "front:0"
    analog-input-front-mic: Front Microphone (priority 8500, latency offset 0 usec, available: no)
    analog-input-rear-mic: Rear Microphone (priority 8200, latency offset 0 usec, available: yes)
    analog-input-linein: Line In (priority 8100, latency offset 0 usec, available: no)
index: 2
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo>
    device.string = "plug:front:1"
    analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 3
name: <alsa_input.usb-Generic_Rmoncam_HD_720P_200901010001-02.analog-stereo.2>
    device.string = "plug:front:2"
    analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: unknown)
index: 7
name: <alsa_output.pci-0000_00_1b.0.hdmi-stereo.monitor>
    device.string = "0"

Corresponding to PulseAudio wiki, The * in front of the index indicates the current default input.

To avoid someone being stupit as me, we can determine if the microphone(source) is plugged, by checking 'available' in the printing result of sources.

Debra answered 3/12, 2019 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.