| Index: third_party/WebKit/Source/platform/audio/AudioDestination.h
|
| diff --git a/third_party/WebKit/Source/platform/audio/AudioDestination.h b/third_party/WebKit/Source/platform/audio/AudioDestination.h
|
| index f1d13c3d6ce715714496458f324d1c2cd7459813..695eb3c05171ba86914e1056a6578229c691f7c4 100644
|
| --- a/third_party/WebKit/Source/platform/audio/AudioDestination.h
|
| +++ b/third_party/WebKit/Source/platform/audio/AudioDestination.h
|
| @@ -36,7 +36,6 @@
|
| #include "public/platform/WebVector.h"
|
| #include "wtf/Allocator.h"
|
| #include "wtf/Noncopyable.h"
|
| -#include "wtf/PassRefPtr.h"
|
| #include "wtf/text/WTFString.h"
|
| #include <memory>
|
|
|
| @@ -45,8 +44,10 @@ namespace blink {
|
| class AudioPullFIFO;
|
| class SecurityOrigin;
|
|
|
| -// An AudioDestination using Chromium's audio system
|
| -
|
| +// The AudioDestination class is an audio sink interface between the media
|
| +// renderer and the Blink's WebAudio module. It has a FIFO to adapt the
|
| +// different processing block sizes of WebAudio renderer and actual hardware
|
| +// audio callback.
|
| class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback,
|
| public AudioSourceProvider {
|
| USING_FAST_MALLOC(AudioDestination);
|
| @@ -54,66 +55,60 @@ class PLATFORM_EXPORT AudioDestination : public WebAudioDevice::RenderCallback,
|
|
|
| public:
|
| AudioDestination(AudioIOCallback&,
|
| - const String& inputDeviceId,
|
| - unsigned numberOfInputChannels,
|
| unsigned numberOfOutputChannels,
|
| float sampleRate,
|
| PassRefPtr<SecurityOrigin>);
|
| ~AudioDestination() override;
|
|
|
| - // Pass in (numberOfInputChannels > 0) if live/local audio input is desired.
|
| - // Port-specific device identification information for live/local input
|
| - // streams can be passed in the inputDeviceId.
|
| static std::unique_ptr<AudioDestination> create(
|
| AudioIOCallback&,
|
| - const String& inputDeviceId,
|
| - unsigned numberOfInputChannels,
|
| unsigned numberOfOutputChannels,
|
| float sampleRate,
|
| PassRefPtr<SecurityOrigin>);
|
|
|
| - virtual void start();
|
| - virtual void stop();
|
| - bool isPlaying() { return m_isPlaying; }
|
| -
|
| - float sampleRate() const { return m_sampleRate; }
|
| -
|
| - // WebAudioDevice::RenderCallback
|
| - void render(const WebVector<float*>& audioData,
|
| + // The actual render function (WebAudioDevice::RenderCallback) isochronously
|
| + // invoked by the media renderer.
|
| + void render(const WebVector<float*>& destinationData,
|
| size_t numberOfFrames,
|
| double delay,
|
| double delayTimestamp,
|
| size_t priorFramesSkipped) override;
|
|
|
| - // AudioSourceProvider
|
| - void provideInput(AudioBus*, size_t framesToProcess) override;
|
| + // AudioSourceProvider (FIFO)
|
| + void provideInput(AudioBus* outputBus, size_t framesToProcess) override;
|
|
|
| - static float hardwareSampleRate();
|
| + virtual void start();
|
| + virtual void stop();
|
|
|
| size_t callbackBufferSize() const { return m_callbackBufferSize; }
|
| + float sampleRate() const { return m_sampleRate; }
|
| + bool isPlaying() { return m_isPlaying; }
|
|
|
| - // maxChannelCount() returns the total number of output channels of the audio
|
| - // hardware. A value of 0 indicates that the number of channels cannot be
|
| - // configured and that only stereo (2-channel) destinations can be created.
|
| - // The numberOfOutputChannels parameter of AudioDestination::create() is
|
| - // allowed to be a value: 1 <= numberOfOutputChannels <= maxChannelCount(),
|
| - // or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2.
|
| + // The information from the actual audio hardware. (via Platform::current)
|
| + static size_t hardwareBufferSize();
|
| + static float hardwareSampleRate();
|
| static unsigned long maxChannelCount();
|
|
|
| private:
|
| - AudioIOCallback& m_callback;
|
| + std::unique_ptr<WebAudioDevice> m_webAudioDevice;
|
| unsigned m_numberOfOutputChannels;
|
| - RefPtr<AudioBus> m_renderBus;
|
| + size_t m_callbackBufferSize;
|
| float m_sampleRate;
|
| bool m_isPlaying;
|
| - std::unique_ptr<WebAudioDevice> m_audioDevice;
|
| - size_t m_callbackBufferSize;
|
|
|
| + // The render callback function of WebAudio engine. (i.e. DestinationNode)
|
| + AudioIOCallback& m_callback;
|
| +
|
| + RefPtr<AudioBus> m_outputBus;
|
| std::unique_ptr<AudioPullFIFO> m_fifo;
|
|
|
| size_t m_framesElapsed;
|
| AudioIOPosition m_outputPosition;
|
| base::TimeTicks m_outputPositionReceivedTimestamp;
|
| +
|
| + // Calculate the optimum buffer size for a given platform. Return false if the
|
| + // buffer size calculation fails.
|
| + bool calculateBufferSize();
|
| };
|
|
|
| } // namespace blink
|
|
|