WinRT: added Windows Phone 8 project files, and got SDL compiling under them
This commit is contained in:
parent
62303fa63a
commit
a1ef55a6f7
5 changed files with 1072 additions and 1 deletions
|
@ -367,6 +367,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
ixa2->SetDebugConfiguration(&debugConfig);
|
||||
*/
|
||||
|
||||
#if ! defined(__WINRT__) || WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
|
||||
if (devname != NULL) {
|
||||
UINT32 devcount = 0;
|
||||
UINT32 i = 0;
|
||||
|
@ -402,6 +403,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
|
|
|
@ -2,12 +2,21 @@
|
|||
#include <xaudio2.h>
|
||||
#include "SDL_xaudio2_winrthelpers.h"
|
||||
|
||||
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
|
||||
using Windows::Devices::Enumeration::DeviceClass;
|
||||
using Windows::Devices::Enumeration::DeviceInformation;
|
||||
using Windows::Devices::Enumeration::DeviceInformationCollection;
|
||||
#endif
|
||||
|
||||
HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
|
||||
{
|
||||
#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
|
||||
// TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background
|
||||
auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
|
||||
while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
|
||||
|
@ -17,10 +26,27 @@ HRESULT IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount)
|
|||
DeviceInformationCollection^ devices = operation->GetResults();
|
||||
*devcount = devices->Size;
|
||||
return S_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details)
|
||||
{
|
||||
#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
|
||||
auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender);
|
||||
while (operation->Status != Windows::Foundation::AsyncStatus::Completed)
|
||||
{
|
||||
|
@ -39,4 +65,5 @@ HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVIC
|
|||
wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE);
|
||||
}
|
||||
return S_OK;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue