Chromium Code Reviews| Index: media/audio/win/core_audio_util_win.h |
| diff --git a/media/audio/win/core_audio_util_win.h b/media/audio/win/core_audio_util_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..999941bea4a3c543259ef60b9d64c4000522e03f |
| --- /dev/null |
| +++ b/media/audio/win/core_audio_util_win.h |
| @@ -0,0 +1,89 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// Utility methods for the Core Audio API on Windows. |
| +// Always ensure that Core Audio is supported before using these methods. |
| +// Use media::CoreAudioIsSupported() for this purpose. |
| + |
| +#ifndef MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
|
scherkus (not reviewing)
2012/10/24 16:48:04
nit: it's your call but we don't have to add a _wi
henrika (OOO until Aug 14)
2012/10/24 19:25:44
Got it. I actually think that I followed lint here
tommi (sloooow) - chröme
2012/10/29 10:45:26
Lint was pointing out that the #if guard must matc
|
| +#define MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |
| + |
| +#include <audioclient.h> |
| +#include <mmdeviceapi.h> |
| +#include <string> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/win/scoped_comptr.h" |
| +#include "media/audio/audio_device_name.h" |
| +#include "media/base/media_export.h" |
| + |
| +using base::win::ScopedComPtr; |
| + |
| +namespace media { |
| + |
| +// Returns true if Windows Core Audio is supported. |
| +MEDIA_EXPORT bool CoreAudioIsSupported(); |
| + |
| +// --- MMDevice |
|
scherkus (not reviewing)
2012/10/24 16:48:04
I find this comment is redundant given the one imm
henrika (OOO until Aug 14)
2012/10/24 19:25:44
Will modify.
henrika (OOO until Aug 14)
2012/10/25 15:14:08
Done.
|
| + |
| +// The Windows Multimedia Device (MMDevice) API enables audio clients to |
| +// discover audio endpoint devices and determine their capabilities. |
| + |
| +// Number of active audio devices in the specified flow data flow direction. |
| +// Set |data_flow| to eAll to retrive the total number of active audio devices. |
| +MEDIA_EXPORT int CoreAudioNumberOfActiveDevices(EDataFlow data_flow); |
|
DaleCurtis
2012/10/25 01:08:08
kind of stinks to have to prefix all these with Co
henrika (OOO until Aug 14)
2012/10/25 15:14:08
Agree. That is why I started out with a nested nam
|
| + |
| +// Creates an IMMDeviceEnumerator interface which provides methods for |
| +// enumerating audio endpoint devices. |
| +MEDIA_EXPORT ScopedComPtr<IMMDeviceEnumerator> |
| + CoreAudioCreateDeviceEnumerator(); |
| + |
| +// Create a default endpoint device that is specified by a data-flow |
| +// direction and role, e.g. default render device. |
| +MEDIA_EXPORT ScopedComPtr<IMMDevice> CoreAudioCreateDefaultDevice( |
| + EDataFlow data_flow, ERole role); |
| + |
| +// Create an endpoint device that is specified by a unique endpoint device- |
| +// identification string. |
| +MEDIA_EXPORT ScopedComPtr<IMMDevice> CoreAudioCreateDevice( |
| + const std::string& device_id); |
| + |
| +// Returns the unique ID and user-friendly name of a given endpoint device. |
| +// Example: "{0.0.1.00000000}.{8db6020f-18e3-4f25-b6f5-7726c9122574}", and |
| +// "Microphone (Realtek High Definition Audio)". |
| +MEDIA_EXPORT HRESULT CoreAudioGetDeviceName(IMMDevice* device, |
| + AudioDeviceName* name); |
| + |
| +// Gets the user-friendly name of the endpoint devcice which is represented |
| +// by a uniqe id in |device_id|. |
| +MEDIA_EXPORT std::string CoreAudioGetFriendlyName(const std::string& device_id); |
| + |
| +// Returns true if the provided uniqe |device_id| correspinds to the current |
| +// default device for the specified by a data-flow direction and role. |
| +MEDIA_EXPORT bool CoreAudioDeviceIsDefault(EDataFlow flow, ERole role, |
| + std::string device_id); |
| + |
| +// Query if the audio endpoint device is a rendering device or a capture device. |
| +MEDIA_EXPORT EDataFlow CoreAudioGetDataFlow(IMMDevice* device); |
| + |
| +// --- WASAPI |
|
scherkus (not reviewing)
2012/10/24 16:48:04
ditto
henrika (OOO until Aug 14)
2012/10/24 19:25:44
Will modify.
henrika (OOO until Aug 14)
2012/10/25 15:14:08
Done.
|
| + |
| +// The Windows Audio Session API (WASAPI) enables client applications to |
| +// manage the flow of audio data between the application and an audio endpoint |
| +// device. |
| + |
| +// Create an IAudioClient interface for an existing IMMDevice given by |
| +// |audio_device|. Flow direction and role is define by the |audio_device|. |
| +// The IAudioClient interface enables a client to create and initialize an |
| +// audio stream between an audio application and the audio engine (for a |
| +// shared-mode stream) or the hardware buffer of an audio endpoint device |
| +// (for an exclusive-mode stream). |
| +MEDIA_EXPORT ScopedComPtr<IAudioClient> CoreAudioCreateClient( |
| + IMMDevice* audio_device); |
| + |
| +// TODO(henrika): add more methods here... |
|
scherkus (not reviewing)
2012/10/24 16:48:04
this isn't very descriptive -- I'd either have it
henrika (OOO until Aug 14)
2012/10/24 19:25:44
Agree. Will delete.
|
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_AUDIO_WIN_CORE_AUDIO_UTIL_WIN_H_ |