SDL  2.0
SDL_xaudio2_winrthelpers.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  XAUDIO2_DEVICE_DETAILS
 

Functions

HRESULT IXAudio2_GetDeviceCount (IXAudio2 *unused, UINT32 *devcount)
 
HRESULT IXAudio2_GetDeviceDetails (IXAudio2 *unused, UINT32 index, XAUDIO2_DEVICE_DETAILS *details)
 

Function Documentation

HRESULT IXAudio2_GetDeviceCount ( IXAudio2 unused,
UINT32 *  devcount 
)

Definition at line 32 of file SDL_xaudio2_winrthelpers.cpp.

References S_OK.

33 {
34 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
35  // There doesn't seem to be any audio device enumeration on Windows Phone.
36  // In lieu of this, just treat things as if there is one and only one
37  // audio device.
38  *devcount = 1;
39  return S_OK;
40 #else
41  // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
42  auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
43  while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
44  {
45  }
46 
47  DeviceInformationCollection^ devices = operation->GetResults();
48  *devcount = devices->Size;
49  return S_OK;
50 #endif
51 }
#define S_OK
Definition: SDL_directx.h:47
EGLDeviceEXT * devices
Definition: eglext.h:621
HRESULT IXAudio2_GetDeviceDetails ( IXAudio2 unused,
UINT32  index,
XAUDIO2_DEVICE_DETAILS details 
)

Definition at line 53 of file SDL_xaudio2_winrthelpers.cpp.

References d, XAUDIO2_DEVICE_DETAILS::DeviceID, XAUDIO2_DEVICE_DETAILS::DisplayName, and S_OK.

54 {
55 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
56  // Windows Phone doesn't seem to have the same device enumeration APIs that
57  // Windows 8/RT has, or it doesn't have them at all. In lieu of this,
58  // just treat things as if there is one, and only one, default device.
59  if (index != 0)
60  {
61  return XAUDIO2_E_INVALID_CALL;
62  }
63 
64  if (details)
65  {
66  wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
67  wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
68  }
69  return S_OK;
70 #else
71  auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
72  while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
73  {
74  }
75 
76  DeviceInformationCollection^ devices = operation->GetResults();
77  if (index >= devices->Size)
78  {
79  return XAUDIO2_E_INVALID_CALL;
80  }
81 
82  DeviceInformation^ d = devices->GetAt(index);
83  if (details)
84  {
85  wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
86  wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
87  }
88  return S_OK;
89 #endif
90 }
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
#define S_OK
Definition: SDL_directx.h:47
GLuint index
EGLDeviceEXT * devices
Definition: eglext.h:621