Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1092)

Side by Side Diff: third_party/WebKit/Source/platform/audio/PushPullFIFO.h

Issue 2549093009: Introduce PushPullFIFO class and remove other FIFOs (Closed)
Patch Set: More comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "public/platform/WebCommon.h"
10 #include "wtf/Allocator.h"
11
12 namespace blink {
13
14 // PushPullFIFO class is an intermediate audio sample storage between
15 // Blink-WebAudio and the renderer. The renderer's hardware callback buffer size
16 // varies on the platform, but the WebAudio always operates by 128 frames of
17 // render quantum; thus FIFO is needed.
18 class BLINK_PLATFORM_EXPORT PushPullFIFO {
19 USING_FAST_MALLOC(PushPullFIFO);
20 WTF_MAKE_NONCOPYABLE(PushPullFIFO);
21
22 public:
23 PushPullFIFO(unsigned numberOfChannels, size_t fifoLength);
24 ~PushPullFIFO();
25
26 // Pushing audio data is done by the WebAudio render-backing thread. The
o1ka 2017/01/24 11:09:02 Do you plan to first finalize all the index calcul
hongchan 2017/01/26 22:33:18 Yes. That's the plan. The FIFO in this CL should
27 // priority of this thread is lower than the actual audio device thread,
28 // thus the thread can be blocked when the audio device thread is pulling
29 // data from the FIFO.
30 void push(const AudioBus* inputBus);
31
32 // Pulling audio data is done by the audio device thread. In the case of
33 // underflow, the rest will be filled up with zeros (thus glitches). Pulling
34 // an empty FIFO is a valid operation, and the consumer will get a block of
35 // silence.
36 void pull(AudioBus* outputBus, size_t framesRequested);
37
38 int framesAvailable() const { return m_framesAvailable; }
39 int length() const { return m_fifoLength; }
40 unsigned numberOfChannels() const { return m_fifoBus->numberOfChannels(); }
41 AudioBus* bus() { return m_fifoBus.get(); }
42
43 private:
44 RefPtr<AudioBus> m_fifoBus;
45
46 // The size of the FIFO.
47 const int m_fifoLength;
o1ka 2017/01/24 11:09:02 You can use "= 0" initialization here.
hongchan 2017/01/26 22:33:18 Done.
48
49 // The number of frames in the FIFO actually available for pulling.
50 int m_framesAvailable;
51
52 int m_indexRead;
53 int m_indexWrite;
54
55 unsigned m_overflowCount;
o1ka 2017/01/24 11:09:02 We should not use a mix of size_t, int and unsigne
hongchan 2017/01/26 22:33:18 This is a great resource. Thanks and we will follo
56 unsigned m_underflowCount;
57 };
58
59 } // namespace blink
60
61 #endif // PushPullFIFO_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698