WebAudio: Use Logging instead of printf.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2012 22:11:52 +0000 (22:11 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Jan 2012 22:11:52 +0000 (22:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=74322

Reviewed by Darin Adler.

No new tests; no net change in functionality.

Add a new WebCoreLogLevel for WebAudio, and use this new log level instead of
printf statements in webaudio classes.

* platform/Logging.cpp:
(WebCore::getChannelFromName):
* platform/Logging.h:
* platform/mac/LoggingMac.mm:
(WebCore::InitializeLoggingChannelsIfNecessary):
* platform/audio/FFTFrame.cpp:
(WebCore::FFTFrame::print):
* webaudio/DefaultAudioDestinationNode.cpp:
(WebCore::DefaultAudioDestinationNode::initialize):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/Logging.cpp
Source/WebCore/platform/Logging.h
Source/WebCore/platform/audio/FFTFrame.cpp
Source/WebCore/platform/mac/LoggingMac.mm
Source/WebCore/webaudio/DefaultAudioDestinationNode.cpp

index cfeadae..7009b50 100644 (file)
@@ -1,3 +1,25 @@
+2011-12-12  Jer Noble  <jer.noble@apple.com>
+
+        WebAudio: Use Logging instead of printf.
+        https://bugs.webkit.org/show_bug.cgi?id=74322
+
+        Reviewed by Darin Adler.
+
+        No new tests; no net change in functionality.
+
+        Add a new WebCoreLogLevel for WebAudio, and use this new log level instead of 
+        printf statements in webaudio classes.
+
+        * platform/Logging.cpp:
+        (WebCore::getChannelFromName):
+        * platform/Logging.h:
+        * platform/mac/LoggingMac.mm:
+        (WebCore::InitializeLoggingChannelsIfNecessary):
+        * platform/audio/FFTFrame.cpp:
+        (WebCore::FFTFrame::print):
+        * webaudio/DefaultAudioDestinationNode.cpp:
+        (WebCore::DefaultAudioDestinationNode::initialize):
+
 2012-01-12  Anders Carlsson  <andersca@apple.com>
 
         Make ScrollElasticityController members private
index 8f64282..bd01964 100644 (file)
@@ -61,6 +61,8 @@ WTFLogChannel LogProgress =          { 0x08000000, "WebCoreLogLevel", WTFLogChan
 
 WTFLogChannel LogFileAPI =           { 0x10000000, "WebCoreLogLevel", WTFLogChannelOff };
 
+WTFLogChannel LogWebAudio =          { 0x20000000, "WebCoreLogLevel", WTFLogChannelOff };
+
 WTFLogChannel* getChannelFromName(const String& channelName)
 {
     if (!(channelName.length() >= 2))
@@ -135,6 +137,9 @@ WTFLogChannel* getChannelFromName(const String& channelName)
     if (equalIgnoringCase(channelName, String("FileAPI")))
         return &LogFileAPI;
 
+    if (equalIgnoringCase(channelName, String("WebAudio")))
+        return &LogWebAudio;
+
     return 0;
 }
 
index 0092699..8201f16 100644 (file)
@@ -59,6 +59,7 @@ namespace WebCore {
     extern WTFLogChannel LogArchives;
     extern WTFLogChannel LogProgress;
     extern WTFLogChannel LogFileAPI;
+    extern WTFLogChannel LogWebAudio;
 
     void initializeLoggingChannelsIfNecessary();
     WTFLogChannel* getChannelFromName(const String& channelName);
index fbb5dfe..4f032a2 100644 (file)
@@ -36,6 +36,7 @@
 #include <stdio.h>
 #endif
 
+#include "Logging.h"
 #include <wtf/Complex.h>
 #include <wtf/MathExtras.h>
 #include <wtf/OwnPtr.h>
@@ -253,8 +254,8 @@ void FFTFrame::print()
     FFTFrame& frame = *this;
     float* realP = frame.realData();
     float* imagP = frame.imagData();
-    printf("**** \n");
-    printf("DC = %f : nyquist = %f\n", realP[0], imagP[0]);
+    LOG(WebAudio, "**** \n");
+    LOG(WebAudio, "DC = %f : nyquist = %f\n", realP[0], imagP[0]);
 
     int n = m_FFTSize / 2;
 
@@ -262,9 +263,9 @@ void FFTFrame::print()
         double mag = sqrt(realP[i] * realP[i] + imagP[i] * imagP[i]);
         double phase = atan2(realP[i], imagP[i]);
 
-        printf("[%d] (%f %f)\n", i, mag, phase);
+        LOG(WebAudio, "[%d] (%f %f)\n", i, mag, phase);
     }
-    printf("****\n");
+    LOG(WebAudio, "****\n");
 }
 #endif // NDEBUG
 
index 7f2ee1f..45cf6e5 100644 (file)
@@ -72,6 +72,7 @@ void initializeLoggingChannelsIfNecessary()
     initializeWithUserDefault(LogMedia);
     initializeWithUserDefault(LogPlugins);
     initializeWithUserDefault(LogArchives);
+    initializeWithUserDefault(LogWebAudio);
 }
 
 }
index f7db34e..e264563 100644 (file)
@@ -28,9 +28,7 @@
 
 #include "DefaultAudioDestinationNode.h"
 
-#ifndef NDEBUG
-#include <stdio.h>
-#endif
+#include "Logging.h"
 
 namespace WebCore {
     
@@ -51,9 +49,7 @@ void DefaultAudioDestinationNode::initialize()
         return;
 
     float hardwareSampleRate = AudioDestination::hardwareSampleRate();
-#ifndef NDEBUG    
-    fprintf(stderr, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
-#endif
+    LOG(WebAudio, ">>>> hardwareSampleRate = %f\n", hardwareSampleRate);
     
     m_destination = AudioDestination::create(*this, hardwareSampleRate);