AudioPannerNode::setPanningModel() does not update m_panningModel properly
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 03:11:43 +0000 (03:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 28 Jan 2012 03:11:43 +0000 (03:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66830

Patch by Raymond Toy <rtoy@google.com> on 2012-01-27
Reviewed by Kenneth Russell.

Source/WebCore:

Test: webaudio/panner-set-model.html

* webaudio/AudioPannerNode.cpp:
(WebCore::AudioPannerNode::setPanningModel):  Update
m_panningModel appropriately.  Also silently do nothing if the
model is invalid.

LayoutTests:

* webaudio/panner-set-model-expected.txt: Added.
* webaudio/panner-set-model.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@106174 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webaudio/panner-set-model-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/panner-set-model.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/webaudio/AudioPannerNode.cpp

index 610fde7..f11c977 100644 (file)
@@ -1,3 +1,13 @@
+2012-01-27  Raymond Toy  <rtoy@google.com>
+
+        AudioPannerNode::setPanningModel() does not update m_panningModel properly
+        https://bugs.webkit.org/show_bug.cgi?id=66830
+
+        Reviewed by Kenneth Russell.
+
+        * webaudio/panner-set-model-expected.txt: Added.
+        * webaudio/panner-set-model.html: Added.
+
 2012-01-27  Michael Saboff  <msaboff@apple.com>
 
         New Regression Test for r106075
diff --git a/LayoutTests/webaudio/panner-set-model-expected.txt b/LayoutTests/webaudio/panner-set-model-expected.txt
new file mode 100644 (file)
index 0000000..1b73964
--- /dev/null
@@ -0,0 +1,13 @@
+Test if panningModel can be set and read.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS Panner set to EQUALPOWER model and read correctly.
+PASS Panner set to HRTF model and read correctly.
+PASS Panner set to SOUNDFIELD model and read correctly.
+PASS Panner set to invalid model and panningModel did not change.
+PASS Panning model tests passed.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/webaudio/panner-set-model.html b/LayoutTests/webaudio/panner-set-model.html
new file mode 100644 (file)
index 0000000..35b171f
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+  <head>
+    <link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
+    <script src="resources/audio-testing.js"></script>
+    <script src="../fast/js/resources/js-test-pre.js"></script>
+    <title>Test Panner setPanningModel values.</title>
+  </head>
+
+  <body>
+    <div id="description"></div>
+    <div id="console"></div>
+
+    <script>
+      description("Test if panningModel can be set and read.");
+
+      // Test to see if we panningModel is updated when we set it.
+      function runTest() {
+          if (window.layoutTestController) {
+              layoutTestController.dumpAsText();
+              layoutTestController.waitUntilDone();
+          }
+
+          window.jsTestIsAsync = true;
+
+          var context = new webkitAudioContext();
+          var success = true;
+          var panner = context.createPanner();
+
+          // Set the panning model and see if it can be read back
+          // correctly.
+          panner.panningModel = panner.EQUALPOWER;
+          if (panner.panningModel == 0) {
+              testPassed("Panner set to EQUALPOWER model and read correctly.");
+          } else {
+              testFailed("Panner model set to EQUALPOWER (0) but returned " + panner.panningModel);
+              success = false;
+          }
+      
+          panner.panningModel = panner.HRTF;
+          if (panner.panningModel == 1) {
+              testPassed("Panner set to HRTF model and read correctly.");
+          } else {
+              testFailed("Panner model set to HRTF (1) but returned " + panner.panningModel);
+              success = false;
+          }
+      
+          panner.panningModel = panner.SOUNDFIELD;
+          if (panner.panningModel == 2) {
+              testPassed("Panner set to SOUNDFIELD model and read correctly.");
+          } else {
+              testFailed("Panner model set to SOUNDFIELD (2) but returned " + panner.panningModel);
+              success = false;
+          }
+
+          // Set to invalid value and make sure it didn't change from
+          // it's previous setting (of 2).
+          panner.panningModel = 99;
+          if (panner.panningModel == 2) {
+              testPassed("Panner set to invalid model and panningModel did not change.");
+          } else {
+              testFailed("Panner set to invalid model, but the panningModel changed from 2 to " + panner.panningModel);
+              success = false;
+          }
+          
+          if (success) {
+              testPassed("Panning model tests passed.");
+          } else {
+              testFailed("Panning model tests failed.");
+          }
+
+          finishJSTest();
+      }
+
+      runTest();
+      successfullyParsed = true;
+
+    </script>
+
+    <script src="../fast/js/resources/js-test-post.js"></script>
+  </body>
+</html>
index a67b1b7..6c58bf9 100644 (file)
@@ -1,3 +1,17 @@
+2012-01-27  Raymond Toy  <rtoy@google.com>
+
+        AudioPannerNode::setPanningModel() does not update m_panningModel properly
+        https://bugs.webkit.org/show_bug.cgi?id=66830
+
+        Reviewed by Kenneth Russell.
+
+        Test: webaudio/panner-set-model.html
+
+        * webaudio/AudioPannerNode.cpp:
+        (WebCore::AudioPannerNode::setPanningModel):  Update
+        m_panningModel appropriately.  Also silently do nothing if the
+        model is invalid.
+
 2012-01-27  Chris Rogers  <crogers@google.com>
 
         HRTFPanner could have high-quality mode for smoother transitions
index faf7f15..d88aba4 100644 (file)
@@ -152,9 +152,19 @@ AudioListener* AudioPannerNode::listener()
 
 void AudioPannerNode::setPanningModel(unsigned short model)
 {
-    if (!m_panner.get() || model != m_panningModel) {
-        OwnPtr<Panner> newPanner = Panner::create(model, sampleRate());
-        m_panner = newPanner.release();
+    switch (model) {
+    case EQUALPOWER:
+    case HRTF:
+    case SOUNDFIELD:
+        if (!m_panner.get() || model != m_panningModel) {
+            OwnPtr<Panner> newPanner = Panner::create(model, sampleRate());
+            m_panner = newPanner.release();
+            m_panningModel = model;
+        }
+        break;
+    default:
+        // FIXME: consider throwing an exception for illegal model values.
+        break;
     }
 }