OLD | NEW |
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/audio/audio_output_stream_sink.h" | 5 #include "media/audio/audio_output_stream_sink.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 FROM_HERE, base::Bind(&AudioOutputStreamSink::DoSetVolume, this, volume)); | 72 FROM_HERE, base::Bind(&AudioOutputStreamSink::DoSetVolume, this, volume)); |
73 return true; | 73 return true; |
74 } | 74 } |
75 | 75 |
76 OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() { | 76 OutputDeviceInfo AudioOutputStreamSink::GetOutputDeviceInfo() { |
77 return OutputDeviceInfo(); | 77 return OutputDeviceInfo(); |
78 } | 78 } |
79 | 79 |
80 int AudioOutputStreamSink::OnMoreData(AudioBus* dest, | 80 int AudioOutputStreamSink::OnMoreData(AudioBus* dest, |
81 uint32_t total_bytes_delay, | 81 uint32_t total_bytes_delay, |
82 uint32_t frames_skipped) { | 82 uint32_t frames_skipped, |
| 83 const AudioTimestamp& timestamp) { |
83 // Note: Runs on the audio thread created by the OS. | 84 // Note: Runs on the audio thread created by the OS. |
84 base::AutoLock al(callback_lock_); | 85 base::AutoLock al(callback_lock_); |
85 if (!active_render_callback_) | 86 if (!active_render_callback_) |
86 return 0; | 87 return 0; |
87 | 88 |
88 uint32_t frames_delayed = std::round(static_cast<double>(total_bytes_delay) / | 89 uint32_t frames_delayed = std::round(static_cast<double>(total_bytes_delay) / |
89 active_params_.GetBytesPerFrame()); | 90 active_params_.GetBytesPerFrame()); |
90 | 91 |
91 return active_render_callback_->Render(dest, frames_delayed, frames_skipped); | 92 return active_render_callback_->Render(dest, frames_delayed, frames_skipped, |
| 93 timestamp); |
92 } | 94 } |
93 | 95 |
94 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) { | 96 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) { |
95 // Note: Runs on the audio thread created by the OS. | 97 // Note: Runs on the audio thread created by the OS. |
96 base::AutoLock al(callback_lock_); | 98 base::AutoLock al(callback_lock_); |
97 if (active_render_callback_) | 99 if (active_render_callback_) |
98 active_render_callback_->OnRenderError(); | 100 active_render_callback_->OnRenderError(); |
99 } | 101 } |
100 | 102 |
101 void AudioOutputStreamSink::DoStart(const AudioParameters& params) { | 103 void AudioOutputStreamSink::DoStart(const AudioParameters& params) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 DCHECK(audio_task_runner_->BelongsToCurrentThread()); | 145 DCHECK(audio_task_runner_->BelongsToCurrentThread()); |
144 stream_->SetVolume(volume); | 146 stream_->SetVolume(volume); |
145 } | 147 } |
146 | 148 |
147 void AudioOutputStreamSink::ClearCallback() { | 149 void AudioOutputStreamSink::ClearCallback() { |
148 base::AutoLock al(callback_lock_); | 150 base::AutoLock al(callback_lock_); |
149 active_render_callback_ = NULL; | 151 active_render_callback_ = NULL; |
150 } | 152 } |
151 | 153 |
152 } // namepace media | 154 } // namepace media |
OLD | NEW |