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 <memory> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
11 #include "media/audio/win/audio_manager_win.h" | 12 #include "media/audio/win/audio_manager_win.h" |
12 #include "media/audio/win/avrt_wrapper_win.h" | 13 #include "media/audio/win/avrt_wrapper_win.h" |
13 #include "media/audio/win/core_audio_util_win.h" | 14 #include "media/audio/win/core_audio_util_win.h" |
14 #include "media/base/audio_bus.h" | 15 #include "media/base/audio_bus.h" |
15 | 16 |
16 using base::win::ScopedComPtr; | 17 using base::win::ScopedComPtr; |
17 using base::win::ScopedCOMInitializer; | 18 using base::win::ScopedCOMInitializer; |
18 | 19 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 285 |
285 // Allocate a buffer with a size that enables us to take care of cases like: | 286 // Allocate a buffer with a size that enables us to take care of cases like: |
286 // 1) The recorded buffer size is smaller, or does not match exactly with, | 287 // 1) The recorded buffer size is smaller, or does not match exactly with, |
287 // the selected packet size used in each callback. | 288 // the selected packet size used in each callback. |
288 // 2) The selected buffer size is larger than the recorded buffer size in | 289 // 2) The selected buffer size is larger than the recorded buffer size in |
289 // each event. | 290 // each event. |
290 size_t buffer_frame_index = 0; | 291 size_t buffer_frame_index = 0; |
291 size_t capture_buffer_size = std::max( | 292 size_t capture_buffer_size = std::max( |
292 2 * endpoint_buffer_size_frames_ * frame_size_, | 293 2 * endpoint_buffer_size_frames_ * frame_size_, |
293 2 * packet_size_frames_ * frame_size_); | 294 2 * packet_size_frames_ * frame_size_); |
294 scoped_ptr<uint8_t[]> capture_buffer(new uint8_t[capture_buffer_size]); | 295 std::unique_ptr<uint8_t[]> capture_buffer(new uint8_t[capture_buffer_size]); |
295 | 296 |
296 LARGE_INTEGER now_count = {}; | 297 LARGE_INTEGER now_count = {}; |
297 bool recording = true; | 298 bool recording = true; |
298 bool error = false; | 299 bool error = false; |
299 double volume = GetVolume(); | 300 double volume = GetVolume(); |
300 HANDLE wait_array[2] = | 301 HANDLE wait_array[2] = |
301 { stop_capture_event_.Get(), audio_samples_ready_event_.Get() }; | 302 { stop_capture_event_.Get(), audio_samples_ready_event_.Get() }; |
302 | 303 |
303 base::win::ScopedComPtr<IAudioClock> audio_clock; | 304 base::win::ScopedComPtr<IAudioClock> audio_clock; |
304 audio_client_->GetService(__uuidof(IAudioClock), audio_clock.ReceiveVoid()); | 305 audio_client_->GetService(__uuidof(IAudioClock), audio_clock.ReceiveVoid()); |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 return hr; | 678 return hr; |
678 | 679 |
679 // Obtain a reference to the ISimpleAudioVolume interface which enables | 680 // Obtain a reference to the ISimpleAudioVolume interface which enables |
680 // us to control the master volume level of an audio session. | 681 // us to control the master volume level of an audio session. |
681 hr = audio_client_->GetService(__uuidof(ISimpleAudioVolume), | 682 hr = audio_client_->GetService(__uuidof(ISimpleAudioVolume), |
682 simple_audio_volume_.ReceiveVoid()); | 683 simple_audio_volume_.ReceiveVoid()); |
683 return hr; | 684 return hr; |
684 } | 685 } |
685 | 686 |
686 } // namespace media | 687 } // namespace media |
OLD | NEW |