![]() |
UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
|
#include <audioclient.h>#include <audiosessiontypes.h>#include <basetsd.h>#include <cassert>#include <cctype>#include <combaseapi.h>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <ksmedia.h>#include <mediaobj.h>#include <mmdeviceapi.h>#include <mmeapi.h>#include <mmreg.h>#include <objbase.h>#include <propidl.h>#include <propsys.h>#include <sstream>#include <string>#include <winerror.h>#include "audio/audio_playback.h"#include "audio/types.h"#include "debug.h"#include "host.h"#include "lib_common.h"#include "types.h"#include "ug_runtime_error.hpp"#include "utils/color_out.h"#include "utils/windows.h"
Go to the source code of this file.
Classes | |
| struct | state_aplay_wasapi |
Macros | |
| #define | CHECK(cmd) |
| #define | DEFAULT_WASAPI_BUFLEN_MS 67 |
| #define | FAIL_IF_NOT(cmd) |
| #define | MOD_NAME "[WASAPI play.] " |
| #define | REFTIMES_PER_MILLISEC 10000 |
| #define | REFTIMES_PER_SEC 10000000 |
| #define | SAFE_RELEASE(u) |
| #define | THROW_IF_FAILED(cmd) |
Functions | |
| static WAVEFORMATEXTENSIBLE | audio_format_to_waveformatex (struct audio_desc *desc) |
| static bool | audio_play_wasapi_ctl (void *state, int request, void *data, size_t *len) |
| static void | audio_play_wasapi_done (void *state) |
| static void | audio_play_wasapi_help () |
| static void * | audio_play_wasapi_init (const char *cfg) |
| static void | audio_play_wasapi_probe (struct device_info **available_devices, int *dev_count, void(**deleter)(void *)) |
| static void | audio_play_wasapi_put_frame (void *state, const struct audio_frame *buffer) |
| static bool | audio_play_wasapi_reconfigure (void *state, struct audio_desc desc) |
| static DWORD | get_channel_mask (int *count) |
| static string | get_name (IMMDevice *pDevice) |
| REGISTER_MODULE (wasapi, &aplay_wasapi_info, LIBRARY_CLASS_AUDIO_PLAYBACK, AUDIO_PLAYBACK_ABI_VERSION) | |
| string | wasapi_get_default_device_id (EDataFlow dataFlow, IMMDeviceEnumerator *enumerator) |
Variables | |
| static const struct audio_playback_info | aplay_wasapi_info |
| const CLSID | CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator) |
| static const GUID | IDevice_FriendlyName = { 0xa45c254e, 0xdf1c, 0x4efd, { 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0 } } |
| const IID | IID_IAudioClient = __uuidof(IAudioClient) |
| const IID | IID_IAudioRenderClient = __uuidof(IAudioRenderClient) |
| const IID | IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator) |
| static const PROPERTYKEY | PKEY_Device_FriendlyName = { IDevice_FriendlyName, 14 } |
| static const GUID | UG_KSDATAFORMAT_SUBTYPE_PCM = { STATIC_KSDATAFORMAT_SUBTYPE_PCM } |
Code for probe and help is very similar - consolidate.
Audio buffer length should be rather adaptive to length of incoming frames.
Definition in file wasapi.cpp.
| #define CHECK | ( | cmd | ) |
Definition at line 374 of file wasapi.cpp.
Referenced by ultragrid::aja::display::display(), ultragrid::aja::display::~display(), audio_play_wasapi_put_frame(), ultragrid::aja::display::Init(), ultragrid::aja::display::process_frames(), ultragrid::aja::display::RouteOutputSignal(), ultragrid::aja::display::SetUpAudio(), and ultragrid::aja::display::SetUpVideo().
| #define DEFAULT_WASAPI_BUFLEN_MS 67 |
Definition at line 63 of file wasapi.cpp.
Referenced by audio_play_wasapi_reconfigure().
| #define FAIL_IF_NOT | ( | cmd | ) |
Definition at line 351 of file wasapi.cpp.
Referenced by audio_play_wasapi_reconfigure().
| #define MOD_NAME "[WASAPI play.] " |
Definition at line 64 of file wasapi.cpp.
Referenced by audio_play_wasapi_ctl(), audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), audio_play_wasapi_put_frame(), and audio_play_wasapi_reconfigure().
| #define REFTIMES_PER_MILLISEC 10000 |
Definition at line 66 of file wasapi.cpp.
Referenced by audio_play_wasapi_reconfigure().
| #define REFTIMES_PER_SEC 10000000 |
Definition at line 65 of file wasapi.cpp.
| #define SAFE_RELEASE | ( | u | ) |
Definition at line 97 of file wasapi.cpp.
Referenced by audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), and get_name().
| #define THROW_IF_FAILED | ( | cmd | ) |
Definition at line 100 of file wasapi.cpp.
Referenced by audio_play_wasapi_help(), audio_play_wasapi_init(), and audio_play_wasapi_probe().
|
static |
Definition at line 296 of file wasapi.cpp.
References AC_PCM, desc, fmt, get_channel_mask(), and UG_KSDATAFORMAT_SUBTYPE_PCM.
Referenced by audio_play_wasapi_ctl(), and audio_play_wasapi_reconfigure().

|
static |
Definition at line 312 of file wasapi.cpp.
References AC_PCM, audio_format_to_waveformatex(), AUDIO_PLAYBACK_CTL_QUERY_FORMAT, desc, fmt, len, LOG, LOG_LEVEL_ERROR, MOD_NAME, and state.

|
static |
Definition at line 275 of file wasapi.cpp.
References state.
|
static |
Definition at line 166 of file wasapi.cpp.
References CLSID_MMDeviceEnumerator, com_initialize(), com_uninitialize(), count, get_name(), IID_IMMDeviceEnumerator, LOG, LOG_LEVEL_WARNING, MOD_NAME, SAFE_RELEASE, SBOLD, SRED, THROW_IF_FAILED, and wasapi_get_default_device_id().
Referenced by audio_play_wasapi_init().

|
static |
Definition at line 207 of file wasapi.cpp.
References audio_play_wasapi_help(), CLSID_MMDeviceEnumerator, com_initialize(), com_uninitialize(), count, get_name(), IID_IAudioClient, IID_IMMDeviceEnumerator, INIT_NOERR, LOG, LOG_LEVEL_ERROR, LOG_LEVEL_NOTICE, LOG_LEVEL_WARNING, MOD_NAME, SAFE_RELEASE, and THROW_IF_FAILED.

|
static |
<
Definition at line 122 of file wasapi.cpp.
References CLSID_MMDeviceEnumerator, com_initialize(), com_uninitialize(), count, deleter, device_info::dev, get_name(), IID_IMMDeviceEnumerator, LOG, LOG_LEVEL_WARNING, MOD_NAME, name, SAFE_RELEASE, and THROW_IF_FAILED.

|
static |
Definition at line 375 of file wasapi.cpp.
References audio_frame::bps, audio_frame::ch_count, CHECK, audio_frame::data, audio_frame::data_len, LOG, LOG_LEVEL_WARNING, MOD_NAME, and state.
|
static |
Definition at line 352 of file wasapi.cpp.
References audio_format_to_waveformatex(), DEFAULT_WASAPI_BUFLEN_MS, desc, FAIL_IF_NOT, fmt, get_commandline_param(), IID_IAudioRenderClient, LOG, LOG_LEVEL_INFO, MOD_NAME, REFTIMES_PER_MILLISEC, and state.

|
static |
Definition at line 281 of file wasapi.cpp.
References count.
Referenced by audio_format_to_waveformatex().
|
static |
Definition at line 102 of file wasapi.cpp.
References FAILED, PKEY_Device_FriendlyName, and SAFE_RELEASE.
Referenced by audio_play_wasapi_help(), audio_play_wasapi_init(), and audio_play_wasapi_probe().
| REGISTER_MODULE | ( | wasapi | , |
| & | aplay_wasapi_info, | ||
| LIBRARY_CLASS_AUDIO_PLAYBACK | , | ||
| AUDIO_PLAYBACK_ABI_VERSION | ) |
| string wasapi_get_default_device_id | ( | EDataFlow | dataFlow, |
| IMMDeviceEnumerator * | enumerator ) |
Definition at line 177 of file wasapi.cpp.
References SAFE_RELEASE.
Referenced by audio_play_wasapi_help(), and show_help().
|
static |
Definition at line 394 of file wasapi.cpp.
| const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator) |
Definition at line 68 of file wasapi.cpp.
Referenced by audio_cap_wasapi_init(), audio_cap_wasapi_probe(), audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), and show_help().
|
static |
Definition at line 72 of file wasapi.cpp.
| const IID IID_IAudioClient = __uuidof(IAudioClient) |
Definition at line 70 of file wasapi.cpp.
Referenced by audio_cap_wasapi_init(), and audio_play_wasapi_init().
| const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient) |
Definition at line 71 of file wasapi.cpp.
Referenced by audio_play_wasapi_reconfigure().
| const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator) |
Definition at line 69 of file wasapi.cpp.
Referenced by audio_cap_wasapi_init(), audio_cap_wasapi_probe(), audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), and show_help().
|
static |
|
static |
Definition at line 76 of file wasapi.cpp.
Referenced by audio_format_to_waveformatex().