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

Side by Side Diff: chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc

Issue 1642143003: [Chromecast] Log sample rate changes and tweak audio logging output. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: sample rate logging fix Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 caller_task_runner_(base::ThreadTaskRunnerHandle::Get()), 69 caller_task_runner_(base::ThreadTaskRunnerHandle::Get()),
70 state_(kStateUninitialized), 70 state_(kStateUninitialized),
71 volume_multiplier_(1.0f), 71 volume_multiplier_(1.0f),
72 queued_frames_(0), 72 queued_frames_(0),
73 queued_frames_including_resampler_(0), 73 queued_frames_including_resampler_(0),
74 current_buffer_offset_(0), 74 current_buffer_offset_(0),
75 max_queued_frames_(kMaxInputQueueUs * input_samples_per_second / 75 max_queued_frames_(kMaxInputQueueUs * input_samples_per_second /
76 base::Time::kMicrosecondsPerSecond), 76 base::Time::kMicrosecondsPerSecond),
77 fade_frames_remaining_(0), 77 fade_frames_remaining_(0),
78 fade_out_frames_total_(0), 78 fade_out_frames_total_(0),
79 zeroed_frames_(0),
79 weak_factory_(this) { 80 weak_factory_(this) {
80 DCHECK(delegate_); 81 DCHECK(delegate_);
81 DCHECK(mixer_); 82 DCHECK(mixer_);
82 weak_this_ = weak_factory_.GetWeakPtr(); 83 weak_this_ = weak_factory_.GetWeakPtr();
83 } 84 }
84 85
85 StreamMixerAlsaInputImpl::~StreamMixerAlsaInputImpl() { 86 StreamMixerAlsaInputImpl::~StreamMixerAlsaInputImpl() {
86 DCHECK(mixer_task_runner_->BelongsToCurrentThread()); 87 DCHECK(mixer_task_runner_->BelongsToCurrentThread());
87 } 88 }
88 89
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 const float* buffer_samples = 357 const float* buffer_samples =
357 reinterpret_cast<const float*>(buffer->data()); 358 reinterpret_cast<const float*>(buffer->data());
358 for (int i = 0; i < kNumOutputChannels; ++i) { 359 for (int i = 0; i < kNumOutputChannels; ++i) {
359 const float* buffer_channel = buffer_samples + (buffer_frames * i); 360 const float* buffer_channel = buffer_samples + (buffer_frames * i);
360 memcpy(output->channel(i) + frames_filled, 361 memcpy(output->channel(i) + frames_filled,
361 buffer_channel + buffer_offset, 362 buffer_channel + buffer_offset,
362 frames_to_copy * sizeof(float)); 363 frames_to_copy * sizeof(float));
363 } 364 }
364 frames_left -= frames_to_copy; 365 frames_left -= frames_to_copy;
365 frames_filled += frames_to_copy; 366 frames_filled += frames_to_copy;
367 LOG_IF(WARNING, zeroed_frames_ > 0)
368 << "Filled a total of " << zeroed_frames_ << " frames with 0";
369 zeroed_frames_ = 0;
366 } else { 370 } else {
367 // No data left in queue; fill remaining frames with zeros. 371 // No data left in queue; fill remaining frames with zeros.
368 LOG(WARNING) << "Filling " << frames_left << " frames with 0"; 372 LOG_IF(WARNING, zeroed_frames_ == 0) << "Starting to fill frames with 0";
373 zeroed_frames_ += frames_left;
369 output->ZeroFramesPartial(frames_filled, frames_left); 374 output->ZeroFramesPartial(frames_filled, frames_left);
370 frames_filled += frames_left; 375 frames_filled += frames_left;
371 frames_left = 0; 376 frames_left = 0;
372 break; 377 break;
373 } 378 }
374 } 379 }
375 380
376 DCHECK_EQ(0, frames_left); 381 DCHECK_EQ(0, frames_left);
377 DCHECK_EQ(frames, frames_filled); 382 DCHECK_EQ(frames, frames_filled);
378 } 383 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 DCHECK(!IsDeleting()); 448 DCHECK(!IsDeleting());
444 if (paused) { 449 if (paused) {
445 if (state_ == kStateUninitialized) { 450 if (state_ == kStateUninitialized) {
446 state_ = kStatePaused; 451 state_ = kStatePaused;
447 } else if (state_ == kStateNormalPlayback) { 452 } else if (state_ == kStateNormalPlayback) {
448 fade_frames_remaining_ = NormalFadeFrames() - fade_frames_remaining_; 453 fade_frames_remaining_ = NormalFadeFrames() - fade_frames_remaining_;
449 state_ = (fade_frames_remaining_ ? kStateFadingOut : kStatePaused); 454 state_ = (fade_frames_remaining_ ? kStateFadingOut : kStatePaused);
450 } else { 455 } else {
451 return; 456 return;
452 } 457 }
453 LOG(INFO) << "Pausing"; 458 LOG(INFO) << "Pausing " << this;
454 } else { 459 } else {
455 if (state_ == kStateFadingOut) { 460 if (state_ == kStateFadingOut) {
456 fade_frames_remaining_ = NormalFadeFrames() - fade_frames_remaining_; 461 fade_frames_remaining_ = NormalFadeFrames() - fade_frames_remaining_;
457 } else if (state_ == kStatePaused) { 462 } else if (state_ == kStatePaused) {
458 fade_frames_remaining_ = NormalFadeFrames(); 463 fade_frames_remaining_ = NormalFadeFrames();
459 } else { 464 } else {
460 return; 465 return;
461 } 466 }
462 LOG(INFO) << "Unpausing"; 467 LOG(INFO) << "Unpausing " << this;
463 state_ = kStateNormalPlayback; 468 state_ = kStateNormalPlayback;
464 } 469 }
465 DCHECK_GE(fade_frames_remaining_, 0); 470 DCHECK_GE(fade_frames_remaining_, 0);
466 471
467 if (state_ == kStateFadingOut) { 472 if (state_ == kStateFadingOut) {
468 // Tell the mixer that some more data might be available (since when fading 473 // Tell the mixer that some more data might be available (since when fading
469 // out, we can drain the queue completely). 474 // out, we can drain the queue completely).
470 mixer_->OnFramesQueued(); 475 mixer_->OnFramesQueued();
471 } 476 }
472 } 477 }
473 478
474 void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float multiplier) { 479 void StreamMixerAlsaInputImpl::SetVolumeMultiplier(float multiplier) {
475 RUN_ON_MIXER_THREAD(SetVolumeMultiplier, multiplier); 480 RUN_ON_MIXER_THREAD(SetVolumeMultiplier, multiplier);
476 DCHECK(!IsDeleting()); 481 DCHECK(!IsDeleting());
477 if (multiplier > 1.0f) 482 if (multiplier > 1.0f)
478 multiplier = 1.0f; 483 multiplier = 1.0f;
479 if (multiplier < 0.0f) 484 if (multiplier < 0.0f)
480 multiplier = 0.0f; 485 multiplier = 0.0f;
481 volume_multiplier_ = multiplier; 486 volume_multiplier_ = multiplier;
482 } 487 }
483 488
484 } // namespace media 489 } // namespace media
485 } // namespace chromecast 490 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698