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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 } | 76 } |
77 | 77 |
78 int AudioOutputStreamSink::OnMoreData(AudioBus* dest, | 78 int AudioOutputStreamSink::OnMoreData(AudioBus* dest, |
79 uint32_t total_bytes_delay, | 79 uint32_t total_bytes_delay, |
80 uint32_t frames_skipped) { | 80 uint32_t frames_skipped) { |
81 // Note: Runs on the audio thread created by the OS. | 81 // Note: Runs on the audio thread created by the OS. |
82 base::AutoLock al(callback_lock_); | 82 base::AutoLock al(callback_lock_); |
83 if (!active_render_callback_) | 83 if (!active_render_callback_) |
84 return 0; | 84 return 0; |
85 | 85 |
86 return active_render_callback_->Render( | 86 uint32_t frames_delayed = std::round(static_cast<double>(total_bytes_delay) / |
87 dest, total_bytes_delay * 1000.0 / active_params_.GetBytesPerSecond(), 0); | 87 active_params_.GetBytesPerFrame()); |
88 | |
89 return active_render_callback_->Render(dest, frames_delayed, 0); | |
chcunningham
2016/02/11 01:25:42
frames_skipped is not propagated? Anyone know why?
DaleCurtis
2016/02/11 01:57:15
This is only used for Mojo demos currently I think
chcunningham
2016/02/11 21:02:52
Done.
Henrik Grunell
2016/02/12 17:47:01
|frames_skipped| is only used for WebRTC. Other cl
chcunningham
2016/02/17 01:56:52
Acknowledged.
| |
88 } | 90 } |
89 | 91 |
90 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) { | 92 void AudioOutputStreamSink::OnError(AudioOutputStream* stream) { |
91 // Note: Runs on the audio thread created by the OS. | 93 // Note: Runs on the audio thread created by the OS. |
92 base::AutoLock al(callback_lock_); | 94 base::AutoLock al(callback_lock_); |
93 if (active_render_callback_) | 95 if (active_render_callback_) |
94 active_render_callback_->OnRenderError(); | 96 active_render_callback_->OnRenderError(); |
95 } | 97 } |
96 | 98 |
97 void AudioOutputStreamSink::DoStart(const AudioParameters& params) { | 99 void AudioOutputStreamSink::DoStart(const AudioParameters& params) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 DCHECK(audio_task_runner_->BelongsToCurrentThread()); | 141 DCHECK(audio_task_runner_->BelongsToCurrentThread()); |
140 stream_->SetVolume(volume); | 142 stream_->SetVolume(volume); |
141 } | 143 } |
142 | 144 |
143 void AudioOutputStreamSink::ClearCallback() { | 145 void AudioOutputStreamSink::ClearCallback() { |
144 base::AutoLock al(callback_lock_); | 146 base::AutoLock al(callback_lock_); |
145 active_render_callback_ = NULL; | 147 active_render_callback_ = NULL; |
146 } | 148 } |
147 | 149 |
148 } // namepace media | 150 } // namepace media |
OLD | NEW |