Den torsdag 14 juli 2016 kl. 04:31:50 UTC+2 skrev ajo...@mozilla.com:
> Supporting two separate audio backends in Linux is duplicated effort.
> 
> I took over the platform media playback team at Mozilla a little over 3 years 
> ago. At that point we only supported WebM/VP8/Vorbis, Ogg/Theora/Vorbis and 
> Wave as well as MP3 on Windows and some additional codecs including 
> MP4/H.264/AAC on a small number of Android phones. At that time most media in 
> the browser ran in Flash.
> 
> Since then we’ve added words like MP3, MP4, H.264, VP9, Opus, AAC, HE-AAC, 
> MSE and EME to our vocabulary. DASH and HLS are handled by site Javascript 
> using MSE. A massive amount of effort has gone into making everything 
> parallel so we can get as many pixels to the screen as possible. We’re 
> working on platform specific performance improvements on Windows, Linux and 
> Mac. We’re also doing some work to protect ourselves against driver crashes 
> on Windows and Android.
> 
> We are seeing an explosion of interest in HTML5 video and the accompanying 
> audio is going through libcubeb, our audio backend. We’ve added low latency 
> support to libcubeb for WebAudio and full duplex support so we can use it 
> directly for microphone input for WebRTC.
> 
> Our official Firefox builds on Linux support both PulseAudio and ALSA. There 
> are a number of additional contributed backends that can be turned on at 
> compile time, although contribution towards long-term maintenance and 
> matching feature parity with the actively developed backends has been low. On 
> Linux, we actively maintain the PulseAudio backend but we also approach the 
> PulseAudio developers when we see issues in PulseAudio. The PulseAudio 
> developers are generally good to work with.
> 
> The most problematic backend across all platforms is ALSA. It is also missing 
> full duplex support. We are intending to add multichannel (5.1) support 
> across all platforms and the ones that don’t make the cut will be the ALSA 
> backend and the WinMM backend used on Windows XP.
> 
> Our ALSA backend has fallen behind in features, it is buggy and difficult to 
> fix. PulseAudio is contrastingly low maintenance. I propose discontinuing 
> support for ALSA in our official builds and moving it to off-by-default in 
> our official builds.
> 
> Leaving all the ALSA code in tree gives people the opportunity to continue 
> maintaining the ALSA backend. Re-enabling it would require bringing it up to 
> the same standard as other backends, not only in terms of current state but 
> also in terms of consistency of contribution.
> 
> As a long time Linux user, I want to get the most value out of our efforts on 
> Linux. I can do that by focusing our efforts on the things that will have the 
> greatest impact. Sometimes that requires taking a step back and deciding to 
> do one thing well instead of two things poorly.
> 
> Just to be clear, I’m proposing we stop spending time on ALSA so we can spend 
> that time on adding 5.1 audio support to our PulseAudio backend.

First, I want to bust these two myths about ALSA. ALSA is the kernel interface 
to the Linux audio subsystem. Thus, if ALSA cannot do stuff, no other library 
can either (unless it is a kernel module). 

1. ALSA does not support full duplex: Wrong: Indeed, it does and JACK requires 
that feature. Otherwise, it cannot be used for step-by-step recording, and 
realtime DSP, which is the whole purpose of JACK. 

2. ALSA does not support 5.1: Wrong: Connect your fat mixer console to the 
computer, start jack, and you will see a lot of inputs and outputs. Why because 
ALSA can record multichannel audio, and also play multichannel audio.

To these two points I want to add that Intel PCH appears to not work in duplex 
mode on ALSA (and thus it would not work on PulseAudio either). But this is 
shitty hardware compared to the real stuff that were build in the 90:s 
(SoundBlaster AWE 64 gold with all connectors you would ever need: Line in, 
Line out, microphone in (+20 dB gain), and MIDI in/out. With right software, 
your home PC was a semi-professional grade music studio).


As a second point, I would like to add a design guide, that should be 
considered before doing any audio programming:

1. There should be one and only one sound server running on the system

2. The sound server should *not* fiddle with sample rates, or anything else 
that requires conversion to frequency domain (such as 5.1 to various surround 
conversions). That should be done by the application internally, or through a 
library. The reason for this is that it adds latency that cannot be removed 
(unless you have a carefully calibrated flux capacitor constructed by Doc Brown 
:-P that pushes the signal back in time). And that boils down to the Heisenberg 
inequality. For those on this list that are more into computer graphics, the 
sample rate of the system should be treated as the refresh rate of the monitor. 
Do the display server convert the video stream into a different framerate so it 
matches the refresh rate of the monitor?

3. Different applications has different latency requirements. The hardest 
requirements determine the sound server period. However, a short period will 
prevent CPU from going idle (not good for laptops on battery).


What does this imply?

1. Any application must be able to deal with any sound server that may be 
running on the given platform. If they have a very different API, consider 
using an external library, like PortAudio to hide their differences.

2. PulseAudio has severe design issues, so sometimes we have to use JACK. In 
this case PulesAudio is rejected in favour of JACK.

3. A sound server must have the options to configure its period. If the wall 
socket is unplugged, it may be necessary for it to restart with a longer period.


Conclusion: Before you dropped ALSA support, you should have implemented robust 
support for both PulseAudio, and JACK.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to