Shiny Drum Machine doesn't play in TRATS device.
authorPraveen R Jadhav <praveen.j@samsung.com>
Fri, 3 May 2013 11:00:10 +0000 (20:00 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 5 Jun 2013 02:01:44 +0000 (11:01 +0900)
[Title] Shiny Drum Machine doesn't play in TRATS device.
[Problem] Total processing time of Audio Nodes is more than max latency.
[Cause] Convolver Node takes more time than max latency and hence no audio is heard.
[Solution] Convolver Node latency is checked before processing.

Change-Id: I2f947eab18e4cb76b78fd4955648455694cf7cbf

Source/WebCore/Modules/webaudio/ConvolverNode.cpp
Source/WebCore/Modules/webaudio/ConvolverNode.h

index c8010d0..2c95424 100644 (file)
@@ -33,6 +33,9 @@
 #include "AudioNodeInput.h"
 #include "AudioNodeOutput.h"
 #include "Reverb.h"
+#if ENABLE(TIZEN_WEB_AUDIO)
+#include <wtf/CurrentTime.h>
+#endif
 #include <wtf/MainThread.h>
 
 // Note about empirical tuning:
@@ -48,6 +51,10 @@ namespace WebCore {
 ConvolverNode::ConvolverNode(AudioContext* context, float sampleRate)
     : AudioNode(context, sampleRate)
     , m_normalize(true)
+#if ENABLE(TIZEN_WEB_AUDIO)
+    , m_latencyTime(0.0)
+    , m_resetCount(0)
+#endif
 {
     addInput(adoptPtr(new AudioNodeInput(this)));
     addOutput(adoptPtr(new AudioNodeOutput(this, 2)));
@@ -67,6 +74,22 @@ void ConvolverNode::process(size_t framesToProcess)
     AudioBus* outputBus = output(0)->bus();
     ASSERT(outputBus);
 
+#if ENABLE(TIZEN_WEB_AUDIO)
+    if (m_resetCount > 5 * sampleRate()) {
+        // Wait for 5 sec before checking again.
+        m_resetCount = 0;
+        m_latencyTime = 0.0;
+    }
+
+    if (m_latencyTime > framesToProcess / sampleRate()) {
+        m_resetCount += framesToProcess;
+        outputBus->zero();
+        return;
+    }
+
+    double currentTime = WTF::currentTime();
+#endif
+
     // Synchronize with possible dynamic changes to the impulse response.
     MutexTryLocker tryLocker(m_processLock);
     if (tryLocker.locked()) {
@@ -83,6 +106,10 @@ void ConvolverNode::process(size_t framesToProcess)
         // Too bad - the tryLock() failed.  We must be in the middle of setting a new impulse response.
         outputBus->zero();
     }
+
+#if ENABLE(TIZEN_WEB_AUDIO)
+    m_latencyTime = WTF::currentTime() - currentTime;
+#endif
 }
 
 void ConvolverNode::reset()
index 6d58918..6465686 100644 (file)
@@ -71,6 +71,10 @@ private:
 
     // Normalize the impulse response or not. Must default to true.
     bool m_normalize;
+#if ENABLE(TIZEN_WEB_AUDIO)
+    double m_latencyTime;
+    unsigned m_resetCount;
+#endif
 };
 
 } // namespace WebCore