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

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

Issue 2578983003: Add AudioStreamRegistry. Move stream counting logic (Closed)
Patch Set: Add missing EXPECT_TRUE. Created 4 years 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.cc
diff --git a/content/browser/renderer_host/media/audio_output_delegate.cc b/content/browser/renderer_host/media/audio_output_delegate.cc
index 32d936eb3f69ad35c575347c5cc2584cddbdb736..a55c323f9cb80a2a4d75a8df9dccbb66513ac58a 100644
--- a/content/browser/renderer_host/media/audio_output_delegate.cc
+++ b/content/browser/renderer_host/media/audio_output_delegate.cc
@@ -18,6 +18,7 @@ namespace content {
AudioOutputDelegate::AudioOutputDelegate(
EventHandler* handler,
+ AudioStreamRegistry* stream_registry,
media::AudioManager* audio_manager,
std::unique_ptr<media::AudioLog> audio_log,
int stream_id,
@@ -26,6 +27,7 @@ AudioOutputDelegate::AudioOutputDelegate(
const media::AudioParameters& params,
const std::string& output_device_id)
: handler_(handler),
+ stream_registry_(stream_registry),
audio_log_(std::move(audio_log)),
reader_(AudioSyncReader::Create(params)),
stream_id_(stream_id),
@@ -37,6 +39,7 @@ AudioOutputDelegate::AudioOutputDelegate(
DCHECK(audio_log_);
weak_this_ = weak_factory_.GetWeakPtr();
audio_log_->OnCreated(stream_id, params, output_device_id);
+ stream_registry_->RegisterOutputStream(this);
controller_ = media::AudioOutputController::Create(
audio_manager, this, params, output_device_id, reader_.get());
DCHECK(controller_);
@@ -51,6 +54,7 @@ AudioOutputDelegate::~AudioOutputDelegate() {
void AudioOutputDelegate::Deleter::operator()(AudioOutputDelegate* delegate) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
delegate->UpdatePlayingState(false);
+ delegate->stream_registry_->DeregisterOutputStream(delegate);
delegate->handler_ = nullptr;
delegate->audio_log_->OnClosed(delegate->stream_id_);
@@ -82,6 +86,7 @@ void AudioOutputDelegate::Deleter::operator()(AudioOutputDelegate* delegate) {
// static
AudioOutputDelegate::UniquePtr AudioOutputDelegate::Create(
EventHandler* handler,
+ AudioStreamRegistry* stream_registry,
media::AudioManager* audio_manager,
std::unique_ptr<media::AudioLog> audio_log,
AudioMirroringManager* mirroring_manager,
@@ -94,9 +99,9 @@ AudioOutputDelegate::UniquePtr AudioOutputDelegate::Create(
if (media_observer)
media_observer->OnCreatingAudioStream(render_process_id, render_frame_id);
UniquePtr delegate(
- new AudioOutputDelegate(handler, audio_manager, std::move(audio_log),
- stream_id, render_frame_id, render_process_id,
- params, output_device_id),
+ new AudioOutputDelegate(handler, stream_registry, audio_manager,
+ std::move(audio_log), stream_id, render_frame_id,
+ render_process_id, params, output_device_id),
Deleter(mirroring_manager));
if (mirroring_manager)
mirroring_manager->AddDiverter(render_process_id, render_frame_id,
@@ -104,6 +109,13 @@ AudioOutputDelegate::UniquePtr AudioOutputDelegate::Create(
return delegate;
}
+#if BUILDFLAG(ENABLE_WEBRTC)
+void AudioOutputDelegate::EnableDebugRecording(
+ const base::FilePath& base_file_name) {}
+
+void AudioOutputDelegate::DisableDebugRecording() {}
+#endif
+
void AudioOutputDelegate::OnPlayStream() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
controller_->Play();
@@ -162,7 +174,7 @@ void AudioOutputDelegate::UpdatePlayingState(bool playing) {
return;
playing_ = playing;
- handler_->OnStreamStateChanged(playing);
+ stream_registry_->OutputStreamStateChanged(this, playing);
if (playing) {
// Note that this takes a reference to |controller_|, and
// (Start|Stop)MonitoringStream calls are async, so we don't have a

Powered by Google App Engine
This is Rietveld 408576698