Chromium Code Reviews| Index: content/browser/renderer_host/media/audio_output_delegate_impl.cc |
| diff --git a/content/browser/renderer_host/media/audio_output_delegate_impl.cc b/content/browser/renderer_host/media/audio_output_delegate_impl.cc |
| index 3625fcbfefaaa18f1dabe65e3af7eabbc3175f99..d3ef87d926ab29468b3e9c421fdd160df453f5aa 100644 |
| --- a/content/browser/renderer_host/media/audio_output_delegate_impl.cc |
| +++ b/content/browser/renderer_host/media/audio_output_delegate_impl.cc |
| @@ -12,6 +12,7 @@ |
| #include "content/browser/media/capture/audio_mirroring_manager.h" |
| #include "content/browser/media/media_internals.h" |
| #include "content/browser/renderer_host/media/audio_sync_reader.h" |
| +#include "content/browser/renderer_host/media/media_stream_manager.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/media_observer.h" |
| #include "media/audio/audio_output_controller.h" |
| @@ -26,20 +27,24 @@ class AudioOutputDelegateImpl::ControllerEventHandler |
| : public media::AudioOutputController::EventHandler { |
| public: |
| explicit ControllerEventHandler( |
|
Max Morin
2017/05/31 13:51:59
Remove explicit since it has two parameters now.
|
| - base::WeakPtr<AudioOutputDelegateImpl> delegate); |
| + base::WeakPtr<AudioOutputDelegateImpl> delegate, |
| + int stream_id); |
| private: |
| void OnControllerCreated() override; |
| void OnControllerPlaying() override; |
| void OnControllerPaused() override; |
| void OnControllerError() override; |
| + void OnLog(const std::string& message) override; |
| base::WeakPtr<AudioOutputDelegateImpl> delegate_; |
| + const int stream_id_; // Retained separately for logging. |
| }; |
| AudioOutputDelegateImpl::ControllerEventHandler::ControllerEventHandler( |
| - base::WeakPtr<AudioOutputDelegateImpl> delegate) |
| - : delegate_(std::move(delegate)) {} |
| + base::WeakPtr<AudioOutputDelegateImpl> delegate, |
| + int stream_id) |
| + : delegate_(std::move(delegate)), stream_id_(stream_id) {} |
| void AudioOutputDelegateImpl::ControllerEventHandler::OnControllerCreated() { |
| BrowserThread::PostTask( |
| @@ -68,6 +73,15 @@ void AudioOutputDelegateImpl::ControllerEventHandler::OnControllerError() { |
| base::BindOnce(&AudioOutputDelegateImpl::OnError, delegate_)); |
| } |
| +void AudioOutputDelegateImpl::ControllerEventHandler::OnLog( |
| + const std::string& message) { |
| + std::ostringstream oss; |
| + oss << "[stream_id=" << stream_id_ << "] " << message; |
| + const std::string out_message = oss.str(); |
| + content::MediaStreamManager::SendMessageToNativeLog(out_message); |
| + DVLOG(1) << out_message; |
| +} |
| + |
| std::unique_ptr<media::AudioOutputDelegate> AudioOutputDelegateImpl::Create( |
| EventHandler* handler, |
| media::AudioManager* audio_manager, |
| @@ -118,8 +132,8 @@ AudioOutputDelegateImpl::AudioOutputDelegateImpl( |
| // Since the event handler never directly calls functions on |this| but rather |
| // posts them to the IO thread, passing a pointer from the constructor is |
| // safe. |
| - controller_event_handler_ = |
| - base::MakeUnique<ControllerEventHandler>(weak_factory_.GetWeakPtr()); |
| + controller_event_handler_ = base::MakeUnique<ControllerEventHandler>( |
| + weak_factory_.GetWeakPtr(), stream_id_); |
| audio_log_->OnCreated(stream_id, params, output_device_id); |
| controller_ = media::AudioOutputController::Create( |
| audio_manager, controller_event_handler_.get(), params, output_device_id, |