Bug 1496497 - Consider 768kHz files valid, but resample down to 384kHz for playback. r=media-playback-reviewers,alwu

Differential Revision: https://phabricator.services.mozilla.com/D205873
This commit is contained in:
Paul Adenot 2024-04-02 12:56:36 +00:00
parent 6959b6a939
commit ae57f69e55
2 changed files with 5 additions and 4 deletions

View File

@ -562,7 +562,7 @@ class AudioInfo : public TrackInfo {
bool operator==(const AudioInfo& rhs) const;
static const uint32_t MAX_RATE = 640000;
static const uint32_t MAX_RATE = 768000;
static const uint32_t MAX_CHANNEL_COUNT = 256;
bool IsValid() const override {

View File

@ -188,12 +188,13 @@ uint32_t DecideAudioPlaybackSampleRate(const AudioInfo& aInfo,
rate = 48000;
} else if (aInfo.mRate >= 44100) {
// The original rate is of good quality and we want to minimize unecessary
// resampling, so we let cubeb decide how to resample (if needed).
rate = aInfo.mRate;
// resampling, so we let cubeb decide how to resample (if needed). Cap to
// 384kHz for good measure.
rate = std::min<unsigned>(aInfo.mRate, 384000u);
} else {
// We will resample all data to match cubeb's preferred sampling rate.
rate = CubebUtils::PreferredSampleRate(aShouldResistFingerprinting);
if (rate > 384000) {
if (rate > 768000) {
// bogus rate, fall back to something else;
rate = 48000;
}