OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef AudioRenderSink_h |
| 6 #define AudioRenderSink_h |
| 7 |
| 8 #include "platform/audio/AudioBus.h" |
| 9 #include "platform/audio/AudioIOCallback.h" |
| 10 #include "platform/audio/AudioSourceProvider.h" |
| 11 #include "public/platform/WebAudioDevice.h" |
| 12 #include "public/platform/WebVector.h" |
| 13 #include "wtf/Allocator.h" |
| 14 #include "wtf/Noncopyable.h" |
| 15 #include "wtf/text/WTFString.h" |
| 16 |
| 17 namespace blink { |
| 18 |
| 19 class AudioPullFIFO; |
| 20 class SecurityOrigin; |
| 21 |
| 22 // AudioRenderSink is a platform-level intermediate layer (that is not abstract) |
| 23 // between Web Audio graph and the audio stack in Chrome media. The most |
| 24 // important role of this class is to respond to the isochronous audio callback |
| 25 // from the audio thread. |
| 26 class PLATFORM_EXPORT AudioRenderSink : public WebAudioDevice::RenderCallback, p
ublic AudioSourceProvider { |
| 27 USING_FAST_MALLOC(AudioRenderSink); |
| 28 WTF_MAKE_NONCOPYABLE(AudioRenderSink); |
| 29 |
| 30 public: |
| 31 AudioRenderSink(AudioIOCallback&, const String&, unsigned, unsigned, float,
const PassRefPtr<SecurityOrigin>&); |
| 32 ~AudioRenderSink() override; |
| 33 |
| 34 static PassOwnPtr<AudioRenderSink> create(AudioIOCallback&, const String&, u
nsigned, unsigned, float, const PassRefPtr<SecurityOrigin>&); |
| 35 static size_t renderQuantumSize(); |
| 36 static unsigned audioHardwareBufferSize(); |
| 37 static float audioHardwareSampleRate(); |
| 38 static unsigned audioHardwareChannelCount(); |
| 39 |
| 40 virtual void start(); |
| 41 virtual void stop(); |
| 42 |
| 43 // This implements WebAudioDevice::RenderCallback. It is the actual callback |
| 44 // function that is called from the audio stack in an isochronous fashion. |
| 45 // |
| 46 // |source| is for the live input, and |destination| is the final audio |
| 47 // buffer passed to the audio stack. |
| 48 void render(const WebVector<float*>& source, const WebVector<float*>& destin
ation, size_t framesToProcess) override; |
| 49 |
| 50 // WIP: Mock-up AudioSourceProvider |
| 51 void provideInput(AudioBus*, size_t numberOfFrames); |
| 52 |
| 53 bool isRunning() { return m_isRunning; } |
| 54 size_t callbackBufferSize() const { return m_callbackBufferSize; } |
| 55 float sampleRate() const { return m_sampleRate; } |
| 56 unsigned numberOfOutputChannels() const { return m_numberOfOutputChannels; } |
| 57 |
| 58 private: |
| 59 bool m_isRunning; |
| 60 size_t m_callbackBufferSize; |
| 61 float m_sampleRate; |
| 62 unsigned m_numberOfOutputChannels; |
| 63 |
| 64 // Callback reference of AudioDestinationNode's render function. |
| 65 AudioIOCallback& m_callback; |
| 66 |
| 67 // Abstract interface to the actual chromium audio stack. |
| 68 OwnPtr<WebAudioDevice> m_webAudioDevice; |
| 69 |
| 70 // Containers for live input and output to the audio stack. |
| 71 RefPtr<AudioBus> m_inputBus; |
| 72 RefPtr<AudioBus> m_outputBus; |
| 73 |
| 74 OwnPtr<AudioPullFIFO> m_pullFifo; |
| 75 }; |
| 76 |
| 77 } // namespace blink |
| 78 |
| 79 #endif // AudioRenderSink_h |
OLD | NEW |