Index: third_party/WebKit/Source/platform/audio/PushPullFIFO.h |
diff --git a/third_party/WebKit/Source/platform/audio/PushPullFIFO.h b/third_party/WebKit/Source/platform/audio/PushPullFIFO.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..22ff551b2aecdf7309932b8ff2d68febc9501c57 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/audio/PushPullFIFO.h |
@@ -0,0 +1,44 @@ |
+// 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 PushPullFIFO_h |
+#define PushPullFIFO_h |
+ |
+#include "platform/audio/AudioBus.h" |
+#include "wtf/Allocator.h" |
+ |
+namespace blink { |
+ |
+class PushPullFIFO { |
+ USING_FAST_MALLOC(PushPullFIFO); |
+ WTF_MAKE_NONCOPYABLE(PushPullFIFO); |
+ |
+ public: |
+ PushPullFIFO(unsigned numberOfChannels, size_t length); |
+ ~PushPullFIFO(); |
+ |
+ // Pushing audio data is done by the WebAudio render-backing thread. The |
+ // priority of this thread is lower than the actual audio device thread, |
+ // thus the thread can be blocked when the audio device thread is pulling |
+ // data from the FIFO. |
+ void push(const AudioBus* inputBus); |
+ |
+ // Pulling audio data is done by the audio device thread. This process must |
+ // be non-blocking to ensure the glitch-less audio playback. |
+ void pull(AudioBus* outputBus, size_t framesToPull); |
o1ka
2017/01/09 14:09:03
How do you plan to ensure thread safety?
hongchan
2017/01/09 21:53:16
I believe this FIFO should give the higher priorit
|
+ |
+ size_t numberOfFrames() const { return m_numberOfFrames; } |
+ |
+ private: |
+ RefPtr<AudioBus> m_dataBus; |
Raymond Toy
2017/01/06 22:22:03
Maybe m_fifoDataBus?
hongchan
2017/01/09 21:53:16
Done.
|
+ |
+ size_t m_length; |
+ size_t m_numberOfFrames; |
+ size_t m_indexRead; |
+ size_t m_indexWrite; |
Raymond Toy
2017/01/06 22:22:03
Please document what all of these mean. If m_leng
hongchan
2017/01/09 21:53:16
Done.
AudioBus uses the term 'length'. The FIFO
|
+}; |
+ |
+} // namespace blink |
+ |
+#endif // PushPullFIFO_h |