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

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

Issue 2738873002: [Chromecast] Implement new volume control API (Closed)
Patch Set: slan comments Created 3 years, 9 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
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/audio_decoder_alsa.h" 5 #include "chromecast/media/cma/backend/alsa/audio_decoder_alsa.h"
6 6
7 #include <time.h> 7 #include <time.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 pending_output_frames_ = kNoPendingOutput; 101 pending_output_frames_ = kNoPendingOutput;
102 102
103 last_mixer_delay_.timestamp_microseconds = kInvalidTimestamp; 103 last_mixer_delay_.timestamp_microseconds = kInvalidTimestamp;
104 last_mixer_delay_.delay_microseconds = 0; 104 last_mixer_delay_.delay_microseconds = 0;
105 } 105 }
106 106
107 bool AudioDecoderAlsa::Start(int64_t start_pts) { 107 bool AudioDecoderAlsa::Start(int64_t start_pts) {
108 TRACE_FUNCTION_ENTRY0(); 108 TRACE_FUNCTION_ENTRY0();
109 current_pts_ = start_pts; 109 current_pts_ = start_pts;
110 DCHECK(IsValidConfig(config_)); 110 DCHECK(IsValidConfig(config_));
111 mixer_input_.reset(new StreamMixerAlsaInput(this, config_.samples_per_second, 111 mixer_input_.reset(new StreamMixerAlsaInput(
112 backend_->Primary(), 112 this, config_.samples_per_second, backend_->Primary(),
113 backend_->DeviceId())); 113 backend_->DeviceId(), backend_->ContentType()));
114 mixer_input_->SetVolumeMultiplier(volume_multiplier_); 114 mixer_input_->SetVolumeMultiplier(volume_multiplier_);
115 // Create decoder_ if necessary. This can happen if Stop() was called, and 115 // Create decoder_ if necessary. This can happen if Stop() was called, and
116 // SetConfig() was not called since then. 116 // SetConfig() was not called since then.
117 if (!decoder_) { 117 if (!decoder_) {
118 CreateDecoder(); 118 CreateDecoder();
119 } 119 }
120 if (!rate_shifter_) { 120 if (!rate_shifter_) {
121 CreateRateShifter(config_.samples_per_second); 121 CreateRateShifter(config_.samples_per_second);
122 } 122 }
123 return true; 123 return true;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 (config.samples_per_second != config_.samples_per_second); 231 (config.samples_per_second != config_.samples_per_second);
232 232
233 if (!rate_shifter_ || changed_sample_rate) { 233 if (!rate_shifter_ || changed_sample_rate) {
234 CreateRateShifter(config.samples_per_second); 234 CreateRateShifter(config.samples_per_second);
235 } 235 }
236 236
237 if (mixer_input_ && changed_sample_rate) { 237 if (mixer_input_ && changed_sample_rate) {
238 // Destroy the old input first to ensure that the mixer output sample rate 238 // Destroy the old input first to ensure that the mixer output sample rate
239 // is updated. 239 // is updated.
240 mixer_input_.reset(); 240 mixer_input_.reset();
241 mixer_input_.reset(new StreamMixerAlsaInput(this, config.samples_per_second, 241 mixer_input_.reset(new StreamMixerAlsaInput(
242 backend_->Primary(), 242 this, config.samples_per_second, backend_->Primary(),
243 backend_->DeviceId())); 243 backend_->DeviceId(), backend_->ContentType()));
244 mixer_input_->SetVolumeMultiplier(volume_multiplier_); 244 mixer_input_->SetVolumeMultiplier(volume_multiplier_);
245 pending_output_frames_ = kNoPendingOutput; 245 pending_output_frames_ = kNoPendingOutput;
246 } 246 }
247 247
248 config_ = config; 248 config_ = config;
249 decoder_.reset(); 249 decoder_.reset();
250 CreateDecoder(); 250 CreateDecoder();
251 251
252 if (pending_buffer_complete_ && changed_sample_rate) { 252 if (pending_buffer_complete_ && changed_sample_rate) {
253 pending_buffer_complete_ = false; 253 pending_buffer_complete_ = false;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 TRACE_FUNCTION_ENTRY0(); 538 TRACE_FUNCTION_ENTRY0();
539 DCHECK(task_runner_->BelongsToCurrentThread()); 539 DCHECK(task_runner_->BelongsToCurrentThread());
540 if (error != MixerError::kInputIgnored) 540 if (error != MixerError::kInputIgnored)
541 LOG(ERROR) << "Mixer error occurred."; 541 LOG(ERROR) << "Mixer error occurred.";
542 mixer_error_ = true; 542 mixer_error_ = true;
543 delegate_->OnDecoderError(); 543 delegate_->OnDecoderError();
544 } 544 }
545 545
546 } // namespace media 546 } // namespace media
547 } // namespace chromecast 547 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/cma/backend/alsa/BUILD.gn ('k') | chromecast/media/cma/backend/alsa/audio_filter_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698