# Two audio output devices at the same time, possible ?



## Adrien2002 (Aug 12, 2018)

Hi guys !

So I was wondering if it was possible to use two audio outputs at once ? I'm trying to stream to Twitch my games, I can, I can send the video and the audio without problem BUT to send the audio, I have to physically link the output jack to the input jack and doing that, I can't hear my games anymore. So, I have the audio or they have but not both.

I bought this





and I bought this





As soon as I connect the USB adapter, dmesg says me this :


```
ugen0.5: <C-Media Electronics Inc. USB Audio Device> at usbus0
uhid0 on uhub1
uhid0: <C-Media Electronics Inc. USB Audio Device, class 0/0, rev 1.10/1.00, addr 4> on usbus0
uaudio0 on uhub1
uaudio0: <C-Media Electronics Inc. USB Audio Device, class 0/0, rev 1.10/1.00, addr 4> on usbus0
uaudio0: Play: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Play: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record: 48000 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: Record: 44100 Hz, 1 ch, 16-bit S-LE PCM format, 2x8ms buffer.
uaudio0: No MIDI sequencer.
pcm5: <USB audio> on uaudio0
uaudio0: HID volume keys found.
```

With this command, I can entirely use the output and the input ports of that adapter :
`# sysctl -w hw.snd.default_unit=5
hw.snd.default_unit: 2 -> 5`
The default unit is set to *2* to use my speakers, I set it to *5* to use the adapter

But then, I won't have sound anymore on my computer, only in the stream !

So what I want is to use my speakers AND that adapter, at the same time, to be able to hear my games as much as people watching me playing on Twitch. Is it possible ? Is it complicated ?

Thank you !


----------



## shepper (Aug 12, 2018)

Adrien2002 said:


> I can, I can send the video and the audio without problem BUT to send the audio, I have to physically link the output jack to the input jack and doing that, I can't hear my games anymore.


It may be the output jack mutes the speakers when it senses a jack.  This can be disabled by adding an entry in /boot/device.hints and changing the nwid entry for the output jack.  The default should have an as=15 and to disable make the as=0 in the device hints entry.
See Thread 66052 and snd_hda(4)


----------



## Adrien2002 (Aug 12, 2018)

shepper said:


> It may be the output jack mutes the speakers when it senses a jack.  This can be disabled by adding an entry in /boot/device.hints and changing the nwid entry for the output jack.  The default should have an as=15 and to disable make the as=0 in the device hints entry.
> See Thread 66052 and snd_hda(4)



Just to answer you that it doesn't mute my speakers. Even I let the default unit to #2 and connect a headphone to the output jack, it won't mute the speakers and the sound, in the headphone, won't work until I change the default unit to #3.

What I know is :
unit #2 ===> speakers
unit #3 ===> green jack from the laptop
unit #5 ===> green jack from the USB adapter (I use this one to stream sound)

To use one of them, I must change using sysctl, it always worked and, using i3-wm, it's damn fast to call a terminal and send the command so it never bothered me as-is.

Maybe you are right about the auto-mute speakers since setting to #3 could let me play sound through both speakers and headphones ? I have no idea for the moment. But I know that, the default setting is on #2 and no headphone can work with that setting.

Now, I'm going to investigate with that /boot/device.hints, maybe I'll find my solution there !  thank you very much !


----------



## shepper (Aug 12, 2018)

Just to head off some confusion.  What you are referring to as "units" are referred to as pcm's in the documentation.  PCM are groupings of pin outs from the sound chip and in FreeBSD, groupings tend to be based on location.  PCM0 may be the internal speakers, PCM1 could be the jacks on the left hand side of the laptop, PCM3 could be output plugs for a laptop dock, PCM4 may be a microphone next to the videocam on the bezel and PCM5 can be assigned to a usb adapter.

Another option is to utilze 2 pcm devices - the default is just 1.  See example 4 of snd_hda(4)


----------



## Adrien2002 (Aug 12, 2018)

I'm going to correct something I said wrong

`$ cat /dev/sndstat
Installed devices:
pcm0: <NVIDIA (0x0041) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0041) (HDMI/DP 8ch)> (play)
pcm2: <Realtek ALC282 (Analog)> (play/rec) default
pcm3: <Realtek ALC282 (Analog 2.0+HP/2.0)> (play/rec)
pcm4: <Realtek ALC282 (Right Digital)> (play)
No devices installed from userspace.`

So, pcm3 (yes, as I was referring to unit #3 because of sysctl calling them like that) is saying *(Analog 2.0+HP/2.0)> (play/rec)* and, INDEED, it works with my speakers if no headphone is connected and auto-mute my sound as soon as something is plugged in the green output jack. So the idea would be to find the way to disable that auto-mute to be able to use the two jacks (output and input) of my laptop (not the one of my USB adapter) to record the sound of my desktop and keep using my speakers to listen to my games.
Or to bind them logically but I will have to keep reading for that to be able to understand how that could be done.

EDIT : Plus, I have to found out how to use my input jack, the one one my laptop (not the one on the USB adapter) cause whatever I set actually, it always use the microphone of my laptop which is not what I want. pcm3 doesn't have anything else but "monitor" as the recsrc actually. I think I'll really have to go deeper.


----------



## shepper (Aug 12, 2018)

Adrien2002 said:


> No devices installed from userspace.


When you plug in your usb device (userspace) that becomes pcm5 which does not seem to be necessary if you use the pcm3 jack


Adrien2002 said:


> So the idea would be to find the way to disable that auto-mute to be able to use the two jacks (output and input) of my laptop (not the one of my USB adapter) to record the sound of my desktop and keep using my speakers to listen to my games.


To do this, you need to determine the pin number, aka nwid,  for the pcm3 jack.  These are enumerated by a pin dump which can be done either by a verbose dmesg or setting 
	
	



```
dev.hdac.%d.pindump
```
 to a non-zero value via sysctl(4).  Once you have the nwid, change just that nwid's seq=15 -> seq=0 with a device.hints entry.


----------

