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

Side by Side Diff: media/audio/cras/cras_input.cc

Issue 11959018: Add a unified audio I/O backend for ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Save params, other cleanups suggested by Dale Created 7 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
« no previous file with comments | « media/audio/cras/audio_manager_cras.cc ('k') | media/audio/cras/cras_output.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/audio/cras/cras_input.h" 5 #include "media/audio/cras/cras_input.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 void CrasInputStream::Start(AudioInputCallback* callback) { 102 void CrasInputStream::Start(AudioInputCallback* callback) {
103 DCHECK(client_); 103 DCHECK(client_);
104 DCHECK(callback); 104 DCHECK(callback);
105 105
106 // If already playing, stop before re-starting. 106 // If already playing, stop before re-starting.
107 if (started_) 107 if (started_)
108 return; 108 return;
109 109
110 callback_ = callback; 110 callback_ = callback;
111 LOG(ERROR) << "Input Start";
111 112
112 // Prepare |audio_format| and |stream_params| for the stream we 113 // Prepare |audio_format| and |stream_params| for the stream we
113 // will create. 114 // will create.
114 cras_audio_format* audio_format = cras_audio_format_create( 115 cras_audio_format* audio_format = cras_audio_format_create(
115 alsa_util::BitsToFormat(params_.bits_per_sample()), 116 alsa_util::BitsToFormat(params_.bits_per_sample()),
116 params_.sample_rate(), 117 params_.sample_rate(),
117 params_.channels()); 118 params_.channels());
118 if (!audio_format) { 119 if (!audio_format) {
119 DLOG(WARNING) << "Error setting up audio parameters."; 120 DLOG(WARNING) << "Error setting up audio parameters.";
120 callback_->OnError(this); 121 callback_->OnError(this);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 270
270 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { 271 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const {
271 return pow(10, dB / 20.0); 272 return pow(10, dB / 20.0);
272 } 273 }
273 274
274 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { 275 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const {
275 return 20 * log10(volume_ratio); 276 return 20 * log10(volume_ratio);
276 } 277 }
277 278
278 } // namespace media 279 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/cras/audio_manager_cras.cc ('k') | media/audio/cras/cras_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698