audio output by per application/process with oss/freebsd ?

hi all,

I have 2 audio outputs. 1st is headphone , 2nd is graphic card's hdmi output/connection to TV. I'm currently using linux and from audio/volume control I can select the audio output per application. is there any way to do the same with oss/freebsd ?

thanks
 
for further reference for anyone else come across such issue:
I asked at freebsd IRC channel, and the reply I got is as following :
yes, install xfce4-volumed-pulse and xfce4-pulseaudio-plugin, it allows switching record/playback devices

if anyone has such issue like mine, they can have the solution as quoted.

however, I dont want to install pulseaudio and I would like to accomplish this with OSS as backend. if anyone can help I really would appreciate it.
 
Hello there.
I have 2 audio outputs. 1st is headphone , 2nd is graphic card's hdmi output/connection to TV. I'm currently using linux and from audio/volume control I can select the audio output per application. is there any way to do the same with oss/freebsd ?
I'm not aware of a utility which configures OSS per application/process from a per user global configuration. Perhaps some DEs (KDE, Gnome, etc.), I don't know, I don't use those, but many audio, audio/video, graphical and non-graphical (TUI) media/audio player (if not all, web browser also), can choose the output audio device. The configuration can be made dynamically, during playback, or per configuration (file) statically.

Here as example multimedia/vlc and multimedia/mpv:

vlc-audio-dev.png mpv-audio-dev.png

VLC (first image) plays sound through HDMI, MPV through default sound device (hw.snd.default_unit: 3), speaker and headphones (Analog 2.0+HP/2.0) at the same time.

TUI audio player:
audio/cmus - mixer.oss.channel, mixer.oss.device
multimedia/musikcube - output driver, output device

See also "Sound" wiki, and "virtual_oss"), and https://vermaden.wordpress.com/2024/01/13/freebsd-desktop-part-29-configuration-audio-improvements
 
Hello there.

I'm not aware of a utility which configures OSS per application/process from a per user global configuration. Perhaps some DEs (KDE, Gnome, etc.), I don't know, I don't use those, but many audio, audio/video, graphical and non-graphical (TUI) media/audio player (if not all, web browser also), can choose the output audio device. The configuration can be made dynamically, during playback, or per configuration (file) statically.

Here as example multimedia/vlc and multimedia/mpv:

View attachment 21881 View attachment 21882

VLC (first image) plays sound through HDMI, MPV through default sound device (hw.snd.default_unit: 3), speaker and headphones (Analog 2.0+HP/2.0) at the same time.

TUI audio player:
audio/cmus - mixer.oss.channel, mixer.oss.device
multimedia/musikcube - output driver, output device

See also "Sound" wiki, and "virtual_oss"), and https://vermaden.wordpress.com/2024/01/13/freebsd-desktop-part-29-configuration-audio-improvements

thank you for your reply.
webkit/surf doesnt seem to have audio output option.
I will definitely use your recommendation for mpv.
however for other applications like webkit/surf, it seems "virtual_oss" path is to go. thank you again :)

Did you try virtual_oss + an appmixer ?
See this thread.
According to some users it is possible to achieve what you want with virtual_oss + the appmixer you can get from that thread.
I looked at that thread, however I couldnt find/see/understand how to seperately redirect/configure programs/applications to a audio output. whatever it is , it seems the answer lies within: mixer(3), sound(4), sysctl(8), virtual_oss(8) . :)


Linux does that via pulseaudio, not their low level API (ALSA). You can also use pulseaudio in FreeBSD.
for some reason; i believe, pulseaudio, consoled, polkitd, etc is not meant to be in a bsd system. I would really like to do it with oss , if possible. thanks :)

------
unfortunately documentation and sources regarding virtual_oss is very narrow and few. I come across to virtual_oss gui and adding to this post for in case if anyone would need:


----
 
Then another question.
Do you want to use both the headphones and the HDMI output simultaneously ?
If not, you could create aliases in your shell config file (.bashrc, .zshrc, etc...).
I for example had a very similar problem, and I would not say I solved it, but this workaround works very well.
Some applications however allow you to set the audio output device in their config files.
I do not have virtual_oss, but each time I want to switch devices for particular applications, I use my aliases:
switch-to-tv-sound-device, switch-to-headphones-sound-device.

In my .zshrc I have:
alias switch-to-monitor-sound-device="sysctl hw.snd.default_unit=%d" (your headphones our HDMI number device, inspect the output of cat /dev/sndstat for the number).
alias switch-to-headphone-sound-device="sysctl hw.snd.default_unit=%d"

After I have done the switch, I just reload the app, and that is it.
 
Then another question.
Do you want to use both the headphones and the HDMI output simultaneously ?
If not, you could create aliases in your shell config file (.bashrc, .zshrc, etc...).
I for example had a very similar problem, and I would not say I solved it, but this workaround works very well.
Some applications however allow you to set the audio output device in their config files.
I do not have virtual_oss, but each time I want to switch devices for particular applications, I use my aliases:
switch-to-tv-sound-device, switch-to-headphones-sound-device.

In my .zshrc I have:
alias switch-to-monitor-sound-device="sysctl hw.snd.default_unit=%d" (your headphones our HDMI number device, inspect the output of cat /dev/sndstat for the number).
alias switch-to-headphone-sound-device="sysctl hw.snd.default_unit=%d"

After I have done the switch, I just reload the app, and that is it.

Do you want to use both the headphones and the HDMI output simultaneously ?
- yes sometimes :/

shell script, noted :)

thanks
 
Back
Top