| 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 AudioOutputStream for Windows using Windows Core Audio | 5 // Implementation of AudioOutputStream for Windows using Windows Core Audio |
| 6 // WASAPI for low latency rendering. | 6 // WASAPI for low latency rendering. |
| 7 // | 7 // |
| 8 // Overview of operation and performance: | 8 // Overview of operation and performance: |
| 9 // | 9 // |
| 10 // - An object of WASAPIAudioOutputStream is created by the AudioManager | 10 // - An object of WASAPIAudioOutputStream is created by the AudioManager |
| 11 // factory. | 11 // factory. |
| 12 // - Next some thread will call Open(), at that point the underlying | 12 // - Next some thread will call Open(), at that point the underlying |
| 13 // Core Audio APIs are utilized to create two WASAPI interfaces called | 13 // Core Audio APIs are utilized to create two WASAPI interfaces called |
| 14 // IAudioClient and IAudioRenderClient. | 14 // IAudioClient and IAudioRenderClient. |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 static ChannelLayout HardwareChannelLayout(); | 207 static ChannelLayout HardwareChannelLayout(); |
| 208 | 208 |
| 209 // Retrieves the sample rate the audio engine uses for its internal | 209 // Retrieves the sample rate the audio engine uses for its internal |
| 210 // processing/mixing of shared-mode streams for the default endpoint device. | 210 // processing/mixing of shared-mode streams for the default endpoint device. |
| 211 static int HardwareSampleRate(ERole device_role); | 211 static int HardwareSampleRate(ERole device_role); |
| 212 | 212 |
| 213 // Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used | 213 // Returns AUDCLNT_SHAREMODE_EXCLUSIVE if --enable-exclusive-mode is used |
| 214 // as command-line flag and AUDCLNT_SHAREMODE_SHARED otherwise (default). | 214 // as command-line flag and AUDCLNT_SHAREMODE_SHARED otherwise (default). |
| 215 static AUDCLNT_SHAREMODE GetShareMode(); | 215 static AUDCLNT_SHAREMODE GetShareMode(); |
| 216 | 216 |
| 217 bool started() const { return started_; } | 217 bool started() const { return render_thread_.get() != NULL; } |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 FRIEND_TEST_ALL_PREFIXES(WASAPIAudioOutputStreamTest, HardwareChannelCount); | 220 FRIEND_TEST_ALL_PREFIXES(WASAPIAudioOutputStreamTest, HardwareChannelCount); |
| 221 | 221 |
| 222 // Implementation of IUnknown (trivial in this case). See | 222 // Implementation of IUnknown (trivial in this case). See |
| 223 // msdn.microsoft.com/en-us/library/windows/desktop/dd371403(v=vs.85).aspx | 223 // msdn.microsoft.com/en-us/library/windows/desktop/dd371403(v=vs.85).aspx |
| 224 // for details regarding why proper implementations of AddRef(), Release() | 224 // for details regarding why proper implementations of AddRef(), Release() |
| 225 // and QueryInterface() are not needed here. | 225 // and QueryInterface() are not needed here. |
| 226 STDMETHOD_(ULONG, AddRef)(); | 226 STDMETHOD_(ULONG, AddRef)(); |
| 227 STDMETHOD_(ULONG, Release)(); | 227 STDMETHOD_(ULONG, Release)(); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Extended PCM waveform format structure based on WAVEFORMATEXTENSIBLE. | 305 // Extended PCM waveform format structure based on WAVEFORMATEXTENSIBLE. |
| 306 // Use this for multiple channel and hi-resolution PCM data. | 306 // Use this for multiple channel and hi-resolution PCM data. |
| 307 WAVEFORMATPCMEX format_; | 307 WAVEFORMATPCMEX format_; |
| 308 | 308 |
| 309 // Copy of the audio format which we know the audio engine supports. | 309 // Copy of the audio format which we know the audio engine supports. |
| 310 // It is recommended to ensure that the sample rate in |format_| is identical | 310 // It is recommended to ensure that the sample rate in |format_| is identical |
| 311 // to the sample rate in |audio_engine_mix_format_|. | 311 // to the sample rate in |audio_engine_mix_format_|. |
| 312 base::win::ScopedCoMem<WAVEFORMATPCMEX> audio_engine_mix_format_; | 312 base::win::ScopedCoMem<WAVEFORMATPCMEX> audio_engine_mix_format_; |
| 313 | 313 |
| 314 bool opened_; | 314 bool opened_; |
| 315 bool started_; | |
| 316 | 315 |
| 317 // Set to true as soon as a new default device is detected, and cleared when | 316 // Set to true as soon as a new default device is detected, and cleared when |
| 318 // the streaming has switched from using the old device to the new device. | 317 // the streaming has switched from using the old device to the new device. |
| 319 // All additional device detections during an active state are ignored to | 318 // All additional device detections during an active state are ignored to |
| 320 // ensure that the ongoing switch can finalize without disruptions. | 319 // ensure that the ongoing switch can finalize without disruptions. |
| 321 bool restart_rendering_mode_; | 320 bool restart_rendering_mode_; |
| 322 | 321 |
| 323 // Volume level from 0 to 1. | 322 // Volume level from 0 to 1. |
| 324 float volume_; | 323 float volume_; |
| 325 | 324 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 384 |
| 386 // Container for retrieving data from AudioSourceCallback::OnMoreData(). | 385 // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| 387 scoped_ptr<AudioBus> audio_bus_; | 386 scoped_ptr<AudioBus> audio_bus_; |
| 388 | 387 |
| 389 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioOutputStream); | 388 DISALLOW_COPY_AND_ASSIGN(WASAPIAudioOutputStream); |
| 390 }; | 389 }; |
| 391 | 390 |
| 392 } // namespace media | 391 } // namespace media |
| 393 | 392 |
| 394 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_ | 393 #endif // MEDIA_AUDIO_WIN_AUDIO_LOW_LATENCY_OUTPUT_WIN_H_ |
| OLD | NEW |