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)
     1 
     2 #include <xaudio2.h>
     3 #include "SDL_xaudio2_winrthelpers.h"
     4 
     5 using Windows::Devices::Enumeration::DeviceClass;
     6 using Windows::Devices::Enumeration::DeviceInformation;
     7 using Windows::Devices::Enumeration::DeviceInformationCollection;
     8 
     9 HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
    10 {
    11     auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    12     while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    13     {
    14     }
    15  
    16     DeviceInformationCollection^ devices = operation->GetResults();
    17     *devcount = devices->Size;
    18     return S_OK;
    19 }
    20 
    21 HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
    22 {
    23     auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    24     while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    25     {
    26     }
    27  
    28     DeviceInformationCollection^ devices = operation->GetResults();
    29     if (index >= devices->Size)
    30     {
    31         return XAUDIO2_E_INVALID_CALL;
    32     }
    33 
    34     DeviceInformation^ d = devices->GetAt(index);
    35     if (details)
    36     {
    37         wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
    38         wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
    39     }
    40     return S_OK;
    41 }