OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/renderer_host/media/audio_output_delegate_impl.h" | 5 #include "content/browser/renderer_host/media/audio_output_delegate_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 subscriber_->OnStreamCreated(stream_id_, reader_->shared_memory(), | 173 subscriber_->OnStreamCreated(stream_id_, reader_->shared_memory(), |
174 reader_->foreign_socket()); | 174 reader_->foreign_socket()); |
175 } | 175 } |
176 | 176 |
177 void AudioOutputDelegateImpl::UpdatePlayingState(bool playing) { | 177 void AudioOutputDelegateImpl::UpdatePlayingState(bool playing) { |
178 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 178 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
179 if (playing == playing_) | 179 if (playing == playing_) |
180 return; | 180 return; |
181 | 181 |
182 playing_ = playing; | 182 playing_ = playing; |
183 subscriber_->OnStreamStateChanged(playing); | |
184 if (playing) { | 183 if (playing) { |
185 // Note that this takes a reference to |controller_|, and | 184 // Note that this takes a reference to |controller_|, and |
186 // (Start|Stop)MonitoringStream calls are async, so we don't have a | 185 // (Start|Stop)MonitoringStream calls are async, so we don't have a |
187 // guarantee for when the controller is destroyed. | 186 // guarantee for when the controller is destroyed. |
188 AudioStreamMonitor::StartMonitoringStream( | 187 AudioStreamMonitor::StartMonitoringStream( |
189 render_process_id_, render_frame_id_, stream_id_, | 188 render_process_id_, render_frame_id_, stream_id_, |
190 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, | 189 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, |
191 controller_)); | 190 controller_)); |
192 } else { | 191 } else { |
193 AudioStreamMonitor::StopMonitoringStream(render_process_id_, | 192 AudioStreamMonitor::StopMonitoringStream(render_process_id_, |
194 render_frame_id_, stream_id_); | 193 render_frame_id_, stream_id_); |
195 } | 194 } |
196 } | 195 } |
197 | 196 |
198 void AudioOutputDelegateImpl::OnError() { | 197 void AudioOutputDelegateImpl::OnError() { |
199 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 198 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
200 | 199 |
201 audio_log_->OnError(stream_id_); | 200 audio_log_->OnError(stream_id_); |
202 subscriber_->OnStreamError(stream_id_); | 201 subscriber_->OnStreamError(stream_id_); |
203 } | 202 } |
204 | 203 |
205 } // namespace content | 204 } // namespace content |
OLD | NEW |