| 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 |
| 11 #ifndef MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ | 11 #ifndef MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| 12 #define MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ | 12 #define MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| 13 | 13 |
| 14 #include <audioclient.h> | 14 #include <audioclient.h> |
| 15 #include <mmdeviceapi.h> | 15 #include <mmdeviceapi.h> |
| 16 #include <string> | 16 #include <string> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | |
| 19 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 20 #include "base/win/scoped_comptr.h" | 19 #include "base/win/scoped_comptr.h" |
| 21 #include "media/audio/audio_device_name.h" | 20 #include "media/audio/audio_device_name.h" |
| 22 #include "media/audio/audio_parameters.h" | 21 #include "media/audio/audio_parameters.h" |
| 23 #include "media/base/media_export.h" | 22 #include "media/base/media_export.h" |
| 24 | 23 |
| 25 using base::win::ScopedComPtr; | 24 using base::win::ScopedComPtr; |
| 26 | 25 |
| 27 namespace media { | 26 namespace media { |
| 28 | 27 |
| 29 | 28 |
| 30 // Represents audio channel configuration constants as understood by Windows. | 29 // Represents audio channel configuration constants as understood by Windows. |
| 31 // E.g. KSAUDIO_SPEAKER_MONO. For a list of possible values see: | 30 // E.g. KSAUDIO_SPEAKER_MONO. For a list of possible values see: |
| 32 // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537083(v=vs.85).as
px | 31 // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537083(v=vs.85).as
px |
| 33 typedef uint32 ChannelConfig; | 32 typedef uint32_t ChannelConfig; |
| 34 | 33 |
| 35 class MEDIA_EXPORT CoreAudioUtil { | 34 class MEDIA_EXPORT CoreAudioUtil { |
| 36 public: | 35 public: |
| 37 // Returns true if Windows Core Audio is supported. | 36 // Returns true if Windows Core Audio is supported. |
| 38 // Always verify that this method returns true before using any of the | 37 // Always verify that this method returns true before using any of the |
| 39 // methods in this class. | 38 // methods in this class. |
| 40 // WARNING: This function must be called once from the main thread before | 39 // WARNING: This function must be called once from the main thread before |
| 41 // it is safe to call from other threads. | 40 // it is safe to call from other threads. |
| 42 static bool IsSupported(); | 41 static bool IsSupported(); |
| 43 | 42 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // In exclusive mode, the client connects directly to the audio hardware. | 197 // In exclusive mode, the client connects directly to the audio hardware. |
| 199 // If a valid event is provided in |event_handle|, the client will be | 198 // If a valid event is provided in |event_handle|, the client will be |
| 200 // initialized for event-driven buffer handling. If |event_handle| is set to | 199 // initialized for event-driven buffer handling. If |event_handle| is set to |
| 201 // NULL, event-driven buffer handling is not utilized. | 200 // NULL, event-driven buffer handling is not utilized. |
| 202 // This function will initialize the audio client as part of the default | 201 // This function will initialize the audio client as part of the default |
| 203 // audio session if NULL is passed for |session_guid|, otherwise the client | 202 // audio session if NULL is passed for |session_guid|, otherwise the client |
| 204 // will be associated with the specified session. | 203 // will be associated with the specified session. |
| 205 static HRESULT SharedModeInitialize(IAudioClient* client, | 204 static HRESULT SharedModeInitialize(IAudioClient* client, |
| 206 const WAVEFORMATPCMEX* format, | 205 const WAVEFORMATPCMEX* format, |
| 207 HANDLE event_handle, | 206 HANDLE event_handle, |
| 208 uint32* endpoint_buffer_size, | 207 uint32_t* endpoint_buffer_size, |
| 209 const GUID* session_guid); | 208 const GUID* session_guid); |
| 210 | 209 |
| 211 // TODO(henrika): add ExclusiveModeInitialize(...) | 210 // TODO(henrika): add ExclusiveModeInitialize(...) |
| 212 | 211 |
| 213 // Create an IAudioRenderClient client for an existing IAudioClient given by | 212 // Create an IAudioRenderClient client for an existing IAudioClient given by |
| 214 // |client|. The IAudioRenderClient interface enables a client to write | 213 // |client|. The IAudioRenderClient interface enables a client to write |
| 215 // output data to a rendering endpoint buffer. | 214 // output data to a rendering endpoint buffer. |
| 216 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( | 215 static ScopedComPtr<IAudioRenderClient> CreateRenderClient( |
| 217 IAudioClient* client); | 216 IAudioClient* client); |
| 218 | 217 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 242 // The special audio session identifier we use when opening up the default | 241 // The special audio session identifier we use when opening up the default |
| 243 // communication device. This has the effect that a separate volume control | 242 // communication device. This has the effect that a separate volume control |
| 244 // will be shown in the system's volume mixer and control over ducking and | 243 // will be shown in the system's volume mixer and control over ducking and |
| 245 // visually observing the behavior of ducking, is easier. | 244 // visually observing the behavior of ducking, is easier. |
| 246 // Use with |SharedModeInitialize|. | 245 // Use with |SharedModeInitialize|. |
| 247 extern const GUID kCommunicationsSessionId; | 246 extern const GUID kCommunicationsSessionId; |
| 248 | 247 |
| 249 } // namespace media | 248 } // namespace media |
| 250 | 249 |
| 251 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ | 250 #endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| OLD | NEW |