| 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.h" | 5 #include "content/browser/renderer_host/media/audio_output_delegate.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "content/browser/media/audio_stream_monitor.h" | 10 #include "content/browser/media/audio_stream_monitor.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 reader_->foreign_socket()); | 155 reader_->foreign_socket()); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 void AudioOutputDelegate::UpdatePlayingState(bool playing) { | 159 void AudioOutputDelegate::UpdatePlayingState(bool playing) { |
| 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 160 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 161 if (!handler_ || playing == playing_) | 161 if (!handler_ || playing == playing_) |
| 162 return; | 162 return; |
| 163 | 163 |
| 164 playing_ = playing; | 164 playing_ = playing; |
| 165 handler_->OnStreamStateChanged(playing); | |
| 166 if (playing) { | 165 if (playing) { |
| 167 // Note that this takes a reference to |controller_|, and | 166 // Note that this takes a reference to |controller_|, and |
| 168 // (Start|Stop)MonitoringStream calls are async, so we don't have a | 167 // (Start|Stop)MonitoringStream calls are async, so we don't have a |
| 169 // guarantee for when the controller is destroyed. | 168 // guarantee for when the controller is destroyed. |
| 170 AudioStreamMonitor::StartMonitoringStream( | 169 AudioStreamMonitor::StartMonitoringStream( |
| 171 render_process_id_, render_frame_id_, stream_id_, | 170 render_process_id_, render_frame_id_, stream_id_, |
| 172 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, | 171 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, |
| 173 controller_)); | 172 controller_)); |
| 174 } else { | 173 } else { |
| 175 AudioStreamMonitor::StopMonitoringStream(render_process_id_, | 174 AudioStreamMonitor::StopMonitoringStream(render_process_id_, |
| 176 render_frame_id_, stream_id_); | 175 render_frame_id_, stream_id_); |
| 177 } | 176 } |
| 178 } | 177 } |
| 179 | 178 |
| 180 void AudioOutputDelegate::OnError() { | 179 void AudioOutputDelegate::OnError() { |
| 181 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 180 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 182 | 181 |
| 183 if (!handler_) | 182 if (!handler_) |
| 184 return; | 183 return; |
| 185 | 184 |
| 186 audio_log_->OnError(stream_id_); | 185 audio_log_->OnError(stream_id_); |
| 187 handler_->OnStreamError(stream_id_); | 186 handler_->OnStreamError(stream_id_); |
| 188 } | 187 } |
| 189 | 188 |
| 190 } // namespace content | 189 } // namespace content |
| OLD | NEW |