Bug 96415 - Pulseaudio does not create a separate source for each input subdevice on a card
Summary: Pulseaudio does not create a separate source for each input subdevice on a card
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-07 04:58 UTC by rorzer
Modified: 2018-07-30 09:34 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description rorzer 2016-06-07 04:58:33 UTC
I am using Pulseaudio 1:8.0-0ubuntu3 on ubuntu xenial.
My built in sound card has two analog input devices, one with a single subdevice, and the other with two subdevices.  Here is the output of arecord -l:
$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: SB [HDA ATI SB], device 0: ALC889A Analog [ALC889A Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 1: ALC889A Digital [ALC889A Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: SB [HDA ATI SB], device 2: ALC889A Alt Analog [ALC889A Alt Analog]
  Subdevices: 2/2
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1

$ pactl list short sources

4	alsa_output.pci-0000_00_14.2.iec958-stereo.monitor	module-alsa-card.c	s16le 2ch 48000Hz	RUNNING
5	alsa_input.pci-0000_00_14.2.analog-stereo	module-alsa-card.c	s16le 2ch 48000Hz	RUNNING


I would expect Pulseaudio (perhaps module-udev-detect?) to detect and create 3 input sources to allow access to all three subdevices (hw:0,0,0; hw:0,2,0; hw:0,2,1).  This would allow me to record from all three analog input ports at once.  However, it seems that pulseaudio stops looking after it finds the first subdevice (hw:0,0,0)

alsamixer detects all three capture ports, and allows me to assign each capture port to a separate input source.

pavucontrol allows me to switch between capture ports on a single input source.  I could understand this for devices with only a single capture subdevice, but it is severely limiting for a device with more than one capture subdevice.
I wish to use pulseaudio as a mixer for three loopback sources on my HTPC: a Chromecast audio, my TV, and a phono amp.
Comment 1 Raymond 2016-06-07 06:35:28 UTC
do it really work since pulseaudio use jack detect to determine the availabilty of input source , the three inputs jacks are plugged when you are recording ?
Comment 2 Raymond 2016-06-07 06:53:41 UTC
how do you map three capture volume controls to the three capture devices ?

Node 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In
  Control: name="Capture Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Capture Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Device: name="ALC889A Analog", type="Audio", device=0
  Amp-In caps: ofs=0x10, nsteps=0x2e, stepsize=0x03, mute=1
  Amp-In vals: [0x11 0x11]
  Converter: stream=4, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Connection: 1
     0x24
Node 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In
  Control: name="Capture Volume", index=1, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Capture Switch", index=1, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Device: name="ALC889A Alt Analog", type="Audio", device=2
  Amp-In caps: ofs=0x10, nsteps=0x2e, stepsize=0x03, mute=1
  Amp-In vals: [0x80 0x80]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Connection: 1
     0x23
Node 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In
  Control: name="Capture Volume", index=2, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Capture Switch", index=2, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x10, nsteps=0x2e, stepsize=0x03, mute=1
  Amp-In vals: [0x80 0x80]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Connection: 1
     0x22
Comment 3 Raymond 2016-06-07 14:32:09 UTC
(In reply to rorzer from comment #0)
>
> I wish to use pulseaudio as a mixer for three loopback sources on my HTPC: a
> Chromecast audio, my TV, and a phono amp.

how do you connect chromecast audio, TV and phono amp since desktop only have rear mic, front mic and line in ?

http://www.realtek.com.tw/products/productsView.aspx?Langid=1&PFid=28&Level=5&Conn=4&ProdID=173

do you mean "Supports legacy analog mixer architecture" ?
Comment 4 rorzer 2016-06-07 21:13:07 UTC
(In reply to Raymond from comment #1)
> do it really work since pulseaudio use jack detect to determine the
> availabilty of input source , the three inputs jacks are plugged when you
> are recording ?

Hi,  thanks for your prompt replies :)

I'm not sure what you are asking here.  Is it:

a) Does recording/loopback work from all three input jacks if you have three sources plugged in?
answer: no.  When I plug the first device in, the dropdown menu on the input tab of pavucontrol automatically re-routes to the correct, plugged in jack.  When I plug the second device in, pulse switches to the new input.  The first input is disconnected.

or;

b) Is it theoretically possible for pulse to behave as I wish, when pulse uses hot switching?
answer: yes, it should be possible.  If pulse created a separate input source for each subdevice present on the card, then when one jack is plugged in, it could grab the first available source, and flag the jack as unavailable.  When a second jack is plugged in, it could grab the next avialable source, and flag a second jack as unavailable.  I'm not a programmer, but this is simple logic analogous to locking files when in use.
Comment 5 rorzer 2016-06-07 21:23:04 UTC
(In reply to Raymond from comment #3)
> (In reply to rorzer from comment #0)
> >
> > I wish to use pulseaudio as a mixer for three loopback sources on my HTPC: a
> > Chromecast audio, my TV, and a phono amp.
> 
> how do you connect chromecast audio, TV and phono amp since desktop only
> have rear mic, front mic and line in ?
> 
> http://www.realtek.com.tw/products/productsView.
> aspx?Langid=1&PFid=28&Level=5&Conn=4&ProdID=173
> 
> do you mean "Supports legacy analog mixer architecture" ?

There is a stereo input jack for each of rear mic, front mic and line in.  Each of these has a separate hardware subdevice that is recognised by ALSA.  I want to be able to plug, for example, Chromecast into Front mic, phono amp into rear mic, and TV into line in.  This is possible in hardware, it should be possible in software.

One solution would be to have a mixer source for all three subdevices, another (preferred for me) solution would be to create a separate input source for each hardware subdevice.  This would allow me to use default.pa to route particular inputs to particular outputs via particular loopback modules.
Comment 6 Raymond 2016-06-07 22:44:13 UTC
the hardware analog mixer of your alc889a has low latency than the module loopback if you just want to route the input to line out 

the "xxx playback volume" and "xxx playback switch" of the analog mixer affect the output volume of the input source to the line out jacks


Node 0x0b [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
  Control: name="Rear Mic Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Rear Mic Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Front Mic Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=1, ofs=0
  Control: name="Front Mic Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=1, ofs=0
  Control: name="Line Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=2, ofs=0
  Control: name="Line Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=2, ofs=0
  Control: name="CD Playback Volume", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=4, ofs=0
  Control: name="CD Playback Switch", index=0, device=0
    ControlAmp: chs=3, dir=In, idx=4, ofs=0
  Amp-In caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
  Amp-In vals: [0x80 0x80] [0x00 0x00] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
  Connection: 10
     0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x14 0x15 0x16 0x17
Comment 7 Raymond 2016-06-07 22:55:27 UTC
only one ADC can select input from the audio mixer 0x0b ( mix of the input sources)

https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/Documentation/sound/alsa/HD-Audio.txt

- add_stereo_mix_input (bool): add the stereo mix (analog-loopback
  mix) to the input mux if available

Node 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In
  Control: name="Capture Volume", index=2, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Control: name="Capture Switch", index=2, device=0
    ControlAmp: chs=3, dir=In, idx=0, ofs=0
  Amp-In caps: ofs=0x10, nsteps=0x2e, stepsize=0x03, mute=1
  Amp-In vals: [0x80 0x80]
  Converter: stream=0, channel=0
  SDI-Select: 0
  PCM:
    rates [0x560]: 44100 48000 96000 192000
    bits [0xe]: 16 20 24
    formats [0x1]: PCM
  Connection: 1
     0x22

Node 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
  Amp-In caps: ofs=0x00, nsteps=0x00, stepsize=0x00, mute=1
  Amp-In vals: [0x00 0x00] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
  Connection: 11
     0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x14 0x15 0x16 0x17 0x0b
Comment 8 Raymond 2016-06-08 00:56:23 UTC
(In reply to rorzer from comment #4)
> (In reply to Raymond from comment #1)

> 
> a) Does recording/loopback work from all three input jacks if you have three
> sources plugged in?
> answer: no.  When I plug the first device in, the dropdown menu on the input
> tab of pavucontrol automatically re-routes to the correct, plugged in jack. 
> When I plug the second device in, pulse switches to the new input.  The
> first input is disconnected.


not all input source of the sound card are supported by pulseaudio (e.g. CD , mix)



https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/analog-input.conf.common

it switch off other port 's element when the port is selected

https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/analog-input-front-mic.conf

https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/analog-input-rear-mic.conf

https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/alsa/mixer/paths/analog-input-linein.conf
Comment 9 rorzer 2016-06-08 10:49:27 UTC
(In reply to Raymond from comment #6)
> the hardware analog mixer of your alc889a has low latency than the module
> loopback if you just want to route the input to line out 

How do I achieve this?
> 
> the "xxx playback volume" and "xxx playback switch" of the analog mixer
> affect the output volume of the input source to the line out jacks
> 

I do not see "xxx playback switch" in alsamixer

> 
> Node 0x0b [Audio Mixer] wcaps 0x20010b: Stereo Amp-In
>   Control: name="Rear Mic Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=0, ofs=0
>   Control: name="Rear Mic Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=0, ofs=0
>   Control: name="Front Mic Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=1, ofs=0
>   Control: name="Front Mic Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=1, ofs=0
>   Control: name="Line Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=2, ofs=0
>   Control: name="Line Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=2, ofs=0
>   Control: name="CD Playback Volume", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=4, ofs=0
>   Control: name="CD Playback Switch", index=0, device=0
>     ControlAmp: chs=3, dir=In, idx=4, ofs=0
>   Amp-In caps: ofs=0x17, nsteps=0x1f, stepsize=0x05, mute=1
>   Amp-In vals: [0x80 0x80] [0x00 0x00] [0x80 0x80] [0x80 0x80] [0x80 0x80]
> [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80] [0x80 0x80]
>   Connection: 10
>      0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x14 0x15 0x16 0x17
Comment 11 GitLab Migration User 2018-07-30 09:34:39 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/26.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.