| OLD | NEW |
| 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 <cmath> | 7 #include <cmath> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 DCHECK(!capture_thread_.get()); | 193 DCHECK(!capture_thread_.get()); |
| 194 capture_thread_.reset(new base::DelegateSimpleThread( | 194 capture_thread_.reset(new base::DelegateSimpleThread( |
| 195 this, "wasapi_capture_thread", | 195 this, "wasapi_capture_thread", |
| 196 base::SimpleThread::Options(base::ThreadPriority::REALTIME_AUDIO))); | 196 base::SimpleThread::Options(base::ThreadPriority::REALTIME_AUDIO))); |
| 197 capture_thread_->Start(); | 197 capture_thread_->Start(); |
| 198 | 198 |
| 199 // Start streaming data between the endpoint buffer and the audio engine. | 199 // Start streaming data between the endpoint buffer and the audio engine. |
| 200 HRESULT hr = audio_client_->Start(); | 200 HRESULT hr = audio_client_->Start(); |
| 201 DLOG_IF(ERROR, FAILED(hr)) << "Failed to start input streaming."; | 201 DLOG_IF(ERROR, FAILED(hr)) << "Failed to start input streaming."; |
| 202 | 202 |
| 203 if (SUCCEEDED(hr) && audio_render_client_for_loopback_.get()) | 203 if (SUCCEEDED(hr) && audio_render_client_for_loopback_.Get()) |
| 204 hr = audio_render_client_for_loopback_->Start(); | 204 hr = audio_render_client_for_loopback_->Start(); |
| 205 | 205 |
| 206 started_ = SUCCEEDED(hr); | 206 started_ = SUCCEEDED(hr); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void WASAPIAudioInputStream::Stop() { | 209 void WASAPIAudioInputStream::Stop() { |
| 210 DCHECK(CalledOnValidThread()); | 210 DCHECK(CalledOnValidThread()); |
| 211 DVLOG(1) << "WASAPIAudioInputStream::Stop()"; | 211 DVLOG(1) << "WASAPIAudioInputStream::Stop()"; |
| 212 if (!started_) | 212 if (!started_) |
| 213 return; | 213 return; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 501 } |
| 502 | 502 |
| 503 void WASAPIAudioInputStream::HandleError(HRESULT err) { | 503 void WASAPIAudioInputStream::HandleError(HRESULT err) { |
| 504 NOTREACHED() << "Error code: " << err; | 504 NOTREACHED() << "Error code: " << err; |
| 505 if (sink_) | 505 if (sink_) |
| 506 sink_->OnError(this); | 506 sink_->OnError(this); |
| 507 } | 507 } |
| 508 | 508 |
| 509 HRESULT WASAPIAudioInputStream::SetCaptureDevice() { | 509 HRESULT WASAPIAudioInputStream::SetCaptureDevice() { |
| 510 DCHECK_EQ(OPEN_RESULT_OK, open_result_); | 510 DCHECK_EQ(OPEN_RESULT_OK, open_result_); |
| 511 DCHECK(!endpoint_device_.get()); | 511 DCHECK(!endpoint_device_.Get()); |
| 512 | 512 |
| 513 ScopedComPtr<IMMDeviceEnumerator> enumerator; | 513 ScopedComPtr<IMMDeviceEnumerator> enumerator; |
| 514 HRESULT hr = enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, | 514 HRESULT hr = enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, |
| 515 CLSCTX_INPROC_SERVER); | 515 CLSCTX_INPROC_SERVER); |
| 516 if (FAILED(hr)) { | 516 if (FAILED(hr)) { |
| 517 open_result_ = OPEN_RESULT_CREATE_INSTANCE; | 517 open_result_ = OPEN_RESULT_CREATE_INSTANCE; |
| 518 return hr; | 518 return hr; |
| 519 } | 519 } |
| 520 | 520 |
| 521 // Retrieve the IMMDevice by using the specified role or the specified | 521 // Retrieve the IMMDevice by using the specified role or the specified |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 OPEN_RESULT_MAX + 1); | 828 OPEN_RESULT_MAX + 1); |
| 829 } | 829 } |
| 830 | 830 |
| 831 double WASAPIAudioInputStream::ProvideInput(AudioBus* audio_bus, | 831 double WASAPIAudioInputStream::ProvideInput(AudioBus* audio_bus, |
| 832 uint32_t frames_delayed) { | 832 uint32_t frames_delayed) { |
| 833 fifo_->Consume()->CopyTo(audio_bus); | 833 fifo_->Consume()->CopyTo(audio_bus); |
| 834 return 1.0; | 834 return 1.0; |
| 835 } | 835 } |
| 836 | 836 |
| 837 } // namespace media | 837 } // namespace media |
| OLD | NEW |