Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

What is the proper way to manage usb audio priority?

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
2 posts • Page 1 of 1
Author
Message
mi_unixbird
Apprentice
Apprentice
User avatar
Posts: 158
Joined: Fri Jul 24, 2015 7:34 pm

What is the proper way to manage usb audio priority?

  • Quote

Post by mi_unixbird » Sun Jan 11, 2026 4:20 pm

The way I understand it, with USB audio, every headphone and speaker essentially registers as its own sound card so there is no difference any more between “headphone” and “speakers”, they are all just “sound cards” as far as the operating system is concerned which obviously presents challenges in automatically managing the common idea that speakers should automatically disable when headphones are plugged in.

Right now, I have a simple daemon written in Bash that simply monitors for USB devices being connected and is simply hardcoded to detect my headphones. Alongside that I have two different speakers as well in my machine so the daemon operates in a simple way: if the headphones be plugged in, then it pipes a loopback device to the headphones, else it pipes it to both speaker sound cards. The names it detects them by are hardcoded into the script so this works for my own use case but this cannot be a proper general solution. I use pure ALSA and no Pipewire or anything like that so I don't know what that does but do USB headphones have some kind of way to “report” that they're headphones and should take priority over speakers? Does Pipewire simply give priority to the last USB sound card inserted? then if so, how would it manage the situation that if the headphones not be inserted it needs to route audio to both fixed speakers? Is the user meant to simply hardcode this in some way based on identifier strings which doesn't feel right to me.
execctl --path exec filectl --current-directory list
Top
flexibeast
l33t
l33t
Posts: 682
Joined: Mon Apr 04, 2022 4:15 am
Location: Naarm/Melbourne, Australia
Contact:
Contact flexibeast
Website

  • Quote

Post by flexibeast » Tue Jan 27, 2026 3:06 am

Replying in the absence of anyone else answering, and because i'm trying to improve my knowledge of digital audio stuff.

Not sure if you're already aware of / using lsusb(8) (provided by sys-apps/usbutils); its -v option provides detailed information about a USB device.

The USB standard specifies an 'Audio' base class for devices. (It also specifies 'an 'Audio/Video' class for devices that handle both.)

Additionally, section A.7 of the USB spec [PDF] specifies "Audio Function Category Codes", which includes things like 'Desktop Speaker' and 'Headset'.

i don't currently have any USB audio devices with which to test this, but hopefully the output of `lsusb -v` might allow you to distinguish the headset via the value of `bFunctionSubClass`, e.g. by using something like this:

Code: Select all

lsusb -v | sed -e '/./{H;d;}' -e 'x;/FunctionSubClass.*Headset/!d;' | sed -n '2p'
https://wiki.gentoo.org/wiki/User:Flexibeast
My most recent wiki contributions
Top
Post Reply

2 posts • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic