Skip to content

Commit

Permalink
[Chromecast] Disable audio filtering on silence data.
Browse files Browse the repository at this point in the history
Audio filters can be costly to run, and this skips them on silence data.

BUG=internal b/30441995
TEST=cast_alsa_cma_backend_unittests; ensured large reduction in CPU
     utilization on live system.

Change-Id: I18bce9c6fea35493adf8a018d6655e11858a3a34
Review-Url: https://codereview.chromium.org/2194773002
Cr-Commit-Position: refs/heads/master@{#408691}
  • Loading branch information
jlevasseur authored and Commit bot committed Jul 29, 2016
1 parent 13c7a2d commit abe5381
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions chromecast/media/cma/backend/alsa/stream_mixer_alsa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ bool StreamMixerAlsa::TryWriteFrames() {
}

mixed_->Zero();
WriteMixedPcm(*mixed_, chunk_size);
WriteMixedPcm(*mixed_, chunk_size, true /* is_silence */);
return true;
}

Expand All @@ -814,7 +814,7 @@ bool StreamMixerAlsa::TryWriteFrames() {
}
}

WriteMixedPcm(*mixed_, chunk_size);
WriteMixedPcm(*mixed_, chunk_size, false /* is_silence */);
return true;
}

Expand All @@ -823,7 +823,7 @@ ssize_t StreamMixerAlsa::BytesPerOutputFormatSample() {
}

void StreamMixerAlsa::WriteMixedPcm(const ::media::AudioBus& mixed,
int frames) {
int frames, bool is_silence) {
DCHECK(mixer_task_runner_->BelongsToCurrentThread());
CHECK_PCM_INITIALIZED();

Expand All @@ -844,7 +844,7 @@ void StreamMixerAlsa::WriteMixedPcm(const ::media::AudioBus& mixed,
mixed.ToInterleaved(frames, BytesPerOutputFormatSample(),
interleaved_.data());
// Filter, send to observers, and post filter
if (pre_loopback_filter_) {
if (pre_loopback_filter_ && !is_silence) {
pre_loopback_filter_->ProcessInterleaved(interleaved_.data(), frames);
}

Expand All @@ -854,7 +854,7 @@ void StreamMixerAlsa::WriteMixedPcm(const ::media::AudioBus& mixed,
interleaved_.data(), interleaved_size);
}

if (post_loopback_filter_) {
if (post_loopback_filter_ && !is_silence) {
post_loopback_filter_->ProcessInterleaved(interleaved_.data(), frames);
}

Expand Down
3 changes: 2 additions & 1 deletion chromecast/media/cma/backend/alsa/stream_mixer_alsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class StreamMixerAlsa {

void WriteFrames();
bool TryWriteFrames();
void WriteMixedPcm(const ::media::AudioBus& mixed, int frames);
void WriteMixedPcm(const ::media::AudioBus& mixed, int frames,
bool is_silence);
void UpdateRenderingDelay(int newly_pushed_frames);
ssize_t BytesPerOutputFormatSample();

Expand Down

0 comments on commit abe5381

Please sign in to comment.