
Originally Posted by
crazycheese
No offence, I have a feel I talk to the wall here.
I was unable to get DMIX do job done for the reasons mentioned in my post of what ALSA lacks.
First it does not support true software mixing - it cannot mix streams of different bitrate and frequency, so if one is playing 44kHz and other starts 22kHz only second is played.
Second DMIX does not prevent any application take over the sound card. This means for example Adobe Flash or Avidemux taking over soundcard, stopping any other music playback instantly. Any new application will exit with error unable to access device or device busy until the hijacker is closed. This never happens in PA.
This and many more is done by Pulse. But ALSA doing it properly will eliminate need for extra 20Mb of RAM(so much takes PulseAudio, almost nothing). Never the less Pulse is sanely implemented, it can take over and give features. If you dont want it, you can remove it.
If you dont see the point of Pulse, why dont you visit at least its Wikipedia entry?
ALSA is not replacing Pulse
Pulse is not replacing ALSA
Pulse implements wide array of features, absent in ALSA, such as live audio stream rerouting. This is similar to JACK, however is desktop (and not workstation) optimized. I consider it pretty cool to have individual per-app volume controlls as well as individual recording controls(where you can separate Mic from sound card and Mic from Webcam and adjust the volume live and per app).
Pulse is not related to Ubuntu.
--Let me introduce you to the basics of Linux multimedia--
---CODECs
liblame, libh264, libwhatever is a codec - it encodes or decodes the encrypted binary stream. Application can talk to the codec library directly. If stream is not encoded(RAW) it can be send directly to sound card driver.
Ffmpeg is just a large codec collection(instead of individual libraries). It is all-in-one library, like Mplayer, featuring many MPEGx codec routines.
Xine is similar to Ffmpeg and Mplayer in terms it is one big all-in-one codec, but it only supports decoding(which is lame) and it also allows linking to external additinal libraries(so its not one massive rock like Mplayer)
Gstreamer is an interface for multimedia. It makes talking to codecs for purpose of code/decode a fuzz. It makes programming easier. It consists of gstreamer core and gst-plugins. Plugins are just binders to individual codec libraries mentioned before. When you install gst-plugin-ffmpeg you also install libffmpeg. You can understand it as an exoskeleton around codecs, making life much easier for a programmer. It talkes corresponding codec and outputs to correspondent sound system - two hares with one shot. It is not like MPlayer or Xine, or Ffmpeg - it lets system stay flexible. However its only Linux(BSD?).
Example:
Libmpeg, Mplayer(having copy of libmpeg it inside), Xine(having it inside as decode only version), Ffmpeg(having its functionality inside) are duplicates in the system. Gstreamer plugin libmpeg and libmpeg are not duplicates.
---- Sound Libraries
This libraries make programmers life easier.
Instead of talking to decoder and sound card system directly, they just talk to Sound Library.
SDL - features capable mixer and backend. Developer just write code for SDL to play his sounds/music, and SDL compiled against ALSA, OSS, Pulse, Jack or even windows directsound - talks to them by itself for the output. Should user have any of this four or one installed, SDL will talk to them. For the en/decoding - SDL can access individual codecs automatically(as far as I know), but also has support for Gstreamer. It is crossplaform and part of big toolkit(it also has layers for networking and 3D via OpenGL). The disadvantage is its interface while more universal - is more generic(basic) than talking to this five personally(and releasing five program verions). But its more than enough for gaming.
OpenAL - same as SDL-audio part, but more 3D audio features. Many apps can output to OpenAL or SDL, whatever you have in your system.
Allegro - heard its same as SDL, but less featurefull, heard its practically depricated. Also Allegro worked on Pulse.
---- Sound Servers
Pulse can:
- mix streams from different sources(applications and cards)
- per-application and per-sound card volume with mouse
- network stream broadcasting
- connect OSS and ALSA to one single thing. Application talk to Pulse and pulse sends to ALSA or OSS. Developer only needs to output to pulse.
What Pulse is not:
- it is not a codec
- it is not a hardware manager
- it cannot connect codecs or connect applications and codecs.
Its just a network-capable awesome mixer.
Phonon is DEPRICATED. Use Pulse and Gstreamer instead. Phonon is not part of KDE, but part of Qt. Originally Phonon was meant to automatically detect wherever Qt application is run on Linux(ALSA,OSS), BSD(OSS) or Windows(DSound). However, on all platforms it is unnecessary now because of pulse. Pulse is crossplatform and gives more than Phonon, hence Qt abadoned it.
JACK is same to Pulse, but shifts on application-to-application links, lower latencies and professional usage. You can connect JACK to Pulse, JACK connects applications together and result goes to Pulse which connects it to multiple sound cards.
---- Sound card systems
Further, ALSA - a hardware management and (to some degree) mixing system vs OSS are end-point audio hardware systems.
These manage the hardware. They can take that binary stream(only unencrypted) and make a card play it.
If you have encrypted stream(ogg,mp3,wav,flac whatever) you need to decode it before it can be send to hardware.
Additionally OSS,compared to ALSA, features more mature mixer, easier API but is known for making crap in the past. A commercial company stands behind it - thats it. Commercial means making money by any case possible. Thats why I consider ALSA better to OSS, I can hardly imagine how OSS can make money not by selling licenses. One day they stop releasing GPL version and Linux is screwed again. Its trilicensed btw, not only GPL.
-------- Possible playback variations:
Raw--->ALSA or OSS--->Sound cards
::App need to work with ALSA or OSS
Encrypted--->liblame---->ALSA or OSS---->Sound cards
::App need to work with liblame and ALSA or OSS
Very bad mixing in ALSA.Takeover possible if app written in bad style.
Encrypted--->Gstreamer(takes out liblame automatically)--->ALSA or OSS(whatever Gstreamer is set to)----->Sound cards
::App need to work with Gstreamer only.
Very bad mixing in ALSA.Takeover not seen, since Gstreamer behaves correctly.
Encrypted--->Gstreamer(takes out liblame automatically, set to pulse plugin)--->Pulse---->ALSA or OSS(whatever pulse is set to)----->Sound cards
::App need to work with Gstreamer only.
Good mixing, no takover possible, regardless if gstreamer is not only app playing.
Encrypted--->SDL(calls Gstreamer automatically, as it sees Gstreamer is present)--->Gstreamer(takes out liblame automatically, set to pulse plugin)--->Pulse---->ALSA or OSS(whatever pulse is set to)----->Sound cards
::App need to work with SDL only. It is crossplatform.
Good mixing, no takeover possible, as above.
Encrypted--->SDL(calls Gstreamer automatically, as it sees Gstreamer is present)--->Gstreamer(takes out liblame automatically, set to alsa or oss)--->ALSA or OSS(whatever pulse is set to)----->Sound cards
::App need to work with SDL only. It is crossplatform.
Very bad mixing in ALSA.Takeover not seen, since Gstreamer behaves correctly.
I dont see any problem with linux.
If you program for linux only or require more features - use Gstreamer for sound operations.
If gstreamer is too generic for you, you will have to 1) talk to codecs 2) talk to sound system of your choice -- all your way, ie manually.
If you dont want gstreamer, xine offers similar functionality(although codec part is totally differently implemented). But gstreamer and xine can coexist(although there will be duplicated stuff)
If you programm crossplatform - use SDL or OpenAL.
Yes, this is not copypaste, comments welcome.