Commit e3d82fc8 authored by Benjamin Shaya's avatar Benjamin Shaya Committed by Commit Bot

[Chromecast] Allow post processors to ring forever.

Bug: 117433735
Test: On device
Change-Id: I2dc2c4aca15640262fc51114910fd77300e03d17
Reviewed-on: https://chromium-review.googlesource.com/c/1311495
Commit-Queue: Benjamin Shaya <bshaya@chromium.org>
Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610469}
parent f7343f66
...@@ -167,6 +167,9 @@ int MediaPipelineBackendManager::TotalPlayingNoneffectsAudioStreamsCount() { ...@@ -167,6 +167,9 @@ int MediaPipelineBackendManager::TotalPlayingNoneffectsAudioStreamsCount() {
void MediaPipelineBackendManager::EnterPowerSaveMode() { void MediaPipelineBackendManager::EnterPowerSaveMode() {
DCHECK_EQ(TotalPlayingAudioStreamsCount(), 0); DCHECK_EQ(TotalPlayingAudioStreamsCount(), 0);
DCHECK(VolumeControl::SetPowerSaveMode); DCHECK(VolumeControl::SetPowerSaveMode);
if (!power_save_enabled_) {
return;
}
metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction(
"Cast.Platform.VolumeControl.PowerSaveOn"); "Cast.Platform.VolumeControl.PowerSaveOn");
VolumeControl::SetPowerSaveMode(true); VolumeControl::SetPowerSaveMode(true);
...@@ -239,5 +242,15 @@ void MediaPipelineBackendManager::RemoveAudioDecoder( ...@@ -239,5 +242,15 @@ void MediaPipelineBackendManager::RemoveAudioDecoder(
audio_decoders_.erase(decoder); audio_decoders_.erase(decoder);
} }
void MediaPipelineBackendManager::SetPowerSaveEnabled(bool power_save_enabled) {
MAKE_SURE_MEDIA_THREAD(SetPowerSaveEnabled, power_save_enabled);
power_save_enabled_ = power_save_enabled;
if (!power_save_enabled_) {
if (VolumeControl::SetPowerSaveMode) {
VolumeControl::SetPowerSaveMode(false);
}
}
}
} // namespace media } // namespace media
} // namespace chromecast } // namespace chromecast
...@@ -121,6 +121,10 @@ class MediaPipelineBackendManager { ...@@ -121,6 +121,10 @@ class MediaPipelineBackendManager {
bool IsPlaying(bool include_sfx, AudioContentType type); bool IsPlaying(bool include_sfx, AudioContentType type);
// If |power_save_enabled| is |false|, power save will be turned off and
// automatic power save will be disabled until this is called with |true|.
void SetPowerSaveEnabled(bool power_save_enabled);
private: private:
friend class MediaPipelineBackendWrapper; friend class MediaPipelineBackendWrapper;
friend class AudioDecoderWrapper; friend class AudioDecoderWrapper;
...@@ -161,6 +165,8 @@ class MediaPipelineBackendManager { ...@@ -161,6 +165,8 @@ class MediaPipelineBackendManager {
BufferDelegate* buffer_delegate_; BufferDelegate* buffer_delegate_;
bool power_save_enabled_ = true;
base::OneShotTimer power_save_timer_; base::OneShotTimer power_save_timer_;
base::WeakPtrFactory<MediaPipelineBackendManager> weak_factory_; base::WeakPtrFactory<MediaPipelineBackendManager> weak_factory_;
......
...@@ -167,13 +167,18 @@ bool PostProcessingPipelineImpl::SetSampleRate(int sample_rate) { ...@@ -167,13 +167,18 @@ bool PostProcessingPipelineImpl::SetSampleRate(int sample_rate) {
} }
bool PostProcessingPipelineImpl::IsRinging() { bool PostProcessingPipelineImpl::IsRinging() {
return silence_frames_processed_ < ringing_time_in_frames_; return ringing_time_in_frames_ < 0 ||
silence_frames_processed_ < ringing_time_in_frames_;
} }
int PostProcessingPipelineImpl::GetRingingTimeInFrames() { int PostProcessingPipelineImpl::GetRingingTimeInFrames() {
int memory_frames = 0; int memory_frames = 0;
for (auto& processor : processors_) { for (auto& processor : processors_) {
memory_frames += processor.ptr->GetRingingTimeInFrames(); int ringing_time = processor.ptr->GetRingingTimeInFrames();
if (ringing_time < 0) {
return -1;
}
memory_frames += ringing_time;
} }
return memory_frames; return memory_frames;
} }
......
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