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 // Implementation of AudioInputStream for Windows using Windows Core Audio | 5 // Implementation of AudioInputStream for Windows using Windows Core Audio |
6 // WASAPI for low latency capturing. | 6 // WASAPI for low latency capturing. |
7 // | 7 // |
8 // Overview of operation: | 8 // Overview of operation: |
9 // | 9 // |
10 // - An object of WASAPIAudioInputStream is created by the AudioManager | 10 // - An object of WASAPIAudioInputStream is created by the AudioManager |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 #include <MMDeviceAPI.h> | 60 #include <MMDeviceAPI.h> |
61 #include <endpointvolume.h> | 61 #include <endpointvolume.h> |
62 #include <stddef.h> | 62 #include <stddef.h> |
63 #include <stdint.h> | 63 #include <stdint.h> |
64 | 64 |
65 #include <memory> | 65 #include <memory> |
66 #include <string> | 66 #include <string> |
67 | 67 |
68 #include "base/compiler_specific.h" | 68 #include "base/compiler_specific.h" |
69 #include "base/macros.h" | 69 #include "base/macros.h" |
70 #include "base/threading/non_thread_safe.h" | 70 #include "base/sequence_checker.h" |
71 #include "base/threading/platform_thread.h" | 71 #include "base/threading/platform_thread.h" |
72 #include "base/threading/simple_thread.h" | 72 #include "base/threading/simple_thread.h" |
73 #include "base/win/scoped_co_mem.h" | 73 #include "base/win/scoped_co_mem.h" |
74 #include "base/win/scoped_com_initializer.h" | 74 #include "base/win/scoped_com_initializer.h" |
75 #include "base/win/scoped_comptr.h" | 75 #include "base/win/scoped_comptr.h" |
76 #include "base/win/scoped_handle.h" | 76 #include "base/win/scoped_handle.h" |
77 #include "media/audio/agc_audio_stream.h" | 77 #include "media/audio/agc_audio_stream.h" |
78 #include "media/base/audio_converter.h" | 78 #include "media/base/audio_converter.h" |
79 #include "media/base/audio_parameters.h" | 79 #include "media/base/audio_parameters.h" |
80 #include "media/base/media_export.h" | 80 #include "media/base/media_export.h" |
81 | 81 |
82 namespace media { | 82 namespace media { |
83 | 83 |
84 class AudioBlockFifo; | 84 class AudioBlockFifo; |
85 class AudioBus; | 85 class AudioBus; |
86 class AudioManagerWin; | 86 class AudioManagerWin; |
87 | 87 |
88 // AudioInputStream implementation using Windows Core Audio APIs. | 88 // AudioInputStream implementation using Windows Core Audio APIs. |
89 class MEDIA_EXPORT WASAPIAudioInputStream | 89 class MEDIA_EXPORT WASAPIAudioInputStream |
90 : public AgcAudioStream<AudioInputStream>, | 90 : public AgcAudioStream<AudioInputStream>, |
91 public base::DelegateSimpleThread::Delegate, | 91 public base::DelegateSimpleThread::Delegate, |
92 public AudioConverter::InputCallback, | 92 public AudioConverter::InputCallback { |
93 NON_EXPORTED_BASE(public base::NonThreadSafe) { | |
94 public: | 93 public: |
95 // The ctor takes all the usual parameters, plus |manager| which is the | 94 // The ctor takes all the usual parameters, plus |manager| which is the |
96 // the audio manager who is creating this object. | 95 // the audio manager who is creating this object. |
97 WASAPIAudioInputStream(AudioManagerWin* manager, | 96 WASAPIAudioInputStream(AudioManagerWin* manager, |
98 const AudioParameters& params, | 97 const AudioParameters& params, |
99 const std::string& device_id); | 98 const std::string& device_id); |
100 | 99 |
101 // The dtor is typically called by the AudioManager only and it is usually | 100 // The dtor is typically called by the AudioManager only and it is usually |
102 // triggered by calling AudioInputStream::Close(). | 101 // triggered by calling AudioInputStream::Close(). |
103 ~WASAPIAudioInputStream() override; | 102 ~WASAPIAudioInputStream() override; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 247 |
249 // Used for the captured audio on the callback thread. | 248 // Used for the captured audio on the callback thread. |
250 std::unique_ptr<AudioBlockFifo> fifo_; | 249 std::unique_ptr<AudioBlockFifo> fifo_; |
251 | 250 |
252 // If the caller requires resampling (should only be in exceptional cases and | 251 // If the caller requires resampling (should only be in exceptional cases and |
253 // ideally, never), we support using an AudioConverter. | 252 // ideally, never), we support using an AudioConverter. |
254 std::unique_ptr<AudioConverter> converter_; | 253 std::unique_ptr<AudioConverter> converter_; |
255 std::unique_ptr<AudioBus> convert_bus_; | 254 std::unique_ptr<AudioBus> convert_bus_; |
256 bool imperfect_buffer_size_conversion_ = false; | 255 bool imperfect_buffer_size_conversion_ = false; |
257 | 256 |
| 257 SEQUENCE_CHECKER(sequence_checker_); |
| 258 |
258 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream); | 259 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioInputStream); |
259 }; | 260 }; |
260 | 261 |
261 } // namespace media | 262 } // namespace media |
262 | 263 |
263 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_ | 264 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_INPUT_WIN_H_ |
OLD | NEW |