| 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::CoreAudioIsSupported() for this purpose. | 7 // Use media::CoreAudioIsSupported() 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // |audio_device|. Flow direction and role is define by the |audio_device|. | 97 // |audio_device|. Flow direction and role is define by the |audio_device|. |
| 98 static ScopedComPtr<IAudioClient> CreateClient(IMMDevice* audio_device); | 98 static ScopedComPtr<IAudioClient> CreateClient(IMMDevice* audio_device); |
| 99 | 99 |
| 100 // Get the mix format that the audio engine uses internally for processing | 100 // Get the mix format that the audio engine uses internally for processing |
| 101 // of shared-mode streams. This format is not necessarily a format that the | 101 // of shared-mode streams. This format is not necessarily a format that the |
| 102 // audio endpoint device supports. Thus, the caller might not succeed in | 102 // audio endpoint device supports. Thus, the caller might not succeed in |
| 103 // creating an exclusive-mode stream with a format obtained by this method. | 103 // creating an exclusive-mode stream with a format obtained by this method. |
| 104 static HRESULT GetSharedModeMixFormat(IAudioClient* client, | 104 static HRESULT GetSharedModeMixFormat(IAudioClient* client, |
| 105 WAVEFORMATPCMEX* format); | 105 WAVEFORMATPCMEX* format); |
| 106 | 106 |
| 107 // Get the mix format that the audio engine uses internally for processing |
| 108 // of shared-mode streams using the default IMMDevice where flow direction |
| 109 // and role is define by |data_flow| and |role|. |
| 110 static HRESULT GetDefaultSharedModeMixFormat(EDataFlow data_flow, |
| 111 ERole role, |
| 112 WAVEFORMATPCMEX* format); |
| 113 |
| 107 // Returns true if the specified |client| supports the format in |format| | 114 // Returns true if the specified |client| supports the format in |format| |
| 108 // for the given |share_mode| (shared or exclusive). | 115 // for the given |share_mode| (shared or exclusive). |
| 109 static bool IsFormatSupported(IAudioClient* client, | 116 static bool IsFormatSupported(IAudioClient* client, |
| 110 AUDCLNT_SHAREMODE share_mode, | 117 AUDCLNT_SHAREMODE share_mode, |
| 111 const WAVEFORMATPCMEX* format); | 118 const WAVEFORMATPCMEX* format); |
| 112 | 119 |
| 113 // For a shared-mode stream, the audio engine periodically processes the | 120 // For a shared-mode stream, the audio engine periodically processes the |
| 114 // data in the endpoint buffer at the period obtained in |device_period|. | 121 // data in the endpoint buffer at the period obtained in |device_period|. |
| 115 // For an exclusive mode stream, |device_period| corresponds to the minimum | 122 // For an exclusive mode stream, |device_period| corresponds to the minimum |
| 116 // time interval between successive processing by the endpoint device. | 123 // time interval between successive processing by the endpoint device. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 // output data to a rendering endpoint buffer. | 156 // output data to a rendering endpoint buffer. |
| 150 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( | 157 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( |
| 151 IAudioClient* client); | 158 IAudioClient* client); |
| 152 | 159 |
| 153 // Create an IAudioCaptureClient client for an existing IAudioClient given by | 160 // Create an IAudioCaptureClient client for an existing IAudioClient given by |
| 154 // |client|. The IAudioCaptureClient interface enables a client to read | 161 // |client|. The IAudioCaptureClient interface enables a client to read |
| 155 // input data from a capture endpoint buffer. | 162 // input data from a capture endpoint buffer. |
| 156 static ScopedComPtr<IAudioCaptureClient> CreateCaptureClient( | 163 static ScopedComPtr<IAudioCaptureClient> CreateCaptureClient( |
| 157 IAudioClient* client); | 164 IAudioClient* client); |
| 158 | 165 |
| 166 // Fills up the endpoint rendering buffer with silence for an existing |
| 167 // IAudioClient given by |client| and a corresponding IAudioRenderClient |
| 168 // given by |render_client|. |
| 169 static bool FillRenderEndpointBufferWithSilence( |
| 170 IAudioClient* client, IAudioRenderClient* render_client); |
| 171 |
| 159 private: | 172 private: |
| 160 CoreAudioUtil() {} | 173 CoreAudioUtil() {} |
| 161 ~CoreAudioUtil() {} | 174 ~CoreAudioUtil() {} |
| 162 DISALLOW_COPY_AND_ASSIGN(CoreAudioUtil); | 175 DISALLOW_COPY_AND_ASSIGN(CoreAudioUtil); |
| 163 }; | 176 }; |
| 164 | 177 |
| 165 } // namespace media | 178 } // namespace media |
| 166 | 179 |
| 167 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ | 180 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| OLD | NEW |