Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4242)

Unified Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc

Issue 1900233006: [Chromecast] Remove command-line switch to change the number of mixer output channels (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa.cc ('k') | chromecast/media/cma/decoder/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
index 2fa15a1005b8c5a581d0c804de76a58ff97a5472..9537a0746137c6cbd286d704aa8cc4caa3d9c797 100644
--- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
+++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
@@ -45,6 +45,7 @@ namespace media {
namespace {
+const int kNumOutputChannels = 2;
const int64_t kMaxInputQueueUs = 90000;
const int64_t kFadeMs = 15;
// Number of samples to report as readable when paused. When paused, the mixer
@@ -111,7 +112,7 @@ void StreamMixerAlsaInputImpl::Initialize(
double resample_ratio = static_cast<double>(input_samples_per_second_) /
mixer_->output_samples_per_second();
resampler_.reset(new ::media::MultiChannelResampler(
- mixer_->num_output_channels(), resample_ratio, kDefaultReadSize,
+ kNumOutputChannels, resample_ratio, kDefaultReadSize,
base::Bind(&StreamMixerAlsaInputImpl::ReadCB, base::Unretained(this))));
resampler_->PrimeWithSilence();
}
@@ -192,8 +193,7 @@ MediaPipelineBackendAlsa::RenderingDelay StreamMixerAlsaInputImpl::QueueData(
const scoped_refptr<DecoderBufferBase>& data) {
queue_lock_.AssertAcquired();
if (!data->end_of_stream()) {
- int frames =
- data->data_size() / (mixer_->num_output_channels() * sizeof(float));
+ int frames = data->data_size() / (kNumOutputChannels * sizeof(float));
queue_.push_back(data);
queued_frames_ += frames;
queued_frames_including_resampler_ += frames;
@@ -238,7 +238,7 @@ void StreamMixerAlsaInputImpl::AfterWriteFrames(
queued_frames_ = 0;
for (const auto& data : queue_)
queued_frames_ +=
- data->data_size() / (mixer_->num_output_channels() * sizeof(float));
+ data->data_size() / (kNumOutputChannels * sizeof(float));
queued_frames_ -= current_buffer_offset_;
DCHECK_GE(queued_frames_, 0);
queued_frames_including_resampler_ =
@@ -291,7 +291,7 @@ void StreamMixerAlsaInputImpl::GetResampledData(::media::AudioBus* dest,
int frames) {
DCHECK(mixer_task_runner_->BelongsToCurrentThread());
DCHECK(dest);
- DCHECK_EQ(mixer_->num_output_channels(), dest->channels());
+ DCHECK_EQ(kNumOutputChannels, dest->channels());
DCHECK_GE(dest->frames(), frames);
if (state_ == kStatePaused || state_ == kStateDeleted) {
@@ -339,8 +339,8 @@ void StreamMixerAlsaInputImpl::FillFrames(int frame_delay,
base::AutoLock lock(queue_lock_);
if (!queue_.empty()) {
buffer = queue_.front();
- buffer_frames = buffer->data_size() /
- (mixer_->num_output_channels() * sizeof(float));
+ buffer_frames =
+ buffer->data_size() / (kNumOutputChannels * sizeof(float));
frames_to_copy =
std::min(frames_left, buffer_frames - current_buffer_offset_);
// Note that queued_frames_ is not updated until AfterWriteFrames().
@@ -357,7 +357,7 @@ void StreamMixerAlsaInputImpl::FillFrames(int frame_delay,
if (buffer) {
const float* buffer_samples =
reinterpret_cast<const float*>(buffer->data());
- for (int i = 0; i < mixer_->num_output_channels(); ++i) {
+ for (int i = 0; i < kNumOutputChannels; ++i) {
const float* buffer_channel = buffer_samples + (buffer_frames * i);
memcpy(output->channel(i) + frames_filled,
buffer_channel + buffer_offset, frames_to_copy * sizeof(float));
@@ -397,7 +397,7 @@ void StreamMixerAlsaInputImpl::FadeIn(::media::AudioBus* dest, int frames) {
base::Time::kMillisecondsPerSecond;
for (int f = 0; f < frames && fade_frames_remaining_; ++f) {
float fade_multiplier = 1.0 - fade_frames_remaining_ / fade_in_frames;
- for (int c = 0; c < mixer_->num_output_channels(); ++c)
+ for (int c = 0; c < kNumOutputChannels; ++c)
dest->channel(c)[f] *= fade_multiplier;
--fade_frames_remaining_;
}
@@ -410,13 +410,13 @@ void StreamMixerAlsaInputImpl::FadeOut(::media::AudioBus* dest, int frames) {
for (; f < frames && fade_frames_remaining_; ++f) {
float fade_multiplier =
fade_frames_remaining_ / static_cast<float>(fade_out_frames_total_);
- for (int c = 0; c < mixer_->num_output_channels(); ++c)
+ for (int c = 0; c < kNumOutputChannels; ++c)
dest->channel(c)[f] *= fade_multiplier;
--fade_frames_remaining_;
}
// Zero remaining frames
for (; f < frames; ++f) {
- for (int c = 0; c < mixer_->num_output_channels(); ++c)
+ for (int c = 0; c < kNumOutputChannels; ++c)
dest->channel(c)[f] = 0.0f;
}
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa.cc ('k') | chromecast/media/cma/decoder/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698