| Index: third_party/WebKit/Source/platform/audio/AudioRenderSink.h
|
| diff --git a/third_party/WebKit/Source/platform/audio/AudioRenderSink.h b/third_party/WebKit/Source/platform/audio/AudioRenderSink.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a914e1e45e5966ec38c657b6827ff513fb6b1fa9
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/platform/audio/AudioRenderSink.h
|
| @@ -0,0 +1,79 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef AudioRenderSink_h
|
| +#define AudioRenderSink_h
|
| +
|
| +#include "platform/audio/AudioBus.h"
|
| +#include "platform/audio/AudioIOCallback.h"
|
| +#include "platform/audio/AudioSourceProvider.h"
|
| +#include "public/platform/WebAudioDevice.h"
|
| +#include "public/platform/WebVector.h"
|
| +#include "wtf/Allocator.h"
|
| +#include "wtf/Noncopyable.h"
|
| +#include "wtf/text/WTFString.h"
|
| +
|
| +namespace blink {
|
| +
|
| +class AudioPullFIFO;
|
| +class SecurityOrigin;
|
| +
|
| +// AudioRenderSink is a platform-level intermediate layer (that is not abstract)
|
| +// between Web Audio graph and the audio stack in Chrome media. The most
|
| +// important role of this class is to respond to the isochronous audio callback
|
| +// from the audio thread.
|
| +class PLATFORM_EXPORT AudioRenderSink : public WebAudioDevice::RenderCallback, public AudioSourceProvider {
|
| + USING_FAST_MALLOC(AudioRenderSink);
|
| + WTF_MAKE_NONCOPYABLE(AudioRenderSink);
|
| +
|
| +public:
|
| + AudioRenderSink(AudioIOCallback&, const String&, unsigned, unsigned, float, const PassRefPtr<SecurityOrigin>&);
|
| + ~AudioRenderSink() override;
|
| +
|
| + static PassOwnPtr<AudioRenderSink> create(AudioIOCallback&, const String&, unsigned, unsigned, float, const PassRefPtr<SecurityOrigin>&);
|
| + static size_t renderQuantumSize();
|
| + static unsigned audioHardwareBufferSize();
|
| + static float audioHardwareSampleRate();
|
| + static unsigned audioHardwareChannelCount();
|
| +
|
| + virtual void start();
|
| + virtual void stop();
|
| +
|
| + // This implements WebAudioDevice::RenderCallback. It is the actual callback
|
| + // function that is called from the audio stack in an isochronous fashion.
|
| + //
|
| + // |source| is for the live input, and |destination| is the final audio
|
| + // buffer passed to the audio stack.
|
| + void render(const WebVector<float*>& source, const WebVector<float*>& destination, size_t framesToProcess) override;
|
| +
|
| + // WIP: Mock-up AudioSourceProvider
|
| + void provideInput(AudioBus*, size_t numberOfFrames);
|
| +
|
| + bool isRunning() { return m_isRunning; }
|
| + size_t callbackBufferSize() const { return m_callbackBufferSize; }
|
| + float sampleRate() const { return m_sampleRate; }
|
| + unsigned numberOfOutputChannels() const { return m_numberOfOutputChannels; }
|
| +
|
| +private:
|
| + bool m_isRunning;
|
| + size_t m_callbackBufferSize;
|
| + float m_sampleRate;
|
| + unsigned m_numberOfOutputChannels;
|
| +
|
| + // Callback reference of AudioDestinationNode's render function.
|
| + AudioIOCallback& m_callback;
|
| +
|
| + // Abstract interface to the actual chromium audio stack.
|
| + OwnPtr<WebAudioDevice> m_webAudioDevice;
|
| +
|
| + // Containers for live input and output to the audio stack.
|
| + RefPtr<AudioBus> m_inputBus;
|
| + RefPtr<AudioBus> m_outputBus;
|
| +
|
| + OwnPtr<AudioPullFIFO> m_pullFifo;
|
| +};
|
| +
|
| +} // namespace blink
|
| +
|
| +#endif // AudioRenderSink_h
|
|
|