| 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 // Utility methods for the Core Audio API on Windows. | 5 // Utility methods for the Core Audio API on Windows. |
| 6 // Always ensure that Core Audio is supported before using these methods. | 6 // Always ensure that Core Audio is supported before using these methods. |
| 7 // Use media::CoreAudioUtil::IsSupported() for this purpose. | 7 // Use media::CoreAudioUtil::IsSupported() for this purpose. |
| 8 // Also, all methods must be called on a valid COM thread. This can be done | 8 // Also, all methods must be called on a valid COM thread. This can be done |
| 9 // by using the base::win::ScopedCOMInitializer helper class. | 9 // by using the base::win::ScopedCOMInitializer helper class. |
| 10 | 10 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 EDataFlow data_flow); | 193 EDataFlow data_flow); |
| 194 | 194 |
| 195 // After activating an IAudioClient interface on an audio endpoint device, | 195 // After activating an IAudioClient interface on an audio endpoint device, |
| 196 // the client must initialize it once, and only once, to initialize the audio | 196 // the client must initialize it once, and only once, to initialize the audio |
| 197 // stream between the client and the device. In shared mode, the client | 197 // stream between the client and the device. In shared mode, the client |
| 198 // connects indirectly through the audio engine which does the mixing. | 198 // connects indirectly through the audio engine which does the mixing. |
| 199 // In exclusive mode, the client connects directly to the audio hardware. | 199 // In exclusive mode, the client connects directly to the audio hardware. |
| 200 // If a valid event is provided in |event_handle|, the client will be | 200 // If a valid event is provided in |event_handle|, the client will be |
| 201 // initialized for event-driven buffer handling. If |event_handle| is set to | 201 // initialized for event-driven buffer handling. If |event_handle| is set to |
| 202 // NULL, event-driven buffer handling is not utilized. | 202 // NULL, event-driven buffer handling is not utilized. |
| 203 // This function will initialize the audio client as part of the default |
| 204 // audio session if NULL is passed for |session_guid|, otherwise the client |
| 205 // will be associated with the specified session. |
| 203 static HRESULT SharedModeInitialize(IAudioClient* client, | 206 static HRESULT SharedModeInitialize(IAudioClient* client, |
| 204 const WAVEFORMATPCMEX* format, | 207 const WAVEFORMATPCMEX* format, |
| 205 HANDLE event_handle, | 208 HANDLE event_handle, |
| 206 uint32* endpoint_buffer_size); | 209 uint32* endpoint_buffer_size, |
| 210 const GUID* session_guid); |
| 211 |
| 207 // TODO(henrika): add ExclusiveModeInitialize(...) | 212 // TODO(henrika): add ExclusiveModeInitialize(...) |
| 208 | 213 |
| 209 // Create an IAudioRenderClient client for an existing IAudioClient given by | 214 // Create an IAudioRenderClient client for an existing IAudioClient given by |
| 210 // |client|. The IAudioRenderClient interface enables a client to write | 215 // |client|. The IAudioRenderClient interface enables a client to write |
| 211 // output data to a rendering endpoint buffer. | 216 // output data to a rendering endpoint buffer. |
| 212 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( | 217 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( |
| 213 IAudioClient* client); | 218 IAudioClient* client); |
| 214 | 219 |
| 215 // Create an IAudioCaptureClient client for an existing IAudioClient given by | 220 // Create an IAudioCaptureClient client for an existing IAudioClient given by |
| 216 // |client|. The IAudioCaptureClient interface enables a client to read | 221 // |client|. The IAudioCaptureClient interface enables a client to read |
| 217 // input data from a capture endpoint buffer. | 222 // input data from a capture endpoint buffer. |
| 218 static ScopedComPtr<IAudioCaptureClient> CreateCaptureClient( | 223 static ScopedComPtr<IAudioCaptureClient> CreateCaptureClient( |
| 219 IAudioClient* client); | 224 IAudioClient* client); |
| 220 | 225 |
| 221 // Fills up the endpoint rendering buffer with silence for an existing | 226 // Fills up the endpoint rendering buffer with silence for an existing |
| 222 // IAudioClient given by |client| and a corresponding IAudioRenderClient | 227 // IAudioClient given by |client| and a corresponding IAudioRenderClient |
| 223 // given by |render_client|. | 228 // given by |render_client|. |
| 224 static bool FillRenderEndpointBufferWithSilence( | 229 static bool FillRenderEndpointBufferWithSilence( |
| 225 IAudioClient* client, IAudioRenderClient* render_client); | 230 IAudioClient* client, IAudioRenderClient* render_client); |
| 226 | 231 |
| 227 private: | 232 private: |
| 228 CoreAudioUtil() {} | 233 CoreAudioUtil() {} |
| 229 ~CoreAudioUtil() {} | 234 ~CoreAudioUtil() {} |
| 230 DISALLOW_COPY_AND_ASSIGN(CoreAudioUtil); | 235 DISALLOW_COPY_AND_ASSIGN(CoreAudioUtil); |
| 231 }; | 236 }; |
| 232 | 237 |
| 238 // The special audio session identifier we use when opening up the default |
| 239 // communication device. This has the effect that a separate volume control |
| 240 // will be shown in the system's volume mixer and control over ducking and |
| 241 // visually observing the behavior of ducking, is easier. |
| 242 // Use with |SharedModeInitialize|. |
| 243 extern const GUID kCommunicationsSessionId; |
| 244 |
| 233 } // namespace media | 245 } // namespace media |
| 234 | 246 |
| 235 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ | 247 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| OLD | NEW |