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

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

Issue 2158923004: Convert media constants to constexpr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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_buffer_converter.h" 5 #include "media/base/audio_buffer_converter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // We'll need a new |audio_converter_| if there was a config change. 49 // We'll need a new |audio_converter_| if there was a config change.
50 if (IsConfigChange(input_params_, buffer)) 50 if (IsConfigChange(input_params_, buffer))
51 ResetConverter(buffer); 51 ResetConverter(buffer);
52 52
53 // Pass straight through if there's no work to be done. 53 // Pass straight through if there's no work to be done.
54 if (!audio_converter_) { 54 if (!audio_converter_) {
55 queued_outputs_.push_back(buffer); 55 queued_outputs_.push_back(buffer);
56 return; 56 return;
57 } 57 }
58 58
59 if (timestamp_helper_.base_timestamp() == kNoTimestamp()) 59 if (timestamp_helper_.base_timestamp() == kNoTimestamp)
60 timestamp_helper_.SetBaseTimestamp(buffer->timestamp()); 60 timestamp_helper_.SetBaseTimestamp(buffer->timestamp());
61 61
62 queued_inputs_.push_back(buffer); 62 queued_inputs_.push_back(buffer);
63 input_frames_ += buffer->frame_count(); 63 input_frames_ += buffer->frame_count();
64 64
65 ConvertIfPossible(); 65 ConvertIfPossible();
66 } 66 }
67 67
68 bool AudioBufferConverter::HasNextBuffer() { return !queued_outputs_.empty(); } 68 bool AudioBufferConverter::HasNextBuffer() { return !queued_outputs_.empty(); }
69 69
70 scoped_refptr<AudioBuffer> AudioBufferConverter::GetNextBuffer() { 70 scoped_refptr<AudioBuffer> AudioBufferConverter::GetNextBuffer() {
71 DCHECK(!queued_outputs_.empty()); 71 DCHECK(!queued_outputs_.empty());
72 scoped_refptr<AudioBuffer> out = queued_outputs_.front(); 72 scoped_refptr<AudioBuffer> out = queued_outputs_.front();
73 queued_outputs_.pop_front(); 73 queued_outputs_.pop_front();
74 return out; 74 return out;
75 } 75 }
76 76
77 void AudioBufferConverter::Reset() { 77 void AudioBufferConverter::Reset() {
78 audio_converter_.reset(); 78 audio_converter_.reset();
79 queued_inputs_.clear(); 79 queued_inputs_.clear();
80 queued_outputs_.clear(); 80 queued_outputs_.clear();
81 timestamp_helper_.SetBaseTimestamp(kNoTimestamp()); 81 timestamp_helper_.SetBaseTimestamp(kNoTimestamp);
82 input_params_ = output_params_; 82 input_params_ = output_params_;
83 input_frames_ = 0; 83 input_frames_ = 0;
84 buffered_input_frames_ = 0.0; 84 buffered_input_frames_ = 0.0;
85 last_input_buffer_offset_ = 0; 85 last_input_buffer_offset_ = 0;
86 } 86 }
87 87
88 void AudioBufferConverter::ResetTimestampState() { 88 void AudioBufferConverter::ResetTimestampState() {
89 Flush(); 89 Flush();
90 timestamp_helper_.SetBaseTimestamp(kNoTimestamp()); 90 timestamp_helper_.SetBaseTimestamp(kNoTimestamp);
91 } 91 }
92 92
93 double AudioBufferConverter::ProvideInput(AudioBus* audio_bus, 93 double AudioBufferConverter::ProvideInput(AudioBus* audio_bus,
94 uint32_t frames_delayed) { 94 uint32_t frames_delayed) {
95 DCHECK(is_flushing_ || input_frames_ >= audio_bus->frames()); 95 DCHECK(is_flushing_ || input_frames_ >= audio_bus->frames());
96 96
97 int requested_frames_left = audio_bus->frames(); 97 int requested_frames_left = audio_bus->frames();
98 int dest_index = 0; 98 int dest_index = 0;
99 99
100 while (requested_frames_left > 0 && !queued_inputs_.empty()) { 100 while (requested_frames_left > 0 && !queued_inputs_.empty()) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 is_flushing_ = false; 240 is_flushing_ = false;
241 audio_converter_->Reset(); 241 audio_converter_->Reset();
242 DCHECK_EQ(input_frames_, 0); 242 DCHECK_EQ(input_frames_, 0);
243 DCHECK_EQ(last_input_buffer_offset_, 0); 243 DCHECK_EQ(last_input_buffer_offset_, 0);
244 DCHECK_LT(buffered_input_frames_, 1.0); 244 DCHECK_LT(buffered_input_frames_, 1.0);
245 DCHECK(queued_inputs_.empty()); 245 DCHECK(queued_inputs_.empty());
246 buffered_input_frames_ = 0.0; 246 buffered_input_frames_ = 0.0;
247 } 247 }
248 248
249 } // namespace media 249 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698