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

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

Issue 562863002: Gardening: Revert "Use AudioStreamMonitor to control power save blocking." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc
index 8c06395eca68ecf94496c47946a26066060004d0..a34bb18b3e2599821cae55c0f52b6a681204fa45 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc
@@ -10,7 +10,6 @@
#include "base/metrics/histogram.h"
#include "base/process/process.h"
#include "content/browser/browser_main_loop.h"
-#include "content/browser/media/audio_stream_monitor.h"
#include "content/browser/media/capture/audio_mirroring_manager.h"
#include "content/browser/media/media_internals.h"
#include "content/browser/renderer_host/media/audio_input_device_manager.h"
@@ -266,25 +265,28 @@ void AudioRendererHost::DoNotifyStreamStateChanged(int stream_id,
is_playing ? media::AudioOutputIPCDelegate::kPlaying
: media::AudioOutputIPCDelegate::kPaused));
- if (is_playing) {
- AudioStreamMonitor::StartMonitoringStream(
- render_process_id_,
- entry->render_frame_id(),
- entry->stream_id(),
- base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip,
- entry->controller()));
- // TODO(dalecurtis): See about using AudioStreamMonitor instead.
- if (!entry->playing()) {
- entry->set_playing(true);
- base::AtomicRefCountInc(&num_playing_streams_);
- }
- } else {
- AudioStreamMonitor::StopMonitoringStream(
- render_process_id_, entry->render_frame_id(), entry->stream_id());
- // TODO(dalecurtis): See about using AudioStreamMonitor instead.
- if (entry->playing()) {
- entry->set_playing(false);
- base::AtomicRefCountDec(&num_playing_streams_);
+ MediaObserver* const media_observer =
+ GetContentClient()->browser()->GetMediaObserver();
+ if (media_observer) {
+ if (is_playing) {
+ media_observer->OnAudioStreamPlaying(
+ render_process_id_,
+ entry->render_frame_id(),
+ entry->stream_id(),
+ base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip,
+ entry->controller()));
+ if (!entry->playing()) {
+ entry->set_playing(true);
+ base::AtomicRefCountInc(&num_playing_streams_);
+ }
+ } else {
+ media_observer->OnAudioStreamStopped(render_process_id_,
+ entry->render_frame_id(),
+ entry->stream_id());
+ if (entry->playing()) {
+ entry->set_playing(false);
+ base::AtomicRefCountDec(&num_playing_streams_);
+ }
}
}
}
@@ -452,10 +454,17 @@ void AudioRendererHost::OnCloseStream(int stream_id) {
void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- AudioStreamMonitor::StopMonitoringStream(
- render_process_id_, entry->render_frame_id(), entry->stream_id());
- if (entry->playing())
- base::AtomicRefCountDec(&num_playing_streams_);
+
+ // At this point, make the final "say" in audio playback state.
+ MediaObserver* const media_observer =
+ GetContentClient()->browser()->GetMediaObserver();
+ if (media_observer) {
+ media_observer->OnAudioStreamStopped(render_process_id_,
+ entry->render_frame_id(),
+ entry->stream_id());
+ if (entry->playing())
+ base::AtomicRefCountDec(&num_playing_streams_);
+ }
}
void AudioRendererHost::ReportErrorAndClose(int stream_id) {
« no previous file with comments | « content/browser/media/audio_stream_monitor_unittest.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698