Commit ed38892e authored by Henrik Grunell's avatar Henrik Grunell Committed by Commit Bot

Get IAudioClock at initialization in Windows input audio.

Removes unnecessary getting of the interface each processing pass.

Bug: None
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I5097dee52d62f5f29bac9a2d760595ccfe54046f
Reviewed-on: https://chromium-review.googlesource.com/1011615Reviewed-by: default avatarMax Morin <maxmorin@chromium.org>
Commit-Queue: Henrik Grunell <grunell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550579}
parent f6aced63
...@@ -447,11 +447,6 @@ void WASAPIAudioInputStream::PullCaptureDataAndPushToSink() { ...@@ -447,11 +447,6 @@ void WASAPIAudioInputStream::PullCaptureDataAndPushToSink() {
TRACE_EVENT1("audio", "WASAPIAudioInputStream::Run_0", "sample rate", TRACE_EVENT1("audio", "WASAPIAudioInputStream::Run_0", "sample rate",
input_format_.nSamplesPerSec); input_format_.nSamplesPerSec);
Microsoft::WRL::ComPtr<IAudioClock> audio_clock;
audio_client_->GetService(IID_PPV_ARGS(&audio_clock));
if (!audio_clock)
LOG(WARNING) << "IAudioClock unavailable, capture times may be inaccurate.";
// Pull data from the capture endpoint buffer until it's empty or an error // Pull data from the capture endpoint buffer until it's empty or an error
// occurs. // occurs.
while (true) { while (true) {
...@@ -492,12 +487,14 @@ void WASAPIAudioInputStream::PullCaptureDataAndPushToSink() { ...@@ -492,12 +487,14 @@ void WASAPIAudioInputStream::PullCaptureDataAndPushToSink() {
// TODO(dalecurtis, olka, grunell): Is this ever false? If it is, should we // TODO(dalecurtis, olka, grunell): Is this ever false? If it is, should we
// handle |flags & AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR|? // handle |flags & AUDCLNT_BUFFERFLAGS_TIMESTAMP_ERROR|?
if (audio_clock) { if (audio_clock_) {
// The reported timestamp from GetBuffer is not as reliable as the clock // The reported timestamp from GetBuffer is not as reliable as the clock
// from the client. We've seen timestamps reported for USB audio devices, // from the client. We've seen timestamps reported for USB audio devices,
// be off by several days. Furthermore we've seen them jump back in time // be off by several days. Furthermore we've seen them jump back in time
// every 2 seconds or so. // every 2 seconds or so.
audio_clock->GetPosition(&device_position, &capture_time_100ns); // TODO(grunell): Using the audio clock as capture time for the currently
// processed buffer seems incorrect. http://crbug.com/825744.
audio_clock_->GetPosition(&device_position, &capture_time_100ns);
} }
base::TimeTicks capture_time; base::TimeTicks capture_time;
...@@ -932,6 +929,10 @@ HRESULT WASAPIAudioInputStream::InitializeAudioEngine() { ...@@ -932,6 +929,10 @@ HRESULT WASAPIAudioInputStream::InitializeAudioEngine() {
if (FAILED(hr)) if (FAILED(hr))
open_result_ = OPEN_RESULT_NO_AUDIO_VOLUME; open_result_ = OPEN_RESULT_NO_AUDIO_VOLUME;
audio_client_->GetService(IID_PPV_ARGS(&audio_clock_));
if (!audio_clock_)
LOG(WARNING) << "IAudioClock unavailable, capture times may be inaccurate.";
return hr; return hr;
} }
......
...@@ -245,6 +245,11 @@ class MEDIA_EXPORT WASAPIAudioInputStream ...@@ -245,6 +245,11 @@ class MEDIA_EXPORT WASAPIAudioInputStream
// from a capture endpoint buffer. // from a capture endpoint buffer.
Microsoft::WRL::ComPtr<IAudioCaptureClient> audio_capture_client_; Microsoft::WRL::ComPtr<IAudioCaptureClient> audio_capture_client_;
// The IAudioClock interface is used to get the current timestamp, as the
// timestamp from IAudioCaptureClient::GetBuffer can be unreliable with some
// devices.
Microsoft::WRL::ComPtr<IAudioClock> audio_clock_;
// The ISimpleAudioVolume interface enables a client to control the // The ISimpleAudioVolume interface enables a client to control the
// master volume level of an audio session. // master volume level of an audio session.
// The volume-level is a value in the range 0.0 to 1.0. // The volume-level is a value in the range 0.0 to 1.0.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment