RetroArch
Classes | Macros | Functions | Variables
wasapi.c File Reference
#include <stdlib.h>
#include <windows.h>
#include <winerror.h>
#include <propidl.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <mmreg.h>
#include <audioclient.h>
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include "../audio_driver.h"
#include "../../verbosity.h"
#include "../../configuration.h"
Include dependency graph for wasapi.c:

Classes

struct  wasapi_t
 

Macros

#define _WIN32_WINNT   0x0600
 
#define WIN32_LEAN_AND_MEAN
 
#define _IMMDeviceCollection_Item(This, nDevice, ppdevice)   (This)->lpVtbl->Item(This,nDevice,ppdevice)
 
#define _IAudioClient_Start(This)   ( (This)->lpVtbl -> Start(This) )
 
#define _IAudioClient_Stop(This)   ( (This)->lpVtbl -> Stop(This) )
 
#define _IAudioClient_GetCurrentPadding(This, pNumPaddingFrames)   ( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) )
 
#define _IAudioRenderClient_GetBuffer(This, NumFramesRequested, ppData)   ( (This)->lpVtbl -> GetBuffer(This,NumFramesRequested,ppData) )
 
#define _IAudioRenderClient_ReleaseBuffer(This, NumFramesWritten, dwFlags)   ( (This)->lpVtbl -> ReleaseBuffer(This,NumFramesWritten,dwFlags) )
 
#define _IAudioClient_GetService(This, riid, ppv)   ( (This)->lpVtbl -> GetService(This,&(riid),ppv) )
 
#define _IAudioClient_SetEventHandle(This, eventHandle)   ( (This)->lpVtbl -> SetEventHandle(This,eventHandle) )
 
#define _IAudioClient_GetBufferSize(This, pNumBufferFrames)   ( (This)->lpVtbl -> GetBufferSize(This,pNumBufferFrames) )
 
#define _IAudioClient_GetStreamLatency(This, phnsLatency)   ( (This)->lpVtbl -> GetStreamLatency(This,phnsLatency) )
 
#define _IAudioClient_GetDevicePeriod(This, phnsDefaultDevicePeriod, phnsMinimumDevicePeriod)   ( (This)->lpVtbl -> GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
 
#define _IMMDevice_Activate(This, iid, dwClsCtx, pActivationParams, ppv)   ((This)->lpVtbl->Activate(This,&(iid),dwClsCtx,pActivationParams,ppv))
 
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This, dataFlow, dwStateMask, ppDevices)   (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices)
 
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This, dataFlow, role, ppEndpoint)   (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint)
 
#define _IMMDevice_OpenPropertyStore(This, stgmAccess, ppProperties)   (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties)
 
#define _IMMDevice_GetId(This, ppstrId)   (This)->lpVtbl->GetId(This,ppstrId)
 
#define _IPropertyStore_GetValue(This, key, pv)   ( (This)->lpVtbl -> GetValue(This,&(key),pv) )
 
#define _IMMDeviceCollection_GetCount(This, cProps)   ( (This)->lpVtbl -> GetCount(This,cProps) )
 
#define WASAPI_WARN(bool_exp, err_str, warn_exp)
 
#define WASAPI_CHECK(bool_exp, err_str, err_exp)
 
#define WASAPI_HR_CHECK(hr, fun_str, err_exp)
 
#define WASAPI_HR_WARN(hr, fun_str, warn_exp)
 
#define WASAPI_SR_CHECK(bool_exp, fun_str, err_exp)
 
#define WASAPI_RELEASE(iface)
 
#define WASAPI_FREE(ptr)
 
#define WASAPI_CO_FREE(ptr)
 

Functions

 DEFINE_PROPERTYKEY (PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14)
 
static bool wasapi_check_device_id (IMMDevice *device, const char *id)
 
static IMMDevice * wasapi_init_device (const char *id)
 
static unsigned wasapi_pref_rate (unsigned i)
 
static void wasapi_set_format (WAVEFORMATEXTENSIBLE *wf, bool float_fmt, unsigned rate)
 
static IAudioClient * wasapi_init_client_sh (IMMDevice *device, bool *float_fmt, unsigned *rate, unsigned latency)
 
static IAudioClient * wasapi_init_client_ex (IMMDevice *device, bool *float_fmt, unsigned *rate, unsigned latency)
 
static IAudioClient * wasapi_init_client (IMMDevice *device, bool *exclusive, bool *float_fmt, unsigned *rate, unsigned latency)
 
static voidwasapi_init (const char *dev_id, unsigned rate, unsigned latency, unsigned u1, unsigned *u2)
 
static bool wasapi_flush (wasapi_t *w, const void *data, size_t size)
 
static bool wasapi_flush_buffer (wasapi_t *w, size_t size)
 
static ssize_t wasapi_write_sh (wasapi_t *w, const void *data, size_t size)
 
static ssize_t wasapi_write_ex (wasapi_t *w, const void *data, size_t size)
 
static ssize_t wasapi_write (void *wh, const void *data, size_t size)
 
static bool wasapi_stop (void *wh)
 
static bool wasapi_start (void *wh, bool u)
 
static bool wasapi_alive (void *wh)
 
static void wasapi_set_nonblock_state (void *wh, bool nonblock)
 
static void wasapi_free (void *wh)
 
static bool wasapi_use_float (void *wh)
 
static voidwasapi_device_list_new (void *u)
 
static void wasapi_device_list_free (void *u, void *slp)
 
static size_t wasapi_write_avail (void *wh)
 
static size_t wasapi_buffer_size (void *wh)
 

Variables

audio_driver_t audio_wasapi
 

Macro Definition Documentation

◆ _IAudioClient_GetBufferSize

#define _IAudioClient_GetBufferSize (   This,
  pNumBufferFrames 
)    ( (This)->lpVtbl -> GetBufferSize(This,pNumBufferFrames) )

◆ _IAudioClient_GetCurrentPadding

#define _IAudioClient_GetCurrentPadding (   This,
  pNumPaddingFrames 
)    ( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) )

◆ _IAudioClient_GetDevicePeriod

#define _IAudioClient_GetDevicePeriod (   This,
  phnsDefaultDevicePeriod,
  phnsMinimumDevicePeriod 
)    ( (This)->lpVtbl -> GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )

◆ _IAudioClient_GetService

#define _IAudioClient_GetService (   This,
  riid,
  ppv 
)    ( (This)->lpVtbl -> GetService(This,&(riid),ppv) )

◆ _IAudioClient_GetStreamLatency

#define _IAudioClient_GetStreamLatency (   This,
  phnsLatency 
)    ( (This)->lpVtbl -> GetStreamLatency(This,phnsLatency) )

◆ _IAudioClient_SetEventHandle

#define _IAudioClient_SetEventHandle (   This,
  eventHandle 
)    ( (This)->lpVtbl -> SetEventHandle(This,eventHandle) )

◆ _IAudioClient_Start

#define _IAudioClient_Start (   This)    ( (This)->lpVtbl -> Start(This) )

◆ _IAudioClient_Stop

#define _IAudioClient_Stop (   This)    ( (This)->lpVtbl -> Stop(This) )

◆ _IAudioRenderClient_GetBuffer

#define _IAudioRenderClient_GetBuffer (   This,
  NumFramesRequested,
  ppData 
)    ( (This)->lpVtbl -> GetBuffer(This,NumFramesRequested,ppData) )

◆ _IAudioRenderClient_ReleaseBuffer

#define _IAudioRenderClient_ReleaseBuffer (   This,
  NumFramesWritten,
  dwFlags 
)    ( (This)->lpVtbl -> ReleaseBuffer(This,NumFramesWritten,dwFlags) )

◆ _IMMDevice_Activate

#define _IMMDevice_Activate (   This,
  iid,
  dwClsCtx,
  pActivationParams,
  ppv 
)    ((This)->lpVtbl->Activate(This,&(iid),dwClsCtx,pActivationParams,ppv))

◆ _IMMDevice_GetId

#define _IMMDevice_GetId (   This,
  ppstrId 
)    (This)->lpVtbl->GetId(This,ppstrId)

◆ _IMMDevice_OpenPropertyStore

#define _IMMDevice_OpenPropertyStore (   This,
  stgmAccess,
  ppProperties 
)    (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties)

◆ _IMMDeviceCollection_GetCount

#define _IMMDeviceCollection_GetCount (   This,
  cProps 
)    ( (This)->lpVtbl -> GetCount(This,cProps) )

◆ _IMMDeviceCollection_Item

#define _IMMDeviceCollection_Item (   This,
  nDevice,
  ppdevice 
)    (This)->lpVtbl->Item(This,nDevice,ppdevice)

◆ _IMMDeviceEnumerator_EnumAudioEndpoints

#define _IMMDeviceEnumerator_EnumAudioEndpoints (   This,
  dataFlow,
  dwStateMask,
  ppDevices 
)    (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices)

◆ _IMMDeviceEnumerator_GetDefaultAudioEndpoint

#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint (   This,
  dataFlow,
  role,
  ppEndpoint 
)    (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint)

◆ _IPropertyStore_GetValue

#define _IPropertyStore_GetValue (   This,
  key,
  pv 
)    ( (This)->lpVtbl -> GetValue(This,&(key),pv) )

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0600

◆ WASAPI_CHECK

#define WASAPI_CHECK (   bool_exp,
  err_str,
  err_exp 
)
Value:
if (!(bool_exp)) { \
RARCH_ERR("[WASAPI]: %s.\n", err_str); \
err_exp; }

◆ WASAPI_CO_FREE

#define WASAPI_CO_FREE (   ptr)
Value:
if(ptr) {\
CoTaskMemFree(ptr);\
ptr = NULL; }\
const GLvoid * ptr
Definition: nx_glsym.h:242
#define NULL
Pointer to 0.
Definition: gctypes.h:65

◆ WASAPI_FREE

#define WASAPI_FREE (   ptr)
Value:
if(ptr) {\
free(ptr);\
ptr = NULL; }\
const GLvoid * ptr
Definition: nx_glsym.h:242
#define NULL
Pointer to 0.
Definition: gctypes.h:65

◆ WASAPI_HR_CHECK

#define WASAPI_HR_CHECK (   hr,
  fun_str,
  err_exp 
)
Value:
if (FAILED(hr)) { \
RARCH_ERR("[WASAPI]: %s failed with error 0x%.8X.\n", fun_str, hr); \
err_exp; }

◆ WASAPI_HR_WARN

#define WASAPI_HR_WARN (   hr,
  fun_str,
  warn_exp 
)
Value:
if (FAILED(hr)) { \
RARCH_WARN("[WASAPI]: %s failed with error 0x%.8X.\n", fun_str, hr); \
warn_exp; }

◆ WASAPI_RELEASE

#define WASAPI_RELEASE (   iface)
Value:
if(iface) \
{ \
iface->lpVtbl->Release(iface);\
iface = NULL; \
}
#define NULL
Pointer to 0.
Definition: gctypes.h:65

◆ WASAPI_SR_CHECK

#define WASAPI_SR_CHECK (   bool_exp,
  fun_str,
  err_exp 
)
Value:
if (!(bool_exp)) { \
RARCH_ERR("[WASAPI]: %s failed with error %d.\n", fun_str, GetLastError()); \
err_exp; }

◆ WASAPI_WARN

#define WASAPI_WARN (   bool_exp,
  err_str,
  warn_exp 
)
Value:
if (!(bool_exp)) { \
RARCH_WARN("[WASAPI]: %s.\n", err_str); \
warn_exp; }

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Function Documentation

◆ DEFINE_PROPERTYKEY()

DEFINE_PROPERTYKEY ( PKEY_Device_FriendlyName  ,
0xa45c254e  ,
0xdf1c  ,
0x4efd  ,
0x80  ,
0x20  ,
0x67  ,
0xd1  ,
0x46  ,
0xa8  ,
0x50  ,
0xe0  ,
14   
)

◆ wasapi_alive()

static bool wasapi_alive ( void wh)
static

◆ wasapi_buffer_size()

static size_t wasapi_buffer_size ( void wh)
static

◆ wasapi_check_device_id()

static bool wasapi_check_device_id ( IMMDevice *  device,
const char *  id 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_device_list_free()

static void wasapi_device_list_free ( void u,
void slp 
)
static
Here is the call graph for this function:

◆ wasapi_device_list_new()

static void* wasapi_device_list_new ( void u)
static
Here is the call graph for this function:

◆ wasapi_flush()

static bool wasapi_flush ( wasapi_t w,
const void data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_flush_buffer()

static bool wasapi_flush_buffer ( wasapi_t w,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_free()

static void wasapi_free ( void wh)
static
Here is the call graph for this function:

◆ wasapi_init()

static void* wasapi_init ( const char *  dev_id,
unsigned  rate,
unsigned  latency,
unsigned  u1,
unsigned *  u2 
)
static
Here is the call graph for this function:

◆ wasapi_init_client()

static IAudioClient* wasapi_init_client ( IMMDevice *  device,
bool exclusive,
bool float_fmt,
unsigned *  rate,
unsigned  latency 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_init_client_ex()

static IAudioClient* wasapi_init_client_ex ( IMMDevice *  device,
bool float_fmt,
unsigned *  rate,
unsigned  latency 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_init_client_sh()

static IAudioClient* wasapi_init_client_sh ( IMMDevice *  device,
bool float_fmt,
unsigned *  rate,
unsigned  latency 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_init_device()

static IMMDevice* wasapi_init_device ( const char *  id)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_pref_rate()

static unsigned wasapi_pref_rate ( unsigned  i)
static
Here is the caller graph for this function:

◆ wasapi_set_format()

static void wasapi_set_format ( WAVEFORMATEXTENSIBLE wf,
bool  float_fmt,
unsigned  rate 
)
static
Here is the caller graph for this function:

◆ wasapi_set_nonblock_state()

static void wasapi_set_nonblock_state ( void wh,
bool  nonblock 
)
static
Here is the call graph for this function:

◆ wasapi_start()

static bool wasapi_start ( void wh,
bool  u 
)
static
Here is the call graph for this function:

◆ wasapi_stop()

static bool wasapi_stop ( void wh)
static
Here is the call graph for this function:

◆ wasapi_use_float()

static bool wasapi_use_float ( void wh)
static

◆ wasapi_write()

static ssize_t wasapi_write ( void wh,
const void data,
size_t  size 
)
static
Here is the call graph for this function:

◆ wasapi_write_avail()

static size_t wasapi_write_avail ( void wh)
static
Here is the call graph for this function:

◆ wasapi_write_ex()

static ssize_t wasapi_write_ex ( wasapi_t w,
const void data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wasapi_write_sh()

static ssize_t wasapi_write_sh ( wasapi_t w,
const void data,
size_t  size 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ audio_wasapi

audio_driver_t audio_wasapi
Initial value:
= {
"wasapi",
}
static size_t wasapi_write_avail(void *wh)
Definition: wasapi.c:1050
static ssize_t wasapi_write(void *wh, const void *data, size_t size)
Definition: wasapi.c:826
static size_t wasapi_buffer_size(void *wh)
Definition: wasapi.c:1065
static bool wasapi_use_float(void *wh)
Definition: wasapi.c:922
static bool wasapi_stop(void *wh)
Definition: wasapi.c:852
static void wasapi_device_list_free(void *u, void *slp)
Definition: wasapi.c:1043
static void wasapi_free(void *wh)
Definition: wasapi.c:894
static void wasapi_set_nonblock_state(void *wh, bool nonblock)
Definition: wasapi.c:885
static void * wasapi_device_list_new(void *u)
Definition: wasapi.c:929
static bool wasapi_start(void *wh, bool u)
Definition: wasapi.c:863
static bool wasapi_alive(void *wh)
Definition: wasapi.c:878
static void * wasapi_init(const char *dev_id, unsigned rate, unsigned latency, unsigned u1, unsigned *u2)
Definition: wasapi.c:592