Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
69 lines (61 loc) · 2.33 KB

SDL_xaudio2_winrthelpers.cpp

File metadata and controls

69 lines (61 loc) · 2.33 KB
 
1
2
3
4
#include <xaudio2.h>
#include "SDL_xaudio2_winrthelpers.h"
Jan 29, 2013
Jan 29, 2013
5
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
6
7
8
using Windows::Devices::Enumeration::DeviceClass;
using Windows::Devices::Enumeration::DeviceInformation;
using Windows::Devices::Enumeration::DeviceInformationCollection;
Jan 29, 2013
Jan 29, 2013
9
#endif
10
11
12
HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
{
Jan 29, 2013
Jan 29, 2013
13
14
15
16
17
18
19
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
// There doesn't seem to be any audio device enumeration on Windows Phone.
// In lieu of this, just treat things as if there is one and only one
// audio device.
*devcount = 1;
return S_OK;
#else
Nov 24, 2012
Nov 24, 2012
20
// TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
21
22
23
24
25
26
27
28
auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
{
}
DeviceInformationCollection^ devices = operation->GetResults();
*devcount = devices->Size;
return S_OK;
Jan 29, 2013
Jan 29, 2013
29
#endif
30
31
32
33
}
HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
{
Jan 29, 2013
Jan 29, 2013
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
// Windows Phone doesn't seem to have the same device enumeration APIs that
// Windows 8/RT has, or it doesn't have them at all. In lieu of this,
// just treat things as if there is one, and only one, default device.
if (index != 0)
{
return XAUDIO2_E_INVALID_CALL;
}
if (details)
{
wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE);
wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE);
}
return S_OK;
#else
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
{
}
DeviceInformationCollection^ devices = operation->GetResults();
if (index >= devices->Size)
{
return XAUDIO2_E_INVALID_CALL;
}
DeviceInformation^ d = devices->GetAt(index);
if (details)
{
wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
}
return S_OK;
Jan 29, 2013
Jan 29, 2013
68
#endif