Not sure if you remember, but I did blog in the past about the ALSA ac3 plugin, that encodes the audio on the fly to play it through an external amplifier and a digital S/PDIF connection.
Well, beside the fact that the plugin was being shipped without proper testing, as it didn’t work at all (missing call to avcodec_init(), nonetheless), I now came to the conclusion that it was poorly designed too.
Think about it: what is that produces 5.1 output most of the time? Multimedia players, like xine, MPlayer and VLC, most of which also use FFmpeg for decoding in someway (at least xine and VLC do, MPlayer uses its own snapshot so it’s a different problem). So what the problem is? Well..
[NULL @ 0x304810cd10]insufficient thread locking around avcodec_open/close()
this is the error you get when you try to play something through xine using the AC3 encoding plugin of ALSA. The reason is simple: FFmpeg API is not thread-safe at all, especially when it comes to open and close, so xine has to take care of handling a mutex to lock access.. but it’s not possible to synchronise with ALSA’s access, so there’s no way to use a FFmpeg-based software together with that plugin while using a shared copy of FFmpeg. Of course upstream will just say that they don’t support shared FFmpeg, that they don’t give a crap and that it’s the design of the rest of the world that has to be changed, but the bottom line remains the same: ALSA’s ac3 plugin is pretty much useless.
An user commented on an ALSA bug with a patch that makes the plugin use another AC3 encoder, aften that is supposedly faster, I’ll have to try it, it might be worth using that just to workaround FFmpeg braindeadness, even if the current CVS version uses CMake (sigh).
CMake is way better than hand written configure files 😉
And being shot in the shoulder is better than being shot directly in the head, but that’s not much 🙂
Er, wait, so are you saying that the ac3 output plugin is crap? Should I remove the mention of it from the ALSA guide, even though you recommended that I cover it in the alsa-plugins tip? If it’s broken, I don’t think we ought to tell users about it, otherwise they’ll get upset that we gave them a bad recommendation.
I never said broken, I said almost useless. It would work fine with aplay, mplayer, probably gstreamer and audacious if that works.Besides, it’s available only on ~arch alsa-plugins right now.
yet another suggestion:rip the ac3 parts you need and just them and put the in the plugin, it should be the simplest solution.That said we could figure out a generic solution to the generic problem.PS: our hand written scripts are getting simpler and simpler, yet CMake improved a bit, even if I dislike it quite a lot.