Commit 7969de66 authored by Linkun Chen's avatar Linkun Chen Committed by Commit Bot

[AudioOutputRedirector] Handle cases where num_frames is 0

|num_frames| can be 0 when mixer input is not ready to play yet. In this
case, all the previous_ended_in_silence_ logic should be bypassed.

Bug: b/119133585
Test: bulid and run on device, ensure crashes go away
Change-Id: I9a7eb69ecb015dffc9181e94d40d6a8de07d84ba
Reviewed-on: https://chromium-review.googlesource.com/c/1324417Reviewed-by: default avatarKenneth MacKay <kmackay@chromium.org>
Commit-Queue: Linkun Chen <lkchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606241}
parent 7dca8e13
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chromecast/media/cma/backend/audio_output_redirector.h" #include "chromecast/media/cma/backend/audio_output_redirector.h"
#include <algorithm>
#include <utility> #include <utility>
#include "base/logging.h" #include "base/logging.h"
...@@ -69,10 +70,11 @@ void AudioOutputRedirector::InputImpl::Redirect(::media::AudioBus* const buffer, ...@@ -69,10 +70,11 @@ void AudioOutputRedirector::InputImpl::Redirect(::media::AudioBus* const buffer,
RenderingDelay rendering_delay, RenderingDelay rendering_delay,
bool redirected) { bool redirected) {
if (!temp_buffer_ || temp_buffer_->frames() < num_frames) { if (!temp_buffer_ || temp_buffer_->frames() < num_frames) {
temp_buffer_ = temp_buffer_ = ::media::AudioBus::Create(mixer_input_->num_channels(),
::media::AudioBus::Create(mixer_input_->num_channels(), num_frames); std::max(num_frames, 256));
} }
if (num_frames != 0) {
if (previous_ended_in_silence_ && redirected) { if (previous_ended_in_silence_ && redirected) {
// Previous buffer ended in silence, and the current buffer was redirected // Previous buffer ended in silence, and the current buffer was redirected
// by a previous output splitter, so maintain silence. // by a previous output splitter, so maintain silence.
...@@ -94,6 +96,7 @@ void AudioOutputRedirector::InputImpl::Redirect(::media::AudioBus* const buffer, ...@@ -94,6 +96,7 @@ void AudioOutputRedirector::InputImpl::Redirect(::media::AudioBus* const buffer,
num_frames); num_frames);
} }
previous_ended_in_silence_ = redirected; previous_ended_in_silence_ = redirected;
}
output_redirector_->MixInput(mixer_input_, temp_buffer_.get(), num_frames, output_redirector_->MixInput(mixer_input_, temp_buffer_.get(), num_frames,
rendering_delay); rendering_delay);
......
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