Commit c5f4046e authored by Ken MacKay's avatar Ken MacKay Committed by Commit Bot

[Chromecast] Don't consider muted streams to be active

Allows disabling the amp when streams are 'playing' at 0 volume.

Bug: internal b/145634794
Change-Id: I994b23d3be7d0a1bac27b4ab347eb7f03d6f9a18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040614Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Kenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738793}
parent 7ae8393b
......@@ -735,12 +735,20 @@ void StreamMixer::UpdateStreamCounts() {
int primary = 0;
int sfx = 0;
for (const auto& it : inputs_) {
if (it.second->source()->active()) {
(it.second->primary() ? primary : sfx) += 1;
MixerInput* input = it.second.get();
if (input->source()->active() &&
(input->TargetVolume() > 0.0f || input->InstantaneousVolume() > 0.0f)) {
(input->primary() ? primary : sfx) += 1;
}
}
receiver_.Post(FROM_HERE, &MixerServiceReceiver::OnStreamCountChanged,
primary, sfx);
if (primary != last_sent_primary_stream_count_ ||
sfx != last_sent_sfx_stream_count_) {
last_sent_primary_stream_count_ = primary;
last_sent_sfx_stream_count_ = sfx;
receiver_.Post(FROM_HERE, &MixerServiceReceiver::OnStreamCountChanged,
primary, sfx);
}
}
MediaPipelineBackend::AudioDecoder::RenderingDelay
......@@ -767,6 +775,7 @@ void StreamMixer::PlaybackLoop() {
}
WriteOneBuffer();
UpdateStreamCounts();
mixer_task_runner_->PostTask(FROM_HERE, playback_loop_task_);
}
......@@ -886,6 +895,7 @@ void StreamMixer::SetVolume(AudioContentType type, float level) {
if (external_audio_pipeline_supported_ && type == AudioContentType::kMedia) {
ExternalAudioPipelineShlib::SetExternalMediaVolume(effective_volume);
}
UpdateStreamCounts();
}
void StreamMixer::SetMuted(AudioContentType type, bool muted) {
......@@ -901,6 +911,7 @@ void StreamMixer::SetMuted(AudioContentType type, bool muted) {
if (external_audio_pipeline_supported_ && type == AudioContentType::kMedia) {
ExternalAudioPipelineShlib::SetExternalMediaMuted(muted);
}
UpdateStreamCounts();
}
void StreamMixer::SetOutputLimit(AudioContentType type, float limit) {
......@@ -928,6 +939,7 @@ void StreamMixer::SetOutputLimit(AudioContentType type, float limit) {
if (external_audio_pipeline_supported_ && type == AudioContentType::kMedia) {
ExternalAudioPipelineShlib::SetExternalMediaVolume(effective_volume);
}
UpdateStreamCounts();
}
void StreamMixer::SetVolumeMultiplier(MixerInput::Source* source,
......@@ -938,6 +950,7 @@ void StreamMixer::SetVolumeMultiplier(MixerInput::Source* source,
if (it != inputs_.end()) {
it->second->SetVolumeMultiplier(multiplier);
}
UpdateStreamCounts();
}
void StreamMixer::SetPostProcessorConfig(std::string name, std::string config) {
......
......@@ -217,6 +217,9 @@ class StreamMixer {
int redirector_samples_per_second_ = 0;
int redirector_frames_per_write_ = 0;
int last_sent_primary_stream_count_ = 0;
int last_sent_sfx_stream_count_ = 0;
State state_;
base::TimeTicks close_timestamp_;
......
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