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

Side by Side Diff: media/base/audio_block_fifo.h

Issue 532303002: Revert of Reland 501823002: Used native deinterleaved and float point format for the input streams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.cc ('k') | media/base/audio_block_fifo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 5 #ifndef MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
6 #define MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 6 #define MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
7 7
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "media/base/audio_bus.h" 9 #include "media/base/audio_bus.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
(...skipping 10 matching lines...) Expand all
21 // Creates a new AudioBlockFifo and allocates |blocks| memory, each block 21 // Creates a new AudioBlockFifo and allocates |blocks| memory, each block
22 // of memory can store |channels| of length |frames| data. 22 // of memory can store |channels| of length |frames| data.
23 AudioBlockFifo(int channels, int frames, int blocks); 23 AudioBlockFifo(int channels, int frames, int blocks);
24 virtual ~AudioBlockFifo(); 24 virtual ~AudioBlockFifo();
25 25
26 // Pushes interleaved audio data from |source| to the FIFO. 26 // Pushes interleaved audio data from |source| to the FIFO.
27 // The method will deinterleave the data into a audio bus. 27 // The method will deinterleave the data into a audio bus.
28 // Push() will crash if the allocated space is insufficient. 28 // Push() will crash if the allocated space is insufficient.
29 void Push(const void* source, int frames, int bytes_per_sample); 29 void Push(const void* source, int frames, int bytes_per_sample);
30 30
31 // Pushes the audio data from |source| to the FIFO.
32 // Push() will crash if the allocated space is insufficient.
33 void Push(const AudioBus* source);
34
35 // Consumes a block of audio from the FIFO. Returns an AudioBus which 31 // Consumes a block of audio from the FIFO. Returns an AudioBus which
36 // contains the consumed audio data to avoid copying. 32 // contains the consumed audio data to avoid copying.
37 // Consume() will crash if the FIFO does not contain a block of data. 33 // Consume() will crash if the FIFO does not contain a block of data.
38 const AudioBus* Consume(); 34 const AudioBus* Consume();
39 35
40 // Empties the FIFO without deallocating any memory. 36 // Empties the FIFO without deallocating any memory.
41 void Clear(); 37 void Clear();
42 38
43 // Number of available block of memory ready to be consumed in the FIFO. 39 // Number of available block of memory ready to be consumed in the FIFO.
44 int available_blocks() const { return available_blocks_; } 40 int available_blocks() const { return available_blocks_; }
45 41
46 // Number of available frames of data in the FIFO. 42 // Number of available frames of data in the FIFO.
47 int GetAvailableFrames() const; 43 int GetAvailableFrames() const;
48 44
49 // Number of unfilled frames in the whole FIFO. 45 // Number of unfilled frames in the whole FIFO.
50 int GetUnfilledFrames() const; 46 int GetUnfilledFrames() const;
51 47
52 private: 48 private:
53 // Helper method to update the indexes in Push methods.
54 void UpdatePosition(int push_frames);
55
56 // The actual FIFO is a vector of audio buses. 49 // The actual FIFO is a vector of audio buses.
57 ScopedVector<AudioBus> audio_blocks_; 50 ScopedVector<AudioBus> audio_blocks_;
58 51
59 // Maximum number of frames of data one block of memory can contain. 52 // Maximum number of frames of data one block of memory can contain.
60 // This value is set by |frames| in the constructor. 53 // This value is set by |frames| in the constructor.
61 const int block_frames_; 54 const int block_frames_;
62 55
63 // Used to keep track which block of memory to be written. 56 // Used to keep track which block of memory to be written.
64 int write_block_; 57 int write_block_;
65 58
66 // Used to keep track which block of memory to be consumed. 59 // Used to keep track which block of memory to be consumed.
67 int read_block_; 60 int read_block_;
68 61
69 // Number of available blocks of memory to be consumed. 62 // Number of available blocks of memory to be consumed.
70 int available_blocks_; 63 int available_blocks_;
71 64
72 // Current write position in the current written block. 65 // Current write position in the current written block.
73 int write_pos_; 66 int write_pos_;
74 67
75 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); 68 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo);
76 }; 69 };
77 70
78 } // namespace media 71 } // namespace media
79 72
80 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 73 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
OLDNEW
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.cc ('k') | media/base/audio_block_fifo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698