Let us talk about Firefox’s backend audio system. Every sound you hear while you are watching a video or using a WebRTC service comes from the backend audio library. The role of the library is to communicate with audio devices and to provide audio input and/or output. This library is called ‘cubeb’ and it is part of the Firefox source code.
‘Cubeb’ is a cross-platform library, written in C/C++, that was created and has been maintained by the Firefox Media Team. What is most interesting about this, though, is that ‘cubeb’ library is developed in a separate Github repository, independent of the basic Mozilla repository. This has a number of benefits: source code remains completely decoupled from the rest of Firefox platform code. The development test-cycle can be significantly smaller, since it is not required to build the whole Firefox application. However what is most important for the user is that, given the fact that there are no dependencies, the library can be used for personal projects. If ‘cubeb’ is good enough for Firefox it is probably good enough for you!
The functionality of the library is not limited to audio input and output. In addition, it is possible to enumerate all audio devices in the system, as well as to register notifications such as device unplugs. It is also possible to switch between devices at a lower level with a minimal transition gap.
If you are interested in experimenting with the ‘cubeb’ library you can clone the repository:
git clone --recursive https://github.com/kinetiknz/cubeb.git
Read the INSTALL.md file for instructions on how to build and install it. Patches are always welcome!