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..783dab17112fe71e362b7f27c1becfa3a8b591cd 100644 |
--- a/content/browser/renderer_host/media/audio_renderer_host.cc |
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc |
@@ -10,6 +10,7 @@ |
#include "base/metrics/histogram.h" |
#include "base/process/process.h" |
#include "content/browser/browser_main_loop.h" |
+#include "content/browser/loader/resource_dispatcher_host_impl.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" |
@@ -273,19 +274,28 @@ void AudioRendererHost::DoNotifyStreamStateChanged(int stream_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()); |
+ } |
+ |
+ if (entry->playing() != is_playing) { |
mmenke
2014/09/18 14:12:42
Suggest making a method:
AudioRendererHost::Updat
|
// TODO(dalecurtis): See about using AudioStreamMonitor instead. |
aiolos (Not reviewing)
2014/09/18 01:13:24
Dale, I wasn't quite sure where this TODO should g
DaleCurtis
2014/09/18 17:51:23
Hmm, I guess it's not actually all that clear. You
aiolos (Not reviewing)
2014/09/18 21:46:47
Done.
|
- if (entry->playing()) { |
- entry->set_playing(false); |
+ entry->set_playing(is_playing); |
+ if (is_playing) { |
+ base::AtomicRefCountInc(&num_playing_streams_); |
+ } else { |
base::AtomicRefCountDec(&num_playing_streams_); |
} |
+ if (ResourceDispatcherHostImpl::Get()) { |
+ BrowserThread::PostTask( |
DaleCurtis
2014/09/18 17:51:23
Does this need to be a PostTask? You're already on
aiolos (Not reviewing)
2014/09/18 21:46:47
Done.
|
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind( |
+ &ResourceDispatcherHostImpl::OnAudioRenderHostStreamStateChanged, |
+ base::Unretained(ResourceDispatcherHostImpl::Get()), |
+ render_process_id_, entry->render_view_id(), is_playing)); |
mmenke
2014/09/18 14:12:42
Can't we have multiple playing streams per RenderV
DaleCurtis
2014/09/18 17:51:24
Yeah, this should probably just return HasActiveAu
aiolos (Not reviewing)
2014/09/18 21:46:47
Changed to check that we're actually changing the
|
+ } |
} |
} |
@@ -454,8 +464,18 @@ 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()) |
+ if (entry->playing()) { |
base::AtomicRefCountDec(&num_playing_streams_); |
+ if (ResourceDispatcherHostImpl::Get()) { |
+ BrowserThread::PostTask( |
+ BrowserThread::IO, |
+ FROM_HERE, |
+ base::Bind( |
+ &ResourceDispatcherHostImpl::OnAudioRenderHostStreamStateChanged, |
+ base::Unretained(ResourceDispatcherHostImpl::Get()), |
+ render_process_id_, entry->render_view_id(), false)); |
mmenke
2014/09/18 14:12:42
Same here - if we have two playing entries for a s
DaleCurtis
2014/09/18 17:51:23
Ditto.
aiolos (Not reviewing)
2014/09/18 21:46:48
Done.
|
+ } |
+ } |
} |
void AudioRendererHost::ReportErrorAndClose(int stream_id) { |