3 #include "SDL_xaudio2_winrthelpers.h"
5 #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
6 using Windows::Devices::Enumeration::DeviceClass;
7 using Windows::Devices::Enumeration::DeviceInformation;
8 using Windows::Devices::Enumeration::DeviceInformationCollection;
11 extern "C" HRESULT __cdecl IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
13 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
14 // There doesn't seem to be any audio device enumeration on Windows Phone.
15 // In lieu of this, just treat things as if there is one and only one
20 // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
21 auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
22 while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
26 DeviceInformationCollection^ devices = operation->GetResults();
27 *devcount = devices->Size;
32 extern "C" HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
34 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
35 // Windows Phone doesn't seem to have the same device enumeration APIs that
36 // Windows 8/RT has, or it doesn't have them at all. In lieu of this,
37 // just treat things as if there is one, and only one, default device.
40 return XAUDIO2_E_INVALID_CALL;
45 wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
46 wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
50 auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
51 while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
55 DeviceInformationCollection^ devices = operation->GetResults();
56 if (index >= devices->Size)
58 return XAUDIO2_E_INVALID_CALL;
61 DeviceInformation^ d = devices->GetAt(index);
64 wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
65 wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);