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 PushPullFIFO_h | |
6 #define PushPullFIFO_h | |
7 | |
8 #include "platform/audio/AudioBus.h" | |
9 #include "wtf/Allocator.h" | |
10 #include "wtf/ThreadingPrimitives.h" | |
11 | |
12 namespace blink { | |
13 | |
14 class PushPullFIFO { | |
15 USING_FAST_MALLOC(PushPullFIFO); | |
16 WTF_MAKE_NONCOPYABLE(PushPullFIFO); | |
17 | |
18 public: | |
19 PushPullFIFO(unsigned numberOfChannels, size_t length); | |
20 ~PushPullFIFO(); | |
21 | |
22 // Pushing audio data is done by the WebAudio render-backing thread. The | |
23 // priority of this thread is lower than the actual audio device thread, | |
24 // thus the thread can be blocked when the audio device thread is pulling | |
25 // data from the FIFO. | |
26 void push(const AudioBus* inputBus); | |
27 | |
28 // Pulling audio data is done by the audio device thread. This process must | |
29 // be non-blocking to ensure the glitch-less audio playback. | |
30 void pull(AudioBus* outputBus, size_t framesToPull); | |
31 | |
32 // Returns the number of valid frames in FIFO. | |
Raymond Toy
2017/01/09 22:46:02
This comment is probably better placed as a descri
hongchan
2017/01/10 21:15:58
Done.
| |
33 size_t framesInFIFO() const { return m_framesInFIFO; } | |
o1ka
2017/01/10 10:07:20
This one can be inline.
o1ka
2017/01/10 16:41:39
Ignore this comment, I thought I was in cpp :)
| |
34 | |
35 private: | |
36 RefPtr<AudioBus> m_fifoDataBus; | |
37 Mutex m_fifoDataBusLock; | |
38 | |
39 size_t m_fifoLength; | |
o1ka
2017/01/10 10:07:20
const?
Raymond Toy
2017/01/10 16:18:15
Also, do all of these really need to be size_t? I
o1ka
2017/01/10 16:41:39
Agree. And as I mentioned somewhere we really need
hongchan
2017/01/10 21:15:58
I'll investigate corner cases in the next patch se
hongchan
2017/01/10 21:15:58
Done.
hongchan
2017/01/10 21:15:58
Are you suggesting we change our convention starti
| |
40 size_t m_framesInFIFO; | |
Raymond Toy
2017/01/09 22:46:02
I can guess the difference between m_fifoLength an
hongchan
2017/01/10 21:15:58
Done. Yes, that's correct.
| |
41 size_t m_indexRead; | |
42 size_t m_indexWrite; | |
43 }; | |
44 | |
45 } // namespace blink | |
46 | |
47 #endif // PushPullFIFO_h | |
OLD | NEW |