Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: content/browser/renderer_host/media/audio_output_delegate_impl.cc

Issue 2900043002: Added initial set of logging for AudioOutputController. (Closed)
Patch Set: Turned DoLog static, so we can log things even when delegate_ has disappeared. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ebe6826772ce6526d47a814311a2491dab5cac26 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"
@@ -34,12 +35,15 @@ class AudioOutputDelegateImpl::ControllerEventHandler
void OnControllerPaused() override;
void OnControllerError() override;
+ void OnLog(const std::string& message) override;
+
base::WeakPtr<AudioOutputDelegateImpl> delegate_;
+ int stream_id_; // Retained separately for logging.
};
AudioOutputDelegateImpl::ControllerEventHandler::ControllerEventHandler(
base::WeakPtr<AudioOutputDelegateImpl> delegate)
- : delegate_(std::move(delegate)) {}
+ : delegate_(std::move(delegate)), stream_id_(delegate_->stream_id_) {}
void AudioOutputDelegateImpl::ControllerEventHandler::OnControllerCreated() {
BrowserThread::PostTask(
@@ -68,6 +72,13 @@ void AudioOutputDelegateImpl::ControllerEventHandler::OnControllerError() {
base::BindOnce(&AudioOutputDelegateImpl::OnError, delegate_));
}
+void AudioOutputDelegateImpl::ControllerEventHandler::OnLog(
+ const std::string& message) {
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&AudioOutputDelegateImpl::DoLog, stream_id_, message));
Max Morin 2017/05/29 14:25:44 I just realized this should be BindOnce, like in a
ossu-chromium 2017/05/29 14:35:48 I think I've been a bit hazy on the significance o
Max Morin 2017/05/29 14:44:44 Yes, it's a sort of documentation (with added effi
+}
+
std::unique_ptr<media::AudioOutputDelegate> AudioOutputDelegateImpl::Create(
EventHandler* handler,
media::AudioManager* audio_manager,
@@ -221,6 +232,15 @@ void AudioOutputDelegateImpl::OnError() {
subscriber_->OnStreamError(stream_id_);
}
liberato (no reviews please) 2017/05/30 16:53:34 please add "// static".
ossu-chromium 2017/05/31 11:16:27 See comment in audio_output_delegate_impl.h.
+void AudioOutputDelegateImpl::DoLog(int stream_id, const std::string& msg) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ std::ostringstream oss;
+ oss << "[stream_id=" << stream_id << "] " << msg;
+ const std::string message = oss.str();
+ content::MediaStreamManager::SendMessageToNativeLog(message);
+ DVLOG(1) << message;
+}
+
media::AudioOutputController* AudioOutputDelegateImpl::GetControllerForTesting()
const {
return controller_.get();

Powered by Google App Engine
This is Rietveld 408576698