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

Side by Side Diff: media/audio/pulse/pulse_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, 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
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/pulse/pulse_input.h" 5 #include "media/audio/pulse/pulse_input.h"
6 6
7 #include <pulse/pulseaudio.h> 7 #include <pulse/pulseaudio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/audio/pulse/audio_manager_pulse.h" 10 #include "media/audio/pulse/audio_manager_pulse.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0); 239 pa_threaded_mainloop_signal(stream->pa_mainloop_, 0);
240 } 240 }
241 241
242 void PulseAudioInputStream::ReadData() { 242 void PulseAudioInputStream::ReadData() {
243 uint32 hardware_delay = pulse::GetHardwareLatencyInBytes( 243 uint32 hardware_delay = pulse::GetHardwareLatencyInBytes(
244 handle_, params_.sample_rate(), params_.GetBytesPerFrame()); 244 handle_, params_.sample_rate(), params_.GetBytesPerFrame());
245 245
246 // Update the AGC volume level once every second. Note that, 246 // Update the AGC volume level once every second. Note that,
247 // |volume| is also updated each time SetVolume() is called 247 // |volume| is also updated each time SetVolume() is called
248 // through IPC by the render-side AGC. 248 // through IPC by the render-side AGC.
249 // QueryAgcVolume() will trigger a callback to asynchronously update the 249 // We disregard the |normalized_volume| from GetAgcVolume()
250 // |volume_|, we disregard the |normalized_volume| from QueryAgcVolume()
251 // and use the value calculated by |volume_|. 250 // and use the value calculated by |volume_|.
252 double normalized_volume = 0.0; 251 double normalized_volume = 0.0;
253 QueryAgcVolume(&normalized_volume); 252 GetAgcVolume(&normalized_volume);
254 normalized_volume = volume_ / GetMaxVolume(); 253 normalized_volume = volume_ / GetMaxVolume();
255 254
256 do { 255 do {
257 size_t length = 0; 256 size_t length = 0;
258 const void* data = NULL; 257 const void* data = NULL;
259 pa_stream_peek(handle_, &data, &length); 258 pa_stream_peek(handle_, &data, &length);
260 if (!data || length == 0) 259 if (!data || length == 0)
261 break; 260 break;
262 261
263 buffer_->Append(reinterpret_cast<const uint8*>(data), length); 262 buffer_->Append(reinterpret_cast<const uint8*>(data), length);
(...skipping 15 matching lines...) Expand all
279 // input side. 278 // input side.
280 DVLOG(1) << "OnData is being called consecutively, sleep 5ms to " 279 DVLOG(1) << "OnData is being called consecutively, sleep 5ms to "
281 << "wait until render consumes the data"; 280 << "wait until render consumes the data";
282 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); 281 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5));
283 } 282 }
284 283
285 pa_threaded_mainloop_signal(pa_mainloop_, 0); 284 pa_threaded_mainloop_signal(pa_mainloop_, 0);
286 } 285 }
287 286
288 } // namespace media 287 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698