Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/PannerNode.cpp

Issue 1978403004: Add UMA histograms for WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use CustomCountHistogram Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved. 2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 13 matching lines...) Expand all
24 24
25 #include "modules/webaudio/PannerNode.h" 25 #include "modules/webaudio/PannerNode.h"
26 #include "bindings/core/v8/ExceptionMessages.h" 26 #include "bindings/core/v8/ExceptionMessages.h"
27 #include "bindings/core/v8/ExceptionState.h" 27 #include "bindings/core/v8/ExceptionState.h"
28 #include "core/dom/ExceptionCode.h" 28 #include "core/dom/ExceptionCode.h"
29 #include "core/dom/ExecutionContext.h" 29 #include "core/dom/ExecutionContext.h"
30 #include "modules/webaudio/AbstractAudioContext.h" 30 #include "modules/webaudio/AbstractAudioContext.h"
31 #include "modules/webaudio/AudioBufferSourceNode.h" 31 #include "modules/webaudio/AudioBufferSourceNode.h"
32 #include "modules/webaudio/AudioNodeInput.h" 32 #include "modules/webaudio/AudioNodeInput.h"
33 #include "modules/webaudio/AudioNodeOutput.h" 33 #include "modules/webaudio/AudioNodeOutput.h"
34 #include "platform/Histogram.h"
34 #include "platform/audio/HRTFPanner.h" 35 #include "platform/audio/HRTFPanner.h"
35 #include "wtf/MathExtras.h" 36 #include "wtf/MathExtras.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 static void fixNANs(double& x) 40 static void fixNANs(double& x)
40 { 41 {
41 if (std::isnan(x) || std::isinf(x)) 42 if (std::isnan(x) || std::isinf(x))
42 x = 0.0; 43 x = 0.0;
43 } 44 }
44 45
45 PannerHandler::PannerHandler( 46 PannerHandler::PannerHandler(
46 AudioNode& node, float sampleRate, 47 AudioNode& node, float sampleRate,
47 AudioParamHandler& positionX, 48 AudioParamHandler& positionX,
48 AudioParamHandler& positionY, 49 AudioParamHandler& positionY,
49 AudioParamHandler& positionZ, 50 AudioParamHandler& positionZ,
50 AudioParamHandler& orientationX, 51 AudioParamHandler& orientationX,
51 AudioParamHandler& orientationY, 52 AudioParamHandler& orientationY,
52 AudioParamHandler& orientationZ) 53 AudioParamHandler& orientationZ)
53 : AudioHandler(NodeTypePanner, node, sampleRate) 54 : AudioHandler(NodeTypePanner, node, sampleRate)
54 , m_listener(node.context()->listener()) 55 , m_listener(node.context()->listener())
55 , m_panningModel(Panner::PanningModelEqualPower)
56 , m_distanceModel(DistanceEffect::ModelInverse) 56 , m_distanceModel(DistanceEffect::ModelInverse)
57 , m_isAzimuthElevationDirty(true) 57 , m_isAzimuthElevationDirty(true)
58 , m_isDistanceConeGainDirty(true) 58 , m_isDistanceConeGainDirty(true)
59 , m_lastGain(-1.0) 59 , m_lastGain(-1.0)
60 , m_cachedAzimuth(0) 60 , m_cachedAzimuth(0)
61 , m_cachedElevation(0) 61 , m_cachedElevation(0)
62 , m_cachedDistanceConeGain(1.0f) 62 , m_cachedDistanceConeGain(1.0f)
63 , m_positionX(positionX) 63 , m_positionX(positionX)
64 , m_positionY(positionY) 64 , m_positionY(positionY)
65 , m_positionZ(positionZ) 65 , m_positionZ(positionZ)
66 , m_orientationX(orientationX) 66 , m_orientationX(orientationX)
67 , m_orientationY(orientationY) 67 , m_orientationY(orientationY)
68 , m_orientationZ(orientationZ) 68 , m_orientationZ(orientationZ)
69 { 69 {
70 // Load the HRTF database asynchronously so we don't block the Javascript th read while creating the HRTF database. 70 // Load the HRTF database asynchronously so we don't block the Javascript th read while creating the HRTF database.
71 // The HRTF panner will return zeroes until the database is loaded. 71 // The HRTF panner will return zeroes until the database is loaded.
72 listener()->createAndLoadHRTFDatabaseLoader(node.context()->sampleRate()); 72 listener()->createAndLoadHRTFDatabaseLoader(node.context()->sampleRate());
73 73
74 addInput(); 74 addInput();
75 addOutput(2); 75 addOutput(2);
76 76
77 // Node-specific default mixing rules. 77 // Node-specific default mixing rules.
78 m_channelCount = 2; 78 m_channelCount = 2;
79 m_channelCountMode = ClampedMax; 79 m_channelCountMode = ClampedMax;
80 m_channelInterpretation = AudioBus::Speakers; 80 m_channelInterpretation = AudioBus::Speakers;
81 81
82 // Explicitly set the default panning model here so that the histograms
83 // include the default value.
84 setPanningModel("equalpower");
85
82 initialize(); 86 initialize();
83 } 87 }
84 88
85 PassRefPtr<PannerHandler> PannerHandler::create( 89 PassRefPtr<PannerHandler> PannerHandler::create(
86 AudioNode& node, float sampleRate, 90 AudioNode& node, float sampleRate,
87 AudioParamHandler& positionX, 91 AudioParamHandler& positionX,
88 AudioParamHandler& positionY, 92 AudioParamHandler& positionY,
89 AudioParamHandler& positionZ, 93 AudioParamHandler& positionZ,
90 AudioParamHandler& orientationX, 94 AudioParamHandler& orientationX,
91 AudioParamHandler& orientationY, 95 AudioParamHandler& orientationY,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 void PannerHandler::setPanningModel(const String& model) 281 void PannerHandler::setPanningModel(const String& model)
278 { 282 {
279 if (model == "equalpower") 283 if (model == "equalpower")
280 setPanningModel(Panner::PanningModelEqualPower); 284 setPanningModel(Panner::PanningModelEqualPower);
281 else if (model == "HRTF") 285 else if (model == "HRTF")
282 setPanningModel(Panner::PanningModelHRTF); 286 setPanningModel(Panner::PanningModelHRTF);
283 } 287 }
284 288
285 bool PannerHandler::setPanningModel(unsigned model) 289 bool PannerHandler::setPanningModel(unsigned model)
286 { 290 {
291 DEFINE_STATIC_LOCAL(EnumerationHistogram, panningModelHistogram,
292 ("WebAudio.PannerNode.PanningModel", 2));
293 panningModelHistogram.count(model);
294
287 switch (model) { 295 switch (model) {
288 case Panner::PanningModelEqualPower: 296 case Panner::PanningModelEqualPower:
289 case Panner::PanningModelHRTF: 297 case Panner::PanningModelHRTF:
290 if (!m_panner.get() || model != m_panningModel) { 298 if (!m_panner.get() || model != m_panningModel) {
291 // This synchronizes with process(). 299 // This synchronizes with process().
292 MutexLocker processLocker(m_processLock); 300 MutexLocker processLocker(m_processLock);
293 m_panner = Panner::create(model, sampleRate(), listener()->hrtfDatab aseLoader()); 301 m_panner = Panner::create(model, sampleRate(), listener()->hrtfDatab aseLoader());
294 m_panningModel = model; 302 m_panningModel = model;
295 } 303 }
296 break; 304 break;
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 visitor->trace(m_positionZ); 780 visitor->trace(m_positionZ);
773 781
774 visitor->trace(m_orientationX); 782 visitor->trace(m_orientationX);
775 visitor->trace(m_orientationY); 783 visitor->trace(m_orientationY);
776 visitor->trace(m_orientationZ); 784 visitor->trace(m_orientationZ);
777 785
778 AudioNode::trace(visitor); 786 AudioNode::trace(visitor);
779 } 787 }
780 788
781 } // namespace blink 789 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698