The officially official Devuan Forum!

You are not logged in.

#1 2025-10-06 17:20:59

igorzwx
Member
Registered: 2024-05-06
Posts: 330  

How to disable resamplig in Firefox

Resampling in Firefox is easy to disable:

$ cat firefox/dom/media/VideoUtils.cpp | grep DecideAudioPlaybackSampleRate -A27
uint32_t DecideAudioPlaybackSampleRate(const AudioInfo& aInfo,
                                       bool aShouldResistFingerprinting) {
//  bool resampling = StaticPrefs::media_resampling_enabled();

//  uint32_t rate = 0;

//  if (resampling) {
//    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). 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 > 768000) {
//      // bogus rate, fall back to something else;
//      rate = 48000;
//    }
//  }
//  MOZ_DIAGNOSTIC_ASSERT(rate, "output rate can't be 0.");
    
//  return rate;

  return aInfo.mRate;
}

Firefox is easy to compile.

What is special about Chromium is that it has many resamplers inside:

[BUG] WebAudio always resampling to the output device sample rate, even if a different one is specified.
_https://issues.chromium.org/issues/40944208

Offline

#2 Yesterday 13:32:06

igorzwx
Member
Registered: 2024-05-06
Posts: 330  

Re: How to disable resamplig in Firefox

_https://searchfox.org/firefox-main/source/dom/media/AudioConverter.cpp

#include "AudioConverter.h"

#include <speex/speex_resampler.h>

Open the Firefox browser.
Type about:support into the address bar and press Enter.
The page will load, showing a detailed report of your Firefox setup.

To change the "Preferred Sample Rate" in about:support, you have to edit the source code with a text editor and recompile Firefox. For example:

_https://searchfox.org/firefox-main/source/dom/media/CubebUtils.cpp

$ cat firefox/dom/media/CubebUtils.cpp | grep PreferredSampleRate\(bool -A15
uint32_t PreferredSampleRate(bool aShouldResistFingerprinting) {
  StaticMutexAutoLock lock(sMutex);
//  if (sCubebForcedSampleRate) {
//    return sCubebForcedSampleRate;
//  }
//  if (aShouldResistFingerprinting) {
//    return 44100;
//  }
//  if (!InitPreferredSampleRate()) {
//    return 44100;
//  }
//  MOZ_ASSERT(sPreferredSampleRate);
//  return sPreferredSampleRate;
    return 48000;
}

Offline

Board footer