OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h" | 5 #include "chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 state_(kStateUninitialized), | 76 state_(kStateUninitialized), |
77 slew_volume_(kMaxSlewTimeUpMs, kMaxSlewTimeDownMs), | 77 slew_volume_(kMaxSlewTimeUpMs, kMaxSlewTimeDownMs), |
78 queued_frames_(0), | 78 queued_frames_(0), |
79 queued_frames_including_resampler_(0), | 79 queued_frames_including_resampler_(0), |
80 current_buffer_offset_(0), | 80 current_buffer_offset_(0), |
81 max_queued_frames_(kMaxInputQueueUs * input_samples_per_second / | 81 max_queued_frames_(kMaxInputQueueUs * input_samples_per_second / |
82 base::Time::kMicrosecondsPerSecond), | 82 base::Time::kMicrosecondsPerSecond), |
83 fade_frames_remaining_(0), | 83 fade_frames_remaining_(0), |
84 fade_out_frames_total_(0), | 84 fade_out_frames_total_(0), |
85 zeroed_frames_(0), | 85 zeroed_frames_(0), |
86 being_skipped_(false), | |
86 weak_factory_(this) { | 87 weak_factory_(this) { |
87 LOG(INFO) << "Create " << this; | 88 LOG(INFO) << "Create " << this; |
88 DCHECK(delegate_); | 89 DCHECK(delegate_); |
89 DCHECK(mixer_); | 90 DCHECK(mixer_); |
90 weak_this_ = weak_factory_.GetWeakPtr(); | 91 weak_this_ = weak_factory_.GetWeakPtr(); |
91 } | 92 } |
92 | 93 |
93 StreamMixerAlsaInputImpl::~StreamMixerAlsaInputImpl() { | 94 StreamMixerAlsaInputImpl::~StreamMixerAlsaInputImpl() { |
94 LOG(INFO) << "Destroy " << this; | 95 LOG(INFO) << "Destroy " << this; |
95 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); | 96 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 LOG(INFO) << "End of stream for " << this; | 231 LOG(INFO) << "End of stream for " << this; |
231 state_ = kStateGotEos; | 232 state_ = kStateGotEos; |
232 } else if (state_ == kStateUninitialized) { | 233 } else if (state_ == kStateUninitialized) { |
233 state_ = kStateNormalPlayback; | 234 state_ = kStateNormalPlayback; |
234 } | 235 } |
235 mixer_->OnFramesQueued(); | 236 mixer_->OnFramesQueued(); |
236 } | 237 } |
237 | 238 |
238 void StreamMixerAlsaInputImpl::OnSkipped() { | 239 void StreamMixerAlsaInputImpl::OnSkipped() { |
239 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); | 240 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); |
241 if (!being_skipped_) { | |
slan
2016/12/07 00:22:27
Suggestion: I think that an integer |consecutive_f
kmackay
2016/12/07 22:59:58
Changed name to is_underflowing_
| |
242 LOG(WARNING) << "Underflow for " << this; | |
243 being_skipped_ = true; | |
244 } | |
240 if (state_ == kStateNormalPlayback) { | 245 if (state_ == kStateNormalPlayback) { |
241 // Fade in once this input starts providing data again. | 246 // Fade in once this input starts providing data again. |
242 fade_frames_remaining_ = NormalFadeFrames(); | 247 fade_frames_remaining_ = NormalFadeFrames(); |
243 } | 248 } |
244 } | 249 } |
245 | 250 |
246 void StreamMixerAlsaInputImpl::AfterWriteFrames( | 251 void StreamMixerAlsaInputImpl::AfterWriteFrames( |
247 const MediaPipelineBackendAlsa::RenderingDelay& mixer_rendering_delay) { | 252 const MediaPipelineBackendAlsa::RenderingDelay& mixer_rendering_delay) { |
248 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); | 253 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); |
249 double resampler_queued_frames = | 254 double resampler_queued_frames = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 return std::min(available_frames, fade_frames_remaining_); | 314 return std::min(available_frames, fade_frames_remaining_); |
310 return std::max(0, available_frames - NormalFadeFrames()); | 315 return std::max(0, available_frames - NormalFadeFrames()); |
311 } | 316 } |
312 | 317 |
313 void StreamMixerAlsaInputImpl::GetResampledData(::media::AudioBus* dest, | 318 void StreamMixerAlsaInputImpl::GetResampledData(::media::AudioBus* dest, |
314 int frames) { | 319 int frames) { |
315 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); | 320 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); |
316 DCHECK(dest); | 321 DCHECK(dest); |
317 DCHECK_EQ(kNumOutputChannels, dest->channels()); | 322 DCHECK_EQ(kNumOutputChannels, dest->channels()); |
318 DCHECK_GE(dest->frames(), frames); | 323 DCHECK_GE(dest->frames(), frames); |
324 being_skipped_ = false; | |
319 | 325 |
320 if (state_ == kStatePaused || state_ == kStateDeleted) { | 326 if (state_ == kStatePaused || state_ == kStateDeleted) { |
321 dest->ZeroFramesPartial(0, frames); | 327 dest->ZeroFramesPartial(0, frames); |
322 return; | 328 return; |
323 } | 329 } |
324 | 330 |
325 if (resampler_) { | 331 if (resampler_) { |
326 resampler_->Resample(frames, dest); | 332 resampler_->Resample(frames, dest); |
327 } else { | 333 } else { |
328 FillFrames(0, dest, frames); | 334 FillFrames(0, dest, frames); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 | 522 |
517 void StreamMixerAlsaInputImpl::VolumeScaleAccumulate(bool repeat_transition, | 523 void StreamMixerAlsaInputImpl::VolumeScaleAccumulate(bool repeat_transition, |
518 const float* src, | 524 const float* src, |
519 int frames, | 525 int frames, |
520 float* dest) { | 526 float* dest) { |
521 slew_volume_.ProcessFMAC(repeat_transition, src, frames, dest); | 527 slew_volume_.ProcessFMAC(repeat_transition, src, frames, dest); |
522 } | 528 } |
523 | 529 |
524 } // namespace media | 530 } // namespace media |
525 } // namespace chromecast | 531 } // namespace chromecast |
OLD | NEW |