src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
author David Ludwig
Thu, 22 Nov 2012 22:34:50 -0500
changeset 8353 82447809a27e
child 8361 eefad2ec4f76
permissions -rw-r--r--
WinRT: got the XAudio2 backend compiling (but not running, yet)
dludwig@8353
     1
dludwig@8353
     2
#include <xaudio2.h>
dludwig@8353
     3
#include "SDL_xaudio2_winrthelpers.h"
dludwig@8353
     4
dludwig@8353
     5
using Windows::Devices::Enumeration::DeviceClass;
dludwig@8353
     6
using Windows::Devices::Enumeration::DeviceInformation;
dludwig@8353
     7
using Windows::Devices::Enumeration::DeviceInformationCollection;
dludwig@8353
     8
dludwig@8353
     9
HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
dludwig@8353
    10
{
dludwig@8353
    11
    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
dludwig@8353
    12
    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
dludwig@8353
    13
    {
dludwig@8353
    14
    }
dludwig@8353
    15
 
dludwig@8353
    16
    DeviceInformationCollection^ devices = operation->GetResults();
dludwig@8353
    17
    *devcount = devices->Size;
dludwig@8353
    18
    return S_OK;
dludwig@8353
    19
}
dludwig@8353
    20
dludwig@8353
    21
HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
dludwig@8353
    22
{
dludwig@8353
    23
    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
dludwig@8353
    24
    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
dludwig@8353
    25
    {
dludwig@8353
    26
    }
dludwig@8353
    27
 
dludwig@8353
    28
    DeviceInformationCollection^ devices = operation->GetResults();
dludwig@8353
    29
    if (index >= devices->Size)
dludwig@8353
    30
    {
dludwig@8353
    31
        return XAUDIO2_E_INVALID_CALL;
dludwig@8353
    32
    }
dludwig@8353
    33
dludwig@8353
    34
    DeviceInformation^ d = devices->GetAt(index);
dludwig@8353
    35
    if (details)
dludwig@8353
    36
    {
dludwig@8353
    37
        wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
dludwig@8353
    38
        wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
dludwig@8353
    39
    }
dludwig@8353
    40
    return S_OK;
dludwig@8353
    41
}