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

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

Issue 2655413004: Strip out stream counting from AudioRendererHost. (Closed)
Patch Set: Created 3 years, 11 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 2057fa8f73569452296783eef76705073de58fcd..b4c90471b4f39036481f2a6bd169a004e409f9f2 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc
@@ -24,7 +24,6 @@
#include "content/public/browser/media_observer.h"
#include "content/public/browser/render_frame_host.h"
#include "media/audio/audio_device_description.h"
-#include "media/audio/audio_streams_tracker.h"
#include "media/base/audio_bus.h"
#include "media/base/limits.h"
@@ -35,21 +34,6 @@ namespace content {
namespace {
-// Tracks the maximum number of simultaneous output streams browser-wide.
-// Accessed on IO thread.
-base::LazyInstance<media::AudioStreamsTracker> g_audio_streams_tracker =
- LAZY_INSTANCE_INITIALIZER;
-
-void NotifyRenderProcessHostThatAudioStateChanged(int render_process_id) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- RenderProcessHost* render_process_host =
- RenderProcessHost::FromID(render_process_id);
-
- if (render_process_host)
- render_process_host->AudioStateChanged();
-}
-
void UMALogDeviceAuthorizationTime(base::TimeTicks auth_start_time) {
UMA_HISTOGRAM_CUSTOM_TIMES("Media.Audio.OutputDeviceAuthorizationTime",
base::TimeTicks::Now() - auth_start_time,
@@ -84,10 +68,8 @@ AudioRendererHost::AudioRendererHost(int render_process_id,
audio_manager_(audio_manager),
mirroring_manager_(mirroring_manager),
media_stream_manager_(media_stream_manager),
- num_playing_streams_(0),
salt_(salt),
validate_render_frame_id_function_(&ValidateRenderFrameId),
- max_simultaneous_streams_(0),
authorization_handler_(audio_manager_,
media_stream_manager,
render_process_id_,
@@ -98,19 +80,6 @@ AudioRendererHost::AudioRendererHost(int render_process_id,
AudioRendererHost::~AudioRendererHost() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(delegates_.empty());
-
- // If we had any streams, report UMA stats for the maximum number of
- // simultaneous streams for this render process and for the whole browser
- // process since last reported.
- if (max_simultaneous_streams_ > 0) {
- UMA_HISTOGRAM_CUSTOM_COUNTS("Media.AudioRendererIpcStreams",
- max_simultaneous_streams_, 1, 50, 51);
- UMA_HISTOGRAM_CUSTOM_COUNTS(
- "Media.AudioRendererIpcStreamsTotal",
- g_audio_streams_tracker.Get().max_stream_count(),
- 1, 100, 101);
- g_audio_streams_tracker.Get().ResetMaxStreamCount();
- }
}
void AudioRendererHost::GetOutputControllers(
@@ -123,10 +92,6 @@ void AudioRendererHost::GetOutputControllers(
void AudioRendererHost::OnChannelClosing() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
- // Since the IPC sender is gone, close all requested audio streams.
- // The audio streams tracker isn't automatically decremented since the
- // removal isn't done through OnCloseStream.
- g_audio_streams_tracker.Get().DecreaseStreamCount(delegates_.size());
delegates_.clear();
// Remove any authorizations for streams that were not yet created
@@ -347,11 +312,6 @@ void AudioRendererHost::OnCreateStream(int stream_id,
this, audio_manager_, std::move(audio_log), mirroring_manager_,
media_observer, stream_id, render_frame_id, render_process_id_, params,
device_unique_id));
-
- g_audio_streams_tracker.Get().IncreaseStreamCount();
-
- if (delegates_.size() > max_simultaneous_streams_)
- max_simultaneous_streams_ = delegates_.size();
}
void AudioRendererHost::OnPlayStream(int stream_id) {
@@ -410,8 +370,6 @@ void AudioRendererHost::OnCloseStream(int stream_id) {
std::swap(*i, delegates_.back());
delegates_.pop_back();
-
- g_audio_streams_tracker.Get().DecreaseStreamCount();
}
AudioRendererHost::AudioOutputDelegateVector::iterator
@@ -431,40 +389,11 @@ AudioOutputDelegate* AudioRendererHost::LookupById(int stream_id) {
return i != delegates_.end() ? i->get() : nullptr;
}
-void AudioRendererHost::OnStreamStateChanged(bool is_playing) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (is_playing) {
- base::AtomicRefCountInc(&num_playing_streams_);
-
- // Inform the RenderProcessHost when audio starts playing for the first
- // time. The nonatomic increment-and-read is ok since this is the only
- // thread that |num_plaing_streams_| may be updated on.
- if (base::AtomicRefCountIsOne(&num_playing_streams_)) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&NotifyRenderProcessHostThatAudioStateChanged,
- render_process_id_));
- }
- } else {
- // Inform the RenderProcessHost when there is no more audio playing.
- if (!base::AtomicRefCountDec(&num_playing_streams_)) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&NotifyRenderProcessHostThatAudioStateChanged,
- render_process_id_));
- }
- }
-}
-
bool AudioRendererHost::IsAuthorizationStarted(int stream_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return authorizations_.find(stream_id) != authorizations_.end();
}
-bool AudioRendererHost::HasActiveAudio() {
- return !base::AtomicRefCountIsZero(&num_playing_streams_);
-}
-
void AudioRendererHost::OverrideDevicePermissionsForTesting(bool has_access) {
authorization_handler_.OverridePermissionsForTesting(has_access);
}

Powered by Google App Engine
This is Rietveld 408576698