xbmc/xbmc — pull request #4950 by Memphiz (2014-06-23 08:34:39+00:00)
Title: [AE/osxsink] - fix wrong samplerate selection

This should improve the selection of streamFormats in the osx sink by taking the samplerate into account.

The problem was brought up from users with optical links to their amps. OSX assumes that each optical amp allows sample rates up to 96000 Hz. As it seems most amps don't support sample rates higher then 48000 Hz. Our current streamFormat scoring algorithm didn't prefer any samplerates if they don't match exactly. In the example the user wanted to play a mono audiostream with 22050Hz. Our scorealgorithm then picked 96000Hz because it was the first format in the list.

With this PR the samplerates are choosen according to this order:

1. Prefer exact match
2. Prefer exact multiple of source samplerate and prefer the lowest

Of course those users will have issues when trying to play 96000 Hz content - but there is nothing we can do about it (in that case they need to use the "fixed" preset).

Also added test cases for scoreStream.

@jmarshallnz for review