output/osx: improve sample rate selection
The formula in osx_output_score_sample_rate() to detect multiples of
the source sample rate was broken: when given a 44.1 kHz input file,
it preferred 16 kHz over 48 kHz, because its `frac_portion(16)=0.75`
is smaller than `frac_portion(48)=0.91`.
That formula, introduced by commit 40a1ebee29
, looks completely
wrong. It doesn't do what the code comment pretends it does.
Instead of using that `frac_portion` to calculate a score, this patch
adds to the score only if `frac_portion` is nearly `0` or `1`. This
means that the factor is nearly integer.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/904
This commit is contained in:
parent
5c7243d3ad
commit
691b6a236e
2
NEWS
2
NEWS
|
@ -4,6 +4,8 @@ ver 0.21.25 (not yet released)
|
||||||
* input
|
* input
|
||||||
- file: detect premature end of file
|
- file: detect premature end of file
|
||||||
- smbclient: don't send credentials to MPD clients
|
- smbclient: don't send credentials to MPD clients
|
||||||
|
* output
|
||||||
|
- osx: improve sample rate selection
|
||||||
* Windows/Android:
|
* Windows/Android:
|
||||||
- fix Boost detection after breaking change in Meson 0.54
|
- fix Boost detection after breaking change in Meson 0.54
|
||||||
|
|
||||||
|
|
|
@ -342,7 +342,8 @@ osx_output_score_sample_rate(Float64 destination_rate, unsigned source_rate)
|
||||||
double int_portion;
|
double int_portion;
|
||||||
double frac_portion = modf(source_rate / destination_rate, &int_portion);
|
double frac_portion = modf(source_rate / destination_rate, &int_portion);
|
||||||
// prefer sample rates that are multiples of the source sample rate
|
// prefer sample rates that are multiples of the source sample rate
|
||||||
score += (1 - frac_portion) * 1000;
|
if (frac_portion < 0.01 || frac_portion >= 0.99)
|
||||||
|
score += 1000;
|
||||||
// prefer exact matches over other multiples
|
// prefer exact matches over other multiples
|
||||||
score += (int_portion == 1.0) ? 500 : 0;
|
score += (int_portion == 1.0) ? 500 : 0;
|
||||||
if (source_rate == destination_rate)
|
if (source_rate == destination_rate)
|
||||||
|
|
Loading…
Reference in New Issue