src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp
changeset 8353 82447809a27e
child 8361 eefad2ec4f76
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp	Thu Nov 22 22:34:50 2012 -0500
     1.3 @@ -0,0 +1,41 @@
     1.4 +
     1.5 +#include <xaudio2.h>
     1.6 +#include "SDL_xaudio2_winrthelpers.h"
     1.7 +
     1.8 +using Windows::Devices::Enumeration::DeviceClass;
     1.9 +using Windows::Devices::Enumeration::DeviceInformation;
    1.10 +using Windows::Devices::Enumeration::DeviceInformationCollection;
    1.11 +
    1.12 +HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
    1.13 +{
    1.14 +    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    1.15 +    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    1.16 +    {
    1.17 +    }
    1.18 + 
    1.19 +    DeviceInformationCollection^ devices = operation->GetResults();
    1.20 +    *devcount = devices->Size;
    1.21 +    return S_OK;
    1.22 +}
    1.23 +
    1.24 +HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
    1.25 +{
    1.26 +    auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
    1.27 +    while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
    1.28 +    {
    1.29 +    }
    1.30 + 
    1.31 +    DeviceInformationCollection^ devices = operation->GetResults();
    1.32 +    if (index >= devices->Size)
    1.33 +    {
    1.34 +        return XAUDIO2_E_INVALID_CALL;
    1.35 +    }
    1.36 +
    1.37 +    DeviceInformation^ d = devices->GetAt(index);
    1.38 +    if (details)
    1.39 +    {
    1.40 +        wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE);
    1.41 +        wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
    1.42 +    }
    1.43 +    return S_OK;
    1.44 +}