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

Side by Side Diff: media/audio/win/audio_low_latency_input_win.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: tommi@ review 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/win/audio_low_latency_input_win.h" 5 #include "media/audio/win/audio_low_latency_input_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "media/audio/audio_util.h" 10 #include "media/audio/audio_util.h"
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Derive a delay estimate for the captured audio packet. 380 // Derive a delay estimate for the captured audio packet.
381 // The value contains two parts (A+B), where A is the delay of the 381 // The value contains two parts (A+B), where A is the delay of the
382 // first audio frame in the packet and B is the extra delay 382 // first audio frame in the packet and B is the extra delay
383 // contained in any stored data. Unit is in audio frames. 383 // contained in any stored data. Unit is in audio frames.
384 QueryPerformanceCounter(&now_count); 384 QueryPerformanceCounter(&now_count);
385 double audio_delay_frames = 385 double audio_delay_frames =
386 ((perf_count_to_100ns_units_ * now_count.QuadPart - 386 ((perf_count_to_100ns_units_ * now_count.QuadPart -
387 first_audio_frame_timestamp) / 10000.0) * ms_to_frame_count_ + 387 first_audio_frame_timestamp) / 10000.0) * ms_to_frame_count_ +
388 buffer_frame_index - num_frames_to_read; 388 buffer_frame_index - num_frames_to_read;
389 389
390 // Update the AGC volume level once every second. Note that, 390 // Get a cached AGC volume level which is updated once every second
391 // |volume| is also updated each time SetVolume() is called 391 // on the audio manager thread. Note that, |volume| is also updated
392 // through IPC by the render-side AGC. 392 // each time SetVolume() is called through IPC by the render-side AGC.
393 QueryAgcVolume(&volume); 393 GetAgcVolume(&volume);
394 394
395 // Deliver captured data to the registered consumer using a packet 395 // Deliver captured data to the registered consumer using a packet
396 // size which was specified at construction. 396 // size which was specified at construction.
397 uint32 delay_frames = static_cast<uint32>(audio_delay_frames + 0.5); 397 uint32 delay_frames = static_cast<uint32>(audio_delay_frames + 0.5);
398 while (buffer_frame_index >= packet_size_frames_) { 398 while (buffer_frame_index >= packet_size_frames_) {
399 uint8* audio_data = 399 uint8* audio_data =
400 reinterpret_cast<uint8*>(capture_buffer.get()); 400 reinterpret_cast<uint8*>(capture_buffer.get());
401 401
402 // Deliver data packet, delay estimation and volume level to 402 // Deliver data packet, delay estimation and volume level to
403 // the user. 403 // the user.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return hr; 625 return hr;
626 626
627 // Obtain a reference to the ISimpleAudioVolume interface which enables 627 // Obtain a reference to the ISimpleAudioVolume interface which enables
628 // us to control the master volume level of an audio session. 628 // us to control the master volume level of an audio session.
629 hr = audio_client_->GetService(__uuidof(ISimpleAudioVolume), 629 hr = audio_client_->GetService(__uuidof(ISimpleAudioVolume),
630 simple_audio_volume_.ReceiveVoid()); 630 simple_audio_volume_.ReceiveVoid());
631 return hr; 631 return hr;
632 } 632 }
633 633
634 } // namespace media 634 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698