⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267544 in webkit


Ignore:
Timestamp:
Sep 24, 2020, 1:10:05 PM (6 years ago)
Author:
Chris Dumez
Message:

Use more inline initialization and constexpr in WebAudio code
https://bugs.webkit.org/show_bug.cgi?id=216939

Reviewed by Darin Adler.

Use more inline initialization and constexpr in WebAudio code.

  • Modules/webaudio/AudioBufferSourceNode.cpp:
  • Modules/webaudio/AudioDestinationNode.cpp:

(WebCore::AudioDestinationNode::AudioDestinationNode):

  • Modules/webaudio/AudioDestinationNode.h:
  • Modules/webaudio/AudioNodeOutput.cpp:

(WebCore::AudioNodeOutput::AudioNodeOutput):

  • Modules/webaudio/AudioNodeOutput.h:
  • Modules/webaudio/AudioParamTimeline.h:
  • Modules/webaudio/AudioScheduledSourceNode.cpp:

(WebCore::AudioScheduledSourceNode::AudioScheduledSourceNode):
(WebCore::AudioScheduledSourceNode::updateSchedulingInfo):

  • Modules/webaudio/AudioScheduledSourceNode.h:
  • Modules/webaudio/AudioSummingJunction.cpp:

(WebCore::AudioSummingJunction::AudioSummingJunction):

  • Modules/webaudio/AudioSummingJunction.h:
  • Modules/webaudio/BiquadDSPKernel.cpp:
  • Modules/webaudio/BiquadProcessor.cpp:

(WebCore::BiquadProcessor::BiquadProcessor):

  • Modules/webaudio/BiquadProcessor.h:
  • Modules/webaudio/ConvolverNode.cpp:
  • Modules/webaudio/DefaultAudioDestinationNode.cpp:
  • Modules/webaudio/DelayNode.cpp:
  • Modules/webaudio/DynamicsCompressorNode.cpp:
  • Modules/webaudio/MediaElementAudioSourceNode.cpp:
  • Modules/webaudio/PeriodicWave.cpp:

(WebCore::PeriodicWave::PeriodicWave):
(WebCore::PeriodicWave::waveDataForFundamentalFrequency):
(WebCore::PeriodicWave::numberOfPartialsForRange const):

  • Modules/webaudio/PeriodicWave.h:
  • Modules/webaudio/RealtimeAnalyser.cpp:

(WebCore::RealtimeAnalyser::RealtimeAnalyser):

  • Modules/webaudio/RealtimeAnalyser.h:
  • Modules/webaudio/ScriptProcessorNode.cpp:

(WebCore::ScriptProcessorNode::ScriptProcessorNode):

  • Modules/webaudio/ScriptProcessorNode.h:
  • Modules/webaudio/WaveShaperProcessor.cpp:

(WebCore::WaveShaperProcessor::WaveShaperProcessor):

  • Modules/webaudio/WaveShaperProcessor.h:
  • Modules/webaudio/WebKitAudioContext.cpp:
  • Modules/webaudio/WebKitAudioPannerNode.cpp:

(WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):

  • Modules/webaudio/WebKitAudioPannerNode.h:
  • platform/audio/AudioBus.cpp:

(WebCore::AudioBus::AudioBus):

  • platform/audio/AudioBus.h:
  • platform/audio/AudioChannel.h:
  • platform/audio/AudioDSPKernelProcessor.cpp:

(WebCore::AudioDSPKernelProcessor::AudioDSPKernelProcessor):

  • platform/audio/AudioDSPKernelProcessor.h:
  • platform/audio/AudioHardwareListener.cpp:

(WebCore::AudioHardwareListener::AudioHardwareListener):

  • platform/audio/AudioHardwareListener.h:
  • platform/audio/AudioResampler.cpp:

(WebCore::AudioResampler::AudioResampler):

  • platform/audio/AudioResampler.h:
  • platform/audio/AudioResamplerKernel.cpp:

(WebCore::AudioResamplerKernel::AudioResamplerKernel):

  • platform/audio/AudioResamplerKernel.h:
  • platform/audio/Biquad.cpp:
  • platform/audio/Cone.cpp:
  • platform/audio/Cone.h:
  • platform/audio/Distance.cpp:
  • platform/audio/Distance.h:
  • platform/audio/DownSampler.cpp:

(WebCore::DownSampler::DownSampler):

  • platform/audio/DownSampler.h:
  • platform/audio/DynamicsCompressorKernel.cpp:

(WebCore::DynamicsCompressorKernel::DynamicsCompressorKernel):

  • platform/audio/DynamicsCompressorKernel.h:
  • platform/audio/EqualPowerPanner.cpp:

(WebCore::EqualPowerPanner::EqualPowerPanner):

  • platform/audio/EqualPowerPanner.h:
  • platform/audio/FFTConvolver.cpp:

(WebCore::FFTConvolver::FFTConvolver):

  • platform/audio/FFTConvolver.h:
  • platform/audio/HRTFDatabase.cpp:

(WebCore::HRTFDatabase::HRTFDatabase):

  • platform/audio/HRTFDatabase.h:
  • platform/audio/HRTFElevation.cpp:
  • platform/audio/HRTFElevation.h:
  • platform/audio/HRTFKernel.cpp:

(WebCore::HRTFKernel::HRTFKernel):

  • platform/audio/HRTFKernel.h:
  • platform/audio/HRTFPanner.cpp:

(WebCore::HRTFPanner::HRTFPanner):

  • platform/audio/HRTFPanner.h:
  • platform/audio/PlatformMediaSession.cpp:

(WebCore::PlatformMediaSession::PlatformMediaSession):

  • platform/audio/PlatformMediaSession.h:
  • platform/audio/PushPullFIFO.cpp:

(WebCore::PushPullFIFO::PushPullFIFO):

  • platform/audio/PushPullFIFO.h:
  • platform/audio/Reverb.cpp:
  • platform/audio/ReverbAccumulationBuffer.cpp:

(WebCore::ReverbAccumulationBuffer::ReverbAccumulationBuffer):

  • platform/audio/ReverbAccumulationBuffer.h:
  • platform/audio/ReverbConvolver.cpp:
  • platform/audio/ReverbConvolverStage.cpp:

(WebCore::ReverbConvolverStage::ReverbConvolverStage):

  • platform/audio/ReverbConvolverStage.h:
  • platform/audio/ReverbInputBuffer.cpp:

(WebCore::ReverbInputBuffer::ReverbInputBuffer):

  • platform/audio/ReverbInputBuffer.h:
Location:
trunk/Source/WebCore
Files:
74 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267543 r267544  
     12020-09-24  Chris Dumez  <cdumez@apple.com>
     2
     3        Use more inline initialization and constexpr in WebAudio code
     4        https://bugs.webkit.org/show_bug.cgi?id=216939
     5
     6        Reviewed by Darin Adler.
     7
     8        Use more inline initialization and constexpr in WebAudio code.
     9
     10        * Modules/webaudio/AudioBufferSourceNode.cpp:
     11        * Modules/webaudio/AudioDestinationNode.cpp:
     12        (WebCore::AudioDestinationNode::AudioDestinationNode):
     13        * Modules/webaudio/AudioDestinationNode.h:
     14        * Modules/webaudio/AudioNodeOutput.cpp:
     15        (WebCore::AudioNodeOutput::AudioNodeOutput):
     16        * Modules/webaudio/AudioNodeOutput.h:
     17        * Modules/webaudio/AudioParamTimeline.h:
     18        * Modules/webaudio/AudioScheduledSourceNode.cpp:
     19        (WebCore::AudioScheduledSourceNode::AudioScheduledSourceNode):
     20        (WebCore::AudioScheduledSourceNode::updateSchedulingInfo):
     21        * Modules/webaudio/AudioScheduledSourceNode.h:
     22        * Modules/webaudio/AudioSummingJunction.cpp:
     23        (WebCore::AudioSummingJunction::AudioSummingJunction):
     24        * Modules/webaudio/AudioSummingJunction.h:
     25        * Modules/webaudio/BiquadDSPKernel.cpp:
     26        * Modules/webaudio/BiquadProcessor.cpp:
     27        (WebCore::BiquadProcessor::BiquadProcessor):
     28        * Modules/webaudio/BiquadProcessor.h:
     29        * Modules/webaudio/ConvolverNode.cpp:
     30        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
     31        * Modules/webaudio/DelayNode.cpp:
     32        * Modules/webaudio/DynamicsCompressorNode.cpp:
     33        * Modules/webaudio/MediaElementAudioSourceNode.cpp:
     34        * Modules/webaudio/PeriodicWave.cpp:
     35        (WebCore::PeriodicWave::PeriodicWave):
     36        (WebCore::PeriodicWave::waveDataForFundamentalFrequency):
     37        (WebCore::PeriodicWave::numberOfPartialsForRange const):
     38        * Modules/webaudio/PeriodicWave.h:
     39        * Modules/webaudio/RealtimeAnalyser.cpp:
     40        (WebCore::RealtimeAnalyser::RealtimeAnalyser):
     41        * Modules/webaudio/RealtimeAnalyser.h:
     42        * Modules/webaudio/ScriptProcessorNode.cpp:
     43        (WebCore::ScriptProcessorNode::ScriptProcessorNode):
     44        * Modules/webaudio/ScriptProcessorNode.h:
     45        * Modules/webaudio/WaveShaperProcessor.cpp:
     46        (WebCore::WaveShaperProcessor::WaveShaperProcessor):
     47        * Modules/webaudio/WaveShaperProcessor.h:
     48        * Modules/webaudio/WebKitAudioContext.cpp:
     49        * Modules/webaudio/WebKitAudioPannerNode.cpp:
     50        (WebCore::WebKitAudioPannerNode::WebKitAudioPannerNode):
     51        * Modules/webaudio/WebKitAudioPannerNode.h:
     52        * platform/audio/AudioBus.cpp:
     53        (WebCore::AudioBus::AudioBus):
     54        * platform/audio/AudioBus.h:
     55        * platform/audio/AudioChannel.h:
     56        * platform/audio/AudioDSPKernelProcessor.cpp:
     57        (WebCore::AudioDSPKernelProcessor::AudioDSPKernelProcessor):
     58        * platform/audio/AudioDSPKernelProcessor.h:
     59        * platform/audio/AudioHardwareListener.cpp:
     60        (WebCore::AudioHardwareListener::AudioHardwareListener):
     61        * platform/audio/AudioHardwareListener.h:
     62        * platform/audio/AudioResampler.cpp:
     63        (WebCore::AudioResampler::AudioResampler):
     64        * platform/audio/AudioResampler.h:
     65        * platform/audio/AudioResamplerKernel.cpp:
     66        (WebCore::AudioResamplerKernel::AudioResamplerKernel):
     67        * platform/audio/AudioResamplerKernel.h:
     68        * platform/audio/Biquad.cpp:
     69        * platform/audio/Cone.cpp:
     70        * platform/audio/Cone.h:
     71        * platform/audio/Distance.cpp:
     72        * platform/audio/Distance.h:
     73        * platform/audio/DownSampler.cpp:
     74        (WebCore::DownSampler::DownSampler):
     75        * platform/audio/DownSampler.h:
     76        * platform/audio/DynamicsCompressorKernel.cpp:
     77        (WebCore::DynamicsCompressorKernel::DynamicsCompressorKernel):
     78        * platform/audio/DynamicsCompressorKernel.h:
     79        * platform/audio/EqualPowerPanner.cpp:
     80        (WebCore::EqualPowerPanner::EqualPowerPanner):
     81        * platform/audio/EqualPowerPanner.h:
     82        * platform/audio/FFTConvolver.cpp:
     83        (WebCore::FFTConvolver::FFTConvolver):
     84        * platform/audio/FFTConvolver.h:
     85        * platform/audio/HRTFDatabase.cpp:
     86        (WebCore::HRTFDatabase::HRTFDatabase):
     87        * platform/audio/HRTFDatabase.h:
     88        * platform/audio/HRTFElevation.cpp:
     89        * platform/audio/HRTFElevation.h:
     90        * platform/audio/HRTFKernel.cpp:
     91        (WebCore::HRTFKernel::HRTFKernel):
     92        * platform/audio/HRTFKernel.h:
     93        * platform/audio/HRTFPanner.cpp:
     94        (WebCore::HRTFPanner::HRTFPanner):
     95        * platform/audio/HRTFPanner.h:
     96        * platform/audio/PlatformMediaSession.cpp:
     97        (WebCore::PlatformMediaSession::PlatformMediaSession):
     98        * platform/audio/PlatformMediaSession.h:
     99        * platform/audio/PushPullFIFO.cpp:
     100        (WebCore::PushPullFIFO::PushPullFIFO):
     101        * platform/audio/PushPullFIFO.h:
     102        * platform/audio/Reverb.cpp:
     103        * platform/audio/ReverbAccumulationBuffer.cpp:
     104        (WebCore::ReverbAccumulationBuffer::ReverbAccumulationBuffer):
     105        * platform/audio/ReverbAccumulationBuffer.h:
     106        * platform/audio/ReverbConvolver.cpp:
     107        * platform/audio/ReverbConvolverStage.cpp:
     108        (WebCore::ReverbConvolverStage::ReverbConvolverStage):
     109        * platform/audio/ReverbConvolverStage.h:
     110        * platform/audio/ReverbInputBuffer.cpp:
     111        (WebCore::ReverbInputBuffer::ReverbInputBuffer):
     112        * platform/audio/ReverbInputBuffer.h:
     113
    11142020-09-24  Chris Dumez  <cdumez@apple.com>
    2115
  • trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp

    r267543 r267544  
    4646WTF_MAKE_ISO_ALLOCATED_IMPL(WebKitAudioBufferSourceNode);
    4747
    48 const double DefaultGrainDuration = 0.020; // 20ms
     48constexpr double DefaultGrainDuration = 0.020; // 20ms
    4949
    5050// Arbitrary upper limit on playback rate.
  • trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.cpp

    r267543 r267544  
    4242AudioDestinationNode::AudioDestinationNode(BaseAudioContext& context)
    4343    : AudioNode(context)
    44     , m_currentSampleFrame(0)
    45     , m_isSilent(true)
    46     , m_isEffectivelyPlayingAudio(false)
    47     , m_muted(false)
    4844{
    4945    setNodeType(NodeTypeDestination);
  • trunk/Source/WebCore/Modules/webaudio/AudioDestinationNode.h

    r267537 r267544  
    7272
    7373    // Counts the number of sample-frames processed by the destination.
    74     size_t m_currentSampleFrame;
     74    size_t m_currentSampleFrame { 0 };
    7575
    76     bool m_isSilent;
    77     bool m_isEffectivelyPlayingAudio;
    78     bool m_muted;
     76    bool m_isSilent { true };
     77    bool m_isEffectivelyPlayingAudio { false };
     78    bool m_muted { false };
    7979};
    8080
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeOutput.cpp

    r267541 r267544  
    4141    , m_numberOfChannels(numberOfChannels)
    4242    , m_desiredNumberOfChannels(numberOfChannels)
    43     , m_isInPlace(false)
    44     , m_isEnabled(true)
    45     , m_renderingFanOutCount(0)
    46     , m_renderingParamFanOutCount(0)
    4743{
    4844    ASSERT(numberOfChannels <= AudioContext::maxNumberOfChannels());
  • trunk/Source/WebCore/Modules/webaudio/AudioNodeOutput.h

    r266518 r267544  
    139139    RefPtr<AudioBus> m_inPlaceBus;
    140140    // If m_isInPlace is true, use m_inPlaceBus as the valid AudioBus; If false, use the default m_internalBus.
    141     bool m_isInPlace;
     141    bool m_isInPlace { false };
    142142
    143143    HashSet<AudioNodeInput*> m_inputs;
    144144    typedef HashSet<AudioNodeInput*>::iterator InputsIterator;
    145     bool m_isEnabled;
     145    bool m_isEnabled { true };
    146146
    147147    // For the purposes of rendering, keeps track of the number of inputs and AudioParams we're connected to.
    148148    // These value should only be changed at the very start or end of the rendering quantum.
    149     unsigned m_renderingFanOutCount;
    150     unsigned m_renderingParamFanOutCount;
     149    unsigned m_renderingFanOutCount { 0 };
     150    unsigned m_renderingParamFanOutCount { 0 };
    151151
    152152    HashSet<RefPtr<AudioParam>> m_params;
  • trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h

    r267381 r267544  
    4040    WTF_MAKE_FAST_ALLOCATED;
    4141public:
    42     AudioParamTimeline()
    43     {
    44     }
     42    AudioParamTimeline() = default;
    4543
    4644    ExceptionOr<void> setValueAtTime(float value, Seconds time);
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp

    r267541 r267544  
    4848WTF_MAKE_ISO_ALLOCATED_IMPL(AudioScheduledSourceNode);
    4949
    50 const double AudioScheduledSourceNode::UnknownTime = -1;
    51 
    5250AudioScheduledSourceNode::AudioScheduledSourceNode(BaseAudioContext& context)
    5351    : AudioNode(context)
    5452    , ActiveDOMObject(context.scriptExecutionContext())
    55     , m_endTime(UnknownTime)
    5653{
    5754    suspendIfNeeded();
     
    8178    size_t startFrame = AudioUtilities::timeToSampleFrame(m_startTime, sampleRate, AudioUtilities::SampleFrameRounding::Up);
    8279    size_t endFrame = 0;
    83     if (m_endTime != UnknownTime) {
     80    if (m_endTime) {
    8481        // The end frame is the end time rounded up because it is an exclusive upper
    8582        // bound of the end time. We also need to take care to handle huge end
    8683        // times and clamp the corresponding frame to the largest size_t value.
    87         endFrame = AudioUtilities::timeToSampleFrame(m_endTime, sampleRate, AudioUtilities::SampleFrameRounding::Up);
     84        endFrame = AudioUtilities::timeToSampleFrame(*m_endTime, sampleRate, AudioUtilities::SampleFrameRounding::Up);
    8885    }
    8986
    9087    // If we know the end time and it's already passed, then don't bother doing any more rendering this cycle.
    91     if (m_endTime != UnknownTime && endFrame <= quantumStartFrame)
     88    if (m_endTime && endFrame <= quantumStartFrame)
    9289        finish();
    9390
     
    128125    // If the end time is somewhere in the middle of this time quantum, then zero out the
    129126    // frames from the end time to the very end of the quantum.
    130     if (m_endTime != UnknownTime && endFrame >= quantumStartFrame && endFrame < quantumEndFrame) {
     127    if (m_endTime && endFrame >= quantumStartFrame && endFrame < quantumEndFrame) {
    131128        size_t zeroStartFrame = endFrame - quantumStartFrame;
    132129        size_t framesToZero = quantumFrameSize - zeroStartFrame;
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.h

    r266417 r267544  
    9191    // If it hasn't been set explicitly, then the sound will not stop playing (if looping) or will stop when the end of the AudioBuffer
    9292    // has been reached.
    93     double m_endTime; // in seconds
    94 
    95     static const double UnknownTime;
     93    Optional<double> m_endTime; // in seconds
    9694};
    9795
  • trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp

    r263410 r267544  
    3737AudioSummingJunction::AudioSummingJunction(BaseAudioContext& context)
    3838    : m_context(context)
    39     , m_renderingStateNeedUpdating(false)
    4039{
    4140}
  • trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.h

    r263410 r267544  
    7878
    7979    // m_renderingStateNeedUpdating keeps track if m_outputs is modified.
    80     bool m_renderingStateNeedUpdating;
     80    bool m_renderingStateNeedUpdating { false };
    8181};
    8282
  • trunk/Source/WebCore/Modules/webaudio/BiquadDSPKernel.cpp

    r267541 r267544  
    3838namespace WebCore {
    3939
    40 // FIXME: As a recursive linear filter, depending on its parameters, a biquad filter can have
    41 // an infinite tailTime. In practice, Biquad filters do not usually (except for very high resonance values)
    42 // have a tailTime of longer than approx. 200ms. This value could possibly be calculated based on the
    43 // settings of the Biquad.
    44 static const double MaxBiquadDelayTime = 0.2;
    45 
    4640static bool hasConstantValues(float* values, int framesToProcess)
    4741{
  • trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.cpp

    r267541 r267544  
    3535BiquadProcessor::BiquadProcessor(BaseAudioContext& context, float sampleRate, size_t numberOfChannels, bool autoInitialize)
    3636    : AudioDSPKernelProcessor(sampleRate, numberOfChannels)
    37     , m_type(BiquadFilterType::Lowpass)
    3837    , m_parameter1(AudioParam::create(context, "frequency", 350.0, 0.0, 0.5 * sampleRate, AutomationRate::ARate))
    3938    , m_parameter2(AudioParam::create(context, "Q", 1, -FLT_MAX, FLT_MAX, AutomationRate::ARate))
    4039    , m_parameter3(AudioParam::create(context, "gain", 0.0, -FLT_MAX, 40 * std::log10(std::numeric_limits<float>::max()), AutomationRate::ARate))
    4140    , m_parameter4(AudioParam::create(context, "detune", 0.0, -153600, 153600, AutomationRate::ARate))
    42     , m_filterCoefficientsDirty(true)
    43     , m_hasSampleAccurateValues(false)
    4441{
    4542    if (autoInitialize)
  • trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.h

    r267432 r267544  
    7070
    7171private:
    72     BiquadFilterType m_type;
     72    BiquadFilterType m_type { BiquadFilterType::Lowpass };
    7373
    7474    Ref<AudioParam> m_parameter1;
     
    7878
    7979    // so DSP kernels know when to re-compute coefficients
    80     bool m_filterCoefficientsDirty;
     80    bool m_filterCoefficientsDirty { true };
    8181
    8282    // Set to true if any of the filter parameters are sample-accurate.
    83     bool m_hasSampleAccurateValues;
     83    bool m_hasSampleAccurateValues { false };
    8484
    8585    bool m_shouldUseARate { true };
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r267543 r267544  
    4343// But, the Reverb object is multi-threaded, so we want this as high as possible without losing too much accuracy.
    4444// Very large FFTs will have worse phase errors. Given these constraints 32768 is a good compromise.
    45 const size_t MaxFFTSize = 32768;
     45constexpr size_t MaxFFTSize = 32768;
    4646
    4747namespace WebCore {
  • trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp

    r267014 r267544  
    3838#include <wtf/MainThread.h>
    3939
    40 const unsigned EnabledInputChannels = 2;
     40constexpr unsigned EnabledInputChannels = 2;
    4141
    4242namespace WebCore {
  • trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp

    r267432 r267544  
    3737WTF_MAKE_ISO_ALLOCATED_IMPL(DelayNode);
    3838
    39 const double maximumAllowedDelayTime = 180;
     39constexpr double maximumAllowedDelayTime = 180;
    4040
    4141inline DelayNode::DelayNode(BaseAudioContext& context, double maxDelayTime)
  • trunk/Source/WebCore/Modules/webaudio/DynamicsCompressorNode.cpp

    r267543 r267544  
    3939
    4040// Set output to stereo by default.
    41 static const unsigned defaultNumberOfOutputChannels = 2;
     41static constexpr unsigned defaultNumberOfOutputChannels = 2;
    4242
    4343namespace WebCore {
  • trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp

    r267543 r267544  
    3939
    4040// These are somewhat arbitrary limits, but we need to do some kind of sanity-checking.
    41 const unsigned minSampleRate = 8000;
    42 const unsigned maxSampleRate = 192000;
     41constexpr unsigned minSampleRate = 8000;
     42constexpr unsigned maxSampleRate = 192000;
    4343
    4444namespace WebCore {
  • trunk/Source/WebCore/Modules/webaudio/PeriodicWave.cpp

    r267383 r267544  
    134134    : m_sampleRate(sampleRate)
    135135    , m_numberOfRanges(0.5 + NumberOfOctaveBands * log2f(periodicWaveSize()))
    136     , m_centsPerRange(CentsPerRange)
    137136{
    138137    float nyquist = 0.5 * m_sampleRate;
     
    151150
    152151    // Add one to round-up to the next range just in time to truncate partials before aliasing occurs.
    153     float pitchRange = 1 + centsAboveLowestFrequency / m_centsPerRange;
     152    float pitchRange = 1 + centsAboveLowestFrequency / CentsPerRange;
    154153
    155154    pitchRange = std::max(pitchRange, 0.0f);
     
    177176{
    178177    // Number of cents below nyquist where we cull partials.
    179     float centsToCull = rangeIndex * m_centsPerRange;
     178    float centsToCull = rangeIndex * CentsPerRange;
    180179
    181180    // A value from 0 -> 1 representing what fraction of the partials to keep.
  • trunk/Source/WebCore/Modules/webaudio/PeriodicWave.h

    r267153 r267544  
    8484    float m_sampleRate;
    8585    unsigned m_numberOfRanges;
    86     float m_centsPerRange;
    8786
    8887    // The lowest frequency (in Hertz) where playback will include all of the partials.
  • trunk/Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp

    r267541 r267544  
    4343namespace WebCore {
    4444
    45 const double RealtimeAnalyser::DefaultSmoothingTimeConstant  = 0.8;
    46 const double RealtimeAnalyser::DefaultMinDecibels = -100;
    47 const double RealtimeAnalyser::DefaultMaxDecibels = -30;
    48 
    49 const unsigned RealtimeAnalyser::DefaultFFTSize = 2048;
    50 // All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
    51 const unsigned RealtimeAnalyser::MinFFTSize = 32;
    52 const unsigned RealtimeAnalyser::MaxFFTSize = 32768;
    53 const unsigned RealtimeAnalyser::InputBufferSize = RealtimeAnalyser::MaxFFTSize * 2;
    54 
    5545RealtimeAnalyser::RealtimeAnalyser()
    5646    : m_inputBuffer(InputBufferSize)
    57     , m_writeIndex(0)
    5847    , m_downmixBus(AudioBus::create(1, AudioUtilities::renderQuantumSize))
    59     , m_fftSize(DefaultFFTSize)
    60     , m_magnitudeBuffer(DefaultFFTSize / 2)
    61     , m_smoothingTimeConstant(DefaultSmoothingTimeConstant)
    62     , m_minDecibels(DefaultMinDecibels)
    63     , m_maxDecibels(DefaultMaxDecibels)
    6448{
    6549    m_analysisFrame = makeUnique<FFTFrame>(DefaultFFTSize);
  • trunk/Source/WebCore/Modules/webaudio/RealtimeAnalyser.h

    r267537 r267544  
    6666    void writeInput(AudioBus*, size_t framesToProcess);
    6767
    68     static const double DefaultSmoothingTimeConstant;
    69     static const double DefaultMinDecibels;
    70     static const double DefaultMaxDecibels;
     68    static constexpr double DefaultSmoothingTimeConstant { 0.8 };
     69    static constexpr double DefaultMinDecibels { -100 };
     70    static constexpr double DefaultMaxDecibels { -30 };
    7171
    72     static const unsigned DefaultFFTSize;
    73     static const unsigned MinFFTSize;
    74     static const unsigned MaxFFTSize;
    75     static const unsigned InputBufferSize;
     72    // All FFT implementations are expected to handle power-of-two sizes MinFFTSize <= size <= MaxFFTSize.
     73    static constexpr unsigned DefaultFFTSize { 2048 };
     74    static constexpr unsigned MinFFTSize { 32 };
     75    static constexpr unsigned MaxFFTSize { 32768 };
     76    static constexpr unsigned InputBufferSize { MaxFFTSize * 2 };
    7677
    7778private:
    7879    // The audio thread writes the input audio here.
    7980    AudioFloatArray m_inputBuffer;
    80     unsigned m_writeIndex;
     81    unsigned m_writeIndex { 0 };
    8182
    8283    // AudioBus used for downmixing input audio before copying it to m_inputBuffer.
    8384    RefPtr<AudioBus> m_downmixBus;
    8485   
    85     size_t m_fftSize;
     86    size_t m_fftSize { DefaultFFTSize };
    8687    std::unique_ptr<FFTFrame> m_analysisFrame;
    8788    void doFFTAnalysisIfNecessary();
    8889   
    8990    // doFFTAnalysisIfNecessary() stores the floating-point magnitude analysis data here.
    90     AudioFloatArray m_magnitudeBuffer;
     91    AudioFloatArray m_magnitudeBuffer { DefaultFFTSize / 2 };
    9192    AudioFloatArray& magnitudeBuffer() { return m_magnitudeBuffer; }
    9293
    9394    // A value between 0 and 1 which averages the previous version of m_magnitudeBuffer with the current analysis magnitude data.
    94     double m_smoothingTimeConstant;   
     95    double m_smoothingTimeConstant { DefaultSmoothingTimeConstant };
    9596
    9697    // The range used when converting when using getByteFrequencyData().
    97     double m_minDecibels;
    98     double m_maxDecibels;
     98    double m_minDecibels { DefaultMinDecibels };
     99    double m_maxDecibels { DefaultMaxDecibels };
    99100
    100101    // We should only do the FFT analysis once per render quantum.
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.cpp

    r267543 r267544  
    5555    : AudioNode(context)
    5656    , ActiveDOMObject(context.scriptExecutionContext())
    57     , m_doubleBufferIndex(0)
    5857    , m_bufferSize(bufferSize)
    59     , m_bufferReadWriteIndex(0)
    6058    , m_numberOfInputChannels(numberOfInputChannels)
    6159    , m_numberOfOutputChannels(numberOfOutputChannels)
  • trunk/Source/WebCore/Modules/webaudio/ScriptProcessorNode.h

    r267537 r267544  
    8282    unsigned doubleBufferIndex() const { return m_doubleBufferIndex; }
    8383    void swapBuffers() { m_doubleBufferIndex = 1 - m_doubleBufferIndex; }
    84     unsigned m_doubleBufferIndex;
     84    unsigned m_doubleBufferIndex { 0 };
    8585    Vector<RefPtr<AudioBuffer>> m_inputBuffers;
    8686    Vector<RefPtr<AudioBuffer>> m_outputBuffers;
    8787
    8888    size_t m_bufferSize;
    89     unsigned m_bufferReadWriteIndex;
     89    unsigned m_bufferReadWriteIndex { 0 };
    9090
    9191    unsigned m_numberOfInputChannels;
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp

    r257688 r267544  
    3535WaveShaperProcessor::WaveShaperProcessor(float sampleRate, size_t numberOfChannels)
    3636    : AudioDSPKernelProcessor(sampleRate, numberOfChannels)
    37     , m_oversample(OverSampleNone)
    3837{
    3938}
  • trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h

    r233650 r267544  
    6363    RefPtr<Float32Array> m_curve;
    6464
    65     OverSampleType m_oversample;
     65    OverSampleType m_oversample { OverSampleNone };
    6666
    6767    // This synchronizes process() with setCurve().
  • trunk/Source/WebCore/Modules/webaudio/WebKitAudioContext.cpp

    r267147 r267544  
    5252#endif
    5353
    54 const unsigned MaxPeriodicWaveLength = 4096;
     54constexpr unsigned MaxPeriodicWaveLength = 4096;
    5555
    5656namespace WebCore {
  • trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.cpp

    r267543 r267544  
    5151WebKitAudioPannerNode::WebKitAudioPannerNode(WebKitAudioContext& context)
    5252    : PannerNodeBase(context)
    53     , m_panningModel(PanningModelType::HRTF)
    54     , m_connectionCount(0)
    5553{
    5654    setNodeType(NodeTypePanner);
  • trunk/Source/WebCore/Modules/webaudio/WebKitAudioPannerNode.h

    r267537 r267544  
    130130
    131131    std::unique_ptr<Panner> m_panner;
    132     PanningModelType m_panningModel;
     132    PanningModelType m_panningModel { PanningModelType::HRTF };
    133133
    134134    FloatPoint3D m_position;
     
    143143    RefPtr<HRTFDatabaseLoader> m_hrtfDatabaseLoader;
    144144
    145     unsigned m_connectionCount;
     145    unsigned m_connectionCount { 0 };
    146146
    147147    // Synchronize process() and setPanningModel() which can change the panner.
  • trunk/Source/WebCore/platform/audio/AudioBus.cpp

    r266794 r267544  
    4545using namespace VectorMath;
    4646
    47 const unsigned MaxBusChannels = 32;
     47constexpr unsigned MaxBusChannels = 32;
    4848
    4949RefPtr<AudioBus> AudioBus::create(unsigned numberOfChannels, size_t length, bool allocate)
     
    5858AudioBus::AudioBus(unsigned numberOfChannels, size_t length, bool allocate)
    5959    : m_length(length)
    60     , m_busGain(1)
    61     , m_isFirstTime(true)
    62     , m_sampleRate(0)
    6360{
    6461    m_channels.reserveInitialCapacity(numberOfChannels);
  • trunk/Source/WebCore/platform/audio/AudioBus.h

    r266794 r267544  
    161161    Vector<std::unique_ptr<AudioChannel>> m_channels;
    162162    int m_layout;
    163     float m_busGain;
     163    float m_busGain { 1 };
    164164    std::unique_ptr<AudioFloatArray> m_dezipperGainValues;
    165     bool m_isFirstTime;
    166     float m_sampleRate; // 0.0 if unknown or N/A
     165    bool m_isFirstTime { 0 };
     166    float m_sampleRate { 0 }; // 0.0 if unknown or N/A
    167167};
    168168
  • trunk/Source/WebCore/platform/audio/AudioChannel.h

    r248846 r267544  
    5555    explicit AudioChannel(size_t length)
    5656        : m_length(length)
    57         , m_rawPointer(0)
    58         , m_silent(true)
    5957    {
    6058        m_memBuffer = makeUnique<AudioFloatArray>(length);
     
    6260
    6361    // A "blank" audio channel -- must call set() before it's useful...
    64     AudioChannel()
    65         : m_length(0)
    66         , m_rawPointer(0)
    67         , m_silent(true)
    68     {
    69     }
     62    AudioChannel() = default;
    7063
    7164    // Redefine the memory for this channel.
     
    130123
    131124private:
    132     size_t m_length;
     125    size_t m_length { 0 };
    133126
    134     float* m_rawPointer;
     127    float* m_rawPointer { nullptr };
    135128    std::unique_ptr<AudioFloatArray> m_memBuffer;
    136     bool m_silent;
     129    bool m_silent { true };
    137130};
    138131
  • trunk/Source/WebCore/platform/audio/AudioDSPKernelProcessor.cpp

    r267432 r267544  
    4242AudioDSPKernelProcessor::AudioDSPKernelProcessor(float sampleRate, unsigned numberOfChannels)
    4343    : AudioProcessor(sampleRate, numberOfChannels)
    44     , m_hasJustReset(true)
    4544{
    4645}
  • trunk/Source/WebCore/platform/audio/AudioDSPKernelProcessor.h

    r267432 r267544  
    7070protected:
    7171    Vector<std::unique_ptr<AudioDSPKernel>> m_kernels;
    72     bool m_hasJustReset;
     72    bool m_hasJustReset { true };
    7373};
    7474
  • trunk/Source/WebCore/platform/audio/AudioHardwareListener.cpp

    r237266 r267544  
    3838AudioHardwareListener::AudioHardwareListener(Client& client)
    3939    : m_client(client)
    40     , m_activity(AudioHardwareActivityType::Unknown)
    41     , m_outputDeviceSupportsLowPowerMode(false)
    4240{
    4341#if PLATFORM(IOS_FAMILY)
  • trunk/Source/WebCore/platform/audio/AudioHardwareListener.h

    r228483 r267544  
    6161
    6262    Client& m_client;
    63     AudioHardwareActivityType m_activity;
    64     bool m_outputDeviceSupportsLowPowerMode;
     63    AudioHardwareActivityType m_activity { AudioHardwareActivityType::Unknown };
     64    bool m_outputDeviceSupportsLowPowerMode { false };
    6565};
    6666
  • trunk/Source/WebCore/platform/audio/AudioResampler.cpp

    r248846 r267544  
    3535namespace WebCore {
    3636
    37 const double AudioResampler::MaxRate = 8.0;
    38 
    3937AudioResampler::AudioResampler()
    40     : m_rate(1.0)
    4138{
    4239    m_kernels.append(makeUnique<AudioResamplerKernel>(this));
     
    4542
    4643AudioResampler::AudioResampler(unsigned numberOfChannels)
    47     : m_rate(1.0)
    4844{
    4945    for (unsigned i = 0; i < numberOfChannels; ++i)
  • trunk/Source/WebCore/platform/audio/AudioResampler.h

    r248762 r267544  
    5757    double rate() const { return m_rate; }
    5858
    59     static const double MaxRate;
     59    static constexpr double MaxRate { 8 };
    6060
    6161private:
    62     double m_rate;
     62    double m_rate { 1 };
    6363    Vector<std::unique_ptr<AudioResamplerKernel>> m_kernels;
    6464    RefPtr<AudioBus> m_sourceBus;
  • trunk/Source/WebCore/platform/audio/AudioResamplerKernel.cpp

    r267541 r267544  
    3939    // The buffer size must be large enough to hold up to two extra sample frames for the linear interpolation.
    4040    , m_sourceBuffer(2 + static_cast<int>(AudioUtilities::renderQuantumSize * AudioResampler::MaxRate))
    41     , m_virtualReadIndex(0.0)
    42     , m_fillIndex(0)
    4341{
    4442    m_lastValues[0] = 0.0f;
  • trunk/Source/WebCore/platform/audio/AudioResamplerKernel.h

    r267541 r267544  
    6464   
    6565    // This is a (floating point) read index on the input stream.
    66     double m_virtualReadIndex;
     66    double m_virtualReadIndex { 0 };
    6767
    6868    // We need to have continuity from one call of process() to the next.
     
    7171    // For the first call to process() (or after reset()) there will be no buffered samples.
    7272    float m_lastValues[2];
    73     unsigned m_fillIndex;
     73    unsigned m_fillIndex { 0 };
    7474};
    7575
  • trunk/Source/WebCore/platform/audio/Biquad.cpp

    r267541 r267544  
    4848
    4949#if USE(ACCELERATE)
    50 const int kBufferSize = 1024;
     50constexpr int kBufferSize = 1024;
    5151#endif
    5252
  • trunk/Source/WebCore/platform/audio/Cone.cpp

    r165676 r267544  
    3636namespace WebCore {
    3737
    38 ConeEffect::ConeEffect()
    39     : m_innerAngle(360.0)
    40     , m_outerAngle(360.0)
    41     , m_outerGain(0.0)
    42 {
    43 }
     38ConeEffect::ConeEffect() = default;
    4439
    4540double ConeEffect::gain(FloatPoint3D sourcePosition, FloatPoint3D sourceOrientation, FloatPoint3D listenerPosition)
  • trunk/Source/WebCore/platform/audio/Cone.h

    r248762 r267544  
    5555
    5656protected:
    57     double m_innerAngle;
    58     double m_outerAngle;
    59     double m_outerGain;
     57    double m_innerAngle { 360 };
     58    double m_outerAngle { 360 };
     59    double m_outerGain { 0 };
    6060};
    6161
  • trunk/Source/WebCore/platform/audio/Distance.cpp

    r265838 r267544  
    3838namespace WebCore {
    3939
    40 DistanceEffect::DistanceEffect()
    41     : m_model(DistanceModelType::Inverse)
    42     , m_isClamped(true)
    43     , m_refDistance(1.0)
    44     , m_maxDistance(10000.0)
    45     , m_rolloffFactor(1.0)
    46 {
    47 }
     40DistanceEffect::DistanceEffect() = default;
    4841
    4942double DistanceEffect::gain(double distance)
  • trunk/Source/WebCore/platform/audio/Distance.h

    r248762 r267544  
    7171    double exponentialGain(double distance);
    7272
    73     DistanceModelType m_model;
    74     bool m_isClamped;
    75     double m_refDistance;
    76     double m_maxDistance;
    77     double m_rolloffFactor;
     73    DistanceModelType m_model { DistanceModelType::Inverse };
     74    bool m_isClamped { true };
     75    double m_refDistance { 1 };
     76    double m_maxDistance { 10000 };
     77    double m_rolloffFactor { 1 };
    7878};
    7979
  • trunk/Source/WebCore/platform/audio/DownSampler.cpp

    r165676 r267544  
    3939DownSampler::DownSampler(size_t inputBlockSize)
    4040    : m_inputBlockSize(inputBlockSize)
    41     , m_reducedKernel(DefaultKernelSize / 2)
    4241    , m_convolver(inputBlockSize / 2) // runs at 1/2 source sample-rate
    4342    , m_tempBuffer(inputBlockSize / 2)
  • trunk/Source/WebCore/platform/audio/DownSampler.h

    r248762 r267544  
    5858    // In other words, filter out all frequencies higher than 0.25 * Nyquist.
    5959    void initializeKernel();
    60     AudioFloatArray m_reducedKernel;
     60    AudioFloatArray m_reducedKernel { DefaultKernelSize / 2 };
    6161
    6262    // Half-band filter.
  • trunk/Source/WebCore/platform/audio/DynamicsCompressorKernel.cpp

    r267361 r267544  
    4343
    4444// Metering hits peaks instantly, but releases this fast (in seconds).
    45 const float meteringReleaseTimeConstant = 0.325f;
    46 
    47 const float uninitializedValue = -1;
     45constexpr float meteringReleaseTimeConstant = 0.325f;
    4846
    4947DynamicsCompressorKernel::DynamicsCompressorKernel(float sampleRate, unsigned numberOfChannels)
    5048    : m_sampleRate(sampleRate)
    51     , m_lastPreDelayFrames(DefaultPreDelayFrames)
    52     , m_preDelayReadIndex(0)
    53     , m_preDelayWriteIndex(DefaultPreDelayFrames)
    54     , m_ratio(uninitializedValue)
    55     , m_slope(uninitializedValue)
    56     , m_linearThreshold(uninitializedValue)
    57     , m_dbThreshold(uninitializedValue)
    58     , m_dbKnee(uninitializedValue)
    59     , m_kneeThreshold(uninitializedValue)
    60     , m_kneeThresholdDb(uninitializedValue)
    61     , m_ykneeThresholdDb(uninitializedValue)
    62     , m_K(uninitializedValue)
    6349{
    6450    setNumberOfChannels(numberOfChannels);
  • trunk/Source/WebCore/platform/audio/DynamicsCompressorKernel.h

    r267361 r267544  
    7575
    7676protected:
     77    static constexpr float uninitializedValue = -1;
    7778    float m_sampleRate;
    7879
     
    8889    enum { MaxPreDelayFramesMask = MaxPreDelayFrames - 1 };
    8990    enum { DefaultPreDelayFrames = 256 }; // setPreDelayTime() will override this initial value
    90     unsigned m_lastPreDelayFrames;
     91    unsigned m_lastPreDelayFrames { DefaultPreDelayFrames };
    9192    void setPreDelayTime(float);
    9293
    9394    Vector<std::unique_ptr<AudioFloatArray>> m_preDelayBuffers;
    94     int m_preDelayReadIndex;
    95     int m_preDelayWriteIndex;
     95    int m_preDelayReadIndex { 0 };
     96    int m_preDelayWriteIndex { DefaultPreDelayFrames };
    9697
    9798    float m_maxAttackCompressionDiffDb;
     
    107108    // Amount of input change in dB required for 1 dB of output change.
    108109    // This applies to the portion of the curve above m_kneeThresholdDb (see below).
    109     float m_ratio;
    110     float m_slope; // Inverse ratio.
     110    float m_ratio { uninitializedValue };
     111    float m_slope { uninitializedValue }; // Inverse ratio.
    111112
    112113    // The input to output change below the threshold is linear 1:1.
    113     float m_linearThreshold;
    114     float m_dbThreshold;
     114    float m_linearThreshold { uninitializedValue };
     115    float m_dbThreshold { uninitializedValue };
    115116
    116117    // m_dbKnee is the number of dB above the threshold before we enter the "ratio" portion of the curve.
     
    118119    // The portion between m_dbThreshold and m_kneeThresholdDb is the "soft knee" portion of the curve
    119120    // which transitions smoothly from the linear portion to the ratio portion.
    120     float m_dbKnee;
    121     float m_kneeThreshold;
    122     float m_kneeThresholdDb;
    123     float m_ykneeThresholdDb;
     121    float m_dbKnee { uninitializedValue };
     122    float m_kneeThreshold { uninitializedValue };
     123    float m_kneeThresholdDb { uninitializedValue };
     124    float m_ykneeThresholdDb { uninitializedValue };
    124125
    125126    // Internal parameter for the knee portion of the curve.
    126     float m_K;
     127    float m_K { uninitializedValue };
    127128};
    128129
  • trunk/Source/WebCore/platform/audio/EqualPowerPanner.cpp

    r266319 r267544  
    3535
    3636// Use a 50ms smoothing / de-zippering time-constant.
    37 const float SmoothingTimeConstant = 0.050f;
     37constexpr float SmoothingTimeConstant = 0.050f;
    3838
    3939namespace WebCore {
     
    4141EqualPowerPanner::EqualPowerPanner(float sampleRate)
    4242    : Panner(PanningModelType::Equalpower)
    43     , m_isFirstRender(true)
    44     , m_gainL(0.0)
    45     , m_gainR(0.0)
    4643{
    4744    m_smoothingConstant = AudioUtilities::discreteTimeConstantForSampleRate(SmoothingTimeConstant, sampleRate);
  • trunk/Source/WebCore/platform/audio/EqualPowerPanner.h

    r266417 r267544  
    4949
    5050    // For smoothing / de-zippering
    51     bool m_isFirstRender;
     51    bool m_isFirstRender { true };
    5252    double m_smoothingConstant;
    5353   
    54     double m_gainL;
    55     double m_gainR;
     54    double m_gainL { 0 };
     55    double m_gainR { 0 };
    5656};
    5757
  • trunk/Source/WebCore/platform/audio/FFTConvolver.cpp

    r165676 r267544  
    4141FFTConvolver::FFTConvolver(size_t fftSize)
    4242    : m_frame(fftSize)
    43     , m_readWriteIndex(0)
    4443    , m_inputBuffer(fftSize) // 2nd half of buffer is always zeroed
    4544    , m_outputBuffer(fftSize)
  • trunk/Source/WebCore/platform/audio/FFTConvolver.h

    r248762 r267544  
    5959
    6060    // Buffer input until we get fftSize / 2 samples then do an FFT
    61     size_t m_readWriteIndex;
     61    size_t m_readWriteIndex { 0 };
    6262    AudioFloatArray m_inputBuffer;
    6363
  • trunk/Source/WebCore/platform/audio/HRTFDatabase.cpp

    r194496 r267544  
    3737namespace WebCore {
    3838
    39 const int HRTFDatabase::MinElevation = -45;
    40 const int HRTFDatabase::MaxElevation = 90;
    41 const unsigned HRTFDatabase::RawElevationAngleSpacing = 15;
    42 const unsigned HRTFDatabase::NumberOfRawElevations = 10; // -45 -> +90 (each 15 degrees)
    43 const unsigned HRTFDatabase::InterpolationFactor = 1;
    44 const unsigned HRTFDatabase::NumberOfTotalElevations = NumberOfRawElevations * InterpolationFactor;
    45 
    4639HRTFDatabase::HRTFDatabase(float sampleRate)
    47     : m_elevations(NumberOfTotalElevations)
    48     , m_sampleRate(sampleRate)
     40    : m_sampleRate(sampleRate)
    4941{
    5042    unsigned elevationIndex = 0;
  • trunk/Source/WebCore/platform/audio/HRTFDatabase.h

    r248762 r267544  
    5858
    5959    // Number of elevations loaded from resource.
    60     static const unsigned NumberOfRawElevations;
     60    static const unsigned NumberOfRawElevations { 10 };
    6161
    6262private:
    6363    // Minimum and maximum elevation angles (inclusive) for a HRTFDatabase.
    64     static const int MinElevation;
    65     static const int MaxElevation;
    66     static const unsigned RawElevationAngleSpacing;
     64    static constexpr int MinElevation { -45 };
     65    static constexpr int MaxElevation { 90 };
     66    static constexpr unsigned RawElevationAngleSpacing { 15 };
    6767
    6868    // Interpolates by this factor to get the total number of elevations from every elevation loaded from resource.
    69     static const unsigned InterpolationFactor;
     69    static constexpr unsigned InterpolationFactor { 1 };
    7070   
    7171    // Total number of elevations after interpolation.
    72     static const unsigned NumberOfTotalElevations;
     72    static constexpr unsigned NumberOfTotalElevations { NumberOfRawElevations * InterpolationFactor };
    7373
    7474    // Returns the index for the correct HRTFElevation given the elevation angle.
    7575    static unsigned indexFromElevationAngle(double);
    7676
    77     Vector<std::unique_ptr<HRTFElevation>> m_elevations;
     77    Vector<std::unique_ptr<HRTFElevation>> m_elevations { NumberOfTotalElevations };
    7878    float m_sampleRate;
    7979};
  • trunk/Source/WebCore/platform/audio/HRTFElevation.cpp

    r248846 r267544  
    4545namespace WebCore {
    4646
    47 const unsigned HRTFElevation::AzimuthSpacing = 15;
    48 const unsigned HRTFElevation::NumberOfRawAzimuths = 360 / AzimuthSpacing;
    49 const unsigned HRTFElevation::InterpolationFactor = 8;
    50 const unsigned HRTFElevation::NumberOfTotalAzimuths = NumberOfRawAzimuths * InterpolationFactor;
    51 
    5247// Total number of components of an HRTF database.
    53 const size_t TotalNumberOfResponses = 240;
     48constexpr size_t TotalNumberOfResponses = 240;
    5449
    5550// Number of frames in an individual impulse response.
    56 const size_t ResponseFrameSize = 256;
     51constexpr size_t ResponseFrameSize = 256;
    5752
    5853// Sample-rate of the spatialization impulse responses as stored in the resource file.
    5954// The impulse responses may be resampled to a different sample-rate (depending on the audio hardware) when they are loaded.
    60 const float ResponseSampleRate = 44100;
     55constexpr float ResponseSampleRate = 44100;
    6156
    6257#if PLATFORM(COCOA) || USE(WEBAUDIO_GSTREAMER)
  • trunk/Source/WebCore/platform/audio/HRTFElevation.h

    r248762 r267544  
    7474   
    7575    // Spacing, in degrees, between every azimuth loaded from resource.
    76     static const unsigned AzimuthSpacing;
     76    static constexpr unsigned AzimuthSpacing { 15 };
    7777   
    7878    // Number of azimuths loaded from resource.
    79     static const unsigned NumberOfRawAzimuths;
     79    static constexpr unsigned NumberOfRawAzimuths { 360 / AzimuthSpacing };
    8080
    8181    // Interpolates by this factor to get the total number of azimuths from every azimuth loaded from resource.
    82     static const unsigned InterpolationFactor;
     82    static constexpr unsigned InterpolationFactor { 8 };
    8383   
    8484    // Total number of azimuths after interpolation.
    85     static const unsigned NumberOfTotalAzimuths;
     85    static constexpr unsigned NumberOfTotalAzimuths { NumberOfRawAzimuths * InterpolationFactor };
    8686
    8787    // Given a specific azimuth and elevation angle, returns the left and right HRTFKernel.
  • trunk/Source/WebCore/platform/audio/HRTFKernel.cpp

    r248846 r267544  
    6969
    7070HRTFKernel::HRTFKernel(AudioChannel* channel, size_t fftSize, float sampleRate)
    71     : m_frameDelay(0)
    72     , m_sampleRate(sampleRate)
     71    : m_sampleRate(sampleRate)
    7372{
    7473    ASSERT(channel);
  • trunk/Source/WebCore/platform/audio/HRTFKernel.h

    r216679 r267544  
    8686   
    8787    std::unique_ptr<FFTFrame> m_fftFrame;
    88     float m_frameDelay;
     88    float m_frameDelay { 0 };
    8989    float m_sampleRate;
    9090};
  • trunk/Source/WebCore/platform/audio/HRTFPanner.cpp

    r267541 r267544  
    4141// The value of 2 milliseconds is larger than the largest delay which exists in any HRTFKernel from the default HRTFDatabase (0.0136 seconds).
    4242// We ASSERT the delay values used in process() with this value.
    43 const double MaxDelayTimeSeconds = 0.002;
    44 
    45 const int UninitializedAzimuth = -1;
     43constexpr double MaxDelayTimeSeconds = 0.002;
    4644
    4745HRTFPanner::HRTFPanner(float sampleRate, HRTFDatabaseLoader* databaseLoader)
     
    4947    , m_databaseLoader(databaseLoader)
    5048    , m_sampleRate(sampleRate)
    51     , m_crossfadeSelection(CrossfadeSelection1)
    52     , m_azimuthIndex1(UninitializedAzimuth)
    53     , m_elevation1(0)
    54     , m_azimuthIndex2(UninitializedAzimuth)
    55     , m_elevation2(0)
    56     , m_crossfadeX(0)
    57     , m_crossfadeIncr(0)
    5849    , m_convolverL1(fftSizeForSampleRate(sampleRate))
    5950    , m_convolverR1(fftSizeForSampleRate(sampleRate))
     
    187178
    188179    // Initially snap azimuth and elevation values to first values encountered.
    189     if (m_azimuthIndex1 == UninitializedAzimuth) {
     180    if (!m_azimuthIndex1) {
    190181        m_azimuthIndex1 = desiredAzimuthIndex;
    191182        m_elevation1 = elevation;
    192183    }
    193     if (m_azimuthIndex2 == UninitializedAzimuth) {
     184    if (!m_azimuthIndex2) {
    194185        m_azimuthIndex2 = desiredAzimuthIndex;
    195186        m_elevation2 = elevation;
     
    203194    // Check for azimuth and elevation changes, initiating a cross-fade if needed.
    204195    if (!m_crossfadeX && m_crossfadeSelection == CrossfadeSelection1) {
    205         if (desiredAzimuthIndex != m_azimuthIndex1 || elevation != m_elevation1) {
     196        if (desiredAzimuthIndex != *m_azimuthIndex1 || elevation != m_elevation1) {
    206197            // Cross-fade from 1 -> 2
    207198            m_crossfadeIncr = 1 / fadeFrames;
     
    211202    }
    212203    if (m_crossfadeX == 1 && m_crossfadeSelection == CrossfadeSelection2) {
    213         if (desiredAzimuthIndex != m_azimuthIndex2 || elevation != m_elevation2) {
     204        if (desiredAzimuthIndex != *m_azimuthIndex2 || elevation != m_elevation2) {
    214205            // Cross-fade from 2 -> 1
    215206            m_crossfadeIncr = -1 / fadeFrames;
     
    236227        double frameDelayL2;
    237228        double frameDelayR2;
    238         database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex1, m_elevation1, kernelL1, kernelR1, frameDelayL1, frameDelayR1);
    239         database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex2, m_elevation2, kernelL2, kernelR2, frameDelayL2, frameDelayR2);
     229        database->getKernelsFromAzimuthElevation(azimuthBlend, *m_azimuthIndex1, m_elevation1, kernelL1, kernelR1, frameDelayL1, frameDelayR1);
     230        database->getKernelsFromAzimuthElevation(azimuthBlend, *m_azimuthIndex2, m_elevation2, kernelL2, kernelR2, frameDelayL2, frameDelayR2);
    240231
    241232        bool areKernelsGood = kernelL1 && kernelR1 && kernelL2 && kernelR2;
  • trunk/Source/WebCore/platform/audio/HRTFPanner.h

    r266417 r267544  
    7878    };
    7979
    80     CrossfadeSelection m_crossfadeSelection;
     80    CrossfadeSelection m_crossfadeSelection { CrossfadeSelection1 };
    8181
    8282    // azimuth/elevation for CrossfadeSelection1.
    83     int m_azimuthIndex1;
    84     double m_elevation1;
     83    Optional<int> m_azimuthIndex1;
     84    double m_elevation1 { 0 };
    8585
    8686    // azimuth/elevation for CrossfadeSelection2.
    87     int m_azimuthIndex2;
    88     double m_elevation2;
     87    Optional<int> m_azimuthIndex2;
     88    double m_elevation2 { 0 };
    8989
    9090    // A crossfade value 0 <= m_crossfadeX <= 1.
    91     float m_crossfadeX;
     91    float m_crossfadeX { 0 };
    9292
    9393    // Per-sample-frame crossfade value increment.
    94     float m_crossfadeIncr;
     94    float m_crossfadeIncr { 0 };
    9595
    9696    FFTConvolver m_convolverL1;
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.cpp

    r261899 r267544  
    3636namespace WebCore {
    3737
    38 static const Seconds clientDataBufferingTimerThrottleDelay { 100_ms };
     38static constexpr Seconds clientDataBufferingTimerThrottleDelay { 100_ms };
    3939
    4040#if !RELEASE_LOG_DISABLED
     
    120120    , m_client(client)
    121121    , m_mediaSessionIdentifier(MediaSessionIdentifier::generate())
    122     , m_state(Idle)
    123     , m_stateToRestore(Idle)
    124     , m_notifyingClient(false)
    125122#if !RELEASE_LOG_DISABLED
    126123    , m_logger(client.logger())
  • trunk/Source/WebCore/platform/audio/PlatformMediaSession.h

    r260182 r267544  
    206206    PlatformMediaSessionClient& m_client;
    207207    MediaSessionIdentifier m_mediaSessionIdentifier;
    208     State m_state;
    209     State m_stateToRestore;
     208    State m_state { Idle };
     209    State m_stateToRestore { Idle };
    210210    InterruptionType m_interruptionType { NoInterruption };
    211211    int m_interruptionCount { 0 };
    212     bool m_notifyingClient;
     212    bool m_notifyingClient { false };
    213213    bool m_isPlayingToWirelessPlaybackTarget { false };
    214214    bool m_hasPlayedSinceLastInterruption { false };
  • trunk/Source/WebCore/platform/audio/PushPullFIFO.cpp

    r267014 r267544  
    3232namespace WebCore {
    3333
    34 const size_t PushPullFIFO::kMaxFIFOLength = 65536;
    35 
    3634PushPullFIFO::PushPullFIFO(unsigned numberOfChannels, size_t fifoLength)
    3735    : m_fifoLength(fifoLength)
    3836{
    39     ASSERT(m_fifoLength <= kMaxFIFOLength);
     37    ASSERT(m_fifoLength <= maxFIFOLength);
    4038    m_fifoBus = AudioBus::create(numberOfChannels, m_fifoLength);
    4139}
  • trunk/Source/WebCore/platform/audio/PushPullFIFO.h

    r267014 r267544  
    4343public:
    4444    // Maximum FIFO length. (512 render quanta)
    45     static const size_t kMaxFIFOLength;
     45    static constexpr size_t maxFIFOLength { 65536 };
    4646
    47     // |fifoLength| cannot exceed |kMaxFIFOLength|. Otherwise it crashes.
     47    // |fifoLength| cannot exceed |maxFIFOLength|. Otherwise it crashes.
    4848    PushPullFIFO(unsigned numberOfChannels, size_t fifoLength);
    4949    ~PushPullFIFO();
  • trunk/Source/WebCore/platform/audio/Reverb.cpp

    r266501 r267544  
    4545
    4646// Empirical gain calibration tested across many impulse responses to ensure perceived volume is same as dry (unprocessed) signal
    47 const float GainCalibration = -58;
    48 const float GainCalibrationSampleRate = 44100;
     47constexpr float GainCalibration = -58;
     48constexpr float GainCalibrationSampleRate = 44100;
    4949
    5050// A minimum power value to when normalizing a silent (or very quiet) impulse response
    51 const float MinPower = 0.000125f;
     51constexpr float MinPower = 0.000125f;
    5252   
    5353static float calculateNormalizationScale(AudioBus* response)
  • trunk/Source/WebCore/platform/audio/ReverbAccumulationBuffer.cpp

    r218840 r267544  
    4343ReverbAccumulationBuffer::ReverbAccumulationBuffer(size_t length)
    4444    : m_buffer(length)
    45     , m_readIndex(0)
    46     , m_readTimeFrame(0)
    4745{
    4846}
  • trunk/Source/WebCore/platform/audio/ReverbAccumulationBuffer.h

    r248762 r267544  
    6060private:
    6161    AudioFloatArray m_buffer;
    62     size_t m_readIndex;
    63     size_t m_readTimeFrame; // for debugging (frame on continuous timeline)
     62    size_t m_readIndex { 0 };
     63    size_t m_readTimeFrame { 0 }; // for debugging (frame on continuous timeline)
    6464};
    6565
  • trunk/Source/WebCore/platform/audio/ReverbConvolver.cpp

    r266492 r267544  
    4141using namespace VectorMath;
    4242
    43 const int InputBufferSize = 8 * 16384;
     43constexpr int InputBufferSize = 8 * 16384;
    4444
    4545// We only process the leading portion of the impulse response in the real-time thread.  We don't exceed this length.
     
    5050// the very rough scheduling latencies are similar on these time-scales.  Of course, this code may need to be
    5151// tuned for individual platforms if this assumption is found to be incorrect.
    52 const size_t RealtimeFrameLimit = 8192  + 4096; // ~278msec @ 44.1KHz
    53 
    54 const size_t MinFFTSize = 128;
    55 const size_t MaxRealtimeFFTSize = 2048;
     52constexpr size_t RealtimeFrameLimit = 8192  + 4096; // ~278msec @ 44.1KHz
     53
     54constexpr size_t MinFFTSize = 128;
     55constexpr size_t MaxRealtimeFFTSize = 2048;
    5656
    5757ReverbConvolver::ReverbConvolver(AudioChannel* impulseResponse, size_t renderSliceSize, size_t maxFFTSize, size_t convolverRenderPhase, bool useBackgroundThreads, float scale)
  • trunk/Source/WebCore/platform/audio/ReverbConvolverStage.cpp

    r266492 r267544  
    4848    size_t fftSize, size_t renderPhase, size_t renderSliceSize, ReverbAccumulationBuffer* accumulationBuffer, float scale, bool directMode)
    4949    : m_accumulationBuffer(accumulationBuffer)
    50     , m_accumulationReadIndex(0)
    51     , m_inputReadIndex(0)
    5250    , m_directMode(directMode)
    5351{
  • trunk/Source/WebCore/platform/audio/ReverbConvolverStage.h

    r266492 r267544  
    6868
    6969    ReverbAccumulationBuffer* m_accumulationBuffer;
    70     int m_accumulationReadIndex;
    71     int m_inputReadIndex;
     70    int m_accumulationReadIndex { 0 };
     71    int m_inputReadIndex { 0 };
    7272
    7373    size_t m_preDelayLength;
  • trunk/Source/WebCore/platform/audio/ReverbInputBuffer.cpp

    r165676 r267544  
    3737ReverbInputBuffer::ReverbInputBuffer(size_t length)
    3838    : m_buffer(length)
    39     , m_writeIndex(0)
    4039{
    4140}
  • trunk/Source/WebCore/platform/audio/ReverbInputBuffer.h

    r248762 r267544  
    5858private:
    5959    AudioFloatArray m_buffer;
    60     size_t m_writeIndex;
     60    size_t m_writeIndex { 0 };
    6161};
    6262
Note: See TracChangeset for help on using the changeset viewer.