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

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

Issue 2341783004: [chromecast] Slew stream volume changes in StreamMixerAlsa. (Closed)
Patch Set: Created 4 years, 3 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
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 1e7cc895cc43fcefb9ff7106d9cf1178d2614106..fd0172c06384b4449eac6aa7b7efffc22e5ec44d 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
@@ -56,6 +56,9 @@ const int kPausedReadSamples = 512;
const int kDefaultReadSize = ::media::SincResampler::kDefaultRequestSize;
const int64_t kNoTimestamp = std::numeric_limits<int64_t>::min();
+const int kMaxSlewTimeUpMs = 100;
+const int kMaxSlewTimeDownMs = 100;
+
} // namespace
StreamMixerAlsaInputImpl::StreamMixerAlsaInputImpl(
@@ -71,6 +74,7 @@ StreamMixerAlsaInputImpl::StreamMixerAlsaInputImpl(
caller_task_runner_(base::ThreadTaskRunnerHandle::Get()),
resample_ratio_(1.0),
state_(kStateUninitialized),
+ slew_volume_(kMaxSlewTimeUpMs, kMaxSlewTimeDownMs),
volume_multiplier_(1.0f),
queued_frames_(0),
queued_frames_including_resampler_(0),
@@ -85,6 +89,7 @@ StreamMixerAlsaInputImpl::StreamMixerAlsaInputImpl(
DCHECK(delegate_);
DCHECK(mixer_);
weak_this_ = weak_factory_.GetWeakPtr();
+ slew_volume_.SetSampleRate(input_samples_per_second_);
kmackay 2016/09/14 20:48:15 this doesn't seem right. It is initialized correct
jyw 2016/09/15 01:12:15 Done.
}
StreamMixerAlsaInputImpl::~StreamMixerAlsaInputImpl() {
@@ -120,6 +125,7 @@ void StreamMixerAlsaInputImpl::Initialize(
kNumOutputChannels, resample_ratio_, kDefaultReadSize,
base::Bind(&StreamMixerAlsaInputImpl::ReadCB, base::Unretained(this))));
resampler_->PrimeWithSilence();
+ slew_volume_.SetSampleRate(mixer_->output_samples_per_second());
}
mixer_rendering_delay_ = mixer_rendering_delay;
fade_out_frames_total_ = NormalFadeFrames();
@@ -504,6 +510,13 @@ void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float multiplier) {
if (multiplier < 0.0f)
multiplier = 0.0f;
volume_multiplier_ = multiplier;
+ slew_volume_.SetVolume(volume_multiplier_);
+}
+
+bool StreamMixerAlsaInputImpl::VolumeScaleAccumulate(const float* src,
+ int frames,
+ float* dest) {
+ return slew_volume_.ProcessFMAC(src, frames, dest);
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698