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

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

Issue 16286010: Removed the IsRecordingInProcess check for speech since it is not needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed unused error code and relevant resource, cleaned up include Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_output_proxy_unittest.cc ('k') | media/audio/linux/alsa_input.cc » ('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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 callback_ = NULL; 143 callback_ = NULL;
144 cras_audio_format_destroy(audio_format); 144 cras_audio_format_destroy(audio_format);
145 return; 145 return;
146 } 146 }
147 147
148 // Before starting the stream, save the number of bytes in a frame for use in 148 // Before starting the stream, save the number of bytes in a frame for use in
149 // the callback. 149 // the callback.
150 bytes_per_frame_ = cras_client_format_bytes_per_frame(audio_format); 150 bytes_per_frame_ = cras_client_format_bytes_per_frame(audio_format);
151 151
152 // Adding the stream will start the audio callbacks. 152 // Adding the stream will start the audio callbacks.
153 if (cras_client_add_stream(client_, &stream_id_, stream_params) == 0) { 153 if (cras_client_add_stream(client_, &stream_id_, stream_params)) {
154 audio_manager_->IncreaseActiveInputStreamCount();
155 } else {
156 DLOG(WARNING) << "Failed to add the stream."; 154 DLOG(WARNING) << "Failed to add the stream.";
157 callback_->OnError(this); 155 callback_->OnError(this);
158 callback_ = NULL; 156 callback_ = NULL;
159 } 157 }
160 158
161 // Done with config params. 159 // Done with config params.
162 cras_audio_format_destroy(audio_format); 160 cras_audio_format_destroy(audio_format);
163 cras_client_stream_params_destroy(stream_params); 161 cras_client_stream_params_destroy(stream_params);
164 162
165 started_ = true; 163 started_ = true;
166 } 164 }
167 165
168 void CrasInputStream::Stop() { 166 void CrasInputStream::Stop() {
169 DCHECK(client_); 167 DCHECK(client_);
170 168
171 if (!callback_ || !started_) 169 if (!callback_ || !started_)
172 return; 170 return;
173 171
174 StopAgc(); 172 StopAgc();
175 173
176 // Removing the stream from the client stops audio. 174 // Removing the stream from the client stops audio.
177 cras_client_rm_stream(client_, stream_id_); 175 cras_client_rm_stream(client_, stream_id_);
178 176
179 audio_manager_->DecreaseActiveInputStreamCount();
180
181 started_ = false; 177 started_ = false;
182 } 178 }
183 179
184 // Static callback asking for samples. Run on high priority thread. 180 // Static callback asking for samples. Run on high priority thread.
185 int CrasInputStream::SamplesReady(cras_client* client, 181 int CrasInputStream::SamplesReady(cras_client* client,
186 cras_stream_id_t stream_id, 182 cras_stream_id_t stream_id,
187 uint8* samples, 183 uint8* samples,
188 size_t frames, 184 size_t frames,
189 const timespec* sample_ts, 185 const timespec* sample_ts,
190 void* arg) { 186 void* arg) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 270
275 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const { 271 double CrasInputStream::GetVolumeRatioFromDecibels(double dB) const {
276 return pow(10, dB / 20.0); 272 return pow(10, dB / 20.0);
277 } 273 }
278 274
279 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const { 275 double CrasInputStream::GetDecibelsFromVolumeRatio(double volume_ratio) const {
280 return 20 * log10(volume_ratio); 276 return 20 * log10(volume_ratio);
281 } 277 }
282 278
283 } // namespace media 279 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_proxy_unittest.cc ('k') | media/audio/linux/alsa_input.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698