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 91cea8365224cc79a0625c6c0793c778f053d59b..bd4e0f11e10c6ecdcf4f305d7ac32d71e515d014 100644 |
--- a/content/browser/renderer_host/media/audio_renderer_host.cc |
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc |
@@ -23,6 +23,13 @@ |
#include "media/base/audio_bus.h" |
#include "media/base/limits.h" |
+// Only do audio stream monitoring for platforms that use it for the tab media |
+// indicator UI or the OOM killer. |
+#if !defined(OS_ANDROID) && !defined(OS_IOS) |
+#define AUDIO_STREAM_MONITORING |
jam
2014/09/02 19:50:33
ditto
DaleCurtis
2014/09/04 21:59:06
Done.
|
+#include "content/browser/media/audio_stream_monitor.h" |
+#endif |
+ |
using media::AudioBus; |
using media::AudioManager; |
@@ -272,28 +279,29 @@ void AudioRendererHost::DoNotifyStreamStateChanged(int stream_id, |
is_playing ? media::AudioOutputIPCDelegate::kPlaying |
: media::AudioOutputIPCDelegate::kPaused)); |
- 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_); |
- } |
+ if (is_playing) { |
+#if defined(AUDIO_STREAM_MONITORING) |
+ AudioStreamMonitor::StartMonitoringStream( |
+ render_process_id_, |
+ entry->render_frame_id(), |
+ entry->stream_id(), |
+ base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, |
+ entry->controller())); |
+#endif |
+ // TODO(dalecurtis): See about using AudioStreamMonitor instead. |
+ if (!entry->playing()) { |
+ entry->set_playing(true); |
+ base::AtomicRefCountInc(&num_playing_streams_); |
+ } |
+ } else { |
+#if defined(AUDIO_STREAM_MONITORING) |
+ AudioStreamMonitor::StopMonitoringStream( |
+ render_process_id_, entry->render_frame_id(), entry->stream_id()); |
+#endif |
+ // TODO(dalecurtis): See about using AudioStreamMonitor instead. |
+ if (entry->playing()) { |
+ entry->set_playing(false); |
+ base::AtomicRefCountDec(&num_playing_streams_); |
} |
} |
} |
@@ -463,17 +471,12 @@ void AudioRendererHost::OnCloseStream(int stream_id) { |
void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- |
- // 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_); |
- } |
+#if defined(AUDIO_STREAM_MONITORING) |
+ AudioStreamMonitor::StopMonitoringStream( |
+ render_process_id_, entry->render_frame_id(), entry->stream_id()); |
+#endif |
+ if (entry->playing()) |
+ base::AtomicRefCountDec(&num_playing_streams_); |
} |
void AudioRendererHost::ReportErrorAndClose(int stream_id) { |