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

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

Issue 1596523005: Drop WebRTC audio data if OS has skipped frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review (peah@) + rebase. Created 4 years, 11 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/base/audio_pull_fifo.h ('k') | media/base/audio_pull_fifo_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_pull_fifo.h" 5 #include "media/base/audio_pull_fifo.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 28 matching lines...) Expand all
39 // Try to fulfill the request using what's available in the FIFO. 39 // Try to fulfill the request using what's available in the FIFO.
40 frames_read = 40 frames_read =
41 ReadFromFifo(destination, remaining_frames_to_provide, write_pos); 41 ReadFromFifo(destination, remaining_frames_to_provide, write_pos);
42 write_pos += frames_read; 42 write_pos += frames_read;
43 remaining_frames_to_provide -= frames_read; 43 remaining_frames_to_provide -= frames_read;
44 } 44 }
45 } 45 }
46 46
47 void AudioPullFifo::Clear() { fifo_index_ = fifo_->frames(); } 47 void AudioPullFifo::Clear() { fifo_index_ = fifo_->frames(); }
48 48
49 int AudioPullFifo::SizeInFrames() {
tommi (sloooow) - chröme 2016/01/21 11:51:12 can this method be const?
Henrik Grunell 2016/01/21 12:26:16 Yep. Done.
50 return fifo_->frames();
51 }
52
49 int AudioPullFifo::ReadFromFifo(AudioBus* destination, 53 int AudioPullFifo::ReadFromFifo(AudioBus* destination,
50 int frames_to_provide, 54 int frames_to_provide,
51 int write_pos) { 55 int write_pos) {
52 int frames = std::min(frames_to_provide, fifo_->frames() - fifo_index_); 56 int frames = std::min(frames_to_provide, fifo_->frames() - fifo_index_);
53 if (frames <= 0) 57 if (frames <= 0)
54 return 0; 58 return 0;
55 59
56 for (int ch = 0; ch < fifo_->channels(); ++ch) { 60 for (int ch = 0; ch < fifo_->channels(); ++ch) {
57 const float* src = fifo_->channel(ch) + fifo_index_; 61 const float* src = fifo_->channel(ch) + fifo_index_;
58 float* dest = destination->channel(ch) + write_pos; 62 float* dest = destination->channel(ch) + write_pos;
59 memcpy(dest, src, frames * sizeof(*src)); 63 memcpy(dest, src, frames * sizeof(*src));
60 } 64 }
61 65
62 fifo_index_ += frames; 66 fifo_index_ += frames;
63 return frames; 67 return frames;
64 } 68 }
65 69
66 } // namespace media 70 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_pull_fifo.h ('k') | media/base/audio_pull_fifo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698