summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authordalecurtis <dalecurtis@chromium.org>2014-09-26 15:04:43 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-26 22:05:15 +0000
commit1dbc64a018d46617f2802844dc9080f0cc3aacc2 (patch)
treeadd266887ffc92ae283a84d99a945f5664ed8bfb /media
parent04b34e02245194b01c08cd5cfb350378797e8681 (diff)
downloadchromium_src-1dbc64a018d46617f2802844dc9080f0cc3aacc2.zip
chromium_src-1dbc64a018d46617f2802844dc9080f0cc3aacc2.tar.gz
chromium_src-1dbc64a018d46617f2802844dc9080f0cc3aacc2.tar.bz2
Cleanup some audio classes with C++11 shine!
Use newly allowed features to cleanup some audio code: - auto for iterator based for loop. - nullptr for NULL. Additionally const& cleanup found while cleaning. BUG=none TEST=unittests pass. Review URL: https://codereview.chromium.org/602193003 Cr-Commit-Position: refs/heads/master@{#297048}
Diffstat (limited to 'media')
-rw-r--r--media/audio/audio_output_resampler.cc8
-rw-r--r--media/base/audio_converter.cc7
-rw-r--r--media/base/audio_renderer_mixer.cc7
-rw-r--r--media/base/audio_splicer.cc8
-rw-r--r--media/base/audio_splicer.h2
5 files changed, 12 insertions, 20 deletions
diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc
index cf966e0..5926996 100644
--- a/media/audio/audio_output_resampler.cc
+++ b/media/audio/audio_output_resampler.cc
@@ -40,7 +40,7 @@ class OnMoreDataConverter
// Clears |source_callback_| and flushes the resampler.
void Stop();
- bool started() { return source_callback_ != NULL; }
+ bool started() { return source_callback_ != nullptr; }
private:
// AudioConverter::InputCallback implementation.
@@ -237,7 +237,7 @@ bool AudioOutputResampler::StartStream(
AudioOutputProxy* stream_proxy) {
DCHECK(task_runner_->BelongsToCurrentThread());
- OnMoreDataConverter* resampler_callback = NULL;
+ OnMoreDataConverter* resampler_callback = nullptr;
CallbackMap::iterator it = callbacks_.find(stream_proxy);
if (it == callbacks_.end()) {
resampler_callback = new OnMoreDataConverter(params_, output_params_);
@@ -299,7 +299,7 @@ OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params,
const AudioParameters& output_params)
: io_ratio_(static_cast<double>(input_params.GetBytesPerSecond()) /
output_params.GetBytesPerSecond()),
- source_callback_(NULL),
+ source_callback_(nullptr),
input_bytes_per_second_(input_params.GetBytesPerSecond()),
audio_converter_(input_params, output_params, false) {}
@@ -322,7 +322,7 @@ void OnMoreDataConverter::Start(
void OnMoreDataConverter::Stop() {
CHECK(source_callback_);
- source_callback_ = NULL;
+ source_callback_ = nullptr;
audio_converter_.RemoveInput(this);
}
diff --git a/media/base/audio_converter.cc b/media/base/audio_converter.cc
index aa0be4f..1941119 100644
--- a/media/base/audio_converter.cc
+++ b/media/base/audio_converter.cc
@@ -197,14 +197,11 @@ void AudioConverter::SourceCallback(int fifo_frame_delay, AudioBus* dest) {
transform_inputs_.size() == 1 ? temp_dest : mixer_input_audio_bus_.get();
// Have each mixer render its data into an output buffer then mix the result.
- for (InputCallbackSet::iterator it = transform_inputs_.begin();
- it != transform_inputs_.end(); ++it) {
- InputCallback* input = *it;
-
+ for (auto* input : transform_inputs_) {
const float volume = input->ProvideInput(provide_input_dest, buffer_delay);
// Optimize the most common single input, full volume case.
- if (it == transform_inputs_.begin()) {
+ if (input == transform_inputs_.front()) {
if (volume == 1.0f) {
if (temp_dest != provide_input_dest)
provide_input_dest->CopyTo(temp_dest);
diff --git a/media/base/audio_renderer_mixer.cc b/media/base/audio_renderer_mixer.cc
index 2695651..112d7ef 100644
--- a/media/base/audio_renderer_mixer.cc
+++ b/media/base/audio_renderer_mixer.cc
@@ -94,11 +94,8 @@ int AudioRendererMixer::Render(AudioBus* audio_bus,
void AudioRendererMixer::OnRenderError() {
// Call each mixer input and signal an error.
base::AutoLock auto_lock(lock_);
- for (ErrorCallbackList::const_iterator it = error_callbacks_.begin();
- it != error_callbacks_.end();
- ++it) {
- it->Run();
- }
+ for (const auto& cb : error_callbacks_)
+ cb.Run();
}
} // namespace media
diff --git a/media/base/audio_splicer.cc b/media/base/audio_splicer.cc
index c8e0d4d..9424b0b 100644
--- a/media/base/audio_splicer.cc
+++ b/media/base/audio_splicer.cc
@@ -214,10 +214,8 @@ void AudioStreamSanitizer::AddOutputBuffer(
int AudioStreamSanitizer::GetFrameCount() const {
int frame_count = 0;
- for (BufferQueue::const_iterator it = output_buffers_.begin();
- it != output_buffers_.end(); ++it) {
- frame_count += (*it)->frame_count();
- }
+ for (const auto& buffer : output_buffers_)
+ frame_count += buffer->frame_count();
return frame_count;
}
@@ -451,7 +449,7 @@ scoped_ptr<AudioBus> AudioSplicer::ExtractCrossfadeFromPreSplice(
void AudioSplicer::CrossfadePostSplice(
scoped_ptr<AudioBus> pre_splice_bus,
- scoped_refptr<AudioBuffer> crossfade_buffer) {
+ const scoped_refptr<AudioBuffer>& crossfade_buffer) {
// Use the calculated timestamp and duration to ensure there's no extra gaps
// or overlaps to process when adding the buffer to |output_sanitizer_|.
const AudioTimestampHelper& output_ts_helper =
diff --git a/media/base/audio_splicer.h b/media/base/audio_splicer.h
index 0db5d08..e32a9fd 100644
--- a/media/base/audio_splicer.h
+++ b/media/base/audio_splicer.h
@@ -85,7 +85,7 @@ class MEDIA_EXPORT AudioSplicer {
//
// |post_splice_sanitizer_| will be empty after this operation.
void CrossfadePostSplice(scoped_ptr<AudioBus> pre_splice_bus,
- scoped_refptr<AudioBuffer> crossfade_buffer);
+ const scoped_refptr<AudioBuffer>& crossfade_buffer);
// Reset the splice and splice end timestamps.
void reset_splice_timestamps() {