Bug 898291 - Erase azimuth/elevation history when reset()ing HRTFPanner. r=ehsan, a=lsblakk
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 25 Oct 2013 14:05:42 +1300
changeset 286409 d8a337af4346ac8bc75f73f9e48f92c7c0474dc2
parent 286408 bb69444071a90ea4977086194605372dc85952e1
child 286410 da6663c9edcd718f07b3cc54c353367fe3847342
push id218
push userryanvm@gmail.com
push dateWed, 16 Dec 2015 22:58:33 +0000
reviewersehsan, lsblakk
bugs898291
milestone26.0
Bug 898291 - Erase azimuth/elevation history when reset()ing HRTFPanner. r=ehsan, a=lsblakk So that old cross-fade info does not distort new sound when a PannerNode finishes and restarts.
content/media/webaudio/blink/HRTFPanner.cpp
--- a/content/media/webaudio/blink/HRTFPanner.cpp
+++ b/content/media/webaudio/blink/HRTFPanner.cpp
@@ -42,19 +42,18 @@ const double MaxDelayTimeSeconds = 0.002
 const int UninitializedAzimuth = -1;
 const unsigned RenderingQuantum = 128;
 
 HRTFPanner::HRTFPanner(float sampleRate, mozilla::TemporaryRef<HRTFDatabaseLoader> databaseLoader)
     : m_databaseLoader(databaseLoader)
     , m_sampleRate(sampleRate)
     , m_crossfadeSelection(CrossfadeSelection1)
     , m_azimuthIndex1(UninitializedAzimuth)
-    , m_elevation1(0)
     , m_azimuthIndex2(UninitializedAzimuth)
-    , m_elevation2(0)
+    // m_elevation1 and m_elevation2 are initialized in pan()
     , m_crossfadeX(0)
     , m_crossfadeIncr(0)
     , m_convolverL1(HRTFElevation::fftSizeForSampleRate(sampleRate))
     , m_convolverR1(m_convolverL1.fftSize())
     , m_convolverL2(m_convolverL1.fftSize())
     , m_convolverR2(m_convolverL1.fftSize())
     , m_delayLineL(ceilf(MaxDelayTimeSeconds * sampleRate),
                    WebAudioUtils::ComputeSmoothingRate(0.02, sampleRate))
@@ -72,16 +71,22 @@ HRTFPanner::HRTFPanner(float sampleRate,
 
 HRTFPanner::~HRTFPanner()
 {
     MOZ_COUNT_DTOR(HRTFPanner);
 }
 
 void HRTFPanner::reset()
 {
+    m_azimuthIndex1 = UninitializedAzimuth;
+    m_azimuthIndex2 = UninitializedAzimuth;
+    // m_elevation1 and m_elevation2 are initialized in pan()
+    m_crossfadeSelection = CrossfadeSelection1;
+    m_crossfadeX = 0.0f;
+    m_crossfadeIncr = 0.0f;
     m_convolverL1.reset();
     m_convolverR1.reset();
     m_convolverL2.reset();
     m_convolverR2.reset();
     m_delayLineL.Reset();
     m_delayLineR.Reset();
 }