Bug 1264199: P3. Attempt to minimize audio quality loss and unnecessary processing. r=kinetik

We attempt to avoid unnecessary resampling of 44.1kHz and 48kHz content, for all others we use cubeb's preferred sampling rate as final sampling rate.

MozReview-Commit-ID: 413qnsDFHzY

--HG--
extra : rebase_source : 2c783be7f6d2ccaab88cee70372905ea92b690f4
This commit is contained in:
Jean-Yves Avenard 2016-04-13 17:55:48 +10:00
Родитель d679b38075
Коммит 16c0bd7cd9
2 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -286,6 +286,11 @@ public:
// Returns true when the audio stream is paused.
bool IsPaused();
static uint32_t GetPreferredRate()
{
CubebUtils::InitPreferredSampleRate();
return CubebUtils::PreferredSampleRate();
}
uint32_t GetRate() { return mOutRate; }
uint32_t GetChannels() { return mChannels; }
uint32_t GetOutChannels() { return mOutChannels; }

Просмотреть файл

@ -49,8 +49,20 @@ DecodedAudioDataSink::DecodedAudioDataSink(AbstractThread* aThread,
, mLastEndTime(0)
{
bool resampling = gfxPrefs::AudioSinkResampling();
uint32_t resamplingRate = gfxPrefs::AudioSinkResampleRate();
mOutputRate = resampling ? resamplingRate : mInfo.mRate;
if (resampling) {
mOutputRate = gfxPrefs::AudioSinkResampleRate();
} else if (mInfo.mRate == 44100 || mInfo.mRate == 48000) {
// The original rate is of good quality and we want to minimize unecessary
// resampling. The common scenario being that the sampling rate is one or
// the other, this allows to minimize audio quality regression and hoping
// content provider want change from those rates mid-stream.
mOutputRate = mInfo.mRate;
} else {
// We will resample all data to match cubeb's preferred sampling rate.
mOutputRate = AudioStream::GetPreferredRate();
}
mOutputChannels = mInfo.mChannels > 2 && gfxPrefs::AudioSinkForceStereo()
? 2 : mInfo.mChannels;