r/linuxdev • • Sep 27 '13
How can the Linux audio infrastructure mess be fixed?
One complaint that has been leveled against Linux is that the audio infrastructure is messy and thusly has too many failure modes. I'm using Linux and enjoying it, but I think there may be a valid complaint here. I'm currently new to programming, and I still haven't learned digital audio signal processing, but I have plenty of free time. I could learn a great deal in a reasonable amount of time. I'd love to develop something that can replace parts of the infrastructure with a single framework. My question is: what are your thoughts on it? What would be the best route to clean up the infrastructure? Does it need to be cleaned up at all?
View all comments
Show parent comment
103
u/wadcann Sep 27 '13 edited Sep 28 '13
[continued from parent]
Other sound systems
I'm not familiar with Bluetooth audio or Firewire, but apparently both have their own audio subsystems. I think that ALSA and Pulseaudio can both talk directly to at least Bluetooth.
Compatibility libraries
Obviously, application developers don't care about most of this. 95% of video game vendors want to play back a simple stereo audio stream and have it show up on the user's headphones.
The result was the development of compatibility libraries, so that instead of having to support all of these interfaces, applications could write to one compatibility library and have things work everywhere.
Major libraries to do this included SDL (which also handled other things, but did a good job of having multiple audio backends) and libao. OpenAL was also used by a number of ported games, though it has different goals (mostly providing 3d audio with Doppler effects). Applications would be written to these libraries. These all could route audio to different backends. They often had configuration (OpenAL had a text config file. SDL used environment variables, though out-of-box configuration was mostly sensible on most systems.)
This meant that switching applications to use a different audio system had another layer of indirection/complexity/place where things could go wrong. You've got some script that set SDL_AUDIODRIVER=alsa to stop using OSS back in the day? Great...until you're trying to get your program to use PulseAudio (via the native interface) and can't figure out why it's going through ALSA.
Audio patch panel, JACK
Often, people have different sound applications that they want to use, and want to hook up to each other. Maybe they've got a synthesizer and a visual effects program for DJing. Maybe they've got some program to pull in MIDI. Back in the day, this would have been done via physical boxes, with audio cables connecting one box to another called a patch panel.
In the computer world, it makes no sense to run audio out of a sound card just to let things be hooked up across programs. People developed systems for letting one program on a computer talk to another on a computer.
Windows has some expensive, proprietary program whose name I don't recall to be a virtual patch panel; as long as two audio programs support it, the user can use it to "connect" a virtual output in one program to a virtual input in another.
Linux has an open-source system called JACK. This does a good job of eliminating latency that prior audio servers had introduced, and pretty much serves the same role.
However, it means yet another audio server and incompatible audio sound server API for applications to support. Generally-speaking, pro audio will use this (i.e. if you want to use serious Linux pro audio stuff like ardour, you're going to be hooking up to JACK. Then "consumer" audio today, simple playback and recording from a mic, mostly goes through PulseAudio.
Summary of issues
Today, I'm not sure how much there is to fix. Most people are using PulseAudio for consumer stuff and JACK for pro stuff and simply time and maturity has meant that a lot of the wrinkles have been smoothed out, handled by the distro maintainers. I think that a single app that shows a diagram of where sound is "going" would be nice, and understands the various sound systems, but I don't think that re-engineering chunks of the system would solve much (and would make things worse). What Linux really needs is (a) more weight given to backwards-compatibility and using mature systems and making sure that things are done before they go in and (b) giving app vendors time to adapt to a given system.