Bug 1140450 - Lower speex_resampler quality for Web Audio API. r=padenot
authorBaptiste Emmanuel <baptiste.em@gmail.com>
Thu, 21 May 2015 10:12:23 +0200
changeset 266227 708ccd68fc3a3ed839dfa4addeede3181ff38f92
parent 266226 6f16344cdb289f3f969330419c5fcaa7e39ae7f9
child 266228 7b2b57641325dd63cdd2ee75dcdfe51a43de88cd
push id2231
push usermichael.l.comella@gmail.com
push dateFri, 22 May 2015 20:04:59 +0000
reviewerspadenot
bugs1140450
milestone41.0a1
Bug 1140450 - Lower speex_resampler quality for Web Audio API. r=padenot
dom/media/MediaStreamGraph.cpp
dom/media/webaudio/AudioBufferSourceNode.cpp
dom/media/webaudio/WaveShaperNode.cpp
dom/media/webaudio/blink/HRTFElevation.cpp
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -2518,17 +2518,17 @@ SourceMediaStream::ResampleAudioToGraphS
   // If this segment is just silence, we delay instanciating the resampler.
   if (channels) {
     if (aTrackData->mResampler) {
       MOZ_ASSERT(aTrackData->mResamplerChannelCount == segment->ChannelCount());
     } else {
       SpeexResamplerState* state = speex_resampler_init(channels,
                                                         aTrackData->mInputRate,
                                                         GraphImpl()->GraphRate(),
-                                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
+                                                        SPEEX_RESAMPLER_QUALITY_MIN,
                                                         nullptr);
       if (!state) {
         return;
       }
       aTrackData->mResampler.own(state);
 #ifdef DEBUG
       aTrackData->mResamplerChannelCount = channels;
 #endif
--- a/dom/media/webaudio/AudioBufferSourceNode.cpp
+++ b/dom/media/webaudio/AudioBufferSourceNode.cpp
@@ -170,17 +170,17 @@ public:
 
     if (aOutRate == mBufferSampleRate && !mResampler) {
       return;
     }
 
     if (!mResampler) {
       mChannels = aChannels;
       mResampler = speex_resampler_init(mChannels, mBufferSampleRate, aOutRate,
-                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
+                                        SPEEX_RESAMPLER_QUALITY_MIN,
                                         nullptr);
     } else {
       uint32_t currentOutSampleRate, currentInSampleRate;
       speex_resampler_get_rate(mResampler, &currentInSampleRate,
                                &currentOutSampleRate);
       if (currentOutSampleRate == static_cast<uint32_t>(aOutRate)) {
         return;
       }
--- a/dom/media/webaudio/WaveShaperNode.cpp
+++ b/dom/media/webaudio/WaveShaperNode.cpp
@@ -82,22 +82,22 @@ public:
     if (aType == OverSampleType::None) {
       mBuffer.Clear();
       return;
     }
 
     mUpSampler = speex_resampler_init(aChannels,
                                       aSampleRate,
                                       aSampleRate * ValueOf(aType),
-                                      SPEEX_RESAMPLER_QUALITY_DEFAULT,
+                                      SPEEX_RESAMPLER_QUALITY_MIN,
                                       nullptr);
     mDownSampler = speex_resampler_init(aChannels,
                                         aSampleRate * ValueOf(aType),
                                         aSampleRate,
-                                        SPEEX_RESAMPLER_QUALITY_DEFAULT,
+                                        SPEEX_RESAMPLER_QUALITY_MIN,
                                         nullptr);
     mBuffer.SetLength(WEBAUDIO_BLOCK_SIZE*ValueOf(aType));
   }
 
   float* UpSample(uint32_t aChannel, const float* aInputData, uint32_t aBlocks)
   {
     uint32_t inSamples = WEBAUDIO_BLOCK_SIZE;
     uint32_t outSamples = WEBAUDIO_BLOCK_SIZE*aBlocks;
--- a/dom/media/webaudio/blink/HRTFElevation.cpp
+++ b/dom/media/webaudio/blink/HRTFElevation.cpp
@@ -227,17 +227,17 @@ nsReturnRef<HRTFElevation> HRTFElevation
     static_assert(NumberOfTotalAzimuths ==
                   NumberOfRawAzimuths * InterpolationFactor, "Not a multiple");
 
     HRTFKernelList kernelListL;
     kernelListL.SetLength(NumberOfTotalAzimuths);
 
     SpeexResamplerState* resampler = sampleRate == rawSampleRate ? nullptr :
         speex_resampler_init(1, rawSampleRate, sampleRate,
-                             SPEEX_RESAMPLER_QUALITY_DEFAULT, nullptr);
+                             SPEEX_RESAMPLER_QUALITY_MIN, nullptr);
 
     // Load convolution kernels from HRTF files.
     int interpolatedIndex = 0;
     for (unsigned rawIndex = 0; rawIndex < NumberOfRawAzimuths; ++rawIndex) {
         // Don't let elevation exceed maximum for this azimuth.
         int maxElevation = maxElevations[rawIndex];
         int actualElevation = min(elevation, maxElevation);