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

Side by Side Diff: media/audio/linux/alsa_input.cc

Issue 15563004: Improved AGC update scheme for the audio backend in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes based on feedback from tommi@ Created 7 years, 7 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
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/linux/alsa_input.h" 5 #include "media/audio/linux/alsa_input.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 196 }
197 197
198 int num_buffers = frames / params_.frames_per_buffer(); 198 int num_buffers = frames / params_.frames_per_buffer();
199 uint32 hardware_delay_bytes = 199 uint32 hardware_delay_bytes =
200 static_cast<uint32>(GetCurrentDelay() * params_.GetBytesPerFrame()); 200 static_cast<uint32>(GetCurrentDelay() * params_.GetBytesPerFrame());
201 double normalized_volume = 0.0; 201 double normalized_volume = 0.0;
202 202
203 // Update the AGC volume level once every second. Note that, |volume| is 203 // Update the AGC volume level once every second. Note that, |volume| is
204 // also updated each time SetVolume() is called through IPC by the 204 // also updated each time SetVolume() is called through IPC by the
205 // render-side AGC. 205 // render-side AGC.
206 QueryAgcVolume(&normalized_volume); 206 GetAgcVolume(&normalized_volume);
207 207
208 while (num_buffers--) { 208 while (num_buffers--) {
209 int frames_read = wrapper_->PcmReadi(device_handle_, audio_buffer_.get(), 209 int frames_read = wrapper_->PcmReadi(device_handle_, audio_buffer_.get(),
210 params_.frames_per_buffer()); 210 params_.frames_per_buffer());
211 if (frames_read == params_.frames_per_buffer()) { 211 if (frames_read == params_.frames_per_buffer()) {
212 callback_->OnData(this, audio_buffer_.get(), bytes_per_buffer_, 212 callback_->OnData(this, audio_buffer_.get(), bytes_per_buffer_,
213 hardware_delay_bytes, normalized_volume); 213 hardware_delay_bytes, normalized_volume);
214 } else { 214 } else {
215 LOG(WARNING) << "PcmReadi returning less than expected frames: " 215 LOG(WARNING) << "PcmReadi returning less than expected frames: "
216 << frames_read << " vs. " << params_.frames_per_buffer() 216 << frames_read << " vs. " << params_.frames_per_buffer()
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 334
335 return static_cast<double>(current_volume); 335 return static_cast<double>(current_volume);
336 } 336 }
337 337
338 void AlsaPcmInputStream::HandleError(const char* method, int error) { 338 void AlsaPcmInputStream::HandleError(const char* method, int error) {
339 LOG(WARNING) << method << ": " << wrapper_->StrError(error); 339 LOG(WARNING) << method << ": " << wrapper_->StrError(error);
340 callback_->OnError(this); 340 callback_->OnError(this);
341 } 341 }
342 342
343 } // namespace media 343 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698