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

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

Issue 396263004: Switch the input code to use AudioBlockFifo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« media/base/audio_block_fifo.h ('K') | « media/base/audio_block_fifo.h ('k') | no next file » | 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 #include "media/base/audio_block_fifo.h" 5 #include "media/base/audio_block_fifo.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 26 matching lines...) Expand all
37 while (frames_to_push) { 37 while (frames_to_push) {
38 // Get the current write block. 38 // Get the current write block.
39 AudioBus* current_block = audio_blocks_[write_block_]; 39 AudioBus* current_block = audio_blocks_[write_block_];
40 40
41 // Figure out what segment sizes we need when adding the new content to 41 // Figure out what segment sizes we need when adding the new content to
42 // the FIFO. 42 // the FIFO.
43 const int push_frames = 43 const int push_frames =
44 std::min(block_frames_ - write_pos_, frames_to_push); 44 std::min(block_frames_ - write_pos_, frames_to_push);
45 45
46 // Deinterleave the content to the FIFO and update the |write_pos_|. 46 // Deinterleave the content to the FIFO and update the |write_pos_|.
47 current_block->FromInterleaved(source_ptr, push_frames, bytes_per_sample); 47 current_block->FromInterleavedPartial(source_ptr, write_pos_, push_frames,
DaleCurtis 2014/07/18 18:21:54 Whoops. Is this style clang-format approved?
no longer working on chromium 2014/07/21 15:13:30 Fixed.
48 bytes_per_sample);
48 write_pos_ = (write_pos_ + push_frames) % block_frames_; 49 write_pos_ = (write_pos_ + push_frames) % block_frames_;
49 if (!write_pos_) { 50 if (!write_pos_) {
50 // The current block is completely filled, increment |write_block_| and 51 // The current block is completely filled, increment |write_block_| and
51 // |available_blocks_|. 52 // |available_blocks_|.
52 write_block_ = (write_block_ + 1) % audio_blocks_.size(); 53 write_block_ = (write_block_ + 1) % audio_blocks_.size();
53 ++available_blocks_; 54 ++available_blocks_;
54 } 55 }
55 56
56 source_ptr += push_frames * bytes_per_sample * current_block->channels(); 57 source_ptr += push_frames * bytes_per_sample * current_block->channels();
57 frames_to_push -= push_frames; 58 frames_to_push -= push_frames;
59 DCHECK_GE(frames_to_push, 0);
58 } 60 }
59 } 61 }
60 62
61 const AudioBus* AudioBlockFifo::Consume() { 63 const AudioBus* AudioBlockFifo::Consume() {
62 DCHECK(available_blocks_); 64 DCHECK(available_blocks_);
63 AudioBus* audio_bus = audio_blocks_[read_block_]; 65 AudioBus* audio_bus = audio_blocks_[read_block_];
64 read_block_ = (read_block_ + 1) % audio_blocks_.size(); 66 read_block_ = (read_block_ + 1) % audio_blocks_.size();
65 --available_blocks_; 67 --available_blocks_;
66 return audio_bus; 68 return audio_bus;
67 } 69 }
68 70
69 void AudioBlockFifo::Clear() { 71 void AudioBlockFifo::Clear() {
70 write_pos_ = 0; 72 write_pos_ = 0;
71 write_block_ = 0; 73 write_block_ = 0;
72 read_block_ = 0; 74 read_block_ = 0;
73 available_blocks_ = 0; 75 available_blocks_ = 0;
74 } 76 }
75 77
76 int AudioBlockFifo::GetUnfilledFrames() const { 78 int AudioBlockFifo::GetUnfilledFrames() const {
77 const int unfilled_frames = 79 const int unfilled_frames =
78 (audio_blocks_.size() - available_blocks_) * block_frames_ - write_pos_; 80 (audio_blocks_.size() - available_blocks_) * block_frames_ - write_pos_;
79 DCHECK_GE(unfilled_frames, 0); 81 DCHECK_GE(unfilled_frames, 0);
80 return unfilled_frames; 82 return unfilled_frames;
81 } 83 }
82 84
83 } // namespace media 85 } // namespace media
OLDNEW
« media/base/audio_block_fifo.h ('K') | « media/base/audio_block_fifo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698