Commit 3776bf00 authored by Ken MacKay's avatar Ken MacKay Committed by Commit Bot

[Chromecast] Rename AllowVolumeFeedbackObserver to ActiveAudioStreamObserver

So the name better matches the actual use.

Merge-With: eureka-internal/360190

Bug: none
Change-Id: Icad7d7496a67e6af96f72ccc73e41e0c2d68d935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2039295Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Kenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738681}
parent 90199b9c
...@@ -54,8 +54,9 @@ MediaPipelineBackendManager::MediaPipelineBackendManager( ...@@ -54,8 +54,9 @@ MediaPipelineBackendManager::MediaPipelineBackendManager(
{AudioContentType::kAlarm, 0}, {AudioContentType::kAlarm, 0},
{AudioContentType::kCommunication, 0}, {AudioContentType::kCommunication, 0},
{AudioContentType::kOther, 0}}), {AudioContentType::kOther, 0}}),
allow_volume_feedback_observers_( active_audio_stream_observers_(
new base::ObserverListThreadSafe<AllowVolumeFeedbackObserver>()), base::MakeRefCounted<
base::ObserverListThreadSafe<ActiveAudioStreamObserver>>()),
backend_wrapper_using_video_decoder_(nullptr), backend_wrapper_using_video_decoder_(nullptr),
buffer_delegate_(nullptr), buffer_delegate_(nullptr),
weak_factory_(this) { weak_factory_(this) {
...@@ -153,18 +154,19 @@ void MediaPipelineBackendManager::OnMixerStreamCountChange(int primary_streams, ...@@ -153,18 +154,19 @@ void MediaPipelineBackendManager::OnMixerStreamCountChange(int primary_streams,
int sfx_streams) { int sfx_streams) {
DCHECK(media_task_runner_->BelongsToCurrentThread()); DCHECK(media_task_runner_->BelongsToCurrentThread());
bool had_playing_audio_streams = (TotalPlayingAudioStreamsCount() > 0); bool had_playing_audio_streams = (TotalPlayingAudioStreamsCount() > 0);
bool prev_allow_feedback = (TotalPlayingNoneffectsAudioStreamsCount() == 0); bool had_playing_primary_streams =
(TotalPlayingNoneffectsAudioStreamsCount() > 0);
mixer_primary_stream_count_ = primary_streams; mixer_primary_stream_count_ = primary_streams;
mixer_sfx_stream_count_ = sfx_streams; mixer_sfx_stream_count_ = sfx_streams;
HandlePlayingAudioStreamsChange(had_playing_audio_streams, HandlePlayingAudioStreamsChange(had_playing_audio_streams,
prev_allow_feedback); had_playing_primary_streams);
} }
void MediaPipelineBackendManager::HandlePlayingAudioStreamsChange( void MediaPipelineBackendManager::HandlePlayingAudioStreamsChange(
bool had_playing_audio_streams, bool had_playing_audio_streams,
bool prev_allow_feedback) { bool had_playing_primary_streams) {
DCHECK(media_task_runner_->BelongsToCurrentThread()); DCHECK(media_task_runner_->BelongsToCurrentThread());
int new_playing_audio_streams = TotalPlayingAudioStreamsCount(); int new_playing_audio_streams = TotalPlayingAudioStreamsCount();
if (new_playing_audio_streams == 0) { if (new_playing_audio_streams == 0) {
...@@ -179,11 +181,12 @@ void MediaPipelineBackendManager::HandlePlayingAudioStreamsChange( ...@@ -179,11 +181,12 @@ void MediaPipelineBackendManager::HandlePlayingAudioStreamsChange(
} }
} }
bool new_allow_feedback = (TotalPlayingNoneffectsAudioStreamsCount() == 0); bool new_playing_primary_streams =
if (new_allow_feedback != prev_allow_feedback) { (TotalPlayingNoneffectsAudioStreamsCount() > 0);
allow_volume_feedback_observers_->Notify( if (new_playing_primary_streams != had_playing_primary_streams) {
FROM_HERE, &AllowVolumeFeedbackObserver::AllowVolumeFeedbackSounds, active_audio_stream_observers_->Notify(
new_allow_feedback); FROM_HERE, &ActiveAudioStreamObserver::OnActiveAudioStreamChange,
new_playing_primary_streams);
} }
} }
...@@ -213,14 +216,14 @@ void MediaPipelineBackendManager::EnterPowerSaveMode() { ...@@ -213,14 +216,14 @@ void MediaPipelineBackendManager::EnterPowerSaveMode() {
VolumeControl::SetPowerSaveMode(true); VolumeControl::SetPowerSaveMode(true);
} }
void MediaPipelineBackendManager::AddAllowVolumeFeedbackObserver( void MediaPipelineBackendManager::AddActiveAudioStreamObserver(
AllowVolumeFeedbackObserver* observer) { ActiveAudioStreamObserver* observer) {
allow_volume_feedback_observers_->AddObserver(observer); active_audio_stream_observers_->AddObserver(observer);
} }
void MediaPipelineBackendManager::RemoveAllowVolumeFeedbackObserver( void MediaPipelineBackendManager::RemoveActiveAudioStreamObserver(
AllowVolumeFeedbackObserver* observer) { ActiveAudioStreamObserver* observer) {
allow_volume_feedback_observers_->RemoveObserver(observer); active_audio_stream_observers_->RemoveObserver(observer);
} }
void MediaPipelineBackendManager::AddExtraPlayingStream( void MediaPipelineBackendManager::AddExtraPlayingStream(
......
...@@ -36,12 +36,15 @@ class MediaResourceTracker; ...@@ -36,12 +36,15 @@ class MediaResourceTracker;
// streams (apart from sound-effects streams). // streams (apart from sound-effects streams).
class MediaPipelineBackendManager { class MediaPipelineBackendManager {
public: public:
class AllowVolumeFeedbackObserver { class ActiveAudioStreamObserver {
public: public:
virtual void AllowVolumeFeedbackSounds(bool allow) = 0; // Called when we transition between "no active audio streams" and
// "have at least one active audio stream" states. For this purpose, sound
// effects streams are ignored.
virtual void OnActiveAudioStreamChange(bool have_active_streams) = 0;
protected: protected:
virtual ~AllowVolumeFeedbackObserver() = default; virtual ~ActiveAudioStreamObserver() = default;
}; };
// Delegate which can process Audio buffers sent to us. // Delegate which can process Audio buffers sent to us.
...@@ -109,8 +112,8 @@ class MediaPipelineBackendManager { ...@@ -109,8 +112,8 @@ class MediaPipelineBackendManager {
// Adds/removes an observer for when volume feedback sounds are allowed. // Adds/removes an observer for when volume feedback sounds are allowed.
// An observer must be removed on the same thread that added it. // An observer must be removed on the same thread that added it.
void AddAllowVolumeFeedbackObserver(AllowVolumeFeedbackObserver* observer); void AddActiveAudioStreamObserver(ActiveAudioStreamObserver* observer);
void RemoveAllowVolumeFeedbackObserver(AllowVolumeFeedbackObserver* observer); void RemoveActiveAudioStreamObserver(ActiveAudioStreamObserver* observer);
// Add/remove a playing audio stream that is not accounted for by a // Add/remove a playing audio stream that is not accounted for by a
// CmaBackend instance. |sfx| indicates whether or not the stream is a sound // CmaBackend instance. |sfx| indicates whether or not the stream is a sound
...@@ -150,7 +153,7 @@ class MediaPipelineBackendManager { ...@@ -150,7 +153,7 @@ class MediaPipelineBackendManager {
int change); int change);
void OnMixerStreamCountChange(int primary_streams, int sfx_streams); void OnMixerStreamCountChange(int primary_streams, int sfx_streams);
void HandlePlayingAudioStreamsChange(bool had_playing_audio_streams, void HandlePlayingAudioStreamsChange(bool had_playing_audio_streams,
bool prev_allow_feedback); bool had_playing_primary_streams);
int TotalPlayingAudioStreamsCount(); int TotalPlayingAudioStreamsCount();
int TotalPlayingNoneffectsAudioStreamsCount(); int TotalPlayingNoneffectsAudioStreamsCount();
...@@ -168,8 +171,8 @@ class MediaPipelineBackendManager { ...@@ -168,8 +171,8 @@ class MediaPipelineBackendManager {
// Total number of playing non-effects streams. // Total number of playing non-effects streams.
base::flat_map<AudioContentType, int> playing_noneffects_audio_streams_count_; base::flat_map<AudioContentType, int> playing_noneffects_audio_streams_count_;
scoped_refptr<base::ObserverListThreadSafe<AllowVolumeFeedbackObserver>> scoped_refptr<base::ObserverListThreadSafe<ActiveAudioStreamObserver>>
allow_volume_feedback_observers_; active_audio_stream_observers_;
// Previously issued MediaPipelineBackendWrapper that uses a video decoder. // Previously issued MediaPipelineBackendWrapper that uses a video decoder.
MediaPipelineBackendWrapper* backend_wrapper_using_video_decoder_; MediaPipelineBackendWrapper* backend_wrapper_using_video_decoder_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment