I just made an exciting discovery...
My main OS is Ubuntu 10.04 and I always used Xine as my back end since I find it more polished than Gstreamer. A few posts back, I said that there was no way to make Amarok play music directly to the hw:0,0 ALSA plug. This made Amarok's music go trough Dmix which resampled everything to 48 kHz. It turns out this is not Amarok nor Phonon's fault. It was actually a limitation of the back-end I was using, Xine.
I installed Fedora 16 a few weeks ago to play around with it and see how much different it is from Ubuntu. The main difference is that Fedora is a transparent distribution that works with up-stream projects and distributes the most up to date versions available. It's a change from Ubuntu 10.04, which is running old versions of pretty much everything. Fedora being up to date, it doesn't have Xine as a Phonon back end. I knew that, but out of curiosity I launched Amarok and went to Configure Phonon to see what back end was installed. It was quite a surprise to see hw:0,0 as one of the available output devices! I immediately pushed the hw:0,0 plug at the top, making it the default output device for music. I then added a few tracks from my external disc (all my music is on my Ubuntu partition, which is encrypted and can't be accessed from Fedora
) to Amarok's playlist and hit play. Amarok skipped the MP3s, saying it was missing a plugin, then crashed on the first FLAC file. Indeed I see Gstreamer has not changed. I had to install a bunch of gstreamer plugins packages, restart Amarok, and after a few trial and error it was working (more on that later). Using
cat /proc/asound/card0/pcm0p/sub0/hw_params I was able to confirm that all the files were played using their original sample rate and that Amarok changed sample rate as it was playing different tracks, in the same playlist, with different sample rates. Woot!
So I rebooted on Ubuntu 10.04, installed Gstreamer, the Gstreamer Phonon back-end and the necessary plugin files. Everything works just like on Fedora.
Now that Amarok monopolizes the hardware, I have no mixing. That means that while Amarok is playing, even on pause, no other audio can be played. I can't pause Amarok to watch a youtube video, for exemple. On another hand, now I'm sure that no other sound can disturb my listening.
I also learned something regarding the Gstreamer plugin sets. Anyone who installed those noticed that there are 3 groups, called "good", "bad" and "ugly". When asking about which to install, people often just tell you to install them all, without saying much more. well I finally learned what is the difference between those packages, here it is.
The "good" plugins are well maintained plugins. They have good code and are reviewed, tested and kept up to date. On top of that, they are published under the LGPL. This set can't play MP3, as mpeg is patented and can't be published freely. It is enough to play OGG and FLAC, because those are open formats.
The "bad" plugins are not as well maintained as the good plugins. They might lack proper testing and aren't as well kept up to date. They are published under a public license, probably the LGPL too.
the "ugly" plugins are actually good plugins. They are well written, maintained and kept up to date. The reason why they are called "Ugly" is simply because they are not open source or use elements that might be protected by patents and legal stuff. Their legality is therefor debated. This set can play MP3s.
Ubuntu says the "ugly" plugins might "might pose distribution problems". I suppose it's their way of keeping themselves clear of legal drama. Either way, I don't believe you need to install the 3 sets. You can start with the "good" ones and see if that works for your files. If you have MP3s, all you have to install is the gstreamer ffmpeg package. For me, playback of MP3 files works with ffmpeg, but I can't seek the track in Amarok. I had to install the "ugly" set to get proper support of MP3.