Chromium Code Reviews| Index: remoting/host/audio_capturer_win.cc |
| diff --git a/remoting/host/audio_capturer_win.cc b/remoting/host/audio_capturer_win.cc |
| index c648a0ab0727c5c776e51a9bf66db3c4100bc8e4..50b6ee06214f55389a8acc744cd929adc5bef8a6 100644 |
| --- a/remoting/host/audio_capturer_win.cc |
| +++ b/remoting/host/audio_capturer_win.cc |
| @@ -9,6 +9,7 @@ |
| #include <mmreg.h> |
| #include <mmsystem.h> |
| +#include <algorithm> |
| #include <stdlib.h> |
| #include "base/basictypes.h" |
| @@ -34,6 +35,12 @@ const int kHnsToMs = 10000; |
| // silence. A value of 2 was chosen, because Windows can give samples of 1 and |
| // -1, even when no audio is playing. |
| const int kSilenceThreshold = 2; |
| + |
| +// Lower bound for timer intervals, in milliseconds. |
| +const int kMinTimerInteveral = 30; |
|
Wez
2012/08/16 18:49:36
typo: kMinTimerInterval
kxing
2012/08/16 20:17:21
Done.
|
| + |
| +// Upper bound for the timer precision error, in milliseconds. |
|
Wez
2012/08/16 18:49:36
nit: Clarify where this value comes from, even if
kxing
2012/08/16 20:17:21
Done.
|
| +const int kMaxTimerLag = 30; |
|
Wez
2012/08/16 18:49:36
nit: Consider calling this kMaxExpectedTimerLag; i
kxing
2012/08/16 20:17:21
Done.
|
| } // namespace |
| namespace remoting { |
| @@ -129,7 +136,7 @@ bool AudioCapturerWin::Start(const PacketCapturedCallback& callback) { |
| return false; |
| } |
| audio_device_period_ = base::TimeDelta::FromMilliseconds( |
| - device_period / kChannels / kHnsToMs); |
| + std::max(static_cast<int>(device_period / kHnsToMs), kMinTimerInteveral)); |
|
Wez
2012/08/16 18:49:36
nit: If |device_period| is not an integer number o
kxing
2012/08/16 20:17:21
Done.
|
| // Get the wave format. |
| hr = audio_client_->GetMixFormat(&wave_format_ex_); |
| @@ -193,12 +200,13 @@ bool AudioCapturerWin::Start(const PacketCapturedCallback& callback) { |
| } |
| // Initialize the IAudioClient. |
| - hr = audio_client_->Initialize(AUDCLNT_SHAREMODE_SHARED, |
| - AUDCLNT_STREAMFLAGS_LOOPBACK, |
| - 0, |
| - 0, |
| - wave_format_ex_, |
| - NULL); |
| + hr = audio_client_->Initialize( |
| + AUDCLNT_SHAREMODE_SHARED, |
| + AUDCLNT_STREAMFLAGS_LOOPBACK, |
| + (kMaxTimerLag + audio_device_period_.InMilliseconds()) * kHnsToMs, |
|
Wez
2012/08/16 18:49:36
You're multiplying a value in milliseconds by the
kxing
2012/08/16 20:17:21
Done.
|
| + 0, |
| + wave_format_ex_, |
| + NULL); |
| if (FAILED(hr)) { |
| LOG(ERROR) << "Failed to initialize IAudioClient. Error " << hr; |
| return false; |